summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2022-05-02 16:56:49 -0700
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-03 18:23:02 +0200
commita3a7279a4ab00be69519f98536ec75dc81217b50 (patch)
tree9f4c6349e0896be9a6bfae8dbe03d1e677c64d63 /doc
parent06423b5d1e05d524e8e745f071cbb691b446efd2 (diff)
downloademacs-a3a7279a4ab00be69519f98536ec75dc81217b50.tar.gz
Improve the behavior of concatenating parts of Eshell arguments
Previously, concatenating a list to a string would first convert the list to a string. Now, the string is concatenated with the last element of the list. * lisp/eshell/esh-util.el (eshell-to-flat-string): Make obsolete. * lisp/eshell/esh-arg.el (eshell-concat, eshell-concat-1): New functions. (eshell-resolve-current-argument): Use 'eshell-concat'. * test/lisp/eshell/esh-var-tests.el (esh-var-test/interp-concat-cmd): Add check for concatenation of multiline output of subcommands. (esh-var-test/quoted-interp-concat-cmd): New test. * test/lisp/eshell/em-extpipe-tests.el (em-extpipe-test-13): Use 'eshell-concat'. * doc/misc/eshell.texi (Expansion): Document this behavior. * etc/NEWS: Announce the change (bug#55236).
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/eshell.texi34
1 files changed, 30 insertions, 4 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index be32b2aced4..dfb22bcb514 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -1017,11 +1017,37 @@ parsers (such as @command{cpp} and @command{m4}), but in a command
shell, they are less often used for constants, and usually for using
variables and string manipulation.@footnote{Eshell has no
string-manipulation expansions because the Elisp library already
-provides many functions for this.} For example, @code{$var} on a line
-expands to the value of the variable @code{var} when the line is
+provides many functions for this.} For example, @code{$@var{var}} on
+a line expands to the value of the variable @var{var} when the line is
executed. Expansions are usually passed as arguments, but may also be
-used as commands.@footnote{E.g., entering just @samp{$var} at the prompt
-is equivalent to entering the value of @code{var} at the prompt.}
+used as commands.@footnote{E.g., entering just @samp{$@var{var}} at
+the prompt is equivalent to entering the value of @var{var} at the
+prompt.}
+
+You can concatenate expansions with regular string arguments or even
+other expansions. In the simplest case, when the expansion returns a
+string value, this is equivalent to ordinary string concatenation; for
+example, @samp{$@{echo "foo"@}bar} returns @samp{foobar}. The exact
+behavior depends on the types of each value being concatenated:
+
+@table @asis
+
+@item both strings
+Concatenate both values together.
+
+@item one or both numbers
+Concatenate the string representation of each value, converting back to
+a number if possible.
+
+@item one or both (non-@code{nil}) lists
+Concatenate ``adjacent'' elements of each value (possibly converting
+back to a number as above). For example, @samp{$list("a" "b")c}
+returns @samp{("a" "bc")}.
+
+@item anything else
+Concatenate the string represenation of each value.
+
+@end table
@menu
* Dollars Expansion::