Emacs Lisp - Should You Disable Keys Before Configuring Them?

If I'm going to override the key, should I call (global-unset-key (kbd "key-combo"))

, or using a function to global-set-key

automatically call that for me?

+3


source to share


2 answers


There is absolutely no need to turn off the key before configuring it.



It's like setting a variable in any programming language: you don't have to do foo = NULL

before foo = x

. This comparison is closer than one might think, because it (global-unset-key k)

coincides with (global-set-key k nil)

.

+7


source


Like sds saied, global-unset-key

it actually calls global-set-key

:

(defun global-unset-key (key)
  "Remove global binding of KEY.
KEY is a string or vector representing a sequence of keystrokes."
  (interactive "kUnset key globally: ")
  (global-set-key key nil))

      



so there is no real difference between the set command and the unset key.

+3


source







All Articles