[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50067: Context menus
From: |
Juri Linkov |
Subject: |
bug#50067: Context menus |
Date: |
Sat, 28 Aug 2021 21:50:15 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
> Hi. I'm one of the users of Emacs-jp. Tak introduced us to this
> thread and it got me interested, I'm sending this Email. This
> mail thread is huge and I haven't read all of it, so I'm sorry if
> I misread the context.
>
> I've created a context menu for ispell (referencing `context-menu-ffap`).
> You may find some inspiration from this.
>
> (defun context-menu-ispell (menu)
> "Ispell at point menu."
> (when t ;; (ffap-guess-file-name-at-point)
> (define-key menu [ispell-separator] menu-bar-separator)
> (define-key menu [ispell-at-mouse]
> '(menu-item "Check spelling of word" ispell-word
> :help "Check spelling of word under or before the
> cursor.")))
> menu)
Thanks for the suggestion. I think such menus should be added to their
respective packages. context-menu-ispell could be added to ispell.el
(when flyspell is unavailable).
Then dictionary.el could provide own context menu too:
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index f33cbaf112..7a84f9978f 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -1368,5 +1368,27 @@ global-dictionary-tooltip-mode
(if on #'dictionary-tooltip-track-mouse #'ignore))
on))
+(defun dictionary-search-word-at-mouse (event)
+ (interactive "e")
+ (let ((word (save-window-excursion
+ (save-excursion
+ (mouse-set-point event)
+ (current-word)))))
+ (selected-window)
+ (dictionary-search word)))
+
+(defun context-menu-dictionary (menu)
+ "Dictionary word at point menu."
+ (save-excursion
+ (mouse-set-point last-input-event)
+ (when (thing-at-point '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
bug#50067: Context menus, Naoya Yamashita, 2021/08/28
- bug#50067: Context menus,
Juri Linkov <=
- bug#50067: Context menus, Juri Linkov, 2021/08/18
- bug#50067: Context menus, Mattias Engdegård, 2021/08/18
- bug#50067: Context menus, Eli Zaretskii, 2021/08/18
- bug#50067: Context menus, Mattias Engdegård, 2021/08/19
- bug#50067: Context menus, Juri Linkov, 2021/08/20
- bug#50067: Context menus, Mattias Engdegård, 2021/08/20
- bug#50067: Context menus, Dmitry Gutov, 2021/08/20
- bug#50067: Context menus, Tak Kunihiro, 2021/08/21
- bug#50067: Context menus, Tak Kunihiro, 2021/08/21
- bug#50067: Context menus, Juri Linkov, 2021/08/22