GNU bug report logs -
#72511
30.0.50; prefix-completions is always nil in help--symbol-completion-table
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72511 in the body.
You can then email your comments to 72511 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72511
; Package
emacs
.
(Wed, 07 Aug 2024 12:43:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chris Roberts <frayedultrasonicaligator <at> disroot.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 07 Aug 2024 12:43:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On lines 209-214 inside the function `help--symbol-complete-table' in
help-fns.el there is a following block of code:
(when help-enable-completion-autoload
(let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
(help--load-prefixes prefixes)))
(let ((prefix-completions
(and help-enable-completion-autoload
(mapcar #'intern (all-completions string definition-prefixes)))))
By default, `help-enable-completion-autoload' is t, so this code should
normally run. The perceived problem here is that the definition of
`help-definition-prefixes' function is as follows:
(defun help-definition-prefixes ()
"Return the up-to-date radix-tree form of `definition-prefixes'."
(when (> (hash-table-count definition-prefixes) 0)
(maphash (lambda (prefix files)
(let ((old (radix-tree-lookup help-definition-prefixes prefix)))
(setq help-definition-prefixes
(radix-tree-insert help-definition-prefixes
prefix (append old files)))))
definition-prefixes)
(clrhash definition-prefixes))
help-definition-prefixes)
Because of the `clrhash', `definition-prefixes' will always be empty
after the function call to `help-definition-prefixes'. So in practice,
`definition-prefixes' will always have zero elements when we're trying
to calculate `prefix-completions', which makes the calls to
`all-completions' and `mapcar' basically no-ops. The end result is that
`prefix-completions' will always be NIL.
This can be verified by evaluating the following code in emacs -Q:
(require 'radix-tree)
(require 'help-fns)
(let ((string "string-remove-prefix"))
(format "Definition prefixes count before: %d\n%sDefinition prefixes count after: %d\nPrefix completions: %s\n"
(hash-table-count definition-prefixes)
(or
(when help-enable-completion-autoload
(let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
(help--load-prefixes prefixes)))
"")
(hash-table-count definition-prefixes)
(let ((prefix-completions
(and help-enable-completion-autoload
(mapcar #'intern (all-completions string definition-prefixes)))))
prefix-completions)))
This has been first introduced in commit fd8084a (Automatically find
vars and functions via definition-prefixes)
I'm not sure if this was the intended behavior or not, but it seemed
suspicious to me, so I decided it's better to report it.
It might also be useful to note that `prefix-completion' is used in the
following way:
(complete-with-action action obarray string
(if pred (lambda (sym)
(or (funcall pred sym)
(memq sym prefix-completions)))))
I'm not sure what `pred' will be in this context, or what impact
`prefix-completions' being always NIL will have, if any. But I believe
that at the very least the code pertaining to `prefix-completions' could
concievably be removed.
Also, was clearing out the entirety of `definition-prefixes' on completion
really the intended behavior? As it stands, just C-h f s <TAB> is enough
to completely truncate it.
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2024-01-09 built on cdr
Repository revision: 774c8ec74c98d69d56b2511a613145f2b69fb2eb
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version
11.0.12101004 System Description: Linux Mint 21.2
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND
SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM GTK3
ZLIB
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72511
; Package
emacs
.
(Wed, 07 Aug 2024 14:22:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 72511 <at> debbugs.gnu.org (full text, mbox):
> Date: Wed, 7 Aug 2024 13:53:05 +0200
> From: Chris Roberts via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> On lines 209-214 inside the function `help--symbol-complete-table' in
> help-fns.el there is a following block of code:
>
> (when help-enable-completion-autoload
> (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
> (help--load-prefixes prefixes)))
> (let ((prefix-completions
> (and help-enable-completion-autoload
> (mapcar #'intern (all-completions string definition-prefixes)))))
>
> By default, `help-enable-completion-autoload' is t, so this code should
> normally run. The perceived problem here is that the definition of
> `help-definition-prefixes' function is as follows:
>
> (defun help-definition-prefixes ()
> "Return the up-to-date radix-tree form of `definition-prefixes'."
> (when (> (hash-table-count definition-prefixes) 0)
> (maphash (lambda (prefix files)
> (let ((old (radix-tree-lookup help-definition-prefixes prefix)))
> (setq help-definition-prefixes
> (radix-tree-insert help-definition-prefixes
> prefix (append old files)))))
> definition-prefixes)
> (clrhash definition-prefixes))
> help-definition-prefixes)
>
> Because of the `clrhash', `definition-prefixes' will always be empty
> after the function call to `help-definition-prefixes'. So in practice,
> `definition-prefixes' will always have zero elements when we're trying
> to calculate `prefix-completions', which makes the calls to
> `all-completions' and `mapcar' basically no-ops. The end result is that
> `prefix-completions' will always be NIL.
>
> This can be verified by evaluating the following code in emacs -Q:
>
> (require 'radix-tree)
> (require 'help-fns)
>
> (let ((string "string-remove-prefix"))
> (format "Definition prefixes count before: %d\n%sDefinition prefixes count after: %d\nPrefix completions: %s\n"
> (hash-table-count definition-prefixes)
> (or
> (when help-enable-completion-autoload
> (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
> (help--load-prefixes prefixes)))
> "")
> (hash-table-count definition-prefixes)
> (let ((prefix-completions
> (and help-enable-completion-autoload
> (mapcar #'intern (all-completions string definition-prefixes)))))
> prefix-completions)))
>
> This has been first introduced in commit fd8084a (Automatically find
> vars and functions via definition-prefixes)
>
> I'm not sure if this was the intended behavior or not, but it seemed
> suspicious to me, so I decided it's better to report it.
>
> It might also be useful to note that `prefix-completion' is used in the
> following way:
>
> (complete-with-action action obarray string
> (if pred (lambda (sym)
> (or (funcall pred sym)
> (memq sym prefix-completions)))))
>
> I'm not sure what `pred' will be in this context, or what impact
> `prefix-completions' being always NIL will have, if any. But I believe
> that at the very least the code pertaining to `prefix-completions' could
> concievably be removed.
>
> Also, was clearing out the entirety of `definition-prefixes' on completion
> really the intended behavior? As it stands, just C-h f s <TAB> is enough
> to completely truncate it.
Thanks, I'm adding Stefan, who wrote this code, to the discussion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72511
; Package
emacs
.
(Wed, 14 Aug 2024 15:52:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 72511 <at> debbugs.gnu.org (full text, mbox):
> (when help-enable-completion-autoload
> (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
> (help--load-prefixes prefixes)))
> (let ((prefix-completions
> (and help-enable-completion-autoload
> (mapcar #'intern (all-completions string definition-prefixes)))))
>
> By default, `help-enable-completion-autoload' is t, so this code should
> normally run. The perceived problem here is that the definition of
> `help-definition-prefixes' function is as follows:
>
> (defun help-definition-prefixes ()
> "Return the up-to-date radix-tree form of `definition-prefixes'."
> (when (> (hash-table-count definition-prefixes) 0)
> (maphash (lambda (prefix files)
> (let ((old (radix-tree-lookup help-definition-prefixes prefix)))
> (setq help-definition-prefixes
> (radix-tree-insert help-definition-prefixes
> prefix (append old files)))))
> definition-prefixes)
> (clrhash definition-prefixes))
> help-definition-prefixes)
>
> Because of the `clrhash', `definition-prefixes' will always be empty
> after the function call to `help-definition-prefixes'.
Duh, indeed.
IIRC it's a leftover from some older version of the code.
I think the patch below is in order.
> Also, was clearing out the entirety of `definition-prefixes' on completion
> really the intended behavior?
Originally, yes (after which we'd just use the `help-definition-prefixes`
radix-tree instead), but then other places appeared where using the
radix-tree was not convenient.
Stefan
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 0a469a1fd6d..e3dc23036db 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -86,14 +86,14 @@ help-definition-prefixes
(defun help-definition-prefixes ()
"Return the up-to-date radix-tree form of `definition-prefixes'."
- (when (> (hash-table-count definition-prefixes) 0)
+ (when (and (null help-definition-prefixes)
+ (> (hash-table-count definition-prefixes) 0))
(maphash (lambda (prefix files)
(let ((old (radix-tree-lookup help-definition-prefixes prefix)))
(setq help-definition-prefixes
(radix-tree-insert help-definition-prefixes
prefix (append old files)))))
- definition-prefixes)
- (clrhash definition-prefixes))
+ definition-prefixes))
help-definition-prefixes)
(defun help--loaded-p (file)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72511
; Package
emacs
.
(Sat, 17 Aug 2024 09:36:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 72511 <at> debbugs.gnu.org (full text, mbox):
> Cc: 72511 <at> debbugs.gnu.org
> Date: Wed, 14 Aug 2024 11:50:47 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> > (when help-enable-completion-autoload
> > (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
> > (help--load-prefixes prefixes)))
> > (let ((prefix-completions
> > (and help-enable-completion-autoload
> > (mapcar #'intern (all-completions string definition-prefixes)))))
> >
> > By default, `help-enable-completion-autoload' is t, so this code should
> > normally run. The perceived problem here is that the definition of
> > `help-definition-prefixes' function is as follows:
> >
> > (defun help-definition-prefixes ()
> > "Return the up-to-date radix-tree form of `definition-prefixes'."
> > (when (> (hash-table-count definition-prefixes) 0)
> > (maphash (lambda (prefix files)
> > (let ((old (radix-tree-lookup help-definition-prefixes prefix)))
> > (setq help-definition-prefixes
> > (radix-tree-insert help-definition-prefixes
> > prefix (append old files)))))
> > definition-prefixes)
> > (clrhash definition-prefixes))
> > help-definition-prefixes)
> >
> > Because of the `clrhash', `definition-prefixes' will always be empty
> > after the function call to `help-definition-prefixes'.
>
> Duh, indeed.
> IIRC it's a leftover from some older version of the code.
> I think the patch below is in order.
Thanks, please install on the emacs-30 branch.
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Tue, 20 Aug 2024 12:15:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Chris Roberts <frayedultrasonicaligator <at> disroot.org>
:
bug acknowledged by developer.
(Tue, 20 Aug 2024 12:15:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 72511-done <at> debbugs.gnu.org (full text, mbox):
>> IIRC it's a leftover from some older version of the code.
>> I think the patch below is in order.
>
> Thanks, please install on the emacs-30 branch.
Done, thanks,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 18 Sep 2024 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.