Fix local simulation keys

* exwm-input.el (exwm-input--set-simulation-keys): Try the local
binding first do not clear the hash table (rely on GC).
This commit is contained in:
Chris Feng 2018-03-04 12:21:53 +08:00
parent 7013b0122a
commit 277377c718

View file

@ -762,16 +762,17 @@ multiple keys."
(defun exwm-input--set-simulation-keys (simulation-keys &optional no-refresh) (defun exwm-input--set-simulation-keys (simulation-keys &optional no-refresh)
"Set simulation keys." "Set simulation keys."
(unless no-refresh (unless no-refresh
;; Clear keymaps and the hash table. ;; Unbind simulation keys.
(when (hash-table-p exwm-input--simulation-keys) (let ((hash (buffer-local-value 'exwm-input--simulation-keys
(current-buffer))))
(when (hash-table-p hash)
(maphash (lambda (key _value) (maphash (lambda (key _value)
(when (sequencep key) (when (sequencep key)
(if exwm-input--local-simulation-keys (if exwm-input--local-simulation-keys
(local-unset-key key) (local-unset-key key)
(define-key exwm-mode-map key nil)))) (define-key exwm-mode-map key nil))))
exwm-input--simulation-keys) hash)))
(clrhash exwm-input--simulation-keys)) ;; Abandon the old hash table.
;; Update the hash table.
(setq exwm-input--simulation-keys (make-hash-table :test #'equal))) (setq exwm-input--simulation-keys (make-hash-table :test #'equal)))
(dolist (i simulation-keys) (dolist (i simulation-keys)
(let ((original (vconcat (car i))) (let ((original (vconcat (car i)))