[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-28 da23e60: Select the right buffer for event in context-menu func
From: |
Juri Linkov |
Subject: |
emacs-28 da23e60: Select the right buffer for event in context-menu functions (bug#9923) |
Date: |
Mon, 6 Dec 2021 12:24:33 -0500 (EST) |
branch: emacs-28
commit da23e607d33260c9aabaa3d136722a45457930dc
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
Select the right buffer for event in context-menu functions (bug#9923)
* lisp/mouse.el (context-menu-region):
* lisp/progmodes/prog-mode.el (prog-context-menu):
Switch to the buffer displayed by the window of the event
before using syntax-ppss, char-after.
---
lisp/mouse.el | 17 +++++++++--------
lisp/progmodes/prog-mode.el | 4 +++-
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5c645a4..8474a82 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -479,14 +479,15 @@ Some context functions add menu items below the
separator."
`(menu-item "All"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e
'buffer))
:help "Mark the whole buffer for a subsequent cut/copy"))
- (when (let* ((pos (posn-point (event-end click)))
- (char (when pos (char-after pos))))
- (or (and char (eq (char-syntax char) ?\"))
- (nth 3 (save-excursion (syntax-ppss pos)))))
- (define-key-after submenu [mark-string]
- `(menu-item "String"
- ,(lambda (e) (interactive "e") (mark-thing-at-mouse e
'string))
- :help "Mark the string at click for a subsequent
cut/copy")))
+ (with-current-buffer (window-buffer (posn-window (event-end click)))
+ (when (let* ((pos (posn-point (event-end click)))
+ (char (when pos (char-after pos))))
+ (or (and char (eq (char-syntax char) ?\"))
+ (nth 3 (save-excursion (syntax-ppss pos)))))
+ (define-key-after submenu [mark-string]
+ `(menu-item "String"
+ ,(lambda (e) (interactive "e") (mark-thing-at-mouse e
'string))
+ :help "Mark the string at click for a subsequent
cut/copy"))))
(define-key-after submenu [mark-line]
`(menu-item "Line"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line))
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 4997c27..e43f2ff 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -87,7 +87,9 @@
'mark-whole-buffer)
;; Include text-mode select menu only in strings and comments.
- (when (nth 8 (save-excursion (syntax-ppss (posn-point (event-end click)))))
+ (when (nth 8 (save-excursion
+ (with-current-buffer (window-buffer (posn-window (event-end
click)))
+ (syntax-ppss (posn-point (event-end click))))))
(text-mode-context-menu menu click))
menu)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-28 da23e60: Select the right buffer for event in context-menu functions (bug#9923),
Juri Linkov <=