diff options
| -rw-r--r-- | lisp/mouse.el | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 4ff1b9659e4..d40fea1f50f 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -39,15 +39,23 @@ | |||
| 39 | (defvar mouse-yank-at-point nil | 39 | (defvar mouse-yank-at-point nil |
| 40 | "*If non-nil, mouse yank commands yank at point instead of at click.") | 40 | "*If non-nil, mouse yank commands yank at point instead of at click.") |
| 41 | 41 | ||
| 42 | (defun mouse-minibuffer-check (event) | ||
| 43 | (let ((w (posn-window (event-start event)))) | ||
| 44 | (and (window-minibuffer-p w) | ||
| 45 | (not (minibuffer-window-active-p w)) | ||
| 46 | (error "Minibuffer window is not active")))) | ||
| 47 | |||
| 42 | (defun mouse-delete-window (click) | 48 | (defun mouse-delete-window (click) |
| 43 | "Delete the window you click on. | 49 | "Delete the window you click on. |
| 44 | This must be bound to a mouse click." | 50 | This must be bound to a mouse click." |
| 45 | (interactive "e") | 51 | (interactive "e") |
| 52 | (mouse-minibuffer-check click) | ||
| 46 | (delete-window (posn-window (event-start click)))) | 53 | (delete-window (posn-window (event-start click)))) |
| 47 | 54 | ||
| 48 | (defun mouse-select-window (click) | 55 | (defun mouse-select-window (click) |
| 49 | "Select the window clicked on; don't move point." | 56 | "Select the window clicked on; don't move point." |
| 50 | (interactive "e") | 57 | (interactive "e") |
| 58 | (mouse-minibuffer-check click) | ||
| 51 | (let ((oframe (selected-frame)) | 59 | (let ((oframe (selected-frame)) |
| 52 | (frame (window-frame (posn-window (event-start click))))) | 60 | (frame (window-frame (posn-window (event-start click))))) |
| 53 | (select-window (posn-window (event-start click))) | 61 | (select-window (posn-window (event-start click))) |
| @@ -60,6 +68,7 @@ This must be bound to a mouse click." | |||
| 60 | (defun mouse-tear-off-window (click) | 68 | (defun mouse-tear-off-window (click) |
| 61 | "Delete the window clicked on, and create a new frame displaying its buffer." | 69 | "Delete the window clicked on, and create a new frame displaying its buffer." |
| 62 | (interactive "e") | 70 | (interactive "e") |
| 71 | (mouse-minibuffer-check click) | ||
| 63 | (let* ((window (posn-window (event-start click))) | 72 | (let* ((window (posn-window (event-start click))) |
| 64 | (buf (window-buffer window)) | 73 | (buf (window-buffer window)) |
| 65 | (frame (new-frame))) | 74 | (frame (new-frame))) |
| @@ -77,6 +86,7 @@ This must be bound to a mouse click." | |||
| 77 | The window is split at the line clicked on. | 86 | The window is split at the line clicked on. |
| 78 | This command must be bound to a mouse click." | 87 | This command must be bound to a mouse click." |
| 79 | (interactive "@e") | 88 | (interactive "@e") |
| 89 | (mouse-minibuffer-check click) | ||
| 80 | (let ((start (event-start click))) | 90 | (let ((start (event-start click))) |
| 81 | (select-window (posn-window start)) | 91 | (select-window (posn-window start)) |
| 82 | (let ((new-height (if (eq (posn-point start) 'vertical-scroll-bar) | 92 | (let ((new-height (if (eq (posn-point start) 'vertical-scroll-bar) |
| @@ -95,6 +105,7 @@ This command must be bound to a mouse click." | |||
| 95 | The window is split at the column clicked on. | 105 | The window is split at the column clicked on. |
| 96 | This command must be bound to a mouse click." | 106 | This command must be bound to a mouse click." |
| 97 | (interactive "@e") | 107 | (interactive "@e") |
| 108 | (mouse-minibuffer-check click) | ||
| 98 | (let ((start (event-start click))) | 109 | (let ((start (event-start click))) |
| 99 | (select-window (posn-window start)) | 110 | (select-window (posn-window start)) |
| 100 | (let ((new-width (1+ (car (posn-col-row (event-end click))))) | 111 | (let ((new-width (1+ (car (posn-col-row (event-end click))))) |
| @@ -109,12 +120,10 @@ This command must be bound to a mouse click." | |||
| 109 | "Move point to the position clicked on with the mouse. | 120 | "Move point to the position clicked on with the mouse. |
| 110 | This should be bound to a mouse click event type." | 121 | This should be bound to a mouse click event type." |
| 111 | (interactive "e") | 122 | (interactive "e") |
| 123 | (mouse-minibuffer-check event) | ||
| 112 | ;; Use event-end in case called from mouse-drag-region. | 124 | ;; Use event-end in case called from mouse-drag-region. |
| 113 | ;; If EVENT is a click, event-end and event-start give same value. | 125 | ;; If EVENT is a click, event-end and event-start give same value. |
| 114 | (let ((posn (event-end event))) | 126 | (let ((posn (event-end event))) |
| 115 | (and (window-minibuffer-p (posn-window posn)) | ||
| 116 | (not (minibuffer-window-active-p (posn-window posn))) | ||
| 117 | (error "Minibuffer window is not active")) | ||
| 118 | (select-window (posn-window posn)) | 127 | (select-window (posn-window posn)) |
| 119 | (if (numberp (posn-point posn)) | 128 | (if (numberp (posn-point posn)) |
| 120 | (goto-char (posn-point posn))))) | 129 | (goto-char (posn-point posn))))) |
| @@ -123,6 +132,7 @@ This should be bound to a mouse click event type." | |||
| 123 | "Set the region to the text dragged over, and copy to kill ring. | 132 | "Set the region to the text dragged over, and copy to kill ring. |
| 124 | This should be bound to a mouse drag event." | 133 | This should be bound to a mouse drag event." |
| 125 | (interactive "e") | 134 | (interactive "e") |
| 135 | (mouse-minibuffer-check click) | ||
| 126 | (let ((posn (event-start click)) | 136 | (let ((posn (event-start click)) |
| 127 | (end (event-end click))) | 137 | (end (event-end click))) |
| 128 | (select-window (posn-window posn)) | 138 | (select-window (posn-window posn)) |
| @@ -185,6 +195,7 @@ This must be bound to a button-down mouse event. | |||
| 185 | In Transient Mark mode, the highlighting remains once you | 195 | In Transient Mark mode, the highlighting remains once you |
| 186 | release the mouse button. Otherwise, it does not." | 196 | release the mouse button. Otherwise, it does not." |
| 187 | (interactive "e") | 197 | (interactive "e") |
| 198 | (mouse-minibuffer-check start-event) | ||
| 188 | (let* ((start-posn (event-start start-event)) | 199 | (let* ((start-posn (event-start start-event)) |
| 189 | (start-point (posn-point start-posn)) | 200 | (start-point (posn-point start-posn)) |
| 190 | (start-window (posn-window start-posn)) | 201 | (start-window (posn-window start-posn)) |
| @@ -338,6 +349,7 @@ If DIR is positive skip forward; if negative, skip backward." | |||
| 338 | ;; Subroutine: set the mark where CLICK happened, | 349 | ;; Subroutine: set the mark where CLICK happened, |
| 339 | ;; but don't do anything else. | 350 | ;; but don't do anything else. |
| 340 | (defun mouse-set-mark-fast (click) | 351 | (defun mouse-set-mark-fast (click) |
| 352 | (mouse-minibuffer-check click) | ||
| 341 | (let ((posn (event-start click))) | 353 | (let ((posn (event-start click))) |
| 342 | (select-window (posn-window posn)) | 354 | (select-window (posn-window posn)) |
| 343 | (if (numberp (posn-point posn)) | 355 | (if (numberp (posn-point posn)) |
| @@ -367,6 +379,7 @@ This must be bound to a mouse click." | |||
| 367 | "Kill the region between point and the mouse click. | 379 | "Kill the region between point and the mouse click. |
| 368 | The text is saved in the kill ring, as with \\[kill-region]." | 380 | The text is saved in the kill ring, as with \\[kill-region]." |
| 369 | (interactive "e") | 381 | (interactive "e") |
| 382 | (mouse-minibuffer-check click) | ||
| 370 | (let ((click-posn (posn-point (event-start click)))) | 383 | (let ((click-posn (posn-point (event-start click)))) |
| 371 | (if (numberp click-posn) | 384 | (if (numberp click-posn) |
| 372 | (kill-region (min (point) click-posn) | 385 | (kill-region (min (point) click-posn) |
| @@ -443,6 +456,7 @@ selection through the word or line clicked on. If you do this | |||
| 443 | again in a different position, it extends the selection again. | 456 | again in a different position, it extends the selection again. |
| 444 | If you do this twice in the same position, the selection is killed." | 457 | If you do this twice in the same position, the selection is killed." |
| 445 | (interactive "e") | 458 | (interactive "e") |
| 459 | (mouse-minibuffer-check click) | ||
| 446 | (let ((click-posn (posn-point (event-start click))) | 460 | (let ((click-posn (posn-point (event-start click))) |
| 447 | ;; Don't let a subsequent kill command append to this one: | 461 | ;; Don't let a subsequent kill command append to this one: |
| 448 | ;; prevent setting this-command to kill-region. | 462 | ;; prevent setting this-command to kill-region. |
| @@ -534,6 +548,7 @@ If you do this twice in the same position, the selection is killed." | |||
| 534 | Use \\[mouse-secondary-save-then-kill] to set the other end | 548 | Use \\[mouse-secondary-save-then-kill] to set the other end |
| 535 | and complete the secondary selection." | 549 | and complete the secondary selection." |
| 536 | (interactive "e") | 550 | (interactive "e") |
| 551 | (mouse-minibuffer-check click) | ||
| 537 | (let ((posn (event-start click))) | 552 | (let ((posn (event-start click))) |
| 538 | (save-excursion | 553 | (save-excursion |
| 539 | (set-buffer (window-buffer (posn-window posn))) | 554 | (set-buffer (window-buffer (posn-window posn))) |
| @@ -550,6 +565,7 @@ and complete the secondary selection." | |||
| 550 | "Set the secondary selection to the text that the mouse is dragged over. | 565 | "Set the secondary selection to the text that the mouse is dragged over. |
| 551 | This must be bound to a mouse drag event." | 566 | This must be bound to a mouse drag event." |
| 552 | (interactive "e") | 567 | (interactive "e") |
| 568 | (mouse-minibuffer-check click) | ||
| 553 | (let ((posn (event-start click)) | 569 | (let ((posn (event-start click)) |
| 554 | beg | 570 | beg |
| 555 | (end (event-end click))) | 571 | (end (event-end click))) |
| @@ -567,6 +583,7 @@ This must be bound to a mouse drag event." | |||
| 567 | Highlight the drag area as you move the mouse. | 583 | Highlight the drag area as you move the mouse. |
| 568 | This must be bound to a button-down mouse event." | 584 | This must be bound to a button-down mouse event." |
| 569 | (interactive "e") | 585 | (interactive "e") |
| 586 | (mouse-minibuffer-check start-event) | ||
| 570 | (let* ((start-posn (event-start start-event)) | 587 | (let* ((start-posn (event-start start-event)) |
| 571 | (start-point (posn-point start-posn)) | 588 | (start-point (posn-point start-posn)) |
| 572 | (start-window (posn-window start-posn)) | 589 | (start-window (posn-window start-posn)) |
| @@ -712,6 +729,7 @@ selection through the word or line clicked on. If you do this | |||
| 712 | again in a different position, it extends the selection again. | 729 | again in a different position, it extends the selection again. |
| 713 | If you do this twice in the same position, the selection is killed." | 730 | If you do this twice in the same position, the selection is killed." |
| 714 | (interactive "e") | 731 | (interactive "e") |
| 732 | (mouse-minibuffer-check click) | ||
| 715 | (let ((posn (event-start click)) | 733 | (let ((posn (event-start click)) |
| 716 | (click-posn (posn-point (event-start click))) | 734 | (click-posn (posn-point (event-start click))) |
| 717 | ;; Don't let a subsequent kill command append to this one: | 735 | ;; Don't let a subsequent kill command append to this one: |
| @@ -816,6 +834,7 @@ If you do this twice in the same position, the selection is killed." | |||
| 816 | This switches buffers in the window that you clicked on, | 834 | This switches buffers in the window that you clicked on, |
| 817 | and selects that window." | 835 | and selects that window." |
| 818 | (interactive "e") | 836 | (interactive "e") |
| 837 | (mouse-minibuffer-check event) | ||
| 819 | (let ((menu | 838 | (let ((menu |
| 820 | (list "Buffer Menu" | 839 | (list "Buffer Menu" |
| 821 | (cons "Select Buffer" | 840 | (cons "Select Buffer" |