* lisp/keymap.el (define-keymap): Demote "duplicate def" to a warning
* test/src/keymap-tests.el (keymap-test-duplicate-definitions): Adjust accordingly.
This commit is contained in:
parent
a764b503e1
commit
eb779ae646
2 changed files with 22 additions and 7 deletions
|
@ -577,9 +577,15 @@ should be a MENU form as accepted by `easy-menu-define'.
|
|||
(let ((def (pop definitions)))
|
||||
(if (eq key :menu)
|
||||
(easy-menu-define nil keymap "" def)
|
||||
(if (member key seen-keys)
|
||||
(error "Duplicate definition for key: %S %s" key keymap)
|
||||
(push key seen-keys))
|
||||
(when (member key seen-keys)
|
||||
;; Since the keys can be computed dynamically, it can
|
||||
;; very well happen that we get duplicate definitions
|
||||
;; due to some unfortunate configuration rather than
|
||||
;; due to an actual bug. While such duplicates are
|
||||
;; not desirable, they shouldn't prevent the users
|
||||
;; from getting their job done.
|
||||
(message "Duplicate definition for key: %S %s" key keymap))
|
||||
(push key seen-keys)
|
||||
(keymap-set keymap key def)))))
|
||||
keymap)))
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'ert)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defun keymap-tests--make-keymap-test (fun)
|
||||
(should (eq (car (funcall fun)) 'keymap))
|
||||
|
@ -470,10 +471,18 @@ g .. h foo
|
|||
ert-keymap-duplicate
|
||||
"a" #'next-line
|
||||
"a" #'previous-line))
|
||||
(should-error
|
||||
(define-keymap
|
||||
"a" #'next-line
|
||||
"a" #'previous-line)))
|
||||
(let ((msg ""))
|
||||
;; FIXME: It would be nicer to use `current-message' rather than override
|
||||
;; `message', but `current-message' returns always nil in batch mode :-(
|
||||
(cl-letf (((symbol-function 'message)
|
||||
(lambda (fmt &rest args) (setq msg (apply #'format fmt args)))))
|
||||
(should
|
||||
(string-match "duplicate"
|
||||
(progn
|
||||
(define-keymap
|
||||
"a" #'next-line
|
||||
"a" #'previous-line)
|
||||
msg))))))
|
||||
|
||||
(ert-deftest keymap-unset-test-remove-and-inheritance ()
|
||||
"Check various behaviors of keymap-unset. (Bug#62207)"
|
||||
|
|
Loading…
Add table
Reference in a new issue