jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.4k stars 260 forks source link

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

Open dabrahams opened 1 year ago

dabrahams commented 1 year ago

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

dabrahams commented 1 year ago

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 commented 1 year ago

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

skangas commented 1 year ago

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 commented 1 year ago

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

skangas commented 1 year ago

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

That link is giving me "404 Not Found".

dabrahams commented 1 year ago

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.