all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Juri Linkov <juri@linkov.net>, ndame <emacsuser@freemail.hu>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Intelligent stacking of messages in the echo area
Date: Mon, 23 Dec 2019 11:50:48 +0800	[thread overview]
Message-ID: <878sn3g0o7.fsf@gmail.com> (raw)
In-Reply-To: <87sgldfi9j.fsf@mail.linkov.net>

Hi,

FYI:
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.

(defun set-stacked-message (message)
  (let ((last-message (car messages-stack)))
    (unless (and last-message (equal message (aref last-message 1)))
      (when (and last-message (aref last-message 2)) ;; the last message had `message-log-max' equal to nil. Potential clutter.
	(setq messages-stack (cdr messages-stack)))
      (when (and last-message (> (float-time) (+ (aref last-message 0)
						 messages-stack-timeout)))
	(setq messages-stack nil))
      (push (vector (float-time) message (not message-log-max)) messages-stack)
      ;; (push (vector (float-time) message) messages-stack)
      (when (> (length messages-stack) messages-stack-max)
	(setf (nthcdr messages-stack-max messages-stack) nil)))
    (mapconcat (lambda (m) (aref m 1))
               (reverse messages-stack)
               messages-stack-separator)))

Also, it would be great to avoid stacking the echo-keystrokes, but I
have no clue how to detect them.

Best,
Ihor


Juri Linkov <juri@linkov.net> writes:

>> If two or more packages use the echo area for informational messages
>> then often they fight each other, overwriting each other's messages.
>>
>> For example, in lisp mode eldoc is automatically enabled in my emacs
>> 26.2 If I also turn on a paren mode which shows in the message area
>> the matching part of a paren outside of the screen then eldoc often
>> overwrites this message with its own documentation message.
>>
>> Maybe the echo area could be smarter and stack messages on top of each
>> other if they come from diferent sources and they are close to each
>> other in time.
>>
>> So in case of the above example, if a message comes from eldoc and
>> parens at the same time in quick succession then the echo area could
>> show both of them in two lines.
>>
>> And if the same source is sending multiple messsages or there is
>> enough delay between two messages from different sources (e.g. 1-2
>> seconds) then it would work as today using only a single line.
>
> Please try to eval the following code in the current master.
>
> It allows messages produced in quick succession to be stacked
> in the echo area.
>
> So for example when both show-paren-mode and eldoc want to show their
> messages at the same time, the echo area shows both of them in two lines,
> e.g.:
>
>   No matching parenthesis found
>   defun: (NAME ARGLIST &optional DOCSTRING DECL &rest BODY)
>
> Caveat: it works best only when resize-mini-windows is at its default value
> 'grow-only'.
>
>
> (defcustom messages-stack-timeout 2
>   "Number of seconds between messages before clearing the stack."
>   :type 'number
>   :group 'minibuffer
>   :version "27.1")
>
> (defcustom messages-stack-max 8
>   "Max size of the message stack."
>   :type 'number
>   :group 'minibuffer
>   :version "27.1")
>
> (defvar messages-stack-separator "\n")
>
> (defvar messages-stack nil)
>
> (defun set-stacked-message (message)
>   (let ((last-message (car messages-stack)))
>     (unless (and last-message (equal message (aref last-message 1)))
>       (when (and last-message (> (float-time) (+ (aref last-message 0)
>                                                  messages-stack-timeout)))
>         (setq messages-stack nil))
>       (push (vector (float-time) message) messages-stack)
>       (when (> (length messages-stack) messages-stack-max)
>         (setf (nthcdr messages-stack-max messages-stack) nil)))
>     (mapconcat (lambda (m) (aref m 1))
>                (reverse messages-stack)
>                messages-stack-separator)))
>
> (setq set-message-function 'set-stacked-message)

-- 
Ihor Radchenko,
PhD,
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: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg



  parent reply	other threads:[~2019-12-23  3:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-31  5:35 Intelligent stacking of messages in the echo area ndame
2019-08-31  9:46 ` Marcin Borkowski
2019-12-21 22:07 ` Juri Linkov
2019-12-22  3:30   ` Eli Zaretskii
2019-12-23  2:59   ` Richard Stallman
2019-12-23 22:46     ` Juri Linkov
2019-12-23  3:50   ` Ihor Radchenko [this message]
2019-12-23 13:38     ` Eli Zaretskii
2019-12-24  9:24       ` Ihor Radchenko
2019-12-24 15:36         ` Eli Zaretskii
2019-12-25  4:21           ` Ihor Radchenko
2019-12-23 22:47     ` Juri Linkov
2019-12-24  9:40       ` Ihor Radchenko
2019-12-24 15:43         ` Eli Zaretskii
2019-12-24 17:32           ` Ihor Radchenko
2019-12-25  0:15         ` Juri Linkov
2019-12-25  5:35           ` Ihor Radchenko
2020-01-29 22:54             ` Juri Linkov
2020-01-24 10:14       ` Eric S Fraga
2020-01-28 22:34         ` Juri Linkov
2020-01-29 22:41           ` Juri Linkov
2020-01-29 23:53             ` Stefan Monnier
2020-01-30 22:35               ` Juri Linkov
2020-01-30 23:07                 ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2022-04-09  4:46 emacsq
2022-04-09 18:53 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sn3g0o7.fsf@gmail.com \
    --to=yantar92@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacsuser@freemail.hu \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.