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

bind-key* doesn't actually override everything #1042

Open
dabrahams opened this issue Mar 12, 2023 · 6 comments
Open

bind-key* doesn't actually override everything #1042

dabrahams opened this issue Mar 12, 2023 · 6 comments

Comments

@dabrahams
Copy link
Contributor

Apparently you need to use overriding-terminal-local-map to achieve that.

@dabrahams
Copy link
Contributor Author

e.g., this works:

(unless overriding-terminal-local-map
  (setq overriding-terminal-local-map (make-sparse-keymap)))

(define-key overriding-terminal-local-map [(control return)] 'other-window)

@dabrahams
Copy link
Contributor Author

Egh, but overriding-terminal-local-map also gets cleared from time-to-time; I'm still trying to figure out when/why.

@skangas
Copy link
Collaborator

skangas commented Aug 5, 2023

Egh, but overriding-terminal-local-map also gets cleared from time-to-time; I'm still trying to figure out when/why.

Did you find out more here? What is the issue you are seeing and how can I reproduce it?

@dabrahams
Copy link
Contributor Author

Sorry, everything I know, which isn't much, is captured here

@skangas
Copy link
Collaborator

skangas commented Aug 6, 2023

Sorry, everything I know, which isn't much, is captured here

That link is giving me "404 Not Found".

@dabrahams
Copy link
Contributor Author

dabrahams commented Aug 7, 2023

Sorry, that repo is private for stupid reasons. The code in question is:

;; Prepare the keymap for my globally-overriding bindings.
(unless overriding-terminal-local-map
  (setq overriding-terminal-local-map (make-sparse-keymap)))

(defmacro dwa/global-key (key-name command &optional predicate)
  "Bind KEY-NAME to COMMAND in a way that's hard to override.

Forwards its arguments to `bind-key*', which see."
  `(progn
     (bind-key ,key-name ,command overriding-terminal-local-map ,predicate)
     ;; the above works for a while, but then overriding-terminal-local-map gets stomped on,
     ;; so add insurance with `bind-key*', which is imperfect (Magit overrides it).
     (bind-key* ,key-name ,command ,predicate)))

And note that it doesn't really work very well.

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

No branches or pull requests

2 participants