'symbol-at-point') will narrow to the current field (if any) before
trying to identify the thing at point.
+*** New function 'thing-at-mouse'.
+
** image-dired
---
(save-excursion
(mouse-set-point event)
(current-word)))))
- (selected-window)
(dictionary-popup-matching-words word)))
;;;###autoload
(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
(defvar flyspell-overlay nil)
-(defun flyspell-context-menu (_menu)
+(defun flyspell-context-menu (_menu _click)
"Context menu for `context-menu-mode'."
;; TODO: refactor `flyspell-correct-word' and related functions to return
;; a keymap menu where every menu item is bound to a lambda that calls
(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 tries to use the event
+where the mouse button is clicked to find a thing nearby."
+ (save-excursion
+ (mouse-set-point event)
+ (thing-at-point thing no-properties)))
+
;;;###autoload
(defun thing-at-point (thing &optional no-properties)
"Return the THING at point.