summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Heytings <gregory@heytings.org>2023-01-04 16:48:03 +0000
committerGregory Heytings <gregory@heytings.org>2023-01-14 22:24:33 +0100
commit72c45fa9109a53cb55d13697d69e9a32a7e289b5 (patch)
tree1854754bf62c0cba9ad21ccaf9a977dc1fb3ad78
parent1ef359095ec610a92c1f485b3f301782336dfc4e (diff)
downloademacs-72c45fa9109a53cb55d13697d69e9a32a7e289b5.tar.gz
Further improvement for non-string values in pcomplete
* lisp/pcomplete.el (pcomplete-arg): Use the string representation of the argument value instead of the text representation of the argument. Return the value, even when it is not a string, when index is 'last'. Fixes bug#60464.
-rw-r--r--lisp/pcomplete.el29
1 files changed, 19 insertions, 10 deletions
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 5bee5152463..1ca7a213361 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -632,6 +632,13 @@ This will modify the current buffer."
;;; Internal Functions:
;; argument handling
+(defsubst pcomplete-actual-arg (&optional index offset)
+ "Return the actual text representation of the last argument.
+This is different from `pcomplete-arg', which returns the textual value
+that the last argument evaluated to. This function returns what the
+user actually typed in."
+ (buffer-substring (pcomplete-begin index offset) (point)))
+
(defun pcomplete-arg (&optional index offset)
"Return the textual content of the INDEXth argument.
INDEX is based from the current processing position. If INDEX is
@@ -659,11 +666,20 @@ the pcomplete-arg-value text property of that string."
(_ (- pcomplete-index (or index 0))))
(or offset 0))
pcomplete-args)))
- (if (stringp arg)
+ (if (or (stringp arg)
+ ;; FIXME: 'last' is handled specially in Emacs 29, because
+ ;; 'pcomplete-parse-arguments' accepts a list of strings
+ ;; (which are completion candidates) as return value for
+ ;; (pcomplete-arg 'last). See below: "it means it's a
+ ;; list of completions computed during parsing,
+ ;; e.g. Eshell uses that to turn globs into lists of
+ ;; completions". This special case will be dealt with
+ ;; differently in Emacs 30: the pcomplete-arg-value
+ ;; property will be used by 'pcomplete-parse-arguments'.
+ (eq index 'last))
arg
(propertize
- (buffer-substring (pcomplete-begin index offset)
- (pcomplete-begin (1- (or index 0)) offset))
+ (car (split-string (pcomplete-actual-arg index offset)))
'pcomplete-arg-value arg))))
(defun pcomplete-begin (&optional index offset)
@@ -679,13 +695,6 @@ See the documentation for `pcomplete-arg'."
(setq index (+ index offset)))
(nth index pcomplete-begins))
-(defsubst pcomplete-actual-arg (&optional index offset)
- "Return the actual text representation of the last argument.
-This is different from `pcomplete-arg', which returns the textual value
-that the last argument evaluated to. This function returns what the
-user actually typed in."
- (buffer-substring (pcomplete-begin index offset) (point)))
-
(defsubst pcomplete-next-arg ()
"Move the various pointers to the next argument."
(setq pcomplete-index (1+ pcomplete-index)