Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Lisp - Should you unset keys before setting them?

Tags:

emacs

elisp

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?

like image 925
Czipperz Avatar asked Dec 03 '25 09:12

Czipperz


1 Answers

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

like image 99
sds Avatar answered Dec 06 '25 16:12

sds