diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index ab17748df5..536eef5406 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -151,6 +151,15 @@ bounds-of-thing-at-point (if (and (<= real-beg orig) (<= orig end) (< real-beg end)) (cons real-beg end)))))))))) +;;;###autoload +(defun thing-at-mouse (event thing &optional no-properties) + "Return the THING at mouse click. +Like `thing-at-point', but reacts to the event +where the mouse button is clicked." + (save-excursion + (mouse-set-point last-input-event) + (thing-at-point thing no-properties))) + ;;;###autoload (defun thing-at-point (thing &optional no-properties) "Return the THING at point. diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index f33cbaf112..c9b2bdeaf1 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1368,5 +1367,14 @@ global-dictionary-tooltip-mode (if on #'dictionary-tooltip-track-mouse #'ignore)) on)) +(defun context-menu-dictionary (menu) + "Dictionary context menu." + (when (thing-at-mouse last-input-event '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) + (provide 'dictionary) ;;; dictionary.el ends here