[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 72c45fa910: Further improvement for non-string values in pcompl
From: |
Gregory Heytings |
Subject: |
emacs-29 72c45fa910: Further improvement for non-string values in pcomplete |
Date: |
Sat, 14 Jan 2023 16:24:42 -0500 (EST) |
branch: emacs-29
commit 72c45fa9109a53cb55d13697d69e9a32a7e289b5
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>
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.
---
lisp/pcomplete.el | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 5bee515246..1ca7a21336 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 72c45fa910: Further improvement for non-string values in pcomplete,
Gregory Heytings <=