Search code examples
emacselisp

Emacs Lisp - Should you unset keys before setting them?


If I'm going to redefine a key, should I call (global-unset-key (kbd "key-combo")), or does using the function global-set-key automatically call that for me?


Solution

  • There is absolutely no need to unset the key before setting it.

    This is similar to variable setting in any programming language: you do not need to do foo = NULL before foo = x. This comparison is closer than one might think because (global-unset-key k) is the same as (global-set-key k nil).