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

From: Juri Linkov <[email-masked]>
Date: Wed, 17 Jan 2024 18:48:57 +0200

> Then I think we should consider all of those changes together.

Ok, here is a complete patch.

>> Would it be safe to drop NODISP in the new function?
>> I see that most calls of 'message' with 'sit-for'
>> don't use the NODISP arg.
>
> I don't see a need to remove it, as one caller that uses it is enough
> to justify it, and the price is hardly significant.

The problem is that in most calls the argument NODISP is nil.

diff --git a/etc/NEWS b/etc/NEWS
index 939caed14f6..0754645bdc8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1777,6 +1777,8 @@ The declaration '(important-return-value t)' sets the
 'important-return-value' property which indicates that the function
 return value should probably not be thrown away implicitly.
 
+** New function 'important-message' to display messages with a delay.
+
 +++
 ** New functions 'file-user-uid' and 'file-group-gid'.
 These functions are like 'user-uid' and 'group-gid', respectively, but
diff --git a/lisp/allout.el b/lisp/allout.el
index 95b73c54934..b00e256aaf1 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -1519,7 +1519,7 @@ allout-write-contents-hook-handler
                                          " %s")
                                  (buffer-name (current-buffer))
                                  failure)))
-               (message text)(sit-for 2)
+               (important-message 2 nil text)
                text)))))
     ))
 ;;;_   > allout-after-saves-handler ()
@@ -1957,8 +1957,7 @@ allout-mode
                          (buffer-name)))
             ;; Problem applying exposure -- notify user, but don't
             ;; interrupt, eg, file visit:
-            (error (message "%s" (car (cdr err)))
-                   (sit-for 1))))
+            (error (important-message 1 nil "%s" (car (cdr err))))))
         )                               ; when allout-layout
       )					; if (allout-mode-p)
     )                                   ; let (())
diff --git a/lisp/desktop.el b/lisp/desktop.el
index ff113c85e12..3587636271a 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1373,8 +1373,8 @@ desktop-read
 	    (unless (eq (emacs-pid) owner)
 	      (condition-case nil
 		  (desktop-claim-lock)
-		(file-error (message "Couldn't record use of desktop file")
-			    (sit-for 1))))
+		(file-error (important-message
+                             1 nil "Couldn't record use of desktop file"))))
 
 	    (unless (desktop-restoring-frameset-p)
 	      ;; `desktop-create-buffer' puts buffers at end of the buffer list.
@@ -1736,8 +1736,7 @@ desktop-idle-create-buffers
     (unless desktop-buffer-args-list
       (cancel-timer desktop-lazy-timer)
       (setq desktop-lazy-timer nil)
-      (message "Lazy desktop load complete")
-      (sit-for 3)
+      (important-message 3 nil "Lazy desktop load complete")
       (message "")))))
 
 (defun desktop-lazy-complete ()
diff --git a/lisp/ebuff-menu.el b/lisp/ebuff-menu.el
index 743b92578eb..86b5ce9367f 100644
--- a/lisp/ebuff-menu.el
+++ b/lisp/ebuff-menu.el
@@ -256,8 +256,7 @@ Electric-buffer-menu-mode-view-buffer
     (if bufnam
 	(view-buffer bufnam)
       (ding)
-      (message "Buffer %s does not exist!" bufnam)
-      (sit-for 4))))
+      (important-message 4 nil "Buffer %s does not exist!" bufnam))))
 
 (defvar electric-buffer-overlay nil)
 
diff --git a/lisp/electric.el b/lisp/electric.el
index fee0bf36d7f..20327ed48f6 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -105,26 +105,22 @@ Electric-command-loop
 	    (buffer-read-only (if loop-function
 				  (setq err conditions)
 				(ding)
-				(message "Buffer is read-only")
-				(sit-for 2)))
+				(important-message 2 nil "Buffer is read-only")))
 	    (beginning-of-buffer (if loop-function
 				     (setq err conditions)
 				   (ding)
-				   (message "Beginning of Buffer")
-				   (sit-for 2)))
+				   (important-message 2 nil "Beginning of Buffer")))
 	    (end-of-buffer (if loop-function
 			       (setq err conditions)
 			     (ding)
-			     (message "End of Buffer")
-			     (sit-for 2)))
+			     (important-message 2 nil "End of Buffer")))
 	    (error (if loop-function
 		       (setq err conditions)
 		     (ding)
-		     (message "Error: %s"
+		     (important-message 2 nil "Error: %s"
 			      (if (eq (car conditions) 'error)
 				  (car (cdr conditions))
-				(prin1-to-string conditions)))
-		     (sit-for 2))))
+				(prin1-to-string conditions))))))
 	(ding))
       (if loop-function (funcall loop-function loop-state err))))
   (ding)
diff --git a/lisp/files.el b/lisp/files.el
index 9c8914bfc50..f402dddf1c6 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/ido.el b/lisp/ido.el
index 6e51dc67196..0e7934da59d 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -2015,8 +2015,7 @@ ido-read-internal
 			(condition-case nil
 			    (progn (make-directory d t) t)
 			  (error
-			   (message "Could not create directory")
-			   (sit-for 1)
+			   (important-message 1 nil "Could not create directory")
 			   nil))))
 		  (progn
 		    (ido-set-current-directory d nil (eq ido-exit 'chdir))
diff --git a/lisp/info-look.el b/lisp/info-look.el
index da7beafe500..8d79837fa2e 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -457,8 +457,7 @@ info-lookup
 		      (Info-goto-node node)
 		      (setq doc-found t)))
 		(error
-		 (message "Cannot access Info node %s" node)
-		 (sit-for 1)
+		 (important-message 1 nil "Cannot access Info node %s" node)
 		 nil))
 	  (condition-case nil
 	      (progn
@@ -569,8 +568,7 @@ info-lookup-make-completions
 		    (Info-goto-node node)
 		    (setq doc-found t))
 		(error
-		 (message "Cannot access Info node `%s'" node)
-		 (sit-for 1)
+		 (important-message 1 nil "Cannot access Info node `%s'" node)
 		 nil))
 	  (condition-case nil
 	      (progn
diff --git a/lisp/info.el b/lisp/info.el
index e56344825b9..b35e4edcaa3 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3742,9 +3742,9 @@ Info-apropos-matches
                           (setq nodes (cdr nodes) node (car nodes)))
                       (Info-goto-node node))))
 	    (error
-	     (message "%s" (if (eq (car-safe err) 'error)
-			       (nth 1 err) err))
-	     (sit-for 1 t)))))
+	     (important-message
+              1 t "%s" (if (eq (car-safe err) 'error)
+			   (nth 1 err) err))))))
       (Info-find-node current-file current-node)
       (setq Info-history ohist
 	    Info-history-list ohist-list)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4cac79a3f4a..b7c774f08f4 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2138,12 +2138,12 @@ isearch--momentary-message
   "Print STRING at the end of the isearch prompt for 1 second.
 The optional argument SECONDS overrides the number of seconds."
   (let ((message-log-max nil))
-    (message "%s%s%s"
-             (isearch-message-prefix nil isearch-nonincremental)
-             isearch-message
-             (apply #'propertize (format " [%s]" string)
-                    isearch-message-properties)))
-  (sit-for (or seconds 1)))
+    (important-message
+     (or seconds 1) nil "%s%s%s"
+     (isearch-message-prefix nil isearch-nonincremental)
+     isearch-message
+     (apply #'propertize (format " [%s]" string)
+            isearch-message-properties))))
 
 (isearch-define-mode-toggle lax-whitespace " " nil
   "In ordinary search, toggles the value of the variable
@@ -2777,8 +2777,7 @@ isearch-yank-until-char
                       (search-forward (char-to-string char) nil nil arg)
                       (forward-char -1))
                   (search-failed
-                   (message "`%c' not found" char)
-                   (sit-for 2)))
+                   (important-message 2 nil "`%c' not found" char)))
                 (point)))))
 
 (defun isearch-yank-line (&optional arg)
diff --git a/lisp/proced.el b/lisp/proced.el
index 3435f1ab8cd..9365df95b71 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -2131,8 +2131,7 @@ proced-send-signal
     ;; the command can be used more flexibly in noninteractive ways, too.
     (unless (get 'proced-send-signal 'proced-outdated)
        (put 'proced-send-signal 'proced-outdated t)
-       (message "Outdated usage of `proced-send-signal'")
-       (sit-for 2))
+       (important-message 2 nil "Outdated usage of `proced-send-signal'"))
     (setq process-alist (proced-marked-processes))
     (unless signal
       (let ((pnum (if (= 1 (length process-alist))
diff --git a/lisp/simple.el b/lisp/simple.el
index 692c0dacefc..ece98ec109d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4794,6 +4794,14 @@ 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.
+The arguments SECONDS and NODISP are the same as in `sit-for'.
+The arguments FORMAT-STRING and ARGS are the same as in `message'."
+  (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.
@@ -9772,10 +9780,11 @@ set-variable
 				(t "globally"))))
 	  (val (progn
                  (when obsolete
-                   (message (concat "`%S' is obsolete; "
-                                    (if (symbolp obsolete) "use `%S' instead" "%s"))
-                            var obsolete)
-                   (sit-for 3))
+                   (important-message
+                    3 nil
+                    (concat "`%S' is obsolete; "
+                            (if (symbolp obsolete) "use `%S' instead" "%s"))
+                    var obsolete))
                  (if prop
                      ;; Use VAR's `variable-interactive' property
                      ;; as an interactive spec for prompting.
diff --git a/lisp/subr.el b/lisp/subr.el
index df28989b399..d77d3ab25fe 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3404,8 +3404,8 @@ read-passwd
                   (setq success first))
               (and (arrayp first) (clear-string first))
               (and (arrayp second) (clear-string second))
-              (message "Password not repeated accurately; please start over")
-              (sit-for 1))))
+              (important-message
+               1 nil "Password not repeated accurately; please start over"))))
         success)
     (let (minibuf)
       (minibuffer-with-setup-hook
@@ -3469,8 +3469,7 @@ read-number
 			 ((stringp str) (read str))))
 	      (error nil)))
 	  (unless (numberp n)
-	    (message "Please enter a number.")
-	    (sit-for 1)
+	    (important-message 1 nil "Please enter a number.")
 	    t)))
     n))
 
diff --git a/lisp/tooltip.el b/lisp/tooltip.el
index 4537fdf8087..d03073ec4c2 100644
--- a/lisp/tooltip.el
+++ b/lisp/tooltip.el
@@ -275,8 +275,7 @@ tooltip-show
 		      tooltip-x-offset
 		      tooltip-y-offset))
       (error
-       (message "Error while displaying tooltip: %s" error)
-       (sit-for 1)
+       (important-message 1 nil "Error while displaying tooltip: %s" error)
        (message "%s" text)))))
 
 (declare-function x-hide-tip "xfns.c" ())
diff --git a/lisp/userlock.el b/lisp/userlock.el
index db94bb214e6..72d5595770b 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -83,9 +83,10 @@ ask-user-about-lock
 	    (cond ((null answer)
 		   (beep)
                    ;; FIXME: Why do we use "?" here and "C-h" below?
-                   (message (substitute-command-keys
-                             "Please type \\`q', \\`s', or \\`p'; or \\`?' for help"))
-		   (sit-for 3))
+                   (important-message
+                    3 nil
+                    (substitute-command-keys
+                     "Please type \\`q', \\`s', or \\`p'; or \\`?' for help")))
 		  ((eq (cdr answer) 'help)
 		   (ask-user-about-lock-help)
 		   (setq answer nil))
diff --git a/lisp/view.el b/lisp/view.el
index 2ac7479739f..6f6bcfce2c3 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -900,9 +900,10 @@ view-search
 	  (overlay-put view-overlay 'face view-highlight-face)
 	  (beginning-of-line)
 	  (view-recenter))
-      (message "Can't find occurrence %d of %s%s"
-	       times (if no "no " "") regexp)
-      (sit-for 4))))
+      (important-message
+       4 nil
+       "Can't find occurrence %d of %s%s"
+       times (if no "no " "") regexp))))
 
 ;; This is the dumb approach, looking at each line.  The original
 ;; version of this function looked like it might have been trying to
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el
index cf5ce1761a8..960c39feaf3 100644
--- a/lisp/cedet/semantic/bovine/c.el
+++ b/lisp/cedet/semantic/bovine/c.el
@@ -916,8 +916,7 @@ semantic-c-parse-lexical-token
 		    (format "There was an error initializing %s in buffer \"%s\".  Debug your hooks? "
 			    mode (buffer-name)))
 		   (semantic-c-debug-mode-init mode)
-		 (message "Macro parsing state may be broken...")
-		 (sit-for 1))))
+		 (important-message 1 nil "Macro parsing state may be broken..."))))
 	    )				; save match data
 
 	  ;; Hack in mode-local
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 82c6c03a592..5871ae16b04 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -694,20 +694,17 @@ checkdoc-interactive-loop
 				       'automatic-then-never)))
 		  (if (not fixed)
 		      (progn
-			(message "A Fix was not available.")
-			(sit-for 2))
+			(important-message 2 nil "A Fix was not available."))
 		    (setq err-list (cdr err-list))))
 		(beginning-of-defun)
 		(let ((ne (funcall findfunc nil)))
 		  (if ne
 		      (setq err-list (cons ne err-list))
 		    (cond ((not err-list)
-			   (message "No More Stylistic Errors.")
-			   (sit-for 2))
+			   (important-message 2 nil "No More Stylistic Errors."))
 			  (t
-			   (message
-			    "No Additional style errors.  Continuing...")
-			   (sit-for 2))))))
+			   (important-message 2 nil
+			    "No Additional style errors.  Continuing..."))))))
 	       ;; Move to the next error (if available)
 	       ((memq c '(?n ?\s))
 		(let ((ne (funcall findfunc nil)))
@@ -716,9 +713,8 @@ checkdoc-interactive-loop
 			  (setq returnme err-list
 				err-list nil)
 			(if (not err-list)
-			    (message "No More Stylistic Errors.")
-			  (message "No Additional style errors.  Continuing..."))
-			(sit-for 2))
+			    (important-message 2 nil "No More Stylistic Errors.")
+			  (important-message 2 nil "No Additional style errors.  Continuing...")))
 		    (setq err-list (cons ne err-list)))))
 	       ;; Go backwards in the list of errors
 	       ((memq c '(?p ?\C-?))
@@ -727,8 +723,7 @@ checkdoc-interactive-loop
 		      (setq err-list (cdr err-list))
 		      (goto-char (cdr (car err-list)))
 		      (beginning-of-defun))
-		  (message "No Previous Errors.")
-		  (sit-for 2)))
+		  (important-message 2 nil "No Previous Errors.")))
 	       ;; Edit the buffer recursively.
 	       ((eq c ?e)
 		(checkdoc-recursive-edit
@@ -741,8 +736,7 @@ checkdoc-interactive-loop
 		      (if showstatus
 			  (setq returnme err-list
 				err-list nil)
-			(message "No More Stylistic Errors.")
-			(sit-for 2))
+			(important-message 2 nil "No More Stylistic Errors."))
 		    (setq err-list (cons ne err-list)))))
 	       ;; Quit checkdoc
 	       ((eq c ?q)
diff --git a/lisp/emacs-lisp/helper.el b/lisp/emacs-lisp/helper.el
index 0446109f5ac..a4c1415e694 100644
--- a/lisp/emacs-lisp/helper.el
+++ b/lisp/emacs-lisp/helper.el
@@ -87,9 +87,9 @@ Helper-help-scroller
 (defun Helper-help-options ()
   "Describe help options."
   (interactive)
-  (message (substitute-command-keys
-            "\\`c' (key briefly), \\`m' (mode), \\`k' (key), \\`b' (bindings)"))
-  (sit-for 4))
+  (important-message
+   4 nil (substitute-command-keys
+          "\\`c' (key briefly), \\`m' (mode), \\`k' (key), \\`b' (bindings)")))
 
 (defun Helper-describe-key-briefly (key)
   "Briefly describe binding of KEY."
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index b603f2e6d0b..a26764b6e50 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -250,10 +250,10 @@ map-y-or-n-p
 			  (funcall try-again))
 			 (t
 			  ;; Random char.
-			  (message "Type %s for help."
-				   (key-description (vector help-char)))
 			  (beep)
-			  (sit-for 1)
+			  (important-message
+                           1 nil "Type %s for help."
+			   (key-description (vector help-char)))
 			  (funcall try-again))))
 		  (prompt
 		   (funcall actor elt)
@@ -372,8 +372,7 @@ read-answer
                                (interactive)
                                (delete-minibuffer-contents)
                                (beep)
-                               (message message)
-                               (sit-for 2)))
+                               (important-message 2 nil message)))
                            map)
                          read-answer-map--memoize))))
          answer)
@@ -415,8 +414,7 @@ read-answer
                        answers-with-help ",\n")
                       ".\n")))
         (beep)
-        (message message)
-        (sit-for 2)))
+        (important-message 2 nil message)))
     answer))
 
 ;;; map-ynp.el ends here
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 51c81b9d2f6..3afa33c3068 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -3254,13 +3254,13 @@ compilation-find-file
                  (origname name))
             (cond
              ((not (file-exists-p name))
-              (message "Cannot find file `%s'" name)
-              (ding) (sit-for 2))
+              (ding)
+              (important-message 2 nil "Cannot find file `%s'" name))
              ((and (file-directory-p name)
                    (not (file-exists-p
                          (setq name (compilation--expand-fn name filename)))))
-              (message "No `%s' in directory %s" filename origname)
-              (ding) (sit-for 2))
+              (ding)
+              (important-message 2 nil "No `%s' in directory %s" filename origname))
              (t
               (setq buffer (find-file-noselect name))))))))
     ;; Make intangible overlays tangible.
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 17af1f1d926..7c6aee1cbeb 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2375,9 +2375,9 @@ ispell-command-loop
 		    ;; This may have alignment errors if current line is edited
 		    (if (marker-position ispell-recursive-edit-marker)
 			(progn
-			  (message "Only one recursive edit session supported")
 			  (beep)
-			  (sit-for 2))
+			  (important-message
+                           2 nil "Only one recursive edit session supported"))
 		      (set-marker ispell-recursive-edit-marker start)
 		      ;;(set-marker ispell-region-end reg-end)
 		      (and ispell-highlight-p		; unhighlight
@@ -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 #
@@ -3335,9 +3334,8 @@ ispell-tex-arg-end
 	(while (looking-at "[ \t\n]*\\[") (forward-sexp))
 	(forward-sexp (or arg 1)))
     (error
-     (message "Error skipping s-expressions at point %d." (point))
      (beep)
-     (sit-for 2))))
+     (important-message 2 nil "Error skipping s-expressions at point %d." (point)))))

 (defun ispell-ignore-fcc (start end)
@@ -3413,10 +3411,10 @@ ispell-skip-region
 	  (setq alist (cdr alist))))))
     (if (and (= start (point)) (null null-skip))
 	(progn
-	  (message "Matching region end for `%s' point %d not found"
-		   key (point))
 	  (beep)
-	  (sit-for 2)))))
+	  (important-message
+           2 nil "Matching region end for `%s' point %d not found"
+	   key (point))))))

 (defun ispell-get-line (start end in-comment)
@@ -4168,8 +4166,7 @@ ispell-buffer-local-parsing
 		   (ispell-send-string "-\n~nroff\n"))
 		  ((string-search "~" string) ; Set extended character mode.
 		   (ispell-send-string (concat string "\n")))
-		  (t (message "Invalid Ispell Parsing argument!")
-		     (sit-for 2))))))))
+		  (t (important-message 2 nil "Invalid Ispell Parsing argument!"))))))))

 ;; Can kill the current ispell process
diff --git a/lisp/vc/ediff-diff.el b/lisp/vc/ediff-diff.el
index 83bd7cde12f..381d24f1c77 100644
--- a/lisp/vc/ediff-diff.el
+++ b/lisp/vc/ediff-diff.el
@@ -222,15 +222,15 @@ ediff-make-diff2-buffer
   (let ((file1-size (ediff-file-size file1))
 	(file2-size (ediff-file-size file2)))
     (cond ((not (numberp file1-size))
-	   (message "Can't find file: %s"
-		    (ediff-abbreviate-file-name file1))
-	   (sit-for 2)
+	   (important-message
+            2 nil "Can't find file: %s"
+	    (ediff-abbreviate-file-name file1))
 	   ;; 1 is an error exit code
 	   1)
 	  ((not (numberp file2-size))
-	   (message "Can't find file: %s"
-		    (ediff-abbreviate-file-name file2))
-	   (sit-for 2)
+	   (important-message
+            2 nil "Can't find file: %s"
+	    (ediff-abbreviate-file-name file2))
 	   ;; 1 is an error exit code
 	   1)
 	  (t ;; this erases the diff buffer automatically
diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
index f8d4c1c1c4b..431f6becc10 100644
--- a/lisp/vc/ediff-ptch.el
+++ b/lisp/vc/ediff-ptch.el
@@ -364,8 +364,7 @@ ediff-fixup-patch-map
 			    (setq directory nil)
 			  (setq directory t)
 			  (beep)
-			  (message "%s is a directory" user-file)
-			  (sit-for 2)))
+			  (important-message 2 nil "%s is a directory" user-file)))
 		      (setcar (ediff-get-session-objA session-info)
 			      (cons user-file user-file))))
 		(setcar proposed-file-names
@@ -478,8 +477,7 @@ ediff-fixup-patch-map
 		      (if (not (file-directory-p target))
 			  (setq directory nil)
 			(beep)
-			(message "%s is a directory" target)
-			(sit-for 2)))
+			(important-message 2 nil "%s is a directory" target)))
 		    (setcar session-file-object target))))))
 	    ediff-patch-map)
     ))
diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index 597d8a5e643..425b1c60e5a 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -1047,9 +1047,9 @@ ediff-toggle-read-only
 		  (t
 		   (setq toggle-ro-cmd 'read-only-mode)
 		   (beep 1) (beep 1)
-		   (message
-		    "Boy, this is risky! Don't modify this file...")
-		   (sit-for 3)))) ; let the user see the warning
+		   (important-message
+                    3 nil ; let the user see the warning
+		    "Boy, this is risky! Don't modify this file..."))))
 	(if (and toggle-ro-cmd
 		 (string-match "read-only-mode" (symbol-name toggle-ro-cmd)))
 	    (save-excursion
@@ -2001,11 +2001,12 @@ ediff-copy-diff
 		    (setq
 		     messg
 		     (ediff-save-diff-region n to-buf-type reg-to-delete))))
-	    (error (message "ediff-copy-diff: %s %s"
-			    (car conds)
-			    (mapconcat #'prin1-to-string (cdr conds) " "))
-		   (beep 1)
-		   (sit-for 2) ; let the user see the error msg
+	    (error (beep 1)
+		   (important-message
+                    2 nil ; let the user see the error msg
+                    "ediff-copy-diff: %s %s"
+		    (car conds)
+		    (mapconcat #'prin1-to-string (cdr conds) " "))
 		   (setq saved-p nil)
 		   )))
       )
@@ -2692,9 +2693,8 @@ ediff-write-merge-buffer-and-maybe-kill
 	      (save-buffer))
 	    (if show-file
 		(progn
-		  (message "Merge buffer saved in: %s" file)
 		  (set-buffer-modified-p nil)
-		  (sit-for 3)))
+		  (important-message 3 nil "Merge buffer saved in: %s" file)))
 	    (if (and
 		 (not save-and-continue)
 		 (y-or-n-p "Merge buffer saved.  Now kill the buffer? "))
@@ -3231,8 +3231,9 @@ ediff-save-buffer
 	     (ediff-get-buffer
 	      (ediff-char-to-buftype last-command-event)))
 	    ((eq last-command-event ?d)
-	     (message "Saving diff output ...")
-	     (sit-for 1) ; let the user see the message
+	     (important-message
+              1 nil ; let the user see the message
+              "Saving diff output ...")
 	     (cond ((and arg (ediff-buffer-live-p ediff-diff-buffer))
 		    ediff-diff-buffer)
 		   ((ediff-buffer-live-p ediff-custom-diff-buffer)
@@ -3442,10 +3443,10 @@ ediff-inferior-compare-regions
 			 nil)
 			((equal answer ""))
 			(t (beep 1)
-			   (message
+			   (important-message
+                            2 nil
 			    "Valid values are %s"
 			    (mapconcat #'char-to-string possibilities " or "))
-			   (sit-for 2)
 			   t))
 	     (let ((cursor-in-echo-area t))
 	       (message "Enter the 1st buffer you want to compare (%s): "
@@ -3461,10 +3462,10 @@ ediff-inferior-compare-regions
 			 nil)
 			((equal answer ""))
 			(t (beep 1)
-			   (message
+			   (important-message
+                            2 nil
 			    "Valid values are %s"
 			    (mapconcat #'char-to-string possibilities " or "))
-			   (sit-for 2)
 			   t))
 	     (let ((cursor-in-echo-area t))
 	       (message "Enter the 2nd buffer you want to compare (%s): "