emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange use of (run-with-timer 0 nil #'foo args) in do-after-load-ev


From: Juri Linkov
Subject: Re: Strange use of (run-with-timer 0 nil #'foo args) in do-after-load-evaluation
Date: Thu, 31 Oct 2019 00:10:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> 'message' can be easily replaced with 'minibuffer-message',
>> then it doesn't obscure the minibuffer:
>>
>> (progn
>>   (run-at-time 2 nil (lambda () (minibuffer-message "foo")))
>>   (read-from-minibuffer "Yes? "))
>
> Oh, nice.  I guess whenever we're displaying things from an async
> context, we should be using minibuffer-message?

'minibuffer-message' just calls the 'message' when used outside of
the minibuffer.  Maybe the dependency should be reversed so 'message'
could call 'minibuffer-message' when used in the minibuffer.

>> Whereas it obscures the prompt in y-or-n-p:
>>
>> (progn
>>   (run-at-time 2 nil (lambda () (minibuffer-message "foo")))
>>   (y-or-n-p "Yes? "))
>
> Then I'm all for your suggestion to rewrite y-or-n-p with
> read-from-minibuffer...  but without a history.  (And yes-or-no-p too,
> somehow, I guess.)  (Or fix both of those functions to work the same
> with respect to minibuffer-message.)

Without a history is fine.  There is another problem with
backward-compatibility: currently 'y-or-n-p' uses 'query-replace-map'
to translate input characters to y/n answers via act/skip symbols.

Users customize 'query-replace-map' to map more characters to act/skip
symbols, so we need to use 'query-replace-map', but not directly like

  (let ((prompt "Confirm? "))
    (read-from-minibuffer prompt nil query-replace-map))

that obviously fails with

  call-interactively: (wrong-type-argument commandp act)

query-replace-map needs to be translated to another keymap
where the same characters from 'query-replace-map'
run real commands, not intermediate symbols.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]