Handle non-string values in pcomplete
* lisp/pcomplete.el (pcomplete-arg): When pcomplete-parse-arguments-function returns a non-string value, return the string the user typed in, and attach the value as a text property to that string. Fixes bug#59956 and bug#60021.
This commit is contained in:
parent
beed746f94
commit
dafa6d6bad
1 changed files with 20 additions and 7 deletions
|
@ -645,13 +645,26 @@ parts of the list.
|
||||||
|
|
||||||
The OFFSET argument is added to/taken away from the index that will be
|
The OFFSET argument is added to/taken away from the index that will be
|
||||||
used. This is really only useful with `first' and `last', for
|
used. This is really only useful with `first' and `last', for
|
||||||
accessing absolute argument positions."
|
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."
|
||||||
|
(let ((arg
|
||||||
(nth (+ (pcase index
|
(nth (+ (pcase index
|
||||||
('first 0)
|
('first 0)
|
||||||
('last pcomplete-last)
|
('last pcomplete-last)
|
||||||
(_ (- pcomplete-index (or index 0))))
|
(_ (- pcomplete-index (or index 0))))
|
||||||
(or offset 0))
|
(or offset 0))
|
||||||
pcomplete-args))
|
pcomplete-args)))
|
||||||
|
(if (stringp arg)
|
||||||
|
arg
|
||||||
|
(propertize
|
||||||
|
(buffer-substring (pcomplete-begin index offset)
|
||||||
|
(pcomplete-begin (1- (or index 0)) offset))
|
||||||
|
'pcomplete-arg-value arg))))
|
||||||
|
|
||||||
(defun pcomplete-begin (&optional index offset)
|
(defun pcomplete-begin (&optional index offset)
|
||||||
"Return the beginning position of the INDEXth argument.
|
"Return the beginning position of the INDEXth argument.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue