Function: ruler-mode-mouse-grab-any-column
ruler-mode-mouse-grab-any-column is an interactive and byte-compiled
function defined in ruler-mode.el.gz.
Signature
(ruler-mode-mouse-grab-any-column START-EVENT)
Documentation
Drag a column symbol on the ruler.
Start dragging on mouse down event START-EVENT, and update the column
symbol value with the current value of the ruler graduation while
dragging. See also the variable ruler-mode-dragged-symbol.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/ruler-mode.el.gz
(defun ruler-mode-mouse-grab-any-column (start-event)
"Drag a column symbol on the ruler.
Start dragging on mouse down event START-EVENT, and update the column
symbol value with the current value of the ruler graduation while
dragging. See also the variable `ruler-mode-dragged-symbol'."
(interactive "e")
(setq ruler-mode-dragged-symbol nil)
(let* ((start (event-start start-event))
col newc oldc)
(save-selected-window
(select-window (posn-window start))
(setq col (ruler-mode-window-col (car (posn-col-row start)))
newc (+ col (ruler-mode-text-scaled-window-hscroll)))
(and
(>= col 0) (< col (ruler-mode-text-scaled-window-width))
(cond
;; Handle the fill column.
((eq newc fill-column)
(setq oldc fill-column
ruler-mode-dragged-symbol 'fill-column)
t) ;; Start dragging
;; Handle the comment column.
((eq newc comment-column)
(setq oldc comment-column
ruler-mode-dragged-symbol 'comment-column)
t) ;; Start dragging
;; Handle the goal column.
;; A. On mouse down on the goal column character on the ruler,
;; update the `goal-column' value while dragging.
;; B. If `goal-column' is nil, set the goal column where the
;; mouse is clicked.
;; C. On mouse click on the goal column character on the
;; ruler, unset the goal column.
((eq newc goal-column) ; A. Drag the goal column.
(setq oldc goal-column
ruler-mode-dragged-symbol 'goal-column)
t) ;; Start dragging
((null goal-column) ; B. Set the goal column.
(setq oldc goal-column
goal-column newc)
;; mouse-2 coming AFTER drag-mouse-2 invokes `ding'. This
;; `ding' flushes the next messages about setting goal
;; column. So here I force fetch the event(mouse-2) and
;; throw away.
(read--potential-mouse-event)
;; Ding BEFORE `message' is OK.
(when ruler-mode-set-goal-column-ding-flag
(ding))
(message "Goal column set to %d (click on %s again to unset it)"
newc
(propertize (char-to-string ruler-mode-goal-column-char)
'face 'ruler-mode-goal-column))
nil) ;; Don't start dragging.
)
(if (eq 'click (ruler-mode-mouse-drag-any-column-iteration
(posn-window start)))
(when (eq 'goal-column ruler-mode-dragged-symbol)
;; C. Unset the goal column.
(set-goal-column t))
;; At end of dragging, report the updated column symbol.
(message "%s is set to %d (was %d)"
ruler-mode-dragged-symbol
(symbol-value ruler-mode-dragged-symbol)
oldc))))))