]> git.eshelyaron.com Git - emacs.git/commitdiff
Support completion of variables with the length operator in Eshell
authorJim Porter <jporterbugs@gmail.com>
Sun, 11 Dec 2022 04:52:28 +0000 (20:52 -0800)
committerJim Porter <jporterbugs@gmail.com>
Fri, 16 Dec 2022 05:41:03 +0000 (21:41 -0800)
These are forms like '$#VARIABLE'.

* lisp/eshell/esh-var.el (eshell-complete-variable-reference): Support
the length operator.

lisp/eshell/esh-var.el

index 57ea42f4933ba1bda1f3c8acbb6854fb97069426..5824da6dc0e124f2679d77eb69445abf8acf3335 100644 (file)
@@ -751,12 +751,13 @@ For example, to retrieve the second element of a user's record in
 
 (defun eshell-complete-variable-reference ()
   "If there is a variable reference, complete it."
-  (let ((arg (pcomplete-actual-arg)) index)
-    (when (setq index
-               (string-match
-                (concat "\\$\\(" eshell-variable-name-regexp
-                        "\\)?\\'") arg))
-      (setq pcomplete-stub (substring arg (1+ index)))
+  (let ((arg (pcomplete-actual-arg)))
+    (when (string-match
+           (rx "$" (? "#")
+               (? (group (regexp eshell-variable-name-regexp)))
+               string-end)
+           arg)
+      (setq pcomplete-stub (substring arg (match-beginning 1)))
       (throw 'pcomplete-completions (eshell-variables-list)))))
 
 (defun eshell-variables-list ()