use-package icon indicating copy to clipboard operation
use-package copied to clipboard

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

Open dabrahams opened this issue 1 year ago • 6 comments

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

dabrahams avatar Mar 12 '23 15:03 dabrahams

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 avatar Mar 12 '23 17:03 dabrahams

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

dabrahams avatar Mar 13 '23 00:03 dabrahams

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?

skangas avatar Aug 05 '23 15:08 skangas

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

dabrahams avatar Aug 05 '23 18:08 dabrahams

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

That link is giving me "404 Not Found".

skangas avatar Aug 06 '23 11:08 skangas

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.

dabrahams avatar Aug 07 '23 04:08 dabrahams