diff options
author | Juri Linkov <juri@linkov.net> | 2021-09-12 20:32:02 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-09-12 20:32:02 +0300 |
commit | bd917088e69e71e77c15069f0751096141ca3f1a (patch) | |
tree | 149567f8d3e8e74662c85a708500cd49121c591d /lisp/net/dictionary.el | |
parent | 4877ddeaf739af3a683d8686d1e2fa5e51960623 (diff) | |
download | emacs-bd917088e69e71e77c15069f0751096141ca3f1a.tar.gz emacs-bd917088e69e71e77c15069f0751096141ca3f1a.tar.bz2 emacs-bd917088e69e71e77c15069f0751096141ca3f1a.zip |
* lisp/thingatpt.el (thing-at-mouse): New function (bug#50256).
* lisp/net/dictionary.el: Add 'context-menu-dictionary' to
'context-menu-functions'.
(dictionary-search-word-at-mouse): New function.
(context-menu-dictionary): New function that uses 'thing-at-mouse'.
(dictionary-mouse-popup-matching-words): Remove stray 'selected-window'.
* lisp/textmodes/flyspell.el (flyspell-context-menu): Add '_click' arg.
Diffstat (limited to 'lisp/net/dictionary.el')
-rw-r--r-- | lisp/net/dictionary.el | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 0f42af0911b..5a6f3b555d2 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1211,7 +1211,6 @@ allows editing it." (save-excursion (mouse-set-point event) (current-word))))) - (selected-window) (dictionary-popup-matching-words word))) ;;;###autoload @@ -1368,5 +1367,26 @@ any buffer where (dictionary-tooltip-mode 1) has been called." (if on #'dictionary-tooltip-track-mouse #'ignore)) on)) +;;; Context menu support + +(defun dictionary-search-word-at-mouse (event) + (interactive "e") + (let ((word (save-window-excursion + (save-excursion + (mouse-set-point event) + (current-word))))) + (dictionary-search word))) + +(defun context-menu-dictionary (menu click) + "Dictionary context menu." + (when (thing-at-mouse click 'word) + (define-key menu [dictionary-separator] menu-bar-separator) + (define-key menu [dictionary-search-word-at-mouse] + '(menu-item "Dictionary Search" dictionary-search-word-at-mouse + :help "Search the word at mouse click in dictionary"))) + menu) + +(add-hook 'context-menu-functions 'context-menu-dictionary 15) + (provide 'dictionary) ;;; dictionary.el ends here |