GNU bug report logs - #72511
30.0.50; prefix-completions is always nil in help--symbol-completion-table

Previous Next

Package: emacs;

Reported by: Chris Roberts <frayedultrasonicaligator <at> disroot.org>

Date: Wed, 7 Aug 2024 12:43:01 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 72511 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Chris Roberts <frayedultrasonicaligator <at> disroot.org>
Cc: 72511 <at> debbugs.gnu.org
Subject: Re: bug#72511: 30.0.50; prefix-completions is always nil in
 help--symbol-completion-table
Date: Wed, 14 Aug 2024 11:50:47 -0400
> (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)





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.