all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: Daniel Mendler <mail@daniel-mendler.de>
Cc: 60021@debbugs.gnu.org
Subject: bug#60021: 29.0.60; Eshell completion errors in the presence of buffer redirects
Date: Mon, 19 Dec 2022 22:24:40 +0000	[thread overview]
Message-ID: <a83d47c6f41ead4fab21@heytings.org> (raw)
In-Reply-To: <e6786371716b38ad741e@heytings.org>

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]


Daniel, can you please try the attached patch and tell us if it fixes the 
issue without introducing regressions?

[-- Attachment #2: Handle-non-string-values-in-pcomplete.patch --]
[-- Type: text/x-diff, Size: 2032 bytes --]

From 5bee9d8bec42ddf38bb7e8d8f2a1b36adb96a506 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Mon, 19 Dec 2022 22:18:22 +0000
Subject: [PATCH] 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.
---
 lisp/pcomplete.el | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 4e3a88bbda8..b1fbd88a377 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -645,13 +645,26 @@ pcomplete-arg
 
 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.
-- 
2.35.1


  reply	other threads:[~2022-12-19 22:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 21:23 bug#60021: 29.0.60; Eshell completion errors in the presence of buffer redirects Daniel Mendler
2022-12-12 22:24 ` Gregory Heytings
2022-12-12 22:51   ` Daniel Mendler
2022-12-12 23:34     ` Gregory Heytings
2022-12-13 13:46       ` Daniel Mendler
2022-12-13 13:50         ` Gregory Heytings
2022-12-13 14:15           ` Daniel Mendler
2022-12-13 14:20             ` Gregory Heytings
2022-12-19 22:24               ` Gregory Heytings [this message]
2022-12-20  6:45                 ` Daniel Mendler
2022-12-20  8:55                   ` Gregory Heytings
2022-12-20  9:47                     ` Daniel Mendler
2022-12-20 10:00                       ` Gregory Heytings
2022-12-29 22:03                         ` Gregory Heytings
2022-12-30  4:42                           ` Daniel Mendler
2022-12-12 22:41 ` Augusto Stoffel
2022-12-12 22:45   ` Daniel Mendler

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=a83d47c6f41ead4fab21@heytings.org \
    --to=gregory@heytings.org \
    --cc=60021@debbugs.gnu.org \
    --cc=mail@daniel-mendler.de \
    /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.