all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68568: transient.el interns potentially enormous symbols as commands
@ 2024-01-18 11:50 João Távora
  2024-01-21  4:27 ` Psionic K
  2024-01-27  9:15 ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: João Távora @ 2024-01-18 11:50 UTC (permalink / raw)
  To: 68568, jonas

Hello,

I'd never used a package that made use of "transient.el" before.
I have now, via gptel.el  Takes a bit of getting used to, but I like it
(and can see why people like it in Magit).

Now, immediately after using it, I start noticing that the completion
that Fido mode offers on M-x starts to get weirdly contaminated by these
symbols with enormous symbols names.  This makes my Emacs almost
unusable.  I'd think other completion packages would be similarly
affected unless they special case transient symols some how.

Peeping into the transient source code, we can see that it uses a lot
of 'eval' to define some commands just in time as a user navigates the
menus and submenus.

All these commands seem point to the same actual command, and do not
seem to be meant to be called with M-x at all.  They are generated at
lazily at runtime and only for the submenus being visited.

So they're just temporary artefacts of implementation.  Who know if this
is where the library gets its name.  It's curious, but not going to
argue much on this approach.

Anyway, transient uses 'intern' when I think it could just use
'make-symbol' to avoid polluting the obarray and this whole problem.  It
seems to keep functioning and solves my problem.  Here's the trivial
patch.  Would you look at it, Jonas?

diff --git a/lisp/transient.el b/lisp/transient.el
index f9060f5ba85..249c25262ea 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1127,7 +1127,7 @@ transient--parse-suffix
        ((and (commandp car)
              (not (stringp car)))
         (let ((cmd pop)
-              (sym (intern
+              (sym (make-symbol
                     (format "transient:%s:%s"
                             prefix
                             (let ((desc (plist-get args :description)))
@@ -1156,7 +1156,7 @@ transient--parse-suffix
              (when-let ((shortarg (transient--derive-shortarg arg)))
                (setq args (plist-put args :shortarg shortarg)))
              (setq args (plist-put args :argument arg))))
-          (setq sym (intern (format "transient:%s:%s" prefix arg)))
+          (setq sym (make-symbol (format "transient:%s:%s" prefix arg)))
           (setq args (plist-put
                       args :command
                       `(prog1 ',sym



If some kind of persistent storage for these symbols IS needed I
recommend a separate obarray.  Also, why does the full and potentially
very long description in plain text have to be a part of the symbol
name?  This doesn't matter with the 'make-symbol' approach, but I still
find it curious.

João





^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-01 10:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 11:50 bug#68568: transient.el interns potentially enormous symbols as commands João Távora
2024-01-21  4:27 ` Psionic K
2024-01-21  7:15   ` João Távora
2024-01-21  7:29     ` Psionic K
2024-01-21  8:10       ` João Távora
2024-01-21  8:26         ` Psionic K
2024-01-21  8:33           ` João Távora
2024-01-27  9:15 ` Eli Zaretskii
2024-01-27 18:18   ` Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-01 10:24     ` Eli Zaretskii

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.