Question

I want to silent disabled commands in Emacs. Possibly unbind them altogether.

When I slip on a disabled-command binding (e.g. a in Dired) — which I am not allowing because I don't want to use it — I'd like it to fail silently, instead of having me cancel what I didn't intend to do. On a per-command basis would be nice, but I don't mind removing them all.

I'm aware of Enable all disabled commands permanently, but I'm after disabling them permanently. I could unbind them one by one, I guess, but that would mean sourcing what map they're defined in, which I cannot do (apart from being a hassle).

Was it helpful?

Solution

The simplest way is

(setq disabled-command-function 'ignore)

Then the disabled keys are ignored, nothing happens when you hit, e.g., C-x n n.

OTHER TIPS

Because I was annoyed a couple of times that I hit C-x C-c by mistake, I made a function:

(defun not-anymore ()
"For overwriting wrong keybindings"
  (interactive)
  (message "not anymore")
)

(global-set-key (kbd "C-x C-c") 'not-anymore)

You could just omit the message line, ofcourse.

This allows you to exclude commands as you choose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top