bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last


From: Stefan Monnier
Subject: bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last
Date: Sun, 01 Jan 2023 13:42:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> For the first, would the patch below help?

Well, obviously not because I didn't bother to look at the rest of
the code.

Maybe this one would be closer, tho it probably needs some handling for
the boundary case where `index` is the last.


        Stefan


diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 2d3730e294a..36968d3b73c 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@gnu.org>
 ;; Keywords: processes abbrev
@@ -652,18 +652,17 @@ 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
-       (buffer-substring (pcomplete-begin index offset)
-                         (pcomplete-begin (1- (or index 0)) offset))
+       (buffer-substring (nth index pcomplete-begins)
+                         (nth (1+ index) pcomplete-begins))
        'pcomplete-arg-value arg))))
 
 (defun pcomplete-begin (&optional index offset)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]