diff options
| author | Jim Porter | 2023-09-22 18:22:34 -0700 |
|---|---|---|
| committer | Jim Porter | 2023-09-26 12:29:52 -0700 |
| commit | eef32d13da58d9773d6e1889b8de42e5d1711ad5 (patch) | |
| tree | e1fbeb7b349b879c161c0c42533fb39b1241a142 /test | |
| parent | e88be844bf774b336ab67995e435416328b53776 (diff) | |
| download | emacs-eef32d13da58d9773d6e1889b8de42e5d1711ad5.tar.gz emacs-eef32d13da58d9773d6e1889b8de42e5d1711ad5.zip | |
Use 'unwind-protect' in more places in Eshell
This lets us simplify the logic for how we reset
'eshell-current-command' and 'eshell-last-async-procs', as well as
improving correctness of Eshell command forms in a few esoteric
scenarios. Additionally, this helps set the stage for better support
of background commands in Eshell (bug#66164).
* lisp/eshell/esh-cmd.el (eshell-cmd-initialize): Remove addition to
'eshell-post-command-hook'; this is handled in 'eshell-resume-command'
and 'eshell-resume-eval' now.
(eshell-resume-command): Handle resetting the prompt as needed.
(eshell-resume-eval): Use 'unwind-protect' to ensure that we set
'eshell-last-async-procs' and 'eshell-current-comment' at the right
times.
(eshell-parse-command, eshell-trap-errors, eshell-manipulate): Use
'unwind-protect'.
(eshell-do-eval): Allow 'eshell-defer' to pass through
'unwind-protect' forms without actually calling the unwinding forms
(yet).
* lisp/eshell/esh-proc.el (eshell-kill-process-function)
(eshell-reset-after-proc): Make obsolete. The behavior is now handled
in 'eshell-resume-command'.
(eshell-gather-process-output, eshell-sentinel)
(eshell-interrupt-process, eshell-kill-process, eshell-quit-process)
(eshell-stop-process, eshell-continue-process): Run 'eshell-kill-hook'
directly.
* test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/throw): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/esh-cmd-tests.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index 7c384471e93..643038f89ff 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el | |||
| @@ -442,4 +442,20 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil." | |||
| 442 | (eshell-command-result-equal "unless {[ foo = bar ]} {echo no} {echo yes}" | 442 | (eshell-command-result-equal "unless {[ foo = bar ]} {echo no} {echo yes}" |
| 443 | "no")) | 443 | "no")) |
| 444 | 444 | ||
| 445 | |||
| 446 | ;; Error handling | ||
| 447 | |||
| 448 | (ert-deftest esh-cmd-test/throw () | ||
| 449 | "Test that calling `throw' as an Eshell command unwinds everything properly." | ||
| 450 | (with-temp-eshell | ||
| 451 | (should (= (catch 'tag | ||
| 452 | (eshell-insert-command | ||
| 453 | "echo hi; (throw 'tag 42); echo bye")) | ||
| 454 | 42)) | ||
| 455 | (should (eshell-match-output "\\`hi\n\\'")) | ||
| 456 | (should-not eshell-current-command) | ||
| 457 | (should-not eshell-last-async-procs) | ||
| 458 | ;; Make sure we can call another command after throwing. | ||
| 459 | (eshell-match-command-output "echo again" "\\`again\n"))) | ||
| 460 | |||
| 445 | ;; esh-cmd-tests.el ends here | 461 | ;; esh-cmd-tests.el ends here |