Compare commits

...

1 Commits

Author SHA1 Message Date
4e666d5c6b Warn about key rebinds 2016-11-18 10:27:12 +01:00
2 changed files with 30 additions and 0 deletions

View File

@ -40,6 +40,9 @@
(load "frame-manip") (load "frame-manip")
(load "file-manip") (load "file-manip")
(load "window-manip") (load "window-manip")
(load "gpolonkai-misc")
(advice-add 'define-key :before #'warn-key-rebind)
;; Define aliases ;; Define aliases
(defalias 'yes-or-no-p 'y-or-n-p) (defalias 'yes-or-no-p 'y-or-n-p)

27
lisp/gpolonkai-misc.el Normal file
View 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)))))