diff options
| author | Jim Porter | 2024-05-23 14:52:07 -0700 |
|---|---|---|
| committer | Jim Porter | 2024-05-29 12:09:05 -0700 |
| commit | 9daf1085a9b11e056079edce8dccca92d69bf891 (patch) | |
| tree | 955af8fdd760efca90732a9742e04d4d2f5a6712 /test | |
| parent | 4c924a53334035dc4089b24174012b54c020631b (diff) | |
| download | emacs-9daf1085a9b11e056079edce8dccca92d69bf891.tar.gz emacs-9daf1085a9b11e056079edce8dccca92d69bf891.zip | |
Add ability for Eshell virtual targets to handle closing the target
This was documented to work by calling the output function with 'nil',
but that was never actually implemented. Instead, for compatibility,
we now support a new (optional) close function.
* lisp/eshell/esh-io.el (eshell-virtual-targets): Update docstring.
(eshell-generic-target): New struct...
(eshell-function-target): ... inherit from it, and rename from
'eshell-virtual-target'.
(eshell-get-target): Handle already-created 'eshell-generic-target'.
(eshell-close-target): Call the target's close function if present.
* test/lisp/eshell/esh-io-tests.el (esh-io-test/virtual/device-close):
New test.
* doc/misc/eshell.texi (Redirection): Document the new behavior.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/esh-io-tests.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index 188570161c7..b4e8c0b4a9a 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el | |||
| @@ -381,4 +381,19 @@ stdout originally pointed (the terminal)." | |||
| 381 | (eshell-insert-command "echo three >> /dev/kill") | 381 | (eshell-insert-command "echo three >> /dev/kill") |
| 382 | (should (equal (car kill-ring) "twothree")))) | 382 | (should (equal (car kill-ring) "twothree")))) |
| 383 | 383 | ||
| 384 | (ert-deftest esh-io-test/virtual/device-close () | ||
| 385 | "Check that the close function for `eshell-function-target' works." | ||
| 386 | (let* ((data nil) | ||
| 387 | (status nil) | ||
| 388 | (eshell-virtual-targets | ||
| 389 | `(("/dev/virtual" | ||
| 390 | ,(eshell-function-target-create | ||
| 391 | (lambda (d) (setq data d)) | ||
| 392 | (lambda (s) (setq status s))) | ||
| 393 | nil)))) | ||
| 394 | (with-temp-eshell | ||
| 395 | (eshell-insert-command "echo hello > /dev/virtual") | ||
| 396 | (should (equal data "hello")) | ||
| 397 | (should (equal status t))))) | ||
| 398 | |||
| 384 | ;;; esh-io-tests.el ends here | 399 | ;;; esh-io-tests.el ends here |