GNU bug report logs - #65459
completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH

Previous Next

Package: emacs;

Reported by: Heime <heimeborgia <at> protonmail.com>

Date: Tue, 22 Aug 2023 22:05:02 UTC

Severity: normal

Full log


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

From: Gregory Heytings <gregory <at> heytings.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Heime <heimeborgia <at> protonmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 65459 <at> debbugs.gnu.org
Subject: Re: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION
 and REQUIRE-MATCH
Date: Thu, 24 Aug 2023 12:30:51 +0000
>> (defun my-completing-read (prompt collection start)
>>   (minibuffer-with-setup-hook
>>       (:append
>>        (lambda ()
>>          (setq-local actual-minibuffer-default-add-function
>>                      minibuffer-default-add-function)
>>          (setq-local minibuffer-default-add-function
>>                      '(lambda () (setq minibuffer-default-add-done nil)
>>                         (funcall actual-minibuffer-default-add-function)))
>
> Why use ' on `lambda`?
>

I think my finger slipped.

>
> BTW, rather than the above two `setq-local`s, I think you can write:
>
>    (add-function :before (local 'minibuffer-default-add-function)
>                  (lambda () (setq minibuffer-default-add-done nil)))
>

Right.  I was writing that function as it if were for minibuffer.el, and 
was therefore avoiding advices.  But now I see that there are a couple of 
add-function in core anyway (it's not clear to me where the dividing line 
is).  So here's the final version:

(defun my-completing-read (prompt collection start)
  (minibuffer-with-setup-hook
      (:append
       (lambda ()
         (add-function :before (local 'minibuffer-default-add-function)
                       (lambda () (setq minibuffer-default-add-done nil)))
         (next-history-element start)
         (move-end-of-line nil)))
    (completing-read (format-prompt prompt nil) collection nil t)))

(my-completing-read "Grapheme" '("alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta") 1)

Heime, can you try that and tell us if it solves your problem?





This bug report was last modified 1 year and 289 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.