From e7d0aa248e684a6de0d655d93bfcfee06cc8ff09 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 22 Jan 2023 13:20:46 -0800 Subject: During completion, convert all Eshell arguments to strings Eshell was already converting some types (numbers, nil) to strings, as well as fixing up multiple-dot forms like ".../", so this way is more consistent and should produce fewer problems for Pcomplete functions. * lisp/eshell/em-cmpl.el (eshell-complete-parse-arguments): Always convert parsed arguments to strings. * test/lisp/eshell/em-cmpl-tests.el (eshell-arguments-equal, eshell-arguments-equal--equal-explainer): New functions. (em-cmpl-test/parse-arguments/pipeline) (em-cmpl-test/parse-arguments/multiple-dots) (em-cmpl-test/parse-arguments/variable/numeric) (em-cmpl-test/parse-arguments/variable/nil) (em-cmpl-test/parse-arguments/variable/list) (em-cmpl-test/parse-arguments/variable/splice): Use 'eshell-arguments-equal'. --- lisp/eshell/em-cmpl.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'lisp/eshell') diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index d1c7e81090a..acbf206a3c6 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -386,17 +386,19 @@ to writing a completion function." ;; Convert arguments to forms that Pcomplete can understand. (cons (mapcar (lambda (arg) - (cond - ((numberp arg) - (number-to-string arg)) - ;; Expand ".../" etc that only Eshell understands to the - ;; standard "../../". - ((and (stringp arg) (string-match "\\.\\.\\.+/" arg)) - (eshell-expand-multiple-dots arg)) - ((null arg) - "") - (t - arg))) + (pcase arg + ;; Expand ".../" etc that only Eshell understands to + ;; the standard "../../". + ((rx ".." (+ ".") "/") + (propertize (eshell-expand-multiple-dots arg) + 'pcomplete-arg-value arg)) + ((pred stringp) + arg) + ('nil + (propertize "" 'pcomplete-arg-value arg)) + (_ + (propertize (eshell-stringify arg) + 'pcomplete-arg-value arg)))) args) posns))) -- cgit v1.2.1