Merge from origin/emacs-28

da23e607d3 Select the right buffer for event in context-menu function...
This commit is contained in:
Stefan Kangas 2021-12-07 06:47:32 +01:00
commit abf06a46b4
2 changed files with 12 additions and 9 deletions

View file

@ -489,14 +489,15 @@ Some context functions add menu items below the separator."
`(menu-item "All" `(menu-item "All"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer)) ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer))
:help "Mark the whole buffer for a subsequent cut/copy")) :help "Mark the whole buffer for a subsequent cut/copy"))
(when (let* ((pos (posn-point (event-end click))) (with-current-buffer (window-buffer (posn-window (event-end click)))
(char (when pos (char-after pos)))) (when (let* ((pos (posn-point (event-end click)))
(or (and char (eq (char-syntax char) ?\")) (char (when pos (char-after pos))))
(nth 3 (save-excursion (syntax-ppss pos))))) (or (and char (eq (char-syntax char) ?\"))
(define-key-after submenu [mark-string] (nth 3 (save-excursion (syntax-ppss pos)))))
`(menu-item "String" (define-key-after submenu [mark-string]
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'string)) `(menu-item "String"
:help "Mark the string at click for a subsequent cut/copy"))) ,(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] (define-key-after submenu [mark-line]
`(menu-item "Line" `(menu-item "Line"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line))

View file

@ -93,7 +93,9 @@
'mark-whole-buffer) 'mark-whole-buffer)
;; Include text-mode select menu only in strings and comments. ;; 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)) (text-mode-context-menu menu click))
menu) menu)