summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
authorCase Duckworth2021-08-25 23:44:10 -0500
committerCase Duckworth2021-08-25 23:44:10 -0500
commit274b6fd8bf998278ae78f13c0e3f3258cc3f8191 (patch)
tree95366a8adc044c023623446d3521a40e1d15e3b7 /init.el
parentAdd repeat maps to acdw-compat.el (diff)
downloademacs-274b6fd8bf998278ae78f13c0e3f3258cc3f8191.tar.gz
emacs-274b6fd8bf998278ae78f13c0e3f3258cc3f8191.zip
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.
Diffstat (limited to 'init.el')
-rw-r--r--init.el24
1 files changed, 20 insertions, 4 deletions
diff --git a/init.el b/init.el index f5b9e25..163d628 100644 --- a/init.el +++ b/init.el
@@ -210,15 +210,31 @@
210 (dolist (sym '(view-hello-file 210 (dolist (sym '(view-hello-file
211 suspend-frame 211 suspend-frame
212 scroll-left 212 scroll-left
213 scroll-right)) 213 scroll-right
214 comment-set-column
215 set-fill-column))
214 (put sym 'disabled t)) 216 (put sym 'disabled t))
215 217
216 ;; And set the disabled function to something better than the default. 218 ;; And set the disabled function to something better than the default.
219 ;; Now, I can run any disabled command, but I have to use M-x to do it.
217 (setq disabled-command-function 220 (setq disabled-command-function
218 (defun acdw/disabled-command-function (&optional cmd keys) 221 (defun acdw/disabled-command-function (&optional cmd keys)
219 (unless cmd (setq cmd this-command)) 222 (let ((cmd (or cmd this-command))
220 (unless keys (setq keys (this-command-keys))) 223 (keys (or keys (this-command-keys))))
221 (message "Command `%s' is disabled." cmd)))) 224 ;; this logic stolen from original `disabled-command-function'
225 (if (or (eq (aref keys 0) (if (stringp keys)
226 (aref "\M-x" 0)
227 ?\M-x))
228 (and (>= (length keys) 2)
229 (eq (aref keys 0) meta-prefix-char)
230 (eq (aref keys 1) ?x)))
231 ;; it's been run as an M-x command, we want to do it
232 (call-interactively cmd)
233 ;; else, tell the user it's disabled.
234 (message (substitute-command-keys
235 (concat "Command `%s' has been disabled. "
236 "Run with \\[execute-extended-command]."))
237 cmd))))))
222 238
223(setup ediff 239(setup ediff
224 (:option ediff-window-setup-function 'ediff-setup-windows-plain 240 (:option ediff-window-setup-function 'ediff-setup-windows-plain