diff options
| author | Jim Porter | 2022-03-01 18:53:42 -0800 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-03-03 14:59:33 +0100 |
| commit | d72cd4a2b761d325e5bb3e664781a4c9001eb2c2 (patch) | |
| tree | 7d59b1ede2b3c9620d4b07b7df8c557497d3dc29 /lisp/eshell | |
| parent | 990f36fa108092c8b93692bb80c6fbd0b6b8f391 (diff) | |
| download | emacs-d72cd4a2b761d325e5bb3e664781a4c9001eb2c2.tar.gz emacs-d72cd4a2b761d325e5bb3e664781a4c9001eb2c2.zip | |
Allow splitting strings in Eshell expansions with "plain" strings
Since '$var[hello 0]' doesn't make sense when 'var' is a string, the
previous restriction was unnecessary.
* lisp/eshell/esh-var.el (Commentary): Update documentation.
(eshell-apply-indices): Allow "plain" strings to split strings.
* test/lisp/eshell/esh-var-test.el
(esh-var-test/interp-var-string-split-indices)
(esh-var-test/quoted-interp-var-string-split-indices): Update tests.
* doc/misc/eshell.texi (Dollars expansion): Update documentation.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/esh-var.el | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 6f08a3fbc45..af89e35f553 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el | |||
| @@ -74,9 +74,8 @@ | |||
| 74 | ;; $EXPR["\\\\" 10] | 74 | ;; $EXPR["\\\\" 10] |
| 75 | ;; | 75 | ;; |
| 76 | ;; Separate on backslash characters. Actually, the first argument -- | 76 | ;; Separate on backslash characters. Actually, the first argument -- |
| 77 | ;; if it doesn't have the form of a number, or a plain variable name | 77 | ;; if it doesn't have the form of a number -- can be any regular |
| 78 | ;; -- can be any regular expression. So to split on numbers, use | 78 | ;; expression. So to split on numbers, use '$EXPR["[0-9]+" 10 20]'. |
| 79 | ;; '$EXPR["[0-9]+" 10 20]'. | ||
| 80 | ;; | 79 | ;; |
| 81 | ;; $EXPR[hello] | 80 | ;; $EXPR[hello] |
| 82 | ;; | 81 | ;; |
| @@ -566,13 +565,11 @@ For example, to retrieve the second element of a user's record in | |||
| 566 | (while indices | 565 | (while indices |
| 567 | (let ((refs (car indices))) | 566 | (let ((refs (car indices))) |
| 568 | (when (stringp value) | 567 | (when (stringp value) |
| 569 | (let (separator) | 568 | (let (separator (index (caar indices))) |
| 570 | (if (not (or (not (stringp (caar indices))) | 569 | (when (and (stringp index) |
| 571 | (string-match | 570 | (not (get-text-property 0 'number index))) |
| 572 | (concat "^" eshell-variable-name-regexp "$") | 571 | (setq separator index |
| 573 | (caar indices)))) | 572 | refs (cdr refs))) |
| 574 | (setq separator (caar indices) | ||
| 575 | refs (cdr refs))) | ||
| 576 | (setq value | 573 | (setq value |
| 577 | (mapcar #'eshell-convert | 574 | (mapcar #'eshell-convert |
| 578 | (split-string value separator))))) | 575 | (split-string value separator))))) |