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: Tue, 24 Dec 2019 17:40:18 +0800 Message-ID: <87mubidptp.fsf@localhost> References: <87sgldfi9j.fsf@mail.linkov.net> <878sn3g0o7.fsf@gmail.com> <87pngepti3.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="70419"; mail-complaints-to="usenet@blaine.gmane.org" Cc: ndame , "emacs-devel@gnu.org" To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 24 10:42:33 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 1ijghz-000IC2-Br for ged-emacs-devel@m.gmane.org; Tue, 24 Dec 2019 10:42:31 +0100 Original-Received: from localhost ([::1]:37592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijghx-00088Q-JR for ged-emacs-devel@m.gmane.org; Tue, 24 Dec 2019 04:42:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56991) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijghr-000884-0k for emacs-devel@gnu.org; Tue, 24 Dec 2019 04:42:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijghp-0007ys-PY for emacs-devel@gnu.org; Tue, 24 Dec 2019 04:42:22 -0500 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:41328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ijghp-0007yF-I4 for emacs-devel@gnu.org; Tue, 24 Dec 2019 04:42:21 -0500 Original-Received: by mail-wr1-x42b.google.com with SMTP id c9so19332979wrw.8 for ; Tue, 24 Dec 2019 01:42:21 -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=5B7F+HWN7Fose6kn3bjQE2sAPg6F2vHSv1orurvxkbI=; b=k94cI7nBBBDaEmRrpObc5ohKO06Il0wcZ/1gNSg2IdeDL/HCNKSC5tIfMmM+amAf9s YIyvvX0msNYDFtQiwohakUiVGJgsmILVI0tS1jD4W/uOmN2xlvIvZI6IsIiID4WvE4CD 7mKs6XjfUDdJLdLuQxbEN2aHz5kG7cgI1uCGq7w1lMdyvr++0I5ByiWe2cX4YYHeGAGj 3GURU/379gbwqG0kAVP38ryJJDNg7SzHXRtavzCu/03/cr+b2R3axVsrZ1sNVljJaY49 L6nd/eqYWhFYmg+/xKn5Cv04b2q7H9AMR6zGuordCOuPKuaTDxztRkXlwZDQbaNjZBo5 rA1Q== 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=5B7F+HWN7Fose6kn3bjQE2sAPg6F2vHSv1orurvxkbI=; b=LaG/j8Vgw+FQQ4ywYX3DSb9wzlbC0fo9oN+wZpPEsrqs4v4q/TRn+TO3L9n+A56KIf iE0QuMi3dK7MITUx07Sod07HKwjtNzjO8PSvMMYcjm/SF3NJ0cZHpGvhVEI/hPDy3tPB l6jLjU0+/LmQuTnJMSXSB/O7JeeMT5//InB8xCNxDaTaT3H7Adx+6ehc8BUq5bu+55bb HvTJn75Km97xOYZFpWpmfQkrpTSmGK2hlooG5z4H1/YyYRf2nesyZCBf2naaRese7t2c d4ZWLpZXtaDGkJpJbSef4pOgWGvxfK+rO/dS127MdqHMg6ogYsyj4wcVkiV47HwHsJqv hbEQ== X-Gm-Message-State: APjAAAX3rJqUMqHbtvg7cu1mfteHpZObIUwSTyBi2CE7Ln62cciJPK1K 84x5GcrPcksmyQaG6+KI1a4= X-Google-Smtp-Source: APXvYqzW0ltceRMM3oILRxczZRRwmzT5Sb6vp78z1DEVowfC7Ci7nMBL+crf1LKrfgl4RIExDDQrxg== X-Received: by 2002:adf:dfc1:: with SMTP id q1mr34070463wrn.155.1577180540446; Tue, 24 Dec 2019 01:42:20 -0800 (PST) Original-Received: from localhost ([5.226.137.4]) by smtp.gmail.com with ESMTPSA id j12sm25521688wrw.54.2019.12.24.01.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 01:42:19 -0800 (PST) In-Reply-To: <87pngepti3.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:243604 Archived-At: 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. Best, Ihor Juri Linkov 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, 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