diff options
| author | Sam Steingold | 2008-05-02 14:37:39 +0000 |
|---|---|---|
| committer | Sam Steingold | 2008-05-02 14:37:39 +0000 |
| commit | 5ad4f91cb233c9e277871ed494fcde48d26540d0 (patch) | |
| tree | 7d69b0ef23ce9da178cccc2ec13fbb926f10637c | |
| parent | bfab7c6ec74dc55d640ef36f8cb1790a1420f991 (diff) | |
| download | emacs-5ad4f91cb233c9e277871ed494fcde48d26540d0.tar.gz emacs-5ad4f91cb233c9e277871ed494fcde48d26540d0.zip | |
* vc.el (vc-dir-mode-map): Enable mouse bindings.
(vc-at-event): New macro: run the body at the even location.
(vc-dir-menu, vc-dir-toggle-mark): Use it.
(vc-dir-mark-file, vc-dir-unmark-file): Move only on non-mouse events.
* subr.d (mouse-event-p): Check if the even is mouse-related.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/subr.el | 5 | ||||
| -rw-r--r-- | lisp/vc.el | 32 |
3 files changed, 34 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 125b38a4574..9d7bab9d327 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2008-05-02 Sam Steingold <sds@gnu.org> | ||
| 2 | |||
| 3 | * vc.el (vc-dir-mode-map): Enable mouse bindings. | ||
| 4 | (vc-at-event): New macro: run the body at the even location. | ||
| 5 | (vc-dir-menu, vc-dir-toggle-mark): Use it. | ||
| 6 | (vc-dir-mark-file, vc-dir-unmark-file): Move only on non-mouse events. | ||
| 7 | * subr.d (mouse-event-p): Check if the even is mouse-related. | ||
| 8 | |||
| 1 | 2008-05-02 Nick Roberts <nickrob@snap.net.nz> | 9 | 2008-05-02 Nick Roberts <nickrob@snap.net.nz> |
| 2 | 10 | ||
| 3 | * progmodes/gdb-ui.el (gdb-info-breakpoints-custom): Don't | 11 | * progmodes/gdb-ui.el (gdb-info-breakpoints-custom): Don't |
diff --git a/lisp/subr.el b/lisp/subr.el index 6629589d5ba..7e09de7f3e4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -828,6 +828,11 @@ in the current Emacs session, then this function may return nil." | |||
| 828 | "Return non-nil if OBJECT is a mouse movement event." | 828 | "Return non-nil if OBJECT is a mouse movement event." |
| 829 | (eq (car-safe object) 'mouse-movement)) | 829 | (eq (car-safe object) 'mouse-movement)) |
| 830 | 830 | ||
| 831 | (defun mouse-event-p (object) | ||
| 832 | "Return non-nil if OBJECT is a mouse click event." | ||
| 833 | ;; is this really correct? maybe remove mouse-movement? | ||
| 834 | (memq (event-basic-type object) '(mouse-1 mouse-2 mouse-3 mouse-movement))) | ||
| 835 | |||
| 831 | (defsubst event-start (event) | 836 | (defsubst event-start (event) |
| 832 | "Return the starting position of EVENT. | 837 | "Return the starting position of EVENT. |
| 833 | If EVENT is a mouse or key press or a mouse click, this returns the location | 838 | If EVENT is a mouse or key press or a mouse click, this returns the location |
diff --git a/lisp/vc.el b/lisp/vc.el index f1286aece5e..426f7660eda 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -2991,10 +2991,8 @@ specific headers." | |||
| 2991 | (define-key map "q" 'quit-window) | 2991 | (define-key map "q" 'quit-window) |
| 2992 | (define-key map "g" 'vc-dir-refresh) | 2992 | (define-key map "g" 'vc-dir-refresh) |
| 2993 | (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) | 2993 | (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process) |
| 2994 | ;; Does not work unless mouse sets point. Functions like vc-dir-find-file | 2994 | (define-key map [(down-mouse-3)] 'vc-dir-menu) |
| 2995 | ;; need to find the file from the mouse position, not `point'. | 2995 | (define-key map [(mouse-2)] 'vc-dir-toggle-mark) |
| 2996 | ;; (define-key map [(down-mouse-3)] 'vc-dir-menu) | ||
| 2997 | ;; (define-key map [(mouse-2)] 'vc-dir-toggle-mark) | ||
| 2998 | 2996 | ||
| 2999 | ;; Hook up the menu. | 2997 | ;; Hook up the menu. |
| 3000 | (define-key map [menu-bar vc-dir-mode] | 2998 | (define-key map [menu-bar vc-dir-mode] |
| @@ -3022,10 +3020,21 @@ specific headers." | |||
| 3022 | '("----") | 3020 | '("----") |
| 3023 | ext-binding)))) | 3021 | ext-binding)))) |
| 3024 | 3022 | ||
| 3023 | (defmacro vc-at-event (event &rest body) | ||
| 3024 | "Evaluate `body' wich point located at event-start of `event'. | ||
| 3025 | If `body' uses `event', it should be a variable, | ||
| 3026 | otherwise it will be evaluated twice." | ||
| 3027 | (let ((posn (gensym "vc-at-event-posn"))) | ||
| 3028 | `(let ((,posn (event-start ,event))) | ||
| 3029 | (save-excursion | ||
| 3030 | (set-buffer (window-buffer (posn-window ,posn))) | ||
| 3031 | (goto-char (posn-point ,posn)) | ||
| 3032 | ,@body)))) | ||
| 3033 | |||
| 3025 | (defun vc-dir-menu (e) | 3034 | (defun vc-dir-menu (e) |
| 3026 | "Popup the VC status menu." | 3035 | "Popup the VC status menu." |
| 3027 | (interactive "e") | 3036 | (interactive "e") |
| 3028 | (popup-menu vc-dir-menu-map e)) | 3037 | (vc-at-event e (popup-menu vc-dir-menu-map e))) |
| 3029 | 3038 | ||
| 3030 | (defvar vc-dir-tool-bar-map | 3039 | (defvar vc-dir-tool-bar-map |
| 3031 | (let ((map (make-sparse-keymap))) | 3040 | (let ((map (make-sparse-keymap))) |
| @@ -3416,7 +3425,7 @@ If a prefix argument is given, move by that many lines." | |||
| 3416 | (and (not isdir) (not (vc-dir-parent-marked-p crt)))) | 3425 | (and (not isdir) (not (vc-dir-parent-marked-p crt)))) |
| 3417 | (setf (vc-dir-fileinfo->marked file) t) | 3426 | (setf (vc-dir-fileinfo->marked file) t) |
| 3418 | (ewoc-invalidate vc-ewoc crt) | 3427 | (ewoc-invalidate vc-ewoc crt) |
| 3419 | (unless arg | 3428 | (unless (or arg (mouse-event-p last-command-event)) |
| 3420 | (vc-dir-next-line 1))))) | 3429 | (vc-dir-next-line 1))))) |
| 3421 | 3430 | ||
| 3422 | (defun vc-dir-mark () | 3431 | (defun vc-dir-mark () |
| @@ -3481,7 +3490,8 @@ share the same state." | |||
| 3481 | (file (ewoc-data crt))) | 3490 | (file (ewoc-data crt))) |
| 3482 | (setf (vc-dir-fileinfo->marked file) nil) | 3491 | (setf (vc-dir-fileinfo->marked file) nil) |
| 3483 | (ewoc-invalidate vc-ewoc crt) | 3492 | (ewoc-invalidate vc-ewoc crt) |
| 3484 | (vc-dir-next-line 1))) | 3493 | (unless (mouse-event-p last-command-event) |
| 3494 | (vc-dir-next-line 1)))) | ||
| 3485 | 3495 | ||
| 3486 | (defun vc-dir-unmark () | 3496 | (defun vc-dir-unmark () |
| 3487 | "Unmark the current file or all files in the region. | 3497 | "Unmark the current file or all files in the region. |
| @@ -3545,15 +3555,15 @@ that share the same state." | |||
| 3545 | (vc-dir-unmark-file) | 3555 | (vc-dir-unmark-file) |
| 3546 | (vc-dir-mark-file)))) | 3556 | (vc-dir-mark-file)))) |
| 3547 | 3557 | ||
| 3548 | (defun vc-dir-toggle-mark () | 3558 | (defun vc-dir-toggle-mark (e) |
| 3549 | (interactive) | 3559 | (interactive "e") |
| 3550 | (vc-dir-mark-unmark 'vc-dir-toggle-mark-file)) | 3560 | (vc-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) |
| 3551 | 3561 | ||
| 3552 | (defun vc-dir-register () | 3562 | (defun vc-dir-register () |
| 3553 | "Register the marked files, or the current file if no marks." | 3563 | "Register the marked files, or the current file if no marks." |
| 3554 | (interactive) | 3564 | (interactive) |
| 3555 | ;; FIXME: Just pass the fileset to vc-register. | 3565 | ;; FIXME: Just pass the fileset to vc-register. |
| 3556 | (mapc (lambda (arg) (vc-register nil arg)) | 3566 | (mapc (lambda (arg) (vc-register nil arg)) |
| 3557 | (or (vc-dir-marked-files) (list (vc-dir-current-file))))) | 3567 | (or (vc-dir-marked-files) (list (vc-dir-current-file))))) |
| 3558 | 3568 | ||
| 3559 | (defun vc-dir-delete-file () | 3569 | (defun vc-dir-delete-file () |