Open akashpal-21 opened 5 months ago
The 'server-after-make-frame-hook
should remove the previous set-transient-map -- otherwise there is an extra post-command-hook
that is redundant that will be running.
(defun patch/xah-fly-keys--init ()
;; see issue #103
(run-at-time "0" nil
(lambda ()
(when (and xah-fly-keys (not xah-fly-insert-state-p))
(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-frame-parameters nil '((cursor-color . "red")))))))
(funcall xah-fly--deactivate-command-mode-func)
Will disable the previous transient-map since set-transient-map
returns an exit function that we bind to this variable in the xah-fly-command-mode-init
.
add the function to 'after-make-frame-functions
instead of 'server-after-make-frame-hook
upside: works with #'make-frame-command
too - consistent result
(defun patch/xah-fly-keys--init (&optional frame)
;; see issue #103
(run-at-time "0" nil
(lambda (frame)
(when (and xah-fly-keys (not xah-fly-insert-state-p))
(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-frame-parameters frame '((cursor-color . "red")))))
frame))
Pass optional frame
argument.
The Function definition is as follows:
The following three lines fail to work appropriately when this function is being called during emacs daemon startup due to some race condition.
This causes the problem that when
xah-fly-keys
mode is enabled in init - although the mode is activated - none of the logic of the command mode is active - neither keybindings nor visual indication in the cursorFor the
set-transient-map
to work - hooking ontoserver-after-make-frame-hook
is essential. Additionally for frame-parameters to take action - not only the frame need to be active - the function call must be made "asynchronously" which can be done by running a timer with zero seconds delay.Combining and taking into consideration of not running this on new frame creation when insert-mode is currently active the following is suggested
see additionally #103