From: Ergus Date: Sun, 22 Aug 2021 08:56:01 +0000 (+0300) Subject: * lisp/mouse.el (context-menu-mode-map): New variable. X-Git-Tag: emacs-28.0.90~1364 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6984eea510a579a25bd7811f6d13e1bf2b4a35cb;p=emacs.git * lisp/mouse.el (context-menu-mode-map): New variable. (context-menu--saved-bindings, context-menu--bind-mouse) (context-menu--restore-bindings): Remove. (context-menu-mode): Don't use removed functions. --- diff --git a/lisp/mouse.el b/lisp/mouse.el index 7cdea34d865..6332d9fcec3 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -440,42 +440,22 @@ the same menu with changes such as added new menu items." `(menu-item ,(purecopy "Context Menu") ignore :filter (lambda (_) (context-menu-map)))) -(defvar context-menu--saved-bindings nil - "Alist of bindings to restore when `context-menu-mode' is disabled.") - -(defun context-menu--bind-mouse (click-sym down-sym) - "Enable `context-menu-mode' mouse bindings. -CLICK-SYM and DOWN-SYM are the mouse click and down key symbols to use." - (let ((click (vector click-sym)) - (down (vector down-sym))) - (push (cons click-sym (global-key-binding click)) - context-menu--saved-bindings) - (global-unset-key click) - (push (cons down-sym (global-key-binding down)) - context-menu--saved-bindings) - (global-set-key down context-menu-entry))) - -(defun context-menu--restore-bindings () - "Restore saved `context-menu-mode' bindings." - (pcase-dolist (`(,sym . ,binding) context-menu--saved-bindings) - (let ((key (vector sym))) - (if binding - (global-set-key key binding) - (global-unset-key key))))) +(defvar context-menu-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [mouse-3] nil) + (define-key map [down-mouse-3] context-menu-entry) + (when (featurep 'ns) + (define-key map [C-mouse-1] nil) + (define-key map [C-down-mouse-1] context-menu-entry)) + map) + "Context Menu mode map.") (define-minor-mode context-menu-mode "Toggle Context Menu mode. When Context Menu mode is enabled, clicking the mouse button down-mouse-3 activates the menu whose contents depends on its surrounding context." - :global t :group 'mouse - (if context-menu-mode - (progn - (setq context-menu--saved-bindings nil) - (context-menu--bind-mouse 'mouse-3 'down-mouse-3) - (when (featurep 'ns) - (context-menu--bind-mouse 'C-mouse-1 'C-down-mouse-1))) - (context-menu--restore-bindings))) + :global t :group 'mouse) ;; Commands that operate on windows.