From: Jim Porter <jporterbugs@gmail.com>
To: 67112@debbugs.gnu.org
Cc: monnier@iro.umontreal.ca
Subject: bug#67112: 30.0.50; [PATCH] Fix completion annotations when using 'pcomplete-here-using-help'
Date: Sat, 11 Nov 2023 13:43:04 -0800 [thread overview]
Message-ID: <6955475e-3ea7-f6a9-bc99-58420b7ba2f5@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]
X-Debbugs-Cc: monnier@iro.umontreal.ca
Starting from "emacs -Q -f shell" (or eshell, doesn't matter) on a
GNU/Linux system, type "cp -" and then press TAB. The completions buffer
shows a list of completions. However, they don't show the annotations,
which in this case should be a helpful string for any option taking an
argument.
For example, one completion is "--backup". This takes an optional
"CONTROL" argument, which should show in the completions list. However,
it doesn't. With the attached patch, the completions list now correctly
shows "--backup[=CONTROL]".
This was happening because 'pcomplete-here-using-help' passes along the
annotation as a text property on the first character of each completion
candidate. That property failed to propagate through
'completion-table-with-quoting' though. So the fix is to propagate text
properties on the first character of the candidate, since that's already
a convention in a couple places with completion tables.
(There's a larger question about whether 'pcomplete-here-using-help' is
doing this in the right way. Maybe instead of returning a list of
candidates with text properties for annotations and such, it should
instead return a programmed completion table that specifies an
'annotation-function' for the table's metadata. However, that's both a
much more invasive change, and I think we'd still want this patch to
help improve other parts of completion tables. For example, with this
patch, 'completion-table-merge' could annotate which table each
candidate is from, and then we could resolve the FIXME in that function.)
[-- Attachment #2: 0001-Forward-completion-text-properties-when-using-comple.patch --]
[-- Type: text/plain, Size: 1674 bytes --]
From b4cb492ebe4c7905b83bfbcd81e6bc8385d0a760 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 11 Nov 2023 13:26:44 -0800
Subject: [PATCH] Forward completion text properties when using
'completion-table-with-quoting'
This fixes an issue with 'pcomplete-here-using-help', which passes
annotation strings along as text properties. Previously, those got
clobbered when the completions got requoted.
* lisp/minibuffer.el (completion--twq-all): Apply text properties from
the first character of the unquoted completion to the quoted
completion.
---
lisp/minibuffer.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 3e2e3b6c6f2..fc75cd9cb66 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -677,6 +677,13 @@ completion--twq-all
'completions-common-part)
qprefix))))
(qcompletion (concat qprefix qnew)))
+ ;; Some completion tables (including this one) pass
+ ;; along necessary information as text properties
+ ;; on the first character of the completion. Make
+ ;; sure the quoted completion has these properties
+ ;; too.
+ (add-text-properties 0 1 (text-properties-at 0 completion)
+ qcompletion)
;; Attach unquoted completion string, which is needed
;; to score the completion in `completion--flex-score'.
(put-text-property 0 1 'completion--unquoted
--
2.25.1
next reply other threads:[~2023-11-11 21:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 21:43 Jim Porter [this message]
2023-11-19 23:16 ` bug#67112: 30.0.50; [PATCH] Fix completion annotations when using 'pcomplete-here-using-help' Jim Porter
2023-11-20 0:48 ` Jim Porter
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6955475e-3ea7-f6a9-bc99-58420b7ba2f5@gmail.com \
--to=jporterbugs@gmail.com \
--cc=67112@debbugs.gnu.org \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).