1

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).

Community
  • 1
  • 1
Nikana Reklawyks
  • 3,233
  • 3
  • 33
  • 49

2 Answers2

2

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.

sds
  • 58,617
  • 29
  • 161
  • 278
1

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.

PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
  • Riiight, that's an option, but it messes up overrides by local maps in some cases, I guess ? (And there's still every single one to disable by hand in `.emacs`.) – Nikana Reklawyks Jan 11 '13 at 21:56
  • except that you could override those local maps? and yea, but I thought that was what you were after: whenever a command bothers you, you exclude it? – PascalVKooten Jan 11 '13 at 22:04
  • 1
    True enough, **this has the advantage of knowing what you're skipping, and doing it on a per-command basis**. +1. I accept sds' answer for peace of mind, though. The perfect answer would be a "shut up" case in the disabled-command's menu : *don't do it, and never offer me to do it anymore*, which would *automatically* disable it forever. – Nikana Reklawyks Jan 11 '13 at 23:33