Warn about key rebinds
This commit is contained in:
parent
4ea052b970
commit
4e666d5c6b
3
init.el
3
init.el
@ -40,6 +40,9 @@
|
||||
(load "frame-manip")
|
||||
(load "file-manip")
|
||||
(load "window-manip")
|
||||
(load "gpolonkai-misc")
|
||||
|
||||
(advice-add 'define-key :before #'warn-key-rebind)
|
||||
|
||||
;; Define aliases
|
||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||
|
27
lisp/gpolonkai-misc.el
Normal file
27
lisp/gpolonkai-misc.el
Normal file
@ -0,0 +1,27 @@
|
||||
(defun warn-key-rebind (keymap key new-def)
|
||||
"Warn if a key is being rebound."
|
||||
(let ((global-def (global-key-binding key))
|
||||
(local-def (local-key-binding key))
|
||||
(minor-defs (minor-mode-key-binding key))
|
||||
(key-desc (key-description key)))
|
||||
(when (and global-def
|
||||
(not (numberp global-def))
|
||||
(not (equal global-def new-def)))
|
||||
(warn "'%s' from the global keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
global-def
|
||||
new-def))
|
||||
(when (and local-def
|
||||
(not (numberp local-def))
|
||||
(not (equal local-def new-def)))
|
||||
(warn "'%s' from the local keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
local-def
|
||||
new-def))
|
||||
(when minor-defs
|
||||
(dolist (binding minor-defs)
|
||||
(warn "'%s' from '%s' keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
(car binding)
|
||||
(cdr binding)
|
||||
new-def)))))
|
Loading…
Reference in New Issue
Block a user