From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: Intelligent stacking of messages in the echo area Date: Mon, 23 Dec 2019 11:50:48 +0800 Message-ID: <878sn3g0o7.fsf@gmail.com> References: <87sgldfi9j.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="208811"; mail-complaints-to="usenet@blaine.gmane.org" Cc: "emacs-devel@gnu.org" To: Juri Linkov , ndame Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 23 04:53:27 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ijEmc-000s9I-81 for ged-emacs-devel@m.gmane.org; Mon, 23 Dec 2019 04:53:26 +0100 Original-Received: from localhost ([::1]:52998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijEma-0005nL-Ke for ged-emacs-devel@m.gmane.org; Sun, 22 Dec 2019 22:53:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50406) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijEm7-0005No-EQ for emacs-devel@gnu.org; Sun, 22 Dec 2019 22:52:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijEm5-00047R-RN for emacs-devel@gnu.org; Sun, 22 Dec 2019 22:52:55 -0500 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:35059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ijEm5-00044Z-IC for emacs-devel@gnu.org; Sun, 22 Dec 2019 22:52:53 -0500 Original-Received: by mail-wr1-x42b.google.com with SMTP id g17so15230762wro.2 for ; Sun, 22 Dec 2019 19:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=5XqDJAeuWf2DWaSNt3+Ujx1qX6CW4gbnGZ9Gs96ooMs=; b=hRJkwjsADp867kKbBPWzGgdV5/+A6xSareGQfyO02FQbYAnItppF8epKdQmDEQuCWp OUBeHs0dB+ZrOi20T0Pr3SMRf3TAl79yx1gIn5QhZtmqUkKOmurvFUUcXfA7y1kdeDaL mznn1R2UV97eoHLd7D6sIwlt2Hy/jelmPe+xDTGZvxf6h74n1nLoZAtS+dTiESufwFbt Dvn2W18OYIEG9ou8GPTuEWWzm0Ygrli4kjBCu2Y0p1hl/AH8PtFoVfNOm2okTc3H5lvA PrQNswomhWpX/h7wgypv4lUoUliUhAGO3l2qX0onoSlZSLAZGa9pa8RxwwH/NinF/NTt 7cNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=5XqDJAeuWf2DWaSNt3+Ujx1qX6CW4gbnGZ9Gs96ooMs=; b=L+iEwCN0xpyK7pLuELBQemn6w0P5kQbrNczAVt9SBYyEbYjyrTHMEiywNq4rB3vpIZ DBxGFTLXWYKcn5Ec+U3lDedENmn9sUBuPusrTBnQxDdGiaS/8XoVfqkk4KXZT7v0pO/1 m7HV+YFVQIc0/z3Ni6H0N4kobHHZQWUKa6/HJPL8HE67pIX2fK6Qe7gFHZsaZmBbTuX/ /HlcvY65eWoONNvPvMO+SobkPI9wNvUq1qr1iNCJXBgCO+l71iVgurs3WtwYfPjqQTnD XfGHGJe0Lr5VD4gf2R183NjluYHa28M1JRMOwPz4t6/iK7ow2k2iNUQzknXQtVz/Lzk1 Jl9A== X-Gm-Message-State: APjAAAXKi6VTs46nz0utiBPrTdSfUP1qHe8BhbgSJTbGVmv+NpBYj8o9 rGxqJqigjnZ4liJwQVN489f4a5buFOs= X-Google-Smtp-Source: APXvYqw5Z/1LKMGjy+e30iodfPJgYCGRf6CpUZwd2N2EuPrf1YVNRfrgo3T/5zpMbO0Vols20nqcog== X-Received: by 2002:adf:f80b:: with SMTP id s11mr26120265wrp.12.1577073171600; Sun, 22 Dec 2019 19:52:51 -0800 (PST) Original-Received: from localhost ([5.226.137.4]) by smtp.gmail.com with ESMTPSA id j2sm18517539wmk.23.2019.12.22.19.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2019 19:52:51 -0800 (PST) In-Reply-To: <87sgldfi9j.fsf@mail.linkov.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243577 Archived-At: 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 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