]> git.eshelyaron.com Git - emacs.git/commit
Lazily convert numeric strings to Lisp numbers in Eshell
authorJim Porter <jporterbugs@gmail.com>
Sat, 19 Oct 2024 18:52:42 +0000 (11:52 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 19:00:07 +0000 (21:00 +0200)
commitb9b788d0d9d5419ad4cb4e967b6d676f0c9897ba
tree488ef1b13d073e201072438fcca2151cd0008f4a
parentaf0cdc420ccda09481c562beff8014b0d8c2fafc
Lazily convert numeric strings to Lisp numbers in Eshell

This should reduce the number of issues with Eshell converting strings
to numbers too aggressively and losing information (e.g. "001" -> 1)
while still allowing almost all of the beneficial uses, like summing a
list of numeric strings with '+'.

* lisp/eshell/esh-util.el (eshell--do-mark-numeric-string): New
function.
(eshell-convert-to-number): Make obsolete in favor of...
(eshell-mark-numeric-string): ... this.  Update callers.

* lisp/eshell/esh-arg.el (eshell--numberlike-p): New function...
(eshell-concat-1): ... use it.

* test/lisp/eshell/esh-util-tests.el:  Reimplement type conversion tests
to use 'eshell-convertible-to-number-p' instead.

* test/lisp/eshell/esh-var-tests.el
(esh-var-test/interp-var-splice-concat, esh-var-test/interp-concat-cmd)
(esh-var-test/interp-convert-var-split-indices)
(esh-var-test/interp-convert-quoted-var-split-indices)
(esh-var-test/interp-convert-cmd-multiline)
(esh-var-test/interp-convert-cmd-split-indices): Adjust tests to check
the new behavior.

* doc/misc/eshell.texi (Type Conversion): New section.
(Expansion): Clarify concatenation behavior.

(cherry picked from commit 43d5b7a04c4b1a8a7d57f25824df2e8720d2c567)
doc/misc/eshell.texi
lisp/eshell/esh-arg.el
lisp/eshell/esh-util.el
lisp/eshell/esh-var.el
test/lisp/eshell/esh-util-tests.el
test/lisp/eshell/esh-var-tests.el