Fix bug with keyboard-layout layer an bépo layout

When the bépo layout is set from the `keyboard-layout` layer, the
message `(wrong-type-argument keymapp nil)` shows up. After some
digging, it turns out Spacemacs tries to set shortcuts for `nil`
`map` variables in this function.

This commit ensures it is impossible to try to set a shortcut for an
inexisting keymap.

This commit has been tested with Emacs 27.0.90.
It also removes an unused `if` statement
This commit is contained in:
Lucien Cartier-Tilet 2020-03-31 12:45:39 +02:00 committed by Maximilian Wolff
parent 607d75e2ae
commit 77fe8a6139
No known key found for this signature in database
GPG Key ID: 2DD07025BFDBD89A
1 changed files with 8 additions and 6 deletions

View File

@ -46,12 +46,14 @@ the given MAPS."
"Define keys to the associated definitions of other ones. All
remapping are done atomically, i.e. if `a' -> `b' and `c' -> `a',
then `c' will be defined to the old `a' function, not to `b'."
(declare (indent 1))
(let ((map-original (copy-tree map)))
(dolist (binding bindings)
(let ((key1 (kbd (car binding)))
(key2 (kbd (cdr binding))))
(define-key map key1 (lookup-key map-original key2))))))
(if (keymapp map)
(progn
(declare (indent 1))
(let ((map-original (copy-tree map)))
(dolist (binding bindings)
(let ((key1 (kbd (car binding)))
(key2 (kbd (cdr binding))))
(define-key map key1 (lookup-key map-original key2))))))))
(defun kl//replace-in-list-rec (lst elem repl)
"Replace recursively all occurrences of `elem' by `repl' in the