summaryrefslogtreecommitdiff
path: root/lisp/eshell
AgeCommit message (Collapse)Author
2024-08-28Support "/dev/null" as a target when creating Eshell handlesJim Porter
Previously, you could only use this when setting the handle afterwards. * lisp/eshell/esh-io.el (eshell-set-output-handle): Don't catch 'eshell-null-device' here... (eshell-get-target): ... catch it here. * test/lisp/eshell/eshell-tests.el (eshell-test/eshell-command/output-dev-null): New test (bug#72857).
2024-08-28Fix redirecting Eshell output to symbols in some placesJim Porter
* lisp/eshell/esh-io.el (eshell-output-object-to-target): Don't require TARGET to be bound. * lisp/eshell/em-script.el (eshell-execute-file): * lisp/eshell/eshell.el (eshell-command): Quote the output/error targets. * test/lisp/eshell/em-script-tests.el (eshell-execute-file-output): New variable. (em-script-test/execute-file/output-symbol): New test. * test/lisp/eshell/eshell-tests.el (eshell-command-output): New variable. (eshell-test/eshell-command/output-symbol): New test (bug#72857).
2024-08-28Use 'eshell-with-handles' in a few more placesJim Porter
* lisp/eshell/em-alias.el (eshell-write-aliases-list): * lisp/eshell/em-script.el (eshell-batch-file): * lisp/eshell/esh-cmd.el (eshell-command-to-value): * lisp/eshell/eshell.el (eshell-command): Use 'eshell-with-handles'. * test/lisp/eshell/esh-io-tests.el (eshell-test-file-string): Move to... * test/lisp/eshell/eshell-tests-helpers.el (eshell-test-file-string): ... here. * test/lisp/eshell/eshell-tests.el (eshell-test/eshell-command/output-file): * test/lisp/eshell/em-script-tests.el (em-script-test/execute-file/output-file): New tests.
2024-08-28Use 'eshell-with-handles' when executing an Eshell fileJim Porter
This makes sure we close the handles as we should, which is important for writing the output to an actual file (bug#72857). * lisp/eshell/em-script.el (esh-cmd): Require this, just to be explicit. (eshell-execute-file): Use 'eshell-with-handles'.
2024-08-01; * lisp/eshell/em-dirs.el (eshell/cd): Remove extraneous 'eshell-protect'.Jim Porter
2024-07-27Use 'unwind-protect' to ensure that Eshell always closes I/O handlesJim Porter
See bug#72220. * lisp/eshell/esh-cmd.el (eshell-with-handles): New macro... (eshell-commands): ... use it. (eshell-with-copied-handles): Remove STEAL-P and allow multiple body forms (this is an incompatible change, but the macro is currently internal despite the name). (eshell-parse-command, eshell-do-pipelines) (eshell-do-pipelines-synchronously, eshell--invoke-command-directly-p): Remove handle stealing. (eshell-structure-basic-command, eshell-do-command) (eshell-lisp-command): Remove 'eshell-close-handles'. (eshell-protect): Make obsolete. (eshell-rewrite-for-command, eshell-rewrite-while-command) (eshell-rewrite-if-command, (eshell-parse-pipeline): Remove 'eshell-protect'. * lisp/eshell/esh-io.el (eshell-duplicate-handles): Make STEAL-P obsolete. * lisp/eshell/esh-proc.el (eshell-gather-process-output): Call 'eshell-protect-handles' one more time. Remove 'eshell-close-handles'. * lisp/eshell/esh-var.el (eshell-parse-variable-ref): Reimplement $<COMMAND> form using 'eshell-with-handles'. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/command-not-found/pipeline): New test. * test/lisp/eshell/em-tramp-tests.el (em-tramp-test/should-replace-command): Adjust check for 'eshell-with-copied-handles'.
2024-07-27; Improve correctness of 'eshell-do-eval' in some edge casesJim Porter
* lisp/eshell/esh-cmd.el (eshell-do-eval): Make sure that replacing 'if' forms returns the correct result, and evaluate to 'nil' for 'progn' forms with no body.
2024-07-20; * lisp/eshell/esh-io.el (eshell-close-handles): Fix version annotation.Jim Porter
2024-07-19Don't set exit info in Eshell if the command is being piped elsewhereJim Porter
Previously, the exit info in Eshell was that of the last command that finished, rather than the last command in a pipeline. * lisp/eshell/esh-cmd.el (eshell-exec-lisp) (eshell-lisp-command): Check whether the command is being piped. * lisp/eshell/esh-proc.el (eshell-gather-process-output): Record whether the command is being piped... (eshell-sentinel): ... and do the right thing with that info. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/sigpipe-exits-process): Check the exit status to ensure we don't report the first process's SIGPIPE exit.
2024-07-19Split out exit code parts of 'eshell-close-handles' into a new functionJim Porter
* lisp/eshell/esh-cmd.el (eshell-last-command-status) (eshell-last-command-result): Move here from esh-io.el. (eshell-set-exit-info): New function, extracted from 'eshell-close-handles'. * lisp/eshell/esh-io.el (eshell-close-handles): Make old calling convention obsolete. Update callers to use 'eshell-set-exit-info' as needed.
2024-07-18Allow specifying stdout/stderr separately in some Eshell commandsJim Porter
* lisp/eshell/eshell.el (eshell-command): Add ERROR-TARGET. * lisp/eshell/em-script.el (eshell-execute-file): Make interactive, and add ERROR-TARGET. * doc/misc/eshell.texi (One-Off Commands, Scripts): Update documentation. * etc/NEWS: Announce this change.
2024-07-18Improve implementation of built-in Eshell "kill" commandJim Porter
* lisp/eshell/esh-proc.el (eshell/kill): Fix handling of commands like "kill 123". Use REMOTE when signalling PIDs in remote directories. Signal using process objects when possible. Report errors when failing to signal. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill/process-id) (esh-proc-test/kill/process-object): New tests (bug#72013).
2024-07-18Handle broken pipes in a better way in EshellJim Porter
* lisp/eshell/esh-proc.el (eshell-insertion-filter): Send SIGPIPE delaying for Tramp and falling back to SIGTERM for MS-Windows (bug#72117).
2024-07-18Improve handling of deferrable Eshell commandsJim Porter
Now, we use the 'eshell-deferrable' wrapper to wrap a form that returns a process (or list thereof). This improves upon the old method, which failed to handle 'eshell-replace-command' correctly. In that case, Eshell would fail to unmark commands as deferrable when necessary (e.g. for commands in pipelines). * lisp/eshell/esh-cmd.el (eshell-deferrable-commands): Make into a defvar. (eshell-deferrable): New function... (eshell-structure-basic-command): ... use it. (eshell-trap-errors): Rename to... (eshell-do-command): ... this, and use 'eshell-deferrable'. Update callers. (eshell--unmark-deferrable): Remove. Update callers. (eshell-execute-pipeline): Remove 'eshell-process-identity'. (eshell-process-identity, eshell-named-command*, eshell-lisp-command*): Make obsolete. * test/lisp/eshell/esh-cmd-tests.el (eshell-test-replace-command): New function. (esh-cmd-test/pipeline/replace-command): New test.
2024-07-16Merge from savannah/emacs-30Po Lu
68b7806c319 Support passing signals like 'SIGCODE' to 'tramp-signal-p... 510ca5e84b5 Merge branch 'emacs-30' of git.sv.gnu.org:/srv/git/emacs ... fe28ba5d55b ; Replace quotes with @code{...} in texinfo files ecc8516d9ca ; Replace (non-)nil with (non-)@code{nil} in texinfo files 3407e274999 Don't save to history from 'eshell-command' when aborting
2024-07-15Don't save to history from 'eshell-command' when abortingJim Porter
* lisp/eshell/eshell.el (eshell-add-input-to-history) (eshell--save-history): Declare. (eshell-command-mode-exit): New function... (eshell-command-mode): ... use it. * lisp/eshell/em-hist.el (eshell-hist-initialize): Don't handle minibuffer logic here. Always read history file (this ensures that 'eshell-command' can see the history, too). (eshell-add-command-to-history): Remove.
2024-07-12Merge from savannah/emacs-30Po Lu
a5ef9e25680 Document means of executing Emacs from unrelated Android ... 0de0056fd6b Don't emit a prompt in Eshell when a background command i... ec1e300a215 Fix reference from buffer-stale-function docstring
2024-07-11Don't emit a prompt in Eshell when a background command is killedJim Porter
* lisp/eshell/esh-cmd.el (eshell-resume-command): Check for background-ness before resetting the prompt. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/background/simple-command): Make the regexp a bit stricter. (esh-cmd-test/background/kill): New test.
2024-07-09Improve Eshell's behavior when waiting for processesJim Porter
This has a few benefits. First, it fixes a race condition when killing old processes in 'eshell-command'. Second, the "wait" built-in command is now more useful. Finally, killing processes when exiting Eshell (via 'eshell-round-robin-kill') should be much faster. * lisp/eshell/esh-proc.el (esh-opt): Require. (eshell-wait-for-process): Make obsolete in favor of... (eshell-wait-for-processes): ... this. Accept a timeout and support PIDs. Update callers. (eshell/wait): New implementation accepting -t/--timeout. (eshell-round-robin-kill): Use 'eshell-wait-for-processes'. * lisp/eshell/eshell.el (eshell-command): Use 'eshell-round-robin-kill'. * doc/misc/eshell.texi (List of Built-ins): Document the new "wait" behavior. * etc/NEWS: Announce this change.
2024-07-09Don't use the Lisp implementation of "kill" in remote Eshell directoriesJim Porter
* lisp/eshell/esh-proc.el (eshell/kill): When in a remote directory, fall back to the external "kill" program (bug#72013).
2024-07-09Merge from savannah/emacs-30Po Lu
dce31372a60 editorconfig-core-handle.el: Fix regressions in fnmatch h... ed2986494c7 Checkdoc fixes in `url/*.el` 846c0e10ffa Checkdoc fixes in `term/*.el` 3977aa07568 Checkdoc fixes in `mh-e/*.el` 521f740d013 Checkdoc fixes in `calc/*.el` 336aa6ab17a Checkdoc fixes in `textmodes/*.el` e19fd6a22de Checkdoc fixes in `gnus/*.el` 7350457c793 Checkdoc fixes in `eshell/*.el` 23c1ba81ddd Checkdoc fixes in `emulation/*.el` c85f67a66df Checkdoc fixes in `erc/*.el` e392382e2e2 Checkdoc fixes in `vc/*.el` ef7364b070e Checkdoc fixes in `emacs-lisp/*.el` 5fe1ae0e843 Checkdoc fixes in `mail/*.el` e43e9d09986 Checkdoc fixes in `net/*.el` 4c6e9f5b004 Improve `use-package-vc-valid-keywords` docstring format 928180f32be ; * etc/TODO: New item on installing Magit. c193a702dc2 ; Improve a recent change to the documentation 6ebc5d5c278 ; Delete fixed item from etc/TODO: "proced on macOS" 7b2778e3a3d ; Delete fixed NS bug from etc/TODO 84552ff395c Revert "Fix link to major mode variable in docstring" 198063ba643 * etc/TODO: Add item to convert documentation to 'setopt'. 92de67829ca Prefer 'setopt' in browse-url docs 76683853905 ; Improve 'native-comp-debug' documentation
2024-07-08Checkdoc fixes in `eshell/*.el`Stefan Kangas
* lisp/eshell/em-elecslash.el: * lisp/eshell/em-extpipe.el: * lisp/eshell/em-pred.el (eshell-get-delimited-modifier-argument): * lisp/eshell/esh-cmd.el (eshell--unmark-deferrable) (eshell-named-command-hook): * lisp/eshell/esh-module.el (eshell-module--feature-name): * lisp/eshell/esh-util.el (eshell-find-delimiter): Checkdoc fixes.
2024-07-08Merge from savannah/emacs-30Po Lu
67f291ddae3 Correct conditions for iconification on Android 130c3efa108 Fix execution of MS-Windows app execution aliases in Eshell fffab032b05 Improve 'tab-line-tabs-fixed-window-buffers' sorting perf...
2024-07-07Fix execution of MS-Windows app execution aliases in EshellJim Porter
* lisp/eshell/esh-ext.el (eshell-script-interpreter): Check for 0-size files (bug#71655).
2024-07-05Allow using multiple buffers in 'eshell-command'Thierry Volpiatto
Provide the same functionality as 'async-shell-command-buffer' but for 'eshell-command'. Co-Authored-By: Jim Porter <jporterbugs@gmail.com> * lisp/eshell/eshell.el (eshell-command-async-buffer): New option... (eshell-command): ... use it. * lisp/eshell/esh-proc.el (eshell-sentinel): Check for buffer liveness in 'finish-io'. * test/lisp/eshell/eshell-tests.el (eshell-test/eshell-command/output-buffer/async-kill): New test. * etc/NEWS: Announce this change (bug#71554).
2024-06-25Always perform Eshell process cleanup runs in the Eshell bufferJim Porter
Previously, some code executed in a timer, which could execute in the wrong buffer, leading to a hang. * lisp/eshell/esh-proc.el (eshell-sentinel): Use 'with-current-buffer' in the timer function. * test/lisp/eshell/esh-proc-tests.el (eshell-test-value): New variable. (esh-proc-test/sentinel/change-buffer): New test. (cherry picked from commit da4bc5c9274a6705501e24fb8f2984f5bf5fe099)
2024-06-25Always perform Eshell process cleanup runs in the Eshell bufferJim Porter
Previously, some code executed in a timer, which could execute in the wrong buffer, leading to a hang. * lisp/eshell/esh-proc.el (eshell-sentinel): Use 'with-current-buffer' in the timer function. * test/lisp/eshell/esh-proc-tests.el (eshell-test-value): New variable. (esh-proc-test/sentinel/change-buffer): New test.
2024-06-23; Fix typosStefan Kangas
2024-06-20Ensure navigating by paragraphs in Eshell stops at prompts and paragraphsJim Porter
The previous implementation in 6ae2b74ed20 only stopped at prompts, which isn't the right behavior (bug#61545). * lisp/eshell/em-prompt.el (eshell-forward-paragraph) (eshell-backward-paragraph): Reimplement to handle prompts and paragraphs (the latter by calling the original 'forward-paragraph'). * test/lisp/eshell/em-prompt-tests.el (em-prompt-test/next-previous-prompt/multiline): Rename. (em-prompt-test/forward-backward-paragraph-1): New function. (em-prompt-test/forward-backward-paragraph) (em-prompt-test/forward-backward-paragraph/multiline): New tests.
2024-06-20Limit the amount of text we examine when looking for password promptsJim Porter
Both Comint and Eshell do this, and it can significantly slow down commands that write a lot of output (bug#71576). * lisp/comint.el (comint-password-prompt-max-length): New variable... (comint-watch-for-password-prompt): ... use it. Additionally, use the matched result for the Emacs-based password prompt. * lisp/eshell/esh-mode.el (eshell-password-prompt-max-length): New variable... (eshell-watch-for-password-prompt): ... use it. * etc/NEWS: Announce this change.
2024-06-13; * lisp/eshell/em-script.el (eshell-execute-file): Improve docstring.Jim Porter
2024-06-09Improve correctness of 'eshell-quote-argument'Jim Porter
* lisp/eshell/esh-arg.el (eshell-quote-argument): Mention that this function is for use within Eshell buffers. (eshell-quote-backslash): Properly quote newlines. * lisp/eshell/em-unix.el (eshell/cat, eshell/du): Throw 'eshell-external' instead; that's what it's here for. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test-quote-argument): Remove. (esh-proc-test/emacs-command): * test/lisp/eshell/esh-var-tests.el (esh-var-test/path-var/set) (esh-var-test/path-var/set-locally): Use 'eshell-quote-argument'. * test/lisp/eshell/em-unix-tests.el (em-unix-test/compile/interactive): Use 'shell-quote-argument' (Note: *not* 'eshell-...').
2024-06-09; Use the current system's style of shell-quoting in Eshell debug logsJim Porter
* lisp/eshell/esh-proc.el (eshell-gather-process-output): Don't force POSIX syntax. This is less confusing when running on MS-Windows.
2024-06-09Remove empty Eshell commands when parsingJim Porter
This improves the logic for copying/stealing handles when constructing the command form: now, we should always steal the handles for the last real command, even if there were some trailing semicolons. * lisp/eshell/esh-arg.el (eshell-parse-delimiter): Be stricter about parsing so that things like "& &" aren't parsed as a single "&&" token. * lisp/eshell/esh-cmd.el (eshell-parse-command): Get the commands in reverse, and remove any nil commands. (eshell-split-commands): Always return the trailing terms (except when there were no terms to begin with). * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/empty-background-command): New test.
2024-06-09; Add another test for 'eshell-batch-script'Jim Porter
* lisp/eshell/em-script.el (eshell-close-target): New function. * test/lisp/eshell/em-script-tests.el (em-script-test/batch-file): New test; rename old one to... (em-script-test/batch-file/shebang): ... this.
2024-06-09Fix Eshell tests on MS-WindowsEli Zaretskii
* lisp/eshell/esh-util.el (eshell-get-path): Don't add "." if it is already there. * test/lisp/eshell/esh-var-tests.el (esh-var-test/path-var/preserve-across-hosts): Skip on MS-Windows. (esh-var-test/path-var/set, esh-var-test/path-var/set-locally): Quote the PATH value, for MS-Windows. * test/lisp/eshell/esh-util-tests.el (esh-util-test/path/get): No need to add ".": it is already done by 'eshell-get-path'. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill-pipeline): Accept empty string as valid output. (esh-proc-test/sigpipe-exits-process): Skip on MS-Windows: no SIGPIPE. (esh-proc-test/emacs-command): Quote correctly for MS-Windows. * test/lisp/eshell/em-unix-tests.el (em-unix-test/compile/interactive): Fix test on MS-Windows. * test/lisp/eshell/em-script-tests.el (em-script-test/batch-file): Skip on MS-Windows. * test/lisp/eshell/eshell-tests-helpers.el (eshell-command-result--equal): Compare strings (file names) case-insensitively on MS-Windows.
2024-06-08Improve implementations of some Eshell output filter functionsJim Porter
* lisp/eshell/esh-mode.el (eshell-postoutput-scroll-to-bottom): Use 'get-buffer-window-list' for simplicity. (eshell-handle-control-codes): Use 're-search-forward'; this way is much faster. * test/lisp/eshell/esh-mode-tests.el: New file.
2024-06-08Be more efficient when buffering output in EshellJim Porter
This makes the built-in 'eshell/cat' 5-10x faster on large files in my (somewhat limited) tests. In addition, this change periodically redisplays when using the Eshell buffered output so that users can see some progress. * lisp/eshell/esh-io.el (eshell-print-queue-size, eshell-print-queue, eshell-print-queue-count): Make obsolete in favor of... (eshell-buffered-print-size, eshell--buffered-print-queue) (eshell--buffered-print-current-size): ... these. (eshell-buffered-print-redisplay-throttle): New user option. (eshell--buffered-print-next-redisplay): New variable. (eshell-init-print-buffer): Make obsolete. (eshell-flush): Add new REDISPLAY-NOW argument in favor of CLEAR (which only 'eshell-init-print-buffer' should have used). (eshell-buffered-print): Compare queued output length to 'eshell--buffered-print-current-size'. (eshell-with-buffered-print): New macro. * lisp/eshell/esh-var.el (eshell/env): * lisp/eshell/em-dirs.el (eshell/cd): * lisp/eshell/em-hist.el (eshell/history): * lisp/eshell/em-unix.el (eshell/cat): * lisp/eshell/em-ls.el (eshell/ls): Use 'eshell-with-buffered-print'. (flush-func): Remove. (eshell-ls--insert-directory, eshell-do-ls): Remove 'flush-func'. * test/lisp/eshell/em-unix-tests.el (em-unix-test/compile/interactive) (em-unix-test/compile/pipeline, em-unix-test/compile/subcommand): Fix indentation. (em-unix-test/cat/file-output): New test. * etc/NEWS: Announce these improvements.
2024-06-04Spelling fixesPaul Eggert
2024-06-03Check for a real process when trying to find password prompts in EshellJim Porter
* lisp/eshell/esh-mode.el (eshell-watch-for-password-prompt): Use 'eshell-head-process'.
2024-06-02; Remove superfluous 'quit' handler in 'eshell-send-input'Jim Porter
This is now handled by the command form itself, thanks to eef32d13da5. * lisp/eshell/esh-mode.el (eshell-send-input): Remove 'quit' handler.
2024-06-01Merge from origin/emacs-29Eli Zaretskii
bf50aa38f9d Improve documentation of case-conversion commands 225b426f256 ; Fix typos
2024-05-29Make Eshell's "which" command extensibleJim Porter
Since 'eshell-named-command-hook' already makes execution of commands extensible, "which" should be too. This makes sure that "which" returns the right result for quoted commands like "/:cat". * lisp/eshell/em-alias.el (eshell-aliases-file): Allow it to be nil. (eshell-read-aliases-list, eshell-write-aliases-list): Check if 'eshell-aliases-file' is nil. (eshell-maybe-replace-by-alias--which): New function... (eshell-maybe-replace-by-alias): ... use it. * lisp/eshell/esh-cmd.el (eshell-named-command-hook): Update docstring. (eshell/which): Make extensible. (eshell--find-plain-lisp-command, eshell-plain-command--which): New functions. (eshell-plain-command): Use 'eshell--find-plain-lisp-command'. * lisp/eshell/esh-ext.el (eshell-explicit-command--which): New function... (eshell-explicit-command): ... unise it. (eshell-quoted-file-command--which): New function... (eshell-quoted-file-command): ... use it. (eshell-external-command--which): New function. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/which/plain/eshell-builtin) (esh-cmd-test/which/plain/external-program) (esh-cmd-test/which/plain/not-found, esh-cmd-test/which/alias) (esh-cmd-test/which/explicit, esh-cmd-test/which/explicit/not-found) (esh-cmd-test/which/quoted-file) (esh-cmd-test/which/quoted-file/not-found): New tests. * test/lisp/eshell/eshell-tests-helpers.el (with-temp-eshell-settings): Don't load or save aliases. (eshell-command-result--match,eshell-command-result--match-explainer) (eshell-command-result-match): New functions.
2024-05-29; Improve recent change to deferred evaluation in EshellJim Porter
* lisp/eshell/esh-cmd.el (eshell-do-eval): Move active check later.
2024-05-29Fix calling Eshell scripts outside of EshellJim Porter
* lisp/eshell/em-script.el (eshell-source-file): Make obsolete. (eshell--source-file): Adapt from 'eshell-source-file'... (eshell-script-initialize, eshell/source, eshell/.): ... use it. (eshell-princ-target): New struct. (eshell-output-object-to-target, eshell-target-line-oriented-p): New implementations for 'eshell-princ-target'. (eshell-execute-file, eshell-batch-file): New functions. * lisp/eshell/esh-mode.el (eshell-mode): Just warn if we can't create the Eshell directory. * test/lisp/eshell/em-script-tests.el (em-script-test/execute-file): (em-script-test/execute-file/args), em-script-test/batch-file): New tests. * test/lisp/eshell/eshell-tests-helpers.el (with-temp-eshell-settings): New function... (with-temp-eshell): ... use it. * doc/misc/eshell.texi (Control Flow): Update documentation. * etc/NEWS: Announce this change (bug#70847).
2024-05-29Rework how 'eshell-ensure-newline-p' adds newlinesJim Porter
This allows for other output targets (see the following commit) to be "line-oriented". * lisp/eshell/esh-io.el (eshell-ensure-newline-p): Move from esh-cmd.el. (eshell-target-line-oriented-p, eshell--output-maybe-n) (eshell-print-maybe-n, eshell-error-maybe-n) (eshell-maybe-output-newline): New functions. * lisp/eshell/esh-cmd.el (eshell-lisp-command): Don't print a newline in this function directly; instead, use 'eshell-print-maybe-n' and 'eshell-error-maybe-n'. (eshell-ensure-newline-p): Move to esh-io.el. * lisp/eshell/em-unix.el (eshell/cat): Remove now-unnecessary override of 'eshell-ensure-newline-p'.
2024-05-29Add ability for Eshell virtual targets to handle closing the targetJim Porter
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.
2024-05-29Use 'esh-module-autoload' for Eshell modules' defgroupsJim Porter
This will let modules define their own, regular autoloads, independent of the core Eshell machinery for defining modules. * lisp/eshell/em-alias.el (em-alias): * lisp/eshell/em-banner.el (em-banner): * lisp/eshell/em-basic.el (em-basic): * lisp/eshell/em-cmpl.el (em-cmpl): * lisp/eshell/em-dirs.el (em-dirs): * lisp/eshell/em-elecslash.el (em-elecslash): * lisp/eshell/em-extpipe.el: * lisp/eshell/em-glob.el (em-glob): * lisp/eshell/em-hist.el (em-hist): * lisp/eshell/em-ls.el (em-ls): * lisp/eshell/em-pred.el (em-pred): * lisp/eshell/em-prompt.el (em-prompt): * lisp/eshell/em-rebind.el (em-rebind): * lisp/eshell/em-script.el (em-script): * lisp/eshell/em-smart.el (em-smart): * lisp/eshell/em-term.el (em-term): * lisp/eshell/em-tramp.el (em-tramp): * lisp/eshell/em-unix.el (em-unix): * lisp/eshell/em-xtra.el (em-xtra): Use 'esh-module-autoload'. * lisp/eshell/esh-module.el ("esh-module-loaddefs"): Load this instead of "esh-groups". * .gitignore: Change esh-groups.el to esh-module-loaddefs.el
2024-05-29Consolidate Eshell module loading/unloading codeJim Porter
This also adds the ability to suppress module loading/unloading messages, which will be necessary to support running Eshell scripts as batch scripts. * lisp/eshell/esh-mode.el (eshell-mode): Move module loading/initialization to... * lisp/eshell/esh-module.el (eshell-load-modules) (eshell-initialize-modules): ... here. (eshell-module-loading-messages): New option. (eshell-module--feature-name): Improve docstring. (eshell-unload-modules): Display a real warning if unable to unload a module. * test/lisp/eshell/eshell-tests-helpers.el (with-temp-eshell) (eshell-command-result-equal): * test/lisp/eshell/eshell-tests-unload.el (load-eshell): Silence Eshell loading messages.
2024-05-28Fix adding to history via 'eshell-command'Jim Porter
* lisp/eshell/eshell.el (eshell-read-command): Don't handle history here. * lisp/eshell/em-hist.el (eshell-hist-initialize): Properly set up history for minibuffer. (eshell-add-command-to-history): Immediately save history.