diff options
author | Gregory Heytings <gregory@heytings.org> | 2022-12-19 22:18:22 +0000 |
---|---|---|
committer | Gregory Heytings <gregory@heytings.org> | 2022-12-29 23:00:16 +0100 |
commit | dafa6d6badd6552b6f88ba884e3e5dadb362380d (patch) | |
tree | 70f84eeaa3cd38ff9e81a0b1e7dc124bd6d3f2fe /lisp/pcomplete.el | |
parent | beed746f944aba2559192c057ea294233876e99d (diff) | |
download | emacs-dafa6d6badd6552b6f88ba884e3e5dadb362380d.tar.gz emacs-dafa6d6badd6552b6f88ba884e3e5dadb362380d.tar.bz2 emacs-dafa6d6badd6552b6f88ba884e3e5dadb362380d.zip |
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.
Diffstat (limited to 'lisp/pcomplete.el')
-rw-r--r-- | lisp/pcomplete.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 4e3a88bbda8..2d3730e294a 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -645,13 +645,26 @@ parts of the list. 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 -accessing absolute argument positions." - (nth (+ (pcase index - ('first 0) - ('last pcomplete-last) - (_ (- pcomplete-index (or index 0)))) - (or offset 0)) - pcomplete-args)) +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 + ('first 0) + ('last pcomplete-last) + (_ (- pcomplete-index (or index 0)))) + (or offset 0)) + 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) "Return the beginning position of the INDEXth argument. |