From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72511: 30.0.50; prefix-completions is always nil in help--symbol-completion-table Date: Wed, 07 Aug 2024 17:20:49 +0300 Message-ID: <864j7wo1mm.fsf@gnu.org> References: <20240807135305.189c2c3e@cdr> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19997"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72511@debbugs.gnu.org To: Chris Roberts , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 07 16:21:56 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sbhY3-00054O-EZ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Aug 2024 16:21:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbhXn-0001c3-7X; Wed, 07 Aug 2024 10:21:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbhXl-0001bt-N5 for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 10:21:37 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbhXl-0002Km-Cl for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 10:21:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=vUxq1XX7lRDCUp4aC6UGKc8povm1e4qAj9nvSLp0Qp0=; b=qVWB2oS35MKBsE+QAv1TY9x5EAewO8ddxfASx4BpuhKG4yoraOgHcqVgbegZayRi2aQ0smnrDAys+Uof1vhvnRDoCd2j5jbljJ0NUTFgGPFe3f68qKCOXp0oXV2R4RBAkF6sH1zuX2hiNDxhXwvakMzeo4TU937P2e6l173rs3UXqTTY6CK/5wbLnK3e0Vyh0ivKF2C2VJl4Np4IZcXqvDOEuGoqByVA1Q0p04NxZGytoPUDLYa5C8pW3EYxwAwsWkp8k72ZjdUQQg8ZkRauaM6+xmmVLYjTVDGPLLIhPDggYVH2pJDbLwofySCdGHhFRGiLBlFtA3mO9F4IKZkI4A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sbhYA-0008Fb-Il for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 10:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Aug 2024 14:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72511 X-GNU-PR-Package: emacs Original-Received: via spool by 72511-submit@debbugs.gnu.org id=B72511.172304048831653 (code B ref 72511); Wed, 07 Aug 2024 14:22:02 +0000 Original-Received: (at 72511) by debbugs.gnu.org; 7 Aug 2024 14:21:28 +0000 Original-Received: from localhost ([127.0.0.1]:34855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbhXc-0008ER-7q for submit@debbugs.gnu.org; Wed, 07 Aug 2024 10:21:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbhXa-0008Dy-IQ for 72511@debbugs.gnu.org; Wed, 07 Aug 2024 10:21:27 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbhX3-00023b-45; Wed, 07 Aug 2024 10:20:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=vUxq1XX7lRDCUp4aC6UGKc8povm1e4qAj9nvSLp0Qp0=; b=MfxJPN734auv BK4E1061pDKpRFgNb0wCxp2G7RY8PJ4/78F0RFJinrQ/qbzrKUPaPr953s5JTmTXcHYNS9PIWjR5Z tpraP9u9VNYhWQ4MNfwCudDcEQl9he2eZiBCZFQoKKka84bCi0c7wAR8gBqkzHk92ddcXao6rJi+L y59UBinaAi4GU0P9TfRG+IDKvEdDyDtHU/WZXjIeGMQ2ogIQQqPMhSFjDZRwaYXR8uyPAbZBc+DiT 7/m9qhStR1kQNc0LxF4gQUQFYpS72cbfLllxIYtv7iQkGQ2keavrsHiMsSotEuZ8dFardNyC7LfPO UWtiIdMwBRiHAkrEiP8fMA==; In-Reply-To: <20240807135305.189c2c3e@cdr> (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289886 Archived-At: > 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" > > 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 is enough > to completely truncate it. Thanks, I'm adding Stefan, who wrote this code, to the discussion.