bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#38457: 27.0.50; dabbrev-expand regression due to message change


From: Juri Linkov
Subject: bug#38457: 27.0.50; dabbrev-expand regression due to message change
Date: Tue, 03 Dec 2019 01:00:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> 0. emacs -Q
> 1. M-! te M-/
>
> => It takes about 4 seconds on my machine for the expansion "text" to
> appear, during which the minibuffer displays "[Scanning for
> dabbrevs...100%]" and then "[Scanning for dabbrevs...done]".  On builds
> without this regression, the expansion is virtually instantaneous and no
> message is seen in the minibuffer.

This is because of the current limitation of minibuffer-message.
It uses sit-for to wait for 2 seconds per every message.
This should be fixed by using the timer, so there will be no delays
anymore:

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index a7bdde478f..3febdeb174 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -702,6 +702,9 @@ minibuffer
 (defvar minibuffer-message-properties nil
   "Text properties added to the text shown by `minibuffer-message'.")
 
+(defvar minibuffer-message-timer nil)
+(defvar minibuffer-message-overlay nil)
+
 (defun minibuffer-message (message &rest args)
   "Temporarily display MESSAGE at the end of the minibuffer.
 The text is displayed for `minibuffer-message-timeout' seconds,
@@ -732,24 +735,23 @@ minibuffer-message
                 ;; Don't overwrite the face properties the caller has set
                 (text-properties-at 0 message))
       (setq message (apply #'propertize message 
minibuffer-message-properties)))
-    (let ((ol (make-overlay (point-max) (point-max) nil t t))
-          ;; A quit during sit-for normally only interrupts the sit-for,
-          ;; but since minibuffer-message is used at the end of a command,
-          ;; at a time when the command has virtually finished already, a C-g
-          ;; should really cause an abort-recursive-edit instead (i.e. as if
-          ;; the C-g had been typed at top-level).  Binding inhibit-quit here
-          ;; is an attempt to get that behavior.
-          (inhibit-quit t))
-      (unwind-protect
-          (progn
-            (unless (zerop (length message))
-              ;; The current C cursor code doesn't know to use the overlay's
-              ;; marker's stickiness to figure out whether to place the cursor
-              ;; before or after the string, so let's spoon-feed it the pos.
-              (put-text-property 0 1 'cursor t message))
-            (overlay-put ol 'after-string message)
-            (sit-for (or minibuffer-message-timeout 1000000)))
-        (delete-overlay ol)))))
+
+    (when (timerp minibuffer-message-timer)
+      (cancel-timer minibuffer-message-timer))
+    (when (overlayp minibuffer-message-overlay)
+      (delete-overlay minibuffer-message-overlay))
+    (setq minibuffer-message-overlay
+          (make-overlay (point-max) (point-max) nil t t))
+    (setq minibuffer-message-timer
+          (run-with-timer (or minibuffer-message-timeout 1) nil
+                          (lambda () (when (overlayp 
minibuffer-message-overlay)
+                                       (delete-overlay 
minibuffer-message-overlay)))))
+    (unless (zerop (length message))
+      ;; The current C cursor code doesn't know to use the overlay's
+      ;; marker's stickiness to figure out whether to place the cursor
+      ;; before or after the string, so let's spoon-feed it the pos.
+      (put-text-property 0 1 'cursor t message))
+    (overlay-put minibuffer-message-overlay 'after-string message)))
 
 (defun minibuffer-completion-contents ()
   "Return the user input in a minibuffer before point as a string.

reply via email to

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