[Top][All Lists]

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

Re: Intelligent stacking of messages in the echo area

From: Ihor Radchenko
Subject: Re: Intelligent stacking of messages in the echo area
Date: Tue, 24 Dec 2019 17:40:18 +0800

I was testing the code for a while.
There seem to be one irritating (for me) problem with the way
set-message-function is implemented.
When I run a command changing current buffer and emitting multiple
messages, emacs frame is redrawn every time a new message comes out.
Specifically, I was running org-capture, which changes windows
configuration, switches to different buffer, and emits multiple messages
while running. Normally, it runs very fast (the capture template I used
does not require any user input), but with multi-message, I can see the
frame being redrawn on every new message popping up. Since window
configuration is different, full redraw is forced and the whole
org-capture runs a lot slower.


Juri Linkov <address@hidden> writes:

>> A slightly improved version of the code, which prevents stacking
>> potentially "spammy" messages (like from eldoc or
>> org-display-outline-path). The messages are detected by looking at
>> messages-log-max variable, which is typically set to nil by such
>> functions.
> Good heuristics.  Another heuristics that could be added is
> to filter out transient messages ending with ellipsis -
> added here to a new variable like Eli asked to do:
> (defcustom multi-message-timeout 2
>   "Number of seconds between messages before clearing the accumulated list."
>   :type 'number
>   :group 'minibuffer
>   :version "28.1")
> (defcustom multi-message-max 8
>   "Max size of the list of accumulated messages."
>   :type 'number
>   :group 'minibuffer
>   :version "28.1")
> (defcustom multi-message-transient "\\.\\.\\.\\'"
>   "Regexp to filter out transient messages that should not be stacked."
>   :type 'regexp
>   :group 'minibuffer
>   :version "28.1")
> (defvar multi-message-separator "\n")
> (defvar multi-message-list nil)
> (defun set-multi-message (message)
>   "Return recent messages as one string to display in the echo area.
> Note that this feature works best only when `resize-mini-windows'
> is at its default value `grow-only'."
>   (let ((last-message (car multi-message-list)))
>     (unless (and last-message (equal message (aref last-message 1)))
>       (when last-message
>         (cond
>          ((> (float-time) (+ (aref last-message 0) multi-message-timeout))
>           (setq multi-message-list nil))
>          ((or
>            ;; `message-log-max' was nil, potential clutter.
>            (aref last-message 2)
>            (string-match-p multi-message-transient (aref last-message 1)))
>           (setq multi-message-list (cdr multi-message-list)))))
>       (push (vector (float-time) message (not message-log-max)) 
> multi-message-list)
>       (when (> (length multi-message-list) multi-message-max)
>         (setf (nthcdr multi-message-max multi-message-list) nil)))
>     (mapconcat (lambda (m) (aref m 1))
>                (reverse multi-message-list)
>                multi-message-separator)))
> (setq set-message-function 'set-multi-message)

Ihor Radchenko,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong 
University, Xi'an, China
Email: address@hidden, address@hidden

reply via email to

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