Skip to content

Commit

Permalink
Forward C-g to the terminal when in forbid edit mode.
Browse files Browse the repository at this point in the history
C-g typically exits the backward search mode, which might be what the
user wants. With this change, mistty sends C-g to the terminal in
addition to the normal C-g handling done by Emacs.
  • Loading branch information
szermatt committed Sep 11, 2024
1 parent 8794b7c commit 9743899
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mistty.el
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,9 @@ This function fails if there is no current or previous output."
(message "MisTTY: Canceling replay")
(mistty--cancel-queue mistty--queue))
(mistty--ignore-foreign-overlays)
(mistty--inhibit-clear 'noschedule)))
(mistty--inhibit-clear 'noschedule)
(when mistty--forbid-edit
(mistty-send-key 1 "\C-g"))))

(let ((point-moved (and mistty--old-point (/= (point) mistty--old-point))))
;; Show cursor again if the command moved the point.
Expand Down
21 changes: 21 additions & 0 deletions test/mistty-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,27 @@
(should (not mistty--forbid-edit))
(should (equal ":run" mode-line-process)))))

(ert-deftest mistty-test-exit-forbid-edit ()
(let ((mistty-forbid-edit-regexps
'("^search: .*\n\\(►\\|(no matches)\\)")))
(mistty-with-test-buffer (:shell fish)
(mistty-send-key 1 (kbd "C-r"))
(mistty-wait-for-output :str "search:" :start (point-min))
(should mistty--forbid-edit)

;; C-g
(let ((this-command 'keyboard-quit))
(mistty--pre-command)
(mistty--post-command))

(mistty-wait-for-output
:test (lambda ()
(save-excursion
(goto-char (point-min))
(not (search-forward "search:" nil t)))))

(should (not mistty--forbid-edit)))))

(ert-deftest mistty-test-forbid-edit-map ()
(let ((mistty-forbid-edit-regexps
'("^search: .*\n\\(►\\|(no matches)\\)")))
Expand Down

0 comments on commit 9743899

Please sign in to comment.