all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Daniel Mendler <mail@daniel-mendler.de>,
	Eli Zaretskii <eliz@gnu.org>,
	60464@debbugs.gnu.org, Jim Porter <jporterbugs@gmail.com>
Subject: bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last
Date: Sun, 01 Jan 2023 18:19:20 +0000	[thread overview]
Message-ID: <226b32f79f056489e881@heytings.org> (raw)
In-Reply-To: <jwvk026m94t.fsf-monnier+emacs@gnu.org>


>> After working a bit more on this bug, I concluded that what Stefan 
>> initially suggested, to use the string representation of the value, is 
>> safer than trying to extract the string corresponding to the argument 
>> that the user typed in from the command line.
>
> Could you expand on when/where it's "unsafe" or what it breaks?
>

I simply spent too much time trying to get the "extract the correct part 
of the command line from the buffer" right, and wasn't able to convince 
myself that the result was correct in all circumstances.  Given that 
returning (format "%S" arg) is what you initially suggested, and that it 
cannot be wrong, I concluded that it was the best/safest thing to do.

The semantics of the "index" argument of the pcomplete-arg function are 
tricky: it can be 0, "the current argument being examined", < 0, "closer 
to the last argument", and > 0, "closer to the first argument".  And then 
you also have the special values 'first and 'last.  And it can also be 
nil, which is equivalent to 0.

There is a pcomplete-actual-arg function, which returns "the actual text 
representation of the last argument" (in fact, "the actual text 
representation of the INDEXth argument and the following ones"), but no 
function which returns the actual text representation of a given argument.

Perhaps we could just use it and assume that all arguments are separated 
by spaces, though, in which case the patch would become:

diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 5bee515246..c829b6c3b7 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -648,10 +648,11 @@ pcomplete-arg
  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."
+a string by `pcomplete-parse-arguments-function' and INDEX is not
+`last', 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)
@@ -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))))

  (defun pcomplete-begin (&optional index offset)






  reply	other threads:[~2023-01-01 18:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-01 10:47 bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last Daniel Mendler
2023-01-01 11:16 ` Gregory Heytings
2023-01-01 11:21   ` Daniel Mendler
2023-01-01 11:35     ` Gregory Heytings
2023-01-01 11:53       ` Daniel Mendler
2023-01-01 12:04         ` Gregory Heytings
2023-01-01 16:59           ` Gregory Heytings
2023-01-01 17:18             ` Daniel Mendler
2023-01-01 17:28               ` Gregory Heytings
2023-01-01 17:34                 ` Daniel Mendler
2023-01-01 17:45                   ` Gregory Heytings
2023-01-01 18:02                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-01 18:26                     ` Daniel Mendler
2023-01-01 17:47             ` Eli Zaretskii
2023-01-01 18:29               ` Gregory Heytings
2023-01-01 20:01                 ` Eli Zaretskii
2023-01-01 17:57             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-01 18:19               ` Gregory Heytings [this message]
2023-01-01 18:38                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-01 18:42                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-01 19:13                   ` Gregory Heytings
2023-01-04  5:51             ` Jim Porter
2023-01-04 13:48               ` Gregory Heytings
2023-01-04 14:25                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-04 14:35                   ` Daniel Mendler
2023-01-04 14:46                     ` Gregory Heytings
2023-01-04 15:14                       ` Daniel Mendler
2023-01-04 15:18                         ` Eli Zaretskii
2023-01-04 15:22                           ` Daniel Mendler
2023-01-04 15:39                         ` Gregory Heytings
2023-01-04 15:48                           ` Daniel Mendler
2023-01-04 15:56                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-04 16:08                             ` Gregory Heytings
2023-01-14 21:27                               ` Gregory Heytings
2023-01-04 18:49                             ` Jim Porter
2023-01-04 18:41                       ` Jim Porter
2023-01-04 14:36                   ` Gregory Heytings
2023-01-04 15:19                     ` Daniel Mendler
2023-01-04 14:50                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=226b32f79f056489e881@heytings.org \
    --to=gregory@heytings.org \
    --cc=60464@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=mail@daniel-mendler.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.