diff options
author | Juri Linkov <juri@linkov.net> | 2021-09-23 19:32:36 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-09-23 19:32:36 +0300 |
commit | 5d96fad27863497a427c80550070e435a4c9e0d9 (patch) | |
tree | d696ef623a63d9891f91b3b58b453afda7342205 /lisp/mouse.el | |
parent | da50b7ec133eeb7cdcdb56ade5ad7d2f2c337f6a (diff) | |
download | emacs-5d96fad27863497a427c80550070e435a4c9e0d9.tar.gz emacs-5d96fad27863497a427c80550070e435a4c9e0d9.tar.bz2 emacs-5d96fad27863497a427c80550070e435a4c9e0d9.zip |
New thing-at-point target 'list-or-string' used in context-menu-region
* lisp/mouse.el (context-menu-region): Rearrange the order to
All>Defun>List>Line>Symbol. Show title either "List" or "String"
depending on syntax-ppss, then use thing 'list-or-string' (bug#9054).
* lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point): Add optional
args 'escape-strings' and 'no-syntax-crossing' like in 'up-list'.
(list-or-string): New target 'list-or-string'.
(thing-at-point-bounds-of-list-or-string-at-point): New function.
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r-- | lisp/mouse.el | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 41333eb7f71..382c101159b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -455,10 +455,11 @@ Some context functions add menu items below the separator." `(menu-item "Paste" mouse-yank-at-click :help "Paste (yank) text most recently cut/copied"))) (when (and (cdr yank-menu) (not buffer-read-only)) - (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu")))) - (dolist (item yank-menu) + (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu"))) + (i 0)) + (dolist (item (reverse yank-menu)) (when (consp item) - (define-key-after submenu (vector (car item)) + (define-key submenu (vector (setq i (1+ i))) `(menu-item ,(cadr item) ,(lambda () (interactive) (mouse-yank-from-menu click (car item))))))) @@ -477,18 +478,19 @@ 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")) - (define-key-after submenu [mark-line] - `(menu-item "Line" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) - :help "Mark the line at click for a subsequent cut/copy")) (define-key-after submenu [mark-defun] `(menu-item "Defun" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) :help "Mark the defun at click for a subsequent cut/copy")) - (define-key-after submenu [mark-list] - `(menu-item "List" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) - :help "Mark the list at click for a subsequent cut/copy")) + (define-key-after submenu [mark-list-or-string] + `(menu-item ,(if (nth 8 (syntax-ppss (posn-point (event-end click)))) + "String" "List") + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list-or-string)) + :help "Mark list or 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)) + :help "Mark the line at click for a subsequent cut/copy")) (define-key-after submenu [mark-symbol] `(menu-item "Symbol" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol)) |