Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support keymap symbol in bind-key. Fix #845 #846

Merged
merged 4 commits into from Aug 5, 2020
Merged

Support keymap symbol in bind-key. Fix #845 #846

merged 4 commits into from Aug 5, 2020

Conversation

wyuenho
Copy link
Contributor

@wyuenho wyuenho commented Jun 9, 2020

Sometimes, there are packages such as prettier that expose commands that one would like to bind to multiple modes in their mode hooks. In which case the mode map will likely be dynamically constructed from the mode symbol, and one would like to bind keys like the following:

(dolist (mode '(css-mode js-mode ...))
  (let ((mode-hook (derived-mode-hook-name mode)))
    (add-hook mode-hook (lambda ()
       (bind-key "C-c f" 'prettier-prettify (derived-mode-map-name mode)))))

The problem is, bind-key currently does not support KEYMAP supplied as a symbol, and if it is supplied as a (symbol-value (derived-mode-map-name mode)), there's no way to reverse lookup the name of the variable from the symbol value later on when constructing the buffer for describe-personal-bindings, hence #845 .

This PR proposes a fix to this problem by supporting KEYMAP as symbols, while preserving backward compatibility.

@wyuenho
Copy link
Contributor Author

wyuenho commented Aug 5, 2020

@jwiegley How does this look?

@jwiegley
Copy link
Owner

jwiegley commented Aug 5, 2020

If this is backward compatible with how things worked before, then it sounds good to me.

@wyuenho
Copy link
Contributor Author

wyuenho commented Aug 5, 2020

It is :)

@jwiegley jwiegley merged commit 4fb1f9a into jwiegley:master Aug 5, 2020
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this pull request Nov 24, 2022
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants