mickeynp / discover.el

Discover more of emacs with context menus!
http://www.masteringemacs.org/article/discoverel-discover-emacs-context-menus
GNU General Public License v3.0
177 stars 16 forks source link

Replacing prefix bindings messes up user-added shortcuts #7

Open orki opened 10 years ago

orki commented 10 years ago

Unlike the dired context menu (invoked via ?), the context menus for "C-x r" and "M-s" replace the prefix-map wholesale. Like many others (such as Magnar Sveen), I have "M-s O" bound to moccur. Of course, using discover.el destroys this binding. I do not see how this can be avoided with the approach taken in discover.el other than something similar to guide-key.el.

In general, especially since we are on emacs where everything is configurable, given an interactive function name in a curated list, it should be possible to discover the actual keybinding (if any) for said function in the given prefix keymap, thereby maintaining consistency and avoiding the specification of the actual keys in the action list.

I am not sure my elisp-fu is up to discovering keys automatically, but I will have a go at it.

mickeynp commented 10 years ago

Hi orki

You're right that discover will not display custom commands bound to a prefix group; you're also partially right that this is a "bug."

It's actually more of an oversight or an architectural detail I haven't yet decided on how I want to approach.

The main thrust of discover is that it provides a curated list of shortcuts and variables instead od doing just what guide-key, et al. do which is to map, wholesale, an entire key map and displaying that. There are advantages to both; mine will let you have custom action categories to better categorize content - this is important for discovery. The downside is it's not self-aware enough to pick up on custom prefix keys.

I think the work-around is keep the manual approach but show any stragglers like your custom keys in another action category called "Misc"

Thanks for reporting the issue.

dhaley commented 10 years ago

Really like discover-mode especially in dired. But I have tons of M-s custom bindings I don't want to lose.

Listing them in "Misc" when pressing M-s would be awesome.

colbell commented 10 years ago

Emacs - 24.3.1 on Ubuntu 13.10. Emacs installed from https://launchpad.net/~cassou/+archive/emacs

All packages installed using ELPA.

I use Icicles mode which also remaps the M-s key and so stops the discover M-s context menu from appearing. Here is a list of the Icicles M-s mappings:

M-s M-s         Prefix Command

M-s M-s C-l     icicle-search-pages
M-s M-s ESC     Prefix Command
M-s M-s ,       icicle-tags-search
M-s M-s D       icicle-search-defs-full
M-s M-s I       icicle-imenu-full
M-s M-s J       icicle-search-bookmarks-together
M-s M-s O       icicle-search-overlay-property
M-s M-s T       icicle-search-text-property
M-s M-s X       icicle-search-xml-element-text-node
M-s M-s b       icicle-search-buffer
M-s M-s c       icicle-search-char-property
M-s M-s d       icicle-search-defs
M-s M-s f       icicle-search-file
M-s M-s g       icicle-grep-saved-file-candidates
M-s M-s i       icicle-imenu
M-s M-s j       icicle-search-bookmark
M-s M-s k       icicle-search-keywords
M-s M-s l       icicle-search-lines
M-s M-s o       icicle-occur
M-s M-s p       icicle-search-paragraphs
M-s M-s s       icicle-search-sentences
M-s M-s t       icicle-search-thing
M-s M-s w       icicle-search-word
M-s M-s x       icicle-search-xml-element

You can get around it by changing the Icicles mapping to use M-t M-t instead of M-s M-s. Once you do this the Discover M-s mapping works fine.

(setq icicle-search-key-prefix "\364\364")  ;; Originally \363\363

I also had an intermittent problem with the C-x r mapping not showing the context menu. I seem to have fixed this by removing undo-tree-mode. This was a mode that I installed, played around with and never used again. As the problem was intermittent I can't guarantee that it is fixed but its looking good at the moment.

Other than these two minor issues think that Discover.el is a wonderful idea. For some reason I can never remember the register key bindings so the C-x r menu is very useful to me.

mickeynp commented 10 years ago

This is the unfortunate consequence of having such a flexible. hackable editor: people change their settings and that can sadly break discover! Aside from remapping icicle to another key I don't have much of a suggestion.