[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/xah-fly-keys 79c2afc372 1/5: make sure to clean up on xah-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/xah-fly-keys 79c2afc372 1/5: make sure to clean up on xah-fly-command-mode-init subsequent calls |
Date: |
Sat, 9 Jul 2022 02:59:31 -0400 (EDT) |
branch: elpa/xah-fly-keys
commit 79c2afc372457f6f3a70d78de53936078941b9e0
Author: Grigory Starinkin <starinkin@gmail.com>
Commit: Grigory Starinkin <starinkin@gmail.com>
make sure to clean up on xah-fly-command-mode-init subsequent calls
`xah-fly-command-mode-init` uses a feature of the `set-transient-map`
that explicitly disables a clean up on a pre-command-hook
invocation (`keep-pred` parameter):
```
(setq xah-fly--deactivate-command-mode-func
(set-transient-map xah-fly-command-map (lambda () t)))
```
In our case it is `(lambda () t)`.
From the code of the `set-transient-map`:
```
However, if the optional argument KEEP-PRED is t, MAP stays
active if a key from MAP is used. KEEP-PRED can also be a
function of no arguments: it is called from `pre-command-hook' and
if it returns non-nil, then MAP stays active.
```
Although `xah-fly-command-map` map stays active until insert mode is
started (as it should be since we don't want quite a command mode
prematurely) and XFK takes responsibility of invoking the cleanup
function (`xah-fly--deactivate-command-mode-func`) when insert mode is
activated, `xah-fly-command-mode-init` could be called multiple times.
Subsequent activation of the command mode overwrites
`xah-fly--deactivate-command-mode-func`, meaning that we loose a
reference to a clean up func that is supposed to remove the
`clear-transient-map` items from the `pre-command-hook`.
This commit ensures that a subsequent command mode activation clears
up a transient map set by already active command mode.
---
xah-fly-keys.el | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/xah-fly-keys.el b/xah-fly-keys.el
index ca30652f09..a340e1bf12 100644
--- a/xah-fly-keys.el
+++ b/xah-fly-keys.el
@@ -4591,10 +4591,12 @@ Version: 2018-05-07"
(defun xah-fly-command-mode-init ()
"Set command mode keys.
-Version: 2020-04-28"
+Version: 2022-07-06"
(interactive)
(setq xah-fly-insert-state-p nil)
(xah-fly--update-key-map)
+ (when xah-fly--deactivate-command-mode-func
+ (funcall xah-fly--deactivate-command-mode-func))
(setq xah-fly--deactivate-command-mode-func
(set-transient-map xah-fly-command-map (lambda () t)))
(modify-all-frames-parameters (list (cons 'cursor-type 'box)))
@@ -4706,14 +4708,6 @@ URL `http://xahlee.info/emacs/misc/xah-fly-keys.html'"
;;
)))
-(when (= emacs-major-version 28)
- ;; 2022-06-14 fix a emacs 28.1 bug.
- ;; clear-transient-map bug
- ;; http://xahlee.info/emacs/emacs/clear-transient-map_bug.html
- (progn
- (defun xah-clear-pre-command-hook () (setq pre-command-hook nil))
- (add-hook 'xah-fly-insert-mode-activate-hook 'xah-clear-pre-command-hook)))
-
(provide 'xah-fly-keys)
;; Local Variables: