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#67393: 29.1; Slow to open file if autosave exists Date: Tue, 16 Jan 2024 18:36:51 +0200 Organization: LINKOV.NET Message-ID: <868r4pp74s.fsf@mail.linkov.net> References: <83a5r5gdxk.fsf@gnu.org> <87frztc7iy.fsf@localhost> <867cl4kg4l.fsf@mail.linkov.net> <87cyuwdcb4.fsf@localhost> <868r5jse0m.fsf@mail.linkov.net> <83r0jbbg2z.fsf@gnu.org> <86a5pv508o.fsf@mail.linkov.net> <83h6k38s9g.fsf@gnu.org> <86bkaa7oaa.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17082"; 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: materus213@gmail.com, yantar92@posteo.net, 67393@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 16 17:44:48 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 1rPmYS-0004FB-A2 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Jan 2024 17:44:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPmXk-0001eh-7U; Tue, 16 Jan 2024 11:44:04 -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 1rPmXi-0001Zc-Em for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 11:44:02 -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 1rPmXi-0005vX-5Q for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 11:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPmXi-0000kU-CD for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 11: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, 16 Jan 2024 16:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 67393-submit@debbugs.gnu.org id=B67393.17054233912803 (code B ref 67393); Tue, 16 Jan 2024 16:44:02 +0000 Original-Received: (at 67393) by debbugs.gnu.org; 16 Jan 2024 16:43:11 +0000 Original-Received: from localhost ([127.0.0.1]:49565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPmWt-0000j4-16 for submit@debbugs.gnu.org; Tue, 16 Jan 2024 11:43:11 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:34517) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPmWr-0000ic-0j for 67393@debbugs.gnu.org; Tue, 16 Jan 2024 11:43:09 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id EE7DD60011; Tue, 16 Jan 2024 16:43:00 +0000 (UTC) In-Reply-To: <86bkaa7oaa.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 28 Dec 2023 09:57:01 +0200") 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:278344 Archived-At: --=-=-= Content-Type: text/plain >>> 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'. So here is the new function 'important-message' and its calls in two discussed places. I'm not sure why 'after-find-file' uses non-nil NODISP arg in (sit-for 1 t). This means is that the message is not displayed? Then why 'message' is called? I'm asking this because if NODISP is unnecessary then the signature of 'important-message' without NODISP will be shorter and more nice to use. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=important-message.patch diff --git a/lisp/files.el b/lisp/files.el index 9c8914bfc50..b22bf4a14c6 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2781,8 +2781,9 @@ after-find-file (unless (file-directory-p default-directory) "Use M-x make-directory RET RET to create the directory and its parents"))))) (when (and warn msg) - (message "%s" msg) - (or not-serious (sit-for 1 t)))) + (if not-serious + (message "%s" msg) + (important-message 1 t "%s" msg)))) (when (and auto-save-default (not noauto)) (auto-save-mode 1))) ;; Make people do a little extra work (C-x C-q) diff --git a/lisp/simple.el b/lisp/simple.el index 692c0dacefc..6fa74bde037 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4794,6 +4794,12 @@ max-mini-window-lines ((integerp max-mini-window-height) max-mini-window-height) (t 1))) +(defun important-message (seconds nodisp format-string &rest args) + "Display an important MESSAGE in the echo area. +Make sure that MESSAGE stays displayed for the specified number of SECONDS." + (apply #'message format-string args) + (sit-for seconds nodisp)) + (defun display-message-or-buffer (message &optional buffer-name action frame) "Display MESSAGE in the echo area if possible, otherwise in a pop-up buffer. MESSAGE may be either a string or a buffer. diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 17af1f1d926..3c9eda47cbd 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -2768,8 +2768,7 @@ ispell-parse-output (substring output 2)) ; return root word ((equal 0 (string-match "[\ra-zA-Z]" output)) (ding) ; error message from ispell! - (message "Ispell error: %s" output) - (sit-for 5) + (important-message 5 nil "Ispell error: %s" output) nil) (t ; need to process &, ?, and #'s (let ((type (aref output 0)) ; &, ?, or # --=-=-=--