all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Thierry Volpiatto <thievol@posteo.net>
Cc: 74718@debbugs.gnu.org
Subject: bug#74718: 29.4; Huge metadata with flex completion style
Date: Tue, 10 Dec 2024 16:54:00 -0500	[thread overview]
Message-ID: <jwv34ivrzdp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <877c8bvrx3.fsf@posteo.net> (Thierry Volpiatto's message of "Sat,  07 Dec 2024 08:06:00 +0000")

> Here the offending code in minibuffer.el (in
> completion--nth-completion):
>
> --8<---------------cut here---------------start------------->8---
>    (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata)))
>     (when (and adjust-fn metadata)
>       (setcdr metadata (cdr (funcall adjust-fn metadata))))
> --8<---------------cut here---------------end--------------->8---

Thanks Thierry.
The above code is indeed a hack we should try get rid of.
I suspect it remained unnoticed until now because most UIs get a "fresh"
new metadata before calling `completion-try/all-completions`, but we
shouldn't rely on such a property.

I think I vaguely remember when this code was added that we discussed
whether it's OK to do that (for all I know, I may even have suggested
this hack), so replacing it with a more robust solution may be
not straightforward.

In the mean time, maybe a patch like the one below can temporarily paper
over the underlying problem?


        Stefan


diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 405ee21cdb2..d258085c778 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1307,9 +1307,15 @@ completion--nth-completion
                                string table pred point)))
                    (and probe (cons probe style))))))
            (completion--styles md)))
-         (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata)))
-    (when (and adjust-fn metadata)
-      (setcdr metadata (cdr (funcall adjust-fn metadata))))
+         (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))
+         (adjusted (completion-metadata-get
+                    metadata 'completion--adjusted-metadata)))
+    (when (and adjust-fn metadata
+               ;; Avoid re-applying the same adjustment (bug#74718).
+               (not (memq (cdr result-and-style) adjusted)))
+      (setcdr metadata `((completion--adjusted-metadata
+                          ,(cdr result-and-style) . ,adjusted)
+                         . ,(cdr (funcall adjust-fn metadata)))))
     (if requote
         (funcall requote (car result-and-style) n)
       (car result-and-style))))






  parent reply	other threads:[~2024-12-10 21:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-07  8:06 bug#74718: 29.4; Huge metadata with flex completion style Thierry Volpiatto
2024-12-10  2:27 ` Dmitry Gutov
2024-12-10  6:25   ` Thierry Volpiatto
2024-12-10 15:24     ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11  5:50       ` Thierry Volpiatto
2024-12-10 21:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-12-11  5:45   ` Thierry Volpiatto
2024-12-11 23:35     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=jwv34ivrzdp.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=74718@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=thievol@posteo.net \
    /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.