[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4877dde: * lisp/mouse.el (context-menu-map): Add 'click' arg to c
From: |
Juri Linkov |
Subject: |
master 4877dde: * lisp/mouse.el (context-menu-map): Add 'click' arg to called funs (bug#50256) |
Date: |
Sun, 12 Sep 2021 13:12:06 -0400 (EDT) |
branch: master
commit 4877ddeaf739af3a683d8686d1e2fa5e51960623
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* 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.
---
lisp/dired.el | 4 ++--
lisp/help-mode.el | 4 ++--
lisp/info.el | 4 ++--
lisp/mouse.el | 47 +++++++++++++++++++++++----------------------
lisp/net/eww.el | 6 +++---
lisp/net/goto-addr.el | 4 ++--
lisp/progmodes/prog-mode.el | 6 +++---
7 files changed, 38 insertions(+), 37 deletions(-)
diff --git a/lisp/dired.el b/lisp/dired.el
index 958677c..1ed83cb 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -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
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index d224bdc..d341b4c 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -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")
diff --git a/lisp/info.el b/lisp/info.el
index c09c75a..b861fff 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -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")))
diff --git a/lisp/mouse.el b/lisp/mouse.el
index f7ade5f..bd11ec5 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -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]
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 90301e9..62f1992 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -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
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 2c43d0f..97230f4 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -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
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index be9b72e..bd2c653 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -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]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4877dde: * lisp/mouse.el (context-menu-map): Add 'click' arg to called funs (bug#50256),
Juri Linkov <=