From: Jim Porter Date: Sun, 11 Dec 2022 04:52:28 +0000 (-0800) Subject: Support completion of variables with the length operator in Eshell X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=66ac920b0c233e472c7f54d108503dfe9236d3c0;p=emacs.git Support completion of variables with the length operator in Eshell These are forms like '$#VARIABLE'. * lisp/eshell/esh-var.el (eshell-complete-variable-reference): Support the length operator. --- diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 57ea42f4933..5824da6dc0e 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -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 ()