GNU bug report logs - #60464
29.0.60; Regression - pcomplete-arg fails with argument 'last

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Sun, 1 Jan 2023 10:48:02 UTC

Severity: normal

Found in version 29.0.60

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Daniel Mendler <mail <at> daniel-mendler.de>, Eli Zaretskii <eliz <at> gnu.org>, 60464 <at> debbugs.gnu.org, Jim Porter <jporterbugs <at> gmail.com>
Subject: bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last
Date: Sun, 01 Jan 2023 13:38:28 -0500
>    (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))))

I'm not sure what specific problem this is trying to solve (is it the
choice of the "index" or is it the precise buffer positions of the
bounds)?

For the first, would the patch below help?
[ For the second, I suspect we can't provide 100% reliably correct
  information anyway, so I think we'll need to find concrete usecases
  where it matters before we can judge how much effort is warranted.  ]


        Stefan


diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 2d3730e294a..815ad252fbd 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -1,6 +1,6 @@
 ;;; pcomplete.el --- programmable completion -*- lexical-binding: t -*-
 
-;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2023 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw <at> gnu.org>
 ;; Keywords: processes abbrev
@@ -652,13 +652,12 @@ pcomplete-arg
 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
+  (let* ((index (+ (pcase index
 	           ('first 0)
 	           ('last  pcomplete-last)
 	           (_      (- pcomplete-index (or index 0))))
-	         (or offset 0))
-              pcomplete-args)))
+	         (or offset 0)))
+         (arg (nth index pcomplete-args)))
     (if (stringp arg)
         arg
       (propertize





This bug report was last modified 2 years and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.