;;; 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
(_ (- 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)
(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)