* lisp/mouse.el (context-menu-map): Add 'click' arg to called funs (bug#50256)
(context-menu-toolbar, context-menu-global, context-menu-local) (context-menu-minor, context-menu-buffers, context-menu-vc) (context-menu-undo, context-menu-region, context-menu-ffap): Add 'click' arg. * lisp/dired.el (dired-context-menu): * lisp/help-mode.el (help-mode-context-menu): * lisp/info.el (Info-context-menu): * lisp/net/eww.el (eww-context-menu): * lisp/net/goto-addr.el (goto-address-context-menu): * lisp/progmodes/prog-mode.el (prog-context-menu): Add 'click' arg.
This commit is contained in:
parent
ff4de1bd88
commit
4877ddeaf7
7 changed files with 38 additions and 37 deletions
|
@ -2193,8 +2193,8 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
|
|||
["Delete Image Tag..." image-dired-delete-tag
|
||||
:help "Delete image tag from current or marked files"]))
|
||||
|
||||
(defun dired-context-menu (menu)
|
||||
(when (mouse-posn-property (event-start last-input-event) 'dired-filename)
|
||||
(defun dired-context-menu (menu click)
|
||||
(when (mouse-posn-property (event-start click) 'dired-filename)
|
||||
(define-key menu [dired-separator] menu-bar-separator)
|
||||
(let ((easy-menu (make-sparse-keymap "Immediate")))
|
||||
(easy-menu-define nil easy-menu nil
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
["Customize" help-customize
|
||||
:help "Customize variable or face"]))
|
||||
|
||||
(defun help-mode-context-menu (menu)
|
||||
(defun help-mode-context-menu (menu click)
|
||||
(define-key menu [help-mode-separator] menu-bar-separator)
|
||||
(let ((easy-menu (make-sparse-keymap "Help-Mode")))
|
||||
(easy-menu-define nil easy-menu nil
|
||||
|
@ -85,7 +85,7 @@
|
|||
(when (consp item)
|
||||
(define-key menu (vector (car item)) (cdr item)))))
|
||||
|
||||
(when (mouse-posn-property (event-start last-input-event) 'mouse-face)
|
||||
(when (mouse-posn-property (event-start click) 'mouse-face)
|
||||
(define-key menu [help-mode-push-button]
|
||||
'(menu-item "Follow Link" (lambda (event)
|
||||
(interactive "e")
|
||||
|
|
|
@ -4151,7 +4151,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
|
|||
"---"
|
||||
["Exit" quit-window :help "Stop reading Info"]))
|
||||
|
||||
(defun Info-context-menu (menu)
|
||||
(defun Info-context-menu (menu click)
|
||||
(define-key menu [Info-separator] menu-bar-separator)
|
||||
(let ((easy-menu (make-sparse-keymap "Info")))
|
||||
(easy-menu-define nil easy-menu nil
|
||||
|
@ -4164,7 +4164,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
|
|||
(when (consp item)
|
||||
(define-key menu (vector (car item)) (cdr item)))))
|
||||
|
||||
(when (mouse-posn-property (event-start last-input-event) 'mouse-face)
|
||||
(when (mouse-posn-property (event-start click) 'mouse-face)
|
||||
(define-key menu [Info-mouse-follow-nearest-node]
|
||||
'(menu-item "Follow Link" Info-mouse-follow-nearest-node
|
||||
:help "Follow a link where you click")))
|
||||
|
|
|
@ -284,8 +284,8 @@ not it is actually displayed."
|
|||
context-menu-local
|
||||
context-menu-minor)
|
||||
"List of functions that produce the contents of the context menu.
|
||||
Each function receives the menu as its argument and should return
|
||||
the same menu with changes such as added new menu items."
|
||||
Each function receives the menu and the mouse click event as its arguments
|
||||
and should return the same menu with changes such as added new menu items."
|
||||
:type '(repeat
|
||||
(choice (function-item context-menu-undo)
|
||||
(function-item context-menu-region)
|
||||
|
@ -304,17 +304,18 @@ the same menu with changes such as added new menu items."
|
|||
:type '(choice (const nil) function)
|
||||
:version "28.1")
|
||||
|
||||
(defun context-menu-map ()
|
||||
(defun context-menu-map (&optional click)
|
||||
"Return composite menu map."
|
||||
(let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))))
|
||||
(let ((fun (mouse-posn-property (event-start last-input-event)
|
||||
'context-menu-function)))
|
||||
(if (functionp fun)
|
||||
(setq menu (funcall fun menu))
|
||||
(run-hook-wrapped 'context-menu-functions
|
||||
(lambda (fun)
|
||||
(setq menu (funcall fun menu))
|
||||
nil))))
|
||||
(let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))
|
||||
(click (or click last-input-event))
|
||||
(fun (mouse-posn-property (event-start click)
|
||||
'context-menu-function)))
|
||||
(if (functionp fun)
|
||||
(setq menu (funcall fun menu click))
|
||||
(run-hook-wrapped 'context-menu-functions
|
||||
(lambda (fun)
|
||||
(setq menu (funcall fun menu click))
|
||||
nil)))
|
||||
|
||||
;; Remove duplicate separators
|
||||
(let ((l menu))
|
||||
|
@ -325,10 +326,10 @@ the same menu with changes such as added new menu items."
|
|||
(setq l (cdr l))))
|
||||
|
||||
(when (functionp context-menu-filter-function)
|
||||
(setq menu (funcall context-menu-filter-function menu)))
|
||||
(setq menu (funcall context-menu-filter-function menu click)))
|
||||
menu))
|
||||
|
||||
(defun context-menu-toolbar (menu)
|
||||
(defun context-menu-toolbar (menu _click)
|
||||
"Tool bar menu items."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-toolbar] menu-bar-separator)
|
||||
|
@ -339,7 +340,7 @@ the same menu with changes such as added new menu items."
|
|||
(lookup-key global-map [tool-bar]))
|
||||
menu)
|
||||
|
||||
(defun context-menu-global (menu)
|
||||
(defun context-menu-global (menu _click)
|
||||
"Global submenus."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-global] menu-bar-separator)
|
||||
|
@ -350,7 +351,7 @@ the same menu with changes such as added new menu items."
|
|||
(lookup-key global-map [menu-bar]))
|
||||
menu)
|
||||
|
||||
(defun context-menu-local (menu)
|
||||
(defun context-menu-local (menu _click)
|
||||
"Major mode submenus."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-local] menu-bar-separator)
|
||||
|
@ -363,7 +364,7 @@ the same menu with changes such as added new menu items."
|
|||
keymap)))
|
||||
menu)
|
||||
|
||||
(defun context-menu-minor (menu)
|
||||
(defun context-menu-minor (menu _click)
|
||||
"Minor modes submenus."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-minor] menu-bar-separator)
|
||||
|
@ -376,7 +377,7 @@ the same menu with changes such as added new menu items."
|
|||
(cdr mode))))
|
||||
menu)
|
||||
|
||||
(defun context-menu-buffers (menu)
|
||||
(defun context-menu-buffers (menu _click)
|
||||
"Submenus with buffers."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-buffers] menu-bar-separator)
|
||||
|
@ -387,13 +388,13 @@ the same menu with changes such as added new menu items."
|
|||
(mouse-buffer-menu-keymap))
|
||||
menu)
|
||||
|
||||
(defun context-menu-vc (menu)
|
||||
(defun context-menu-vc (menu _click)
|
||||
"Version Control menu."
|
||||
(define-key-after menu [separator-vc] menu-bar-separator)
|
||||
(define-key-after menu [vc-menu] vc-menu-entry)
|
||||
menu)
|
||||
|
||||
(defun context-menu-undo (menu)
|
||||
(defun context-menu-undo (menu _click)
|
||||
"Undo menu."
|
||||
(define-key-after menu [separator-undo] menu-bar-separator)
|
||||
(when (and (not buffer-read-only)
|
||||
|
@ -411,7 +412,7 @@ the same menu with changes such as added new menu items."
|
|||
:help "Redo last undone edits")))
|
||||
menu)
|
||||
|
||||
(defun context-menu-region (menu)
|
||||
(defun context-menu-region (menu _click)
|
||||
"Region commands menu."
|
||||
(define-key-after menu [separator-region] menu-bar-separator)
|
||||
(when (and mark-active (not buffer-read-only))
|
||||
|
@ -456,10 +457,10 @@ the same menu with changes such as added new menu items."
|
|||
:help "Mark the whole buffer for a subsequent cut/copy"))
|
||||
menu)
|
||||
|
||||
(defun context-menu-ffap (menu)
|
||||
(defun context-menu-ffap (menu click)
|
||||
"File at point menu."
|
||||
(save-excursion
|
||||
(mouse-set-point last-input-event)
|
||||
(mouse-set-point click)
|
||||
(when (ffap-guess-file-name-at-point)
|
||||
(define-key menu [ffap-separator] menu-bar-separator)
|
||||
(define-key menu [ffap-at-mouse]
|
||||
|
|
|
@ -1021,7 +1021,7 @@ the like."
|
|||
["Toggle Paragraph Direction" eww-toggle-paragraph-direction]))
|
||||
map))
|
||||
|
||||
(defun eww-context-menu (menu)
|
||||
(defun eww-context-menu (menu click)
|
||||
(define-key menu [eww-separator] menu-bar-separator)
|
||||
(let ((easy-menu (make-sparse-keymap "Eww")))
|
||||
(easy-menu-define nil easy-menu nil
|
||||
|
@ -1035,8 +1035,8 @@ the like."
|
|||
(when (consp item)
|
||||
(define-key menu (vector (car item)) (cdr item)))))
|
||||
|
||||
(when (or (mouse-posn-property (event-start last-input-event) 'shr-url)
|
||||
(mouse-posn-property (event-start last-input-event) 'image-url))
|
||||
(when (or (mouse-posn-property (event-start click) 'shr-url)
|
||||
(mouse-posn-property (event-start click) 'image-url))
|
||||
(define-key menu [shr-mouse-browse-url-new-window]
|
||||
`(menu-item "Follow URL in new window" ,(if browse-url-new-window-flag
|
||||
'shr-mouse-browse-url
|
||||
|
|
|
@ -124,8 +124,8 @@ will have no effect.")
|
|||
m)
|
||||
"Keymap to hold goto-addr's mouse key defs under highlighted URLs.")
|
||||
|
||||
(defun goto-address-context-menu (menu)
|
||||
(when (mouse-posn-property (event-start last-input-event) 'goto-address)
|
||||
(defun goto-address-context-menu (menu click)
|
||||
(when (mouse-posn-property (event-start click) 'goto-address)
|
||||
(define-key menu [goto-address-separator] menu-bar-separator)
|
||||
(define-key menu [goto-address-at-mouse]
|
||||
'(menu-item "Follow Link" goto-address-at-mouse
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
display-line-numbers-mode
|
||||
prettify-symbols-mode))
|
||||
|
||||
(defun prog-context-menu (menu)
|
||||
(defun prog-context-menu (menu click)
|
||||
(require 'xref)
|
||||
(define-key-after menu [prog-separator] menu-bar-separator
|
||||
'mark-whole-buffer)
|
||||
(when (save-excursion
|
||||
(mouse-set-point last-input-event)
|
||||
(mouse-set-point click)
|
||||
(xref-backend-identifier-at-point
|
||||
(xref-find-backend)))
|
||||
(define-key-after menu [xref-find-def]
|
||||
|
@ -56,7 +56,7 @@
|
|||
:help "Find definition of identifier")
|
||||
'prog-separator))
|
||||
(when (save-excursion
|
||||
(mouse-set-point last-input-event)
|
||||
(mouse-set-point click)
|
||||
(xref-backend-identifier-at-point
|
||||
(xref-find-backend)))
|
||||
(define-key-after menu [xref-find-ref]
|
||||
|
|
Loading…
Add table
Reference in a new issue