;; Switch to the window clicked on, because otherwise
;; the mode's commands may not make sense.
(interactive "@e\nP")
+ ;; Let the mode update its menus first.
+ (run-hooks 'activate-menubar-hook)
(let (;; This is where mouse-major-mode-menu-prefix
;; returns the prefix we should use (after menu-bar).
;; It is either nil or (SOME-SYMBOL).
(defun mouse-delete-window (click)
"Delete the window you click on.
-This must be bound to a mouse click."
+If the frame has just one window, bury the current buffer instead.
+This command must be bound to a mouse click."
(interactive "e")
- (mouse-minibuffer-check click)
- (delete-window (posn-window (event-start click))))
+ (if (one-window-p t)
+ (bury-buffer)
+ (mouse-minibuffer-check click)
+ (delete-window (posn-window (event-start click)))))
(defun mouse-select-window (click)
"Select the window clicked on; don't move point."
'right)))
(if (one-window-p t)
(error "Attempt to resize sole ordinary window"))
- (if (eq which-side 'left)
- (if (= (nth 0 (window-edges start-event-window)) 0)
- (error "Attempt to drag leftmost scrollbar"))
- (if (= (nth 2 (window-edges start-event-window))
- (frame-width start-event-frame))
- (error "Attempt to drag rightmost scrollbar")))
+ (if (eq which-side 'right)
+ (if (= (nth 2 (window-edges start-event-window))
+ (frame-width start-event-frame))
+ (error "Attempt to drag rightmost scrollbar"))
+ (if (= (nth 0 (window-edges start-event-window)) 0)
+ (error "Attempt to drag leftmost scrollbar")))
(track-mouse
(progn
;; enlarge-window only works on the selected window, so
(save-selected-window
;; If the scroll bar is on the window's left,
;; adjust the window on the left.
- (if (eq which-side 'left)
- (select-window (previous-window)))
+ (unless (eq which-side 'right)
+ (select-window (previous-window)))
(setq x (- (car (cdr mouse))
- (if (eq which-side 'left) 2 0))
+ (if (eq which-side 'right) 0 2))
edges (window-edges)
left (nth 0 edges)
right (nth 2 edges))
(mouse-scroll-subr start-window (1+ (- mouse-row bottom))
mouse-drag-overlay start-point)
(setq end-of-range (overlay-end mouse-drag-overlay))))))))))
+ ;; In case we did not get a mouse-motion event
+ ;; for the final move of the mouse before a drag event
+ ;; pretend that we did get one.
+ (when (and (memq 'drag (event-modifiers (car-safe event)))
+ (setq end (event-end event)
+ end-point (posn-point end))
+ (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))))
+
(if (consp event)
(let ((fun (key-binding (vector (car event)))))
;; Run the binding of the terminating up-event, if possible.
If DIR is positive skip forward; if negative, skip backward."
(let* ((char (following-char))
(syntax (char-to-string (char-syntax char))))
- (cond ((or (string= syntax "w") (string= syntax " "))
+ (cond ((string= syntax "w")
+ ;; Here, we can't use skip-syntax-forward/backward because
+ ;; they don't pay attention to word-separating-categories,
+ ;; and thus they will skip over a true word boundary. So,
+ ;; we simularte the original behaviour by using
+ ;; forward-word.
+ (if (< dir 0)
+ (if (not (looking-at "\\<"))
+ (forward-word -1))
+ (if (or (looking-at "\\<") (not (looking-at "\\>")))
+ (forward-word 1))))
+ ((string= syntax " ")
(if (< dir 0)
(skip-syntax-backward syntax)
(skip-syntax-forward syntax)))