Change disabled-command-function and disable commands
I want to be able to do anything, but some commands are bound to keys that I hit all the time and it's annoying. So I've disabled them but changed the `disabled-key-function' to check whether I've passed the command with M-x or using the dumb keybinding, and only allow the M-x form.
This commit is contained in:
parent
b584c1bccf
commit
274b6fd8bf
24
init.el
24
init.el
|
@ -210,15 +210,31 @@
|
|||
(dolist (sym '(view-hello-file
|
||||
suspend-frame
|
||||
scroll-left
|
||||
scroll-right))
|
||||
scroll-right
|
||||
comment-set-column
|
||||
set-fill-column))
|
||||
(put sym 'disabled t))
|
||||
|
||||
;; And set the disabled function to something better than the default.
|
||||
;; Now, I can run any disabled command, but I have to use M-x to do it.
|
||||
(setq disabled-command-function
|
||||
(defun acdw/disabled-command-function (&optional cmd keys)
|
||||
(unless cmd (setq cmd this-command))
|
||||
(unless keys (setq keys (this-command-keys)))
|
||||
(message "Command `%s' is disabled." cmd))))
|
||||
(let ((cmd (or cmd this-command))
|
||||
(keys (or keys (this-command-keys))))
|
||||
;; this logic stolen from original `disabled-command-function'
|
||||
(if (or (eq (aref keys 0) (if (stringp keys)
|
||||
(aref "\M-x" 0)
|
||||
?\M-x))
|
||||
(and (>= (length keys) 2)
|
||||
(eq (aref keys 0) meta-prefix-char)
|
||||
(eq (aref keys 1) ?x)))
|
||||
;; it's been run as an M-x command, we want to do it
|
||||
(call-interactively cmd)
|
||||
;; else, tell the user it's disabled.
|
||||
(message (substitute-command-keys
|
||||
(concat "Command `%s' has been disabled. "
|
||||
"Run with \\[execute-extended-command]."))
|
||||
cmd))))))
|
||||
|
||||
(setup ediff
|
||||
(:option ediff-window-setup-function 'ediff-setup-windows-plain
|
||||
|
|
Loading…
Reference in New Issue