GNU bug report logs -
#60464
29.0.60; Regression - pcomplete-arg fails with argument 'last
Previous Next
Full log
Message #47 received at 60464 <at> debbugs.gnu.org (full text, mbox):
>> After working a bit more on this bug, I concluded that what Stefan
>> initially suggested, to use the string representation of the value, is
>> safer than trying to extract the string corresponding to the argument
>> that the user typed in from the command line.
>
> Could you expand on when/where it's "unsafe" or what it breaks?
>
I simply spent too much time trying to get the "extract the correct part
of the command line from the buffer" right, and wasn't able to convince
myself that the result was correct in all circumstances. Given that
returning (format "%S" arg) is what you initially suggested, and that it
cannot be wrong, I concluded that it was the best/safest thing to do.
The semantics of the "index" argument of the pcomplete-arg function are
tricky: it can be 0, "the current argument being examined", < 0, "closer
to the last argument", and > 0, "closer to the first argument". And then
you also have the special values 'first and 'last. And it can also be
nil, which is equivalent to 0.
There is a pcomplete-actual-arg function, which returns "the actual text
representation of the last argument" (in fact, "the actual text
representation of the INDEXth argument and the following ones"), but no
function which returns the actual text representation of a given argument.
Perhaps we could just use it and assume that all arguments are separated
by spaces, though, in which case the patch would become:
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 5bee515246..c829b6c3b7 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -648,10 +648,11 @@ pcomplete-arg
accessing absolute argument positions.
When the argument has been transformed into something that is not
-a string by `pcomplete-parse-arguments-function', the text
-representation of the argument, namely what the user actually
-typed in, is returned, and the value of the argument is stored in
-the pcomplete-arg-value text property of that string."
+a string by `pcomplete-parse-arguments-function' and INDEX is not
+`last', the text representation of the argument, namely what the
+user actually typed in, is returned, and the value of the
+argument is stored in the pcomplete-arg-value text property of
+that string."
(let ((arg
(nth (+ (pcase index
('first 0)
@@ -659,11 +660,11 @@ pcomplete-arg
(_ (- pcomplete-index (or index 0))))
(or offset 0))
pcomplete-args)))
- (if (stringp arg)
+ (if (or (stringp arg)
+ (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)
This bug report was last modified 2 years and 153 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.