xah-fly-keys
xah-fly-keys copied to clipboard
Backtrace - Debugger execution causes xah-fly-command-mode to fail - requring manual intervention.
If command-mode is active - and the user evaluates an expression that results in the backtrace being called - the debugger-mode will silently clear the transient map - meaning although the command mode is active -- none of the keybindings is currently active - this failure is not resolved when the debugger mode is exited.
This will require from the user to call the command mode to reestablish parity of keybinding with the xah-fly-mode currently active.
(defun xah-fly--backtrace-setup (debug &rest args)
"Advice around `debug` to restart `xah-fly-command-mode` after backtrace,
if the preceding mode before entering backtrace is command-mode,
During the backtrace command-mode is disabled temporarily.
ORIG-FUNC is the original `debug` function. ARGS are its arguments."
(unless xah-fly-insert-state-p
(xah-fly-insert-mode-activate)
(add-hook 'post-command-hook #'xah-fly--backtrace-activate-command-mode))
;; Call the original `debug` function
(apply debug args))
(advice-add 'debug :around #'xah-fly--backtrace-setup)
(defun xah-fly--backtrace-activate-command-mode ()
"Activate `xah-fly-command-mode` after exiting the debugger."
(unless (let ((buffer (get-buffer "*Backtrace*")))
(and buffer (buffer-live-p buffer) (get-buffer-window buffer)))
(xah-fly-command-mode-activate)
(remove-hook 'post-command-hook #'xah-fly--backtrace-activate-command-mode)))
The procedure shown above is an example of how to work around it.
Since the command mode binding is disregarded by debug mode, there is no reason to keep it - during backtrace the switch is made from command-mode to insert-mode and when the backtrace window has been killed using q
or c
(quit or continue), the command mode is restarted if required.
How to reproduce:
- while in command mode evaluate
(xyz)
this will cause a failure and call the backtrace. - the user will find the command mode keybindings no longer work although the mode is clearly active
- when debugger exits the problem is still not resolved
- evaluate
xah-fly-command-mode-active
to re-establish parity.