Commit 08a1c178 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(C-down-mouse-1): Use buffer menu, not font menu.

(S-down-mouse-1): Put font menu here.
parent baf9b8c4
......@@ -285,6 +285,83 @@ This command must be bound to a mouse click."
(/= top (nth 1 (window-edges)))))
(set-window-configuration wconfig)))))))))
(defun mouse-drag-vertical-line (start-event)
"Change the width of a window by dragging on the vertical line."
(interactive "e")
;; Give temporary modes such as isearch a chance to turn off.
(run-hooks 'mouse-leave-buffer-hook)
(let ((done nil)
(echo-keystrokes 0)
(start-event-frame (window-frame (car (car (cdr start-event)))))
(start-event-window (car (car (cdr start-event))))
(start-nwindows (count-windows t))
(old-selected-window (selected-window))
event mouse x left right edges wconfig growth)
(if (one-window-p t)
(error "Attempt to resize sole ordinary window"))
(if (= (nth 2 (window-edges start-event-window))
(frame-width start-event-frame))
(error "Attempt to drag rightmost scrollbar"))
(track-mouse
(progn
;; enlarge-window only works on the selected window, so
;; we must select the window where the start event originated.
;; unwind-protect will restore the old selected window later.
(select-window start-event-window)
;; loop reading events and sampling the position of
;; the mouse.
(while (not done)
(setq event (read-event)
mouse (mouse-position))
;; do nothing if
;; - there is a switch-frame event.
;; - the mouse isn't in the frame that we started in
;; - the mouse isn't in any Emacs frame
;; drag if
;; - there is a mouse-movement event
;; - there is a scroll-bar-movement event
;; (same as mouse movement for our purposes)
;; quit if
;; - there is a keyboard event or some other unknown event
;; unknown event.
(cond ((integerp event)
(setq done t))
((eq (car event) 'switch-frame)
nil)
((not (memq (car event)
'(mouse-movement scroll-bar-movement)))
(if (consp event)
(setq unread-command-events
(cons event unread-command-events)))
(setq done t))
((not (eq (car mouse) start-event-frame))
nil)
((null (car (cdr mouse)))
nil)
(t
(setq x (car (cdr mouse))
edges (window-edges)
left (nth 0 edges)
right (nth 2 edges))
;; scale back a move that would make the
;; window too thin.
(cond ((< (- x left -1) window-min-width)
(setq x (+ left window-min-width -1))))
;; compute size change needed
(setq growth (- x right -1)
wconfig (current-window-configuration))
(enlarge-window growth t)
;; if this window's growth caused another
;; window to be deleted because it was too
;; thin, rescind the change.
;;
;; if size change caused space to be stolen
;; from a window to the left of this one,
;; rescind the change.
(if (or (/= start-nwindows (count-windows t))
(/= left (nth 0 (window-edges))))
(set-window-configuration wconfig)))))))))
(defun mouse-set-point (event)
"Move point to the position clicked on with the mouse.
This should be bound to a mouse click event type."
......@@ -350,11 +427,20 @@ the mouse back into the window, or release the button.
This variable's value may be non-integral.
Setting this to zero causes Emacs to scroll as fast as it can.")
(defvar mouse-scroll-min-lines 1
"*The minimum number of lines scrolled at a time by dragging the mouse
beyond the edge of a window.")
(defun mouse-scroll-subr (window jump &optional overlay start)
"Scroll the window WINDOW, JUMP lines at a time, until new input arrives.
If OVERLAY is an overlay, let it stretch from START to the far edge of
the newly visible text.
Upon exit, point is at the far edge of the newly visible text."
(cond
((and (> jump 0) (< jump mouse-scroll-min-lines))
(setq jump mouse-scroll-min-lines))
((and (< jump 0) (< (- jump) mouse-scroll-min-lines))
(setq jump (- mouse-scroll-min-lines))))
(let ((opoint (point)))
(while (progn
(goto-char (window-start window))
......@@ -410,11 +496,19 @@ release the mouse button. Otherwise, it does not."
(setq mouse-selection-click-count click-count)
(setq mouse-selection-click-count-buffer (current-buffer))
(mouse-set-point start-event)
;; In case the down click is in the middle of some intangible text,
;; use the end of that text, and put it in START-POINT.
(if (< (point) start-point)
(goto-char start-point))
(setq start-point (point))
(let ((range (mouse-start-end start-point start-point click-count)))
(move-overlay mouse-drag-overlay (car range) (nth 1 range)
(window-buffer start-window)))
(deactivate-mark)
(let (event end end-point)
;; end-of-range is used only in the single-click case.
;; It is the place where the drag has reached so far
;; (but not outside the window where the drag started).
(let (event end end-point (end-of-range (point)))
(track-mouse
(while (progn
(setq event (read-event))
......@@ -429,7 +523,13 @@ release the mouse button. Otherwise, it does not."
;; Are we moving within the original window?
((and (eq (posn-window end) start-window)
(integer-or-marker-p end-point))
;; Go to START-POINT first, so that when we move to END-POINT,
;; if it's in the middle of intangible text,
;; point jumps in the direction away from START-POINT.
(goto-char start-point)
(goto-char end-point)
(if (zerop (% click-count 3))
(setq end-of-range (point)))
(let ((range (mouse-start-end start-point (point) click-count)))
(move-overlay mouse-drag-overlay (car range) (nth 1 range))))
......@@ -450,7 +550,11 @@ release the mouse button. Otherwise, it does not."
;; because it would fail to set up a region.
(if (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
;; In this case, we can just let the up-event execute normally.
(progn
(let ((end (event-end event)))
;; Set the position in the event before we replay it,
;; because otherwise it may have a position in the wrong
;; buffer.
(setcar (cdr end) end-of-range)
;; Delete the overlay before calling the function,
;; because delete-overlay increases buffer-modified-tick.
(delete-overlay mouse-drag-overlay)
......@@ -476,15 +580,20 @@ release the mouse button. Otherwise, it does not."
If DIR is positive skip forward; if negative, skip backward."
(let* ((char (following-char))
(syntax (char-to-string (char-syntax char))))
(if (or (string= syntax "w") (string= syntax " "))
(if (< dir 0)
(skip-syntax-backward syntax)
(skip-syntax-forward syntax))
(if (< dir 0)
(while (and (not (bobp)) (= (preceding-char) char))
(forward-char -1))
(while (and (not (eobp)) (= (following-char) char))
(forward-char 1))))))
(cond ((or (string= syntax "w") (string= syntax " "))
(if (< dir 0)
(skip-syntax-backward syntax)
(skip-syntax-forward syntax)))
((string= syntax "_")
(if (< dir 0)
(skip-syntax-backward "w_")
(skip-syntax-forward "w_")))
((< dir 0)
(while (and (not (bobp)) (= (preceding-char) char))
(forward-char -1)))
(t
(while (and (not (eobp)) (= (following-char) char))
(forward-char 1))))))
;; Return a list of region bounds based on START and END according to MODE.
;; If MODE is 0 then set point to (min START END), mark to (max START END).
......@@ -1561,7 +1670,9 @@ and selects that window."
;; By binding these to down-going events, we let the user use the up-going
;; event to make the selection, saving a click.
(global-set-key [C-down-mouse-1] 'mouse-set-font)
(global-set-key [C-down-mouse-1] 'mouse-buffer-menu)
(if (not (eq system-type 'ms-dos))
(global-set-key [S-down-mouse-1] 'mouse-set-font))
;; C-down-mouse-2 is bound in facemenu.el.
(global-set-key [C-down-mouse-3] 'mouse-major-mode-menu)
......@@ -1577,6 +1688,8 @@ and selects that window."
(global-set-key [mode-line C-mouse-2] 'mouse-split-window-horizontally)
(global-set-key [vertical-scroll-bar C-mouse-2] 'mouse-split-window-vertically)
(global-set-key [vertical-line C-mouse-2] 'mouse-split-window-vertically)
(global-set-key [vertical-line down-mouse-1] 'mouse-drag-vertical-line)
(global-set-key [vertical-line mouse-1] 'mouse-select-window)
(provide 'mouse)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment