Subject: bug#67393: 29.1; Slow to open file if autosave exists

From: Juri Linkov <[email-masked]>
Date: Thu, 28 Dec 2023 09:57:01 +0200

>> >>     (ding) ; error message from ispell!
>> >>     (message "Ispell error: %s" output)
>> >>     (sit-for 5)
>> >>
>> >> So I need to waste 5 seconds several times during spell-checking.
>> >
>> > Only when there's an error, right?
>> 
>> Often during spell-checking it's really not an error, but a warning
>> that text in some unsupported encoding can't be spell-checked.
>
> "Unsupported encoding"?  Last time I saw this was when I was using
> ispell as the speller.  Since I switched to Hunspell years ago, these
> problems are gone for good, since Hunspell uses UTF-8.  How come you
> still see this?

This happens occasionally with Hunspell, but I can't explain why,
maybe due to misconfiguration.  I could debug this later.

>> I propose to refactor such code
>> 
>>   (message "Ispell error: %s" output)
>>   (sit-for 5)
>> 
>> to a new separate function, e.g.
>> 
>>   (important-message 5 "Ispell error: %s" output)
>> 
>> with a simple implementation
>> 
>>   (defun important-message (seconds format-string &rest args)
>>     (apply #'message format-string args)
>>     (sit-for seconds))
>> 
>> Then users could easily override such annoying delay.
>> Or maybe even the default implementation can check
>> if set-message-functions already contains set-multi-message
>> that ensures that the important message will not be missed,
>> and not to use sit-for in this case.
>
> I don't mind much, but is this really the best we can do?

This is just the first thing that we could do.
So the first task is to find all such places,
and replace them with the single function call.

> Asking users to customize Emacs by overriding functions is not very
> friendly, and in this case we certainly could do better, for example
> by making 5 be a defcustom.

A defcustom would be one option.  'set-important-message' like
implemented by Ihor would be another option.  All this could be
added after creating the new function 'important-message'.