Context menus in Emacs 28!
Today I learned that Emacs 28 added
context-menu-mode so that we can easily add context menus. This is a minor mode which you can toggle with
M-x context-menu-mode RET
but I added hooks to enable it for text mode and a couple others
(add-hook 'text-mode-hook 'context-menu-mode) (add-hook 'shell-mode-hook 'context-menu-mode) (add-hook 'dired-mode-hook 'context-menu-mode)
I did not hook prog mode because some of the fancier lsp things already use mouse-3.
Last year, I talked about dictionaries including
dictionary-search in Emacs and binding it to a key. Now let's put it on a context menu!
(require 'dictionary) (defun my-context-menu (menu click) "My context menu" (define-key-after menu [dictionary-lookup] '(menu-item "Dict" dictionary-search-word-at-mouse :help "Look up in dictionary")) menu) ;; hook into context menu (add-hook 'context-menu-functions #'my-context-menu)
Now right-clicking on a word in Emacs has a
Dict choice on the context menu.
Selecting it looks up the word