summaryrefslogtreecommitdiff
path: root/lisp/eshell/esh-var.el
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2023-01-18 19:15:38 -0800
committerJim Porter <jporterbugs@gmail.com>2023-01-19 17:51:54 -0800
commit54d5ea66c99f03240379d6d2e411145cced585a5 (patch)
tree77ec57de79d5e41d27205c72a9d63f97c8095522 /lisp/eshell/esh-var.el
parent207901457c018d94b1ce9e13a897d8241b1f3af2 (diff)
downloademacs-54d5ea66c99f03240379d6d2e411145cced585a5.tar.gz
Fix evaluation of asynchronous expansions in Eshell indices
Previously, this code passed the indices to a separate function, which called 'eval' on them, but it should instead make an S-expr that 'eshell-do-eval' can evaluate (bug#60942). * lisp/eshell/esh-var.el (eshell-eval-indices): Mark obsolete. (eshell-prepare-indices): New function... (eshell-parse-variable): ... use it. Also, remove irrelevant comment. (eshell-parse-variable-ref): Fix quoting in docstring. (eshell-parse-indices): Fix typo in docstring. * test/lisp/eshell/esh-var-tests.el (esh-var-test/interp-var-indices-subcommand) (esh-var-test/quoted-interp-var-indices-subcommand): New tests.
Diffstat (limited to 'lisp/eshell/esh-var.el')
-rw-r--r--lisp/eshell/esh-var.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 27e68138aa2..83dd5cb50f5 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -467,9 +467,7 @@ process any indices that come after the variable reference."
indices (and (not (eobp))
(eq (char-after) ?\[)
(eshell-parse-indices))
- ;; This is an expression that will be evaluated by `eshell-do-eval',
- ;; which only support let-binding of dynamically-scoped vars
- value `(let ((indices (eshell-eval-indices ',indices))) ,value))
+ value `(let ((indices ,(eshell-prepare-indices indices))) ,value))
(when get-len
(setq value `(length ,value)))
(when eshell-current-quoted
@@ -496,7 +494,7 @@ Possible variable references are:
NAME an environment or Lisp variable value
\"LONG-NAME\" disambiguates the length of the name
- `LONG-NAME' as above
+ \\='LONG-NAME\\=' as above
{COMMAND} result of command is variable's value
(LISP-FORM) result of Lisp form is variable's value
<COMMAND> write the output of command to a temporary file;
@@ -591,7 +589,7 @@ Possible variable references are:
"Parse and return a list of index-lists.
For example, \"[0 1][2]\" becomes:
- ((\"0\" \"1\") (\"2\")."
+ ((\"0\" \"1\") (\"2\"))."
(let (indices)
(while (eq (char-after) ?\[)
(let ((end (eshell-find-delimiter ?\[ ?\])))
@@ -609,8 +607,14 @@ For example, \"[0 1][2]\" becomes:
(defun eshell-eval-indices (indices)
"Evaluate INDICES, a list of index-lists generated by `eshell-parse-indices'."
+ (declare (obsolete eshell-prepare-indices "30.1"))
(mapcar (lambda (i) (mapcar #'eval i)) indices))
+(defun eshell-prepare-indices (indices)
+ "Prepare INDICES to be evaluated by Eshell.
+INDICES is a list of index-lists generated by `eshell-parse-indices'."
+ `(list ,@(mapcar (lambda (idx-list) (cons 'list idx-list)) indices)))
+
(defun eshell-get-variable (name &optional indices quoted)
"Get the value for the variable NAME.
INDICES is a list of index-lists (see `eshell-parse-indices').