From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#64656: 29.0.91; Doc of minibuffer histories and completing-read - automatic addition of completions to DEFAULT list Date: Tue, 14 Nov 2023 09:30:30 +0200 Organization: LINKOV.NET Message-ID: <86v8a4kfio.fsf@mail.linkov.net> References: <83y1jga0nr.fsf@gnu.org> <83o7kb9a40.fsf@gnu.org> <86bkg84de3.fsf@mail.linkov.net> <86jzrhlrub.fsf_-_@mail.linkov.net> <867cmw83zb.fsf@mail.linkov.net> <867cmvcpco.fsf@mail.linkov.net> <86a5rmanrn.fsf@mail.linkov.net> <83edgyzxcx.fsf@gnu.org> <86jzqqj1u2.fsf@mail.linkov.net> <838r76zpsw.fsf@gnu.org> <86v8aakq69.fsf@mail.linkov.net> <83sf5exbv2.fsf@gnu.org> <864jhrwfad.fsf@mail.linkov.net> <86il657qva.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19234"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , "64656@debbugs.gnu.org" <64656@debbugs.gnu.org>, Stefan Monnier To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 14 08:43:54 2023 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 1r2o5S-0004u3-0d for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Nov 2023 08:43:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2o51-0007fW-SS; Tue, 14 Nov 2023 02:43:27 -0500 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 1r2o4x-0007PM-K6 for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:43:25 -0500 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 1r2o4u-0003ov-Js for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:43:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r2o5a-0003rj-Hx for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Nov 2023 07:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64656 X-GNU-PR-Package: emacs Original-Received: via spool by 64656-submit@debbugs.gnu.org id=B64656.169994780614778 (code B ref 64656); Tue, 14 Nov 2023 07:44:02 +0000 Original-Received: (at 64656) by debbugs.gnu.org; 14 Nov 2023 07:43:26 +0000 Original-Received: from localhost ([127.0.0.1]:59976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2o50-0003qH-Eu for submit@debbugs.gnu.org; Tue, 14 Nov 2023 02:43:26 -0500 Original-Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]:53827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2o4x-0003pq-T5 for 64656@debbugs.gnu.org; Tue, 14 Nov 2023 02:43:24 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 680DB60005; Tue, 14 Nov 2023 07:42:32 +0000 (UTC) In-Reply-To: (Drew Adams's message of "Mon, 13 Nov 2023 18:14:12 +0000") X-GND-Sasl: juri@linkov.net 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:274297 Archived-At: >> > The problem reported by this bug report is that the order is random by >> > `C-h v M-n M-n' because it uses obarray. > > No. That is NOT the problem reported. The problem > reported is: > > 1. Initial completions are added to `M-n' automatically, > instead of just by a user adding them explicitly to > DEFAULTS. > > 2. Given that BUG, _IF_ it won't be fixed, then the doc > should at least make users aware of it and mention > how to work around it. > > Fixing #1 is preferable. Fixing #2 is minimal damage > control, IF you won't fix #1. #1 can be fixed only partially for some popular obarray completions. So here is a patch that fixes #1 partially and #2 completely. diff --git a/lisp/simple.el b/lisp/simple.el index f86b3f9e208..02005e3b4f9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2989,11 +2989,17 @@ minibuffer-default-add-done (defun minibuffer-default-add-completions () "Return a list of all completions without the default value. This function is used to add all elements of the completion table to -the end of the list of defaults just after the default value." +the end of the list of defaults just after the default value. +When you don't want to add initial completions to the default value, +you can use either `minibuffer-setup-hook' or `minibuffer-with-setup-hook' +to set the value of `minibuffer-default-add-function' to nil." (let ((def minibuffer-default) - (all (all-completions "" - minibuffer-completion-table - minibuffer-completion-predicate))) + ;; Avoid some popular completions with undefined order + (all (unless (memq minibuffer-completion-table + `(help--symbol-completion-table ,obarray)) + (all-completions "" + minibuffer-completion-table + minibuffer-completion-predicate)))) (if (listp def) (append def all) (cons def (delete def all)))))