Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mickeynp/discover.el
Discover more of emacs with context menus!
https://github.com/mickeynp/discover.el
emacs emacs-lisp
Last synced: 2 months ago
JSON representation
Discover more of emacs with context menus!
- Host: GitHub
- URL: https://github.com/mickeynp/discover.el
- Owner: mickeynp
- License: gpl-3.0
- Created: 2013-12-18T00:00:55.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-13T08:49:02.000Z (over 10 years ago)
- Last Synced: 2024-04-16T03:46:30.818Z (6 months ago)
- Topics: emacs, emacs-lisp
- Language: Emacs Lisp
- Homepage: http://www.masteringemacs.org/article/discoverel-discover-emacs-context-menus
- Size: 238 KB
- Stars: 174
- Watchers: 18
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
discover.el
===========Discover more of emacs using context menus.
For in-depth information, including screenshots, please read my article on "discover.el: discover more of Emacs using context menus" here:
http://www.masteringemacs.org/articles/2013/12/21/discoverel-discover-emacs-context-menus/
Installation
------------Install it from MELPA. It's called ``discover``.
Third-party module support
--------------------------
If you want to support ``discover.el`` you must use the function ``discover-add-context-menu``, like so::(discover-add-context-menu
:context-menu '(isearch
(description "Isearch, occur and highlighting")
(lisp-switches
("-cf" "Case should fold search" case-fold-search t nil))
(lisp-arguments
("=l" "context lines to show (occur)"
"list-matching-lines-default-context-lines"
(lambda (dummy) (interactive) (read-number "Number of context lines to show: "))))
(actions
("Isearch"
("_" "isearch forward symbol" isearch-forward-symbol)
("w" "isearch forward word" isearch-forward-word))
("Occur"
("o" "occur" occur))
("More"
("h" "highlighters ..." makey-key-mode-popup-isearch-highlight))))
:bind "M-s")This will create a keybinding ``M-s`` against ``discover-mode``, making it generally available.
Under the hood a command is dynamically created to set the key when ``discover-mode-hook`` is called.To create a context menu that is only available to a specific mode is very easy, and is essentially an extension of the example above. This time I will use ``dired`` to demonstrate this::
(discover-add-context-menu
:context-menu '(dired ...)
:bind "?"
:mode 'dired-mode
:mode-hook 'dired-mode-hook
)As you can see, there is not much else to it. This will bind another dynamic command, but this time it will be against the hook specified in the property ``:mode-hook``. You must ensure you pick the correct mode hook; usually it is named after the major mode.
The string you give in ``:bind`` will be passed directly to ``kbd`` -- so no need to escape anything!
You may want to check if ``discover`` is present before you call ``discover-add-context-menu``. The easiest way is to check for its presence, like so::
(when (featurep 'discover)
(discover-add-context-menu
... ))Useful Helper Commands
~~~~~~~~~~~~~~~~~~~~~~
You can get the name of the command that reveals a given context menu by calling ``discover-get-context-menu-command-name``. If you just want to funcall the returned symbol, the function ``discover-show-context-menu`` will do this for you.Long-term Goals
===============#. Replace makey.el with the rewritten version proposed by the Magit team.