From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Certner Newsgroups: gmane.emacs.bugs Subject: bug#46775: Updated patches Date: Tue, 06 Jul 2021 16:23:14 +0200 Message-ID: <1862194.JH98yGZDhS@ravel> References: <3089116.bT80LyP3VS@ravel> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2331168.HzQftjyudI" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40784"; mail-complaints-to="usenet@ciao.gmane.io" To: 46775@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 06 17:12:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0mjx-000AEu-2k for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Jul 2021 17:12:01 +0200 Original-Received: from localhost ([::1]:33978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0mju-0007mp-Vz for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Jul 2021 11:11:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0mXR-0005CS-Iv for bug-gnu-emacs@gnu.org; Tue, 06 Jul 2021 10:59:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0mXQ-0002FK-1b for bug-gnu-emacs@gnu.org; Tue, 06 Jul 2021 10:59:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0mXQ-0006yz-1I for bug-gnu-emacs@gnu.org; Tue, 06 Jul 2021 10:59:04 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <3089116.bT80LyP3VS@ravel> Resent-From: Olivier Certner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Jul 2021 14:59:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46775-submit@debbugs.gnu.org id=B46775.162558352026754 (code B ref 46775); Tue, 06 Jul 2021 14:59:03 +0000 Original-Received: (at 46775) by debbugs.gnu.org; 6 Jul 2021 14:58:40 +0000 Original-Received: from localhost ([127.0.0.1]:49673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0mX1-0006xJ-Ln for submit@debbugs.gnu.org; Tue, 06 Jul 2021 10:58:40 -0400 Original-Received: from smtp5-g21.free.fr ([212.27.42.5]:28826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0lyo-0003sK-1h for 46775@debbugs.gnu.org; Tue, 06 Jul 2021 10:23:19 -0400 Original-Received: from ravel.localnet (unknown [2.15.208.149]) (Authenticated sender: ocert.dev@free.fr) by smtp5-g21.free.fr (Postfix) with ESMTPSA id 787D5602C1 for <46775@debbugs.gnu.org>; Tue, 6 Jul 2021 16:23:15 +0200 (CEST) X-Mailman-Approved-At: Tue, 06 Jul 2021 10:58:37 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209525 Archived-At: This is a multi-part message in MIME format. --nextPart2331168.HzQftjyudI Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Patches slightly edited (commit message, doc text) and rebased on top of a recent 'master'. Ready to apply. Easy to backport to 27 as well. -- Olivier Certner --nextPart2331168.HzQftjyudI Content-Disposition: attachment; filename="0001-ERC-Track-Fix-modified-channels-alist-s-documentatio.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-ERC-Track-Fix-modified-channels-alist-s-documentatio.patch" >From ef79b97fedc46c5317dbb7104163f54335efa30f Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Wed, 13 Jan 2021 17:39:54 +0100 Subject: [PATCH 1/4] ERC: Track: Fix modified channels alist's documentation about its structure * lisp/erc/erc-track.el (erc-modified-channels-alist): Fix the docstring, which reports a proper list structure whereas it is a dotted list, where the last cdr is sometimes a proper list, making it sometimes a proper list. --- lisp/erc/erc-track.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 2364d45d6f..bfaa3e5e72 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -262,14 +262,17 @@ erc-modified-channels-object (defvar erc-modified-channels-alist nil "An ALIST used for tracking channel modification activity. -Each element looks like (BUFFER COUNT FACE) where BUFFER is a buffer -object of the channel the entry corresponds to, COUNT is a number -indicating how often activity was noticed, and FACE is the face to use -when displaying the buffer's name. See `erc-track-faces-priority-list', -and `erc-track-showcount'. +Each element is a list with form (BUFFER COUNT . FACE) where +BUFFER is a buffer object of the channel the entry corresponds +to, COUNT is a number indicating how often activity was noticed, +and FACE is a face (or a list of faces) to use when displaying the +buffer's name. Entries in this list should only happen for buffers where activity occurred -while the buffer was not visible.") +while the buffer was not visible. + +See also `erc-track-faces-priority-list', +`erc-track-faces-normal-list' and `erc-track-showcount'.") (defcustom erc-track-showcount nil "If non-nil, count of unseen messages will be shown for each channel." -- 2.30.0 --nextPart2331168.HzQftjyudI Content-Disposition: attachment; filename="0002-ERC-Track-Clarify-documentation-on-tracked-buffers-a.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0002-ERC-Track-Clarify-documentation-on-tracked-buffers-a.patch" >From d51960947135ddbf479653c7e10845daa6f81162 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 14 Jan 2021 18:20:26 +0100 Subject: [PATCH 2/4] ERC: Track: Clarify documentation on tracked buffers and add references * lisp/erc/erc-track.el (erc-modified-channels-alist): Clarify what the list contains. Add references to variables and functions involved in displaying tracked buffers from this list. * lisp/erc/erc-track.el (erc-make-mode-line-buffer-name): Describe exactly the algorithm, and reference custom variables that influence it. --- lisp/erc/erc-track.el | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index bfaa3e5e72..3e4e557d78 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -265,14 +265,19 @@ erc-modified-channels-alist Each element is a list with form (BUFFER COUNT . FACE) where BUFFER is a buffer object of the channel the entry corresponds to, COUNT is a number indicating how often activity was noticed, -and FACE is a face (or a list of faces) to use when displaying the -buffer's name. +and FACE is a face (or a list of faces, combined as usual) to use +when displaying the buffer's name in the mode line. -Entries in this list should only happen for buffers where activity occurred -while the buffer was not visible. +Entries in this list are only added/updated for buffers that were +not visible when activity occurred in them, and are removed for +each buffer as soon as it becomes visible again (or if the server +is disconnected, provided `erc-track-remove-disconnected-buffers' +is true). -See also `erc-track-faces-priority-list', -`erc-track-faces-normal-list' and `erc-track-showcount'.") +For how the face is chosen for a buffer, see +`erc-track-find-face' and `erc-track-priority-faces-only'. For +how buffers are then displayed in the mode line, see +`erc-modified-channels-display'.") (defcustom erc-track-showcount nil "If non-nil, count of unseen messages will be shown for each channel." @@ -625,8 +630,14 @@ erc-track-mouse-face "The face to use when mouse is over channel names in the mode line.") (defun erc-make-mode-line-buffer-name (string buffer &optional faces count) - "Return STRING as a button that switches to BUFFER when clicked. -If FACES are provided, color STRING with them." + "Returns a button that switches to BUFFER when clicked. +STRING is the string in the button. It is possibly suffixed with +the number of unread messages, according to variables +`erc-track-showcount' and `erc-track-showcount-string'. + +If `erc-track-use-faces' is true and FACES are provided, format +STRING with them. When the mouse hovers above the button, STRING +is displayed according to `erc-track-mouse-face'." ;; We define a new sparse keymap every time, because 1. this data ;; structure is very small, the alternative would require us to ;; defvar a keymap, 2. the user is not interested in customizing it -- 2.30.0 --nextPart2331168.HzQftjyudI Content-Disposition: attachment; filename="0003-ERC-Track-Rewrite-and-rename-erc-track-find-face.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0003-ERC-Track-Rewrite-and-rename-erc-track-find-face.patch" >From 10a98ca9505960b3bc21b6f965cb3184111f5e25 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 14 Jan 2021 18:26:38 +0100 Subject: [PATCH 3/4] ERC: Track: Rewrite and rename `erc-track-find-face' For clarification purposes. No functional changes. * lisp/erc/erc-track.el (erc-track-find-face): Rename it to `erc-track-select-face'. Rewrite it so that it is very clear what is the current algorithm, changing the parameters it takes. No functional changes. Performance improvements. Clarify the documentation and remove the part on some faces being lists, which clearly doesn't apply. * lisp/erc/erc-track.el (erc-track-modified-channels): Replace calls to `erc-track-find-face' by calls to `erc-track-select-face', preserving the existing behavior. * lisp/erc/erc-track.el (erc-modified-channels-alist): Change the reference to `erc-track-select-face' in the documentation following the rename. --- lisp/erc/erc-track.el | 81 ++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 3e4e557d78..d63028cfeb 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -275,7 +275,7 @@ erc-modified-channels-alist is true). For how the face is chosen for a buffer, see -`erc-track-find-face' and `erc-track-priority-faces-only'. For +`erc-track-select-face' and `erc-track-priority-faces-only'. For how buffers are then displayed in the mode line, see `erc-modified-channels-display'.") @@ -733,38 +733,45 @@ erc-modified-channels-remove-buffer (when (called-interactively-p 'interactive) (erc-modified-channels-display))) -(defun erc-track-find-face (faces) - "Return the face to use in the mode line from the faces in FACES. -If `erc-track-faces-priority-list' is set, the one from FACES who -is first in that list will be used. If nothing matches or if -`erc-track-faces-priority-list' is not set, the default mode-line -faces will be used. +(defun erc-track-select-face (cur-face new-faces) + "Return the face to use in the mode line. -If `erc-track-faces-normal-list' is non-nil, use it to produce a -blinking effect that indicates channel activity when the first -element in FACES and the highest-ranking face among the rest of -FACES are both members of `erc-track-faces-normal-list'. +CUR-FACE is the face currently used in the mode line (for the +current buffer). NEW-FACES is the list of new faces that have +just been seen (in the current buffer). -If one of the faces is a list, then it will be ranked according -to its highest-tanking face member. A list of faces including -that member will take priority over just the single member -element." +Initially, the selected face is the one with highest priority in +`erc-track-faces-priority-list' (i.e., the one closest to the +head of the list) among CUR-FACE and NEW-FACES. If nothing +matches (including if `erc-track-faces-priority-list' is not +set), the default mode-line faces will be used (NIL is returned). + +If the selected face is still CUR-FACE (highest priority), and +the highest priority face in NEW-FACES alone is different (which +necessarily means it has lower priority than CUR-FACE), and both +are in `erc-track-faces-normal-list', then the latter is selected +instead. This has the effect of allowing the current mode line +face, if a member of `erc-track-faces-normal-list', to be +replaced by another with lower priority from the new faces, if +that with highest priority in the new ones is also a member of +`erc-track-faces-normal-list'." (let ((choice (catch 'face - (dolist (candidate erc-track-faces-priority-list) - (when (member candidate faces) - (throw 'face candidate))))) - (no-first (and erc-track-faces-normal-list - (catch 'face - (dolist (candidate erc-track-faces-priority-list) - (when (member candidate (cdr faces)) - (throw 'face candidate))))))) - (cond ((null choice) - nil) - ((and (member choice erc-track-faces-normal-list) - (member no-first erc-track-faces-normal-list)) - no-first) - (t - choice)))) + (dolist (candidate erc-track-faces-priority-list) + (when (or (equal candidate cur-face) + (member candidate new-faces)) + (throw 'face candidate)))))) + (when choice + (if (and (equal choice cur-face) + (member choice erc-track-faces-normal-list)) + (let ((only-in-new + (catch 'face + (dolist (candidate erc-track-faces-priority-list) + (when (member candidate new-faces) + (throw 'face candidate)))))) + (if (member only-in-new erc-track-faces-normal-list) + only-in-new + choice)) + choice)))) (defun erc-track-modified-channels () "Hook function for `erc-insert-post-hook' to check if the current @@ -804,17 +811,21 @@ erc-track-modified-channels ;; Add buffer, faces and counts (setq erc-modified-channels-alist (cons (cons (current-buffer) - (cons 1 (erc-track-find-face faces))) + (cons 1 (erc-track-select-mode-line-face + (car faces) + (cdr faces)))) erc-modified-channels-alist)) ;; Else modify the face for the buffer, if necessary. (when faces (let* ((cell (assq (current-buffer) erc-modified-channels-alist)) (old-face (cddr cell)) - (new-face (erc-track-find-face - (if old-face - (cons old-face faces) - faces)))) + (new-face (if old-face + (erc-track-select-mode-line-face old-face + faces) + (erc-track-select-mode-line-face + (car faces) + (cdr faces))))) (setcdr cell (cons (1+ (cadr cell)) new-face))))) ;; And display it (erc-modified-channels-display))) -- 2.30.0 --nextPart2331168.HzQftjyudI Content-Disposition: attachment; filename="0004-ERC-Track-Fix-a-perceived-minor-bug-in-mode-line-fac.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0004-ERC-Track-Fix-a-perceived-minor-bug-in-mode-line-fac.patch" >From 1d4abfa935b1a5f5eb0c6ff7b3c82ebb46747653 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 14 Jan 2021 18:36:08 +0100 Subject: [PATCH 4/4] ERC: Track: Fix a perceived minor bug in mode line face selection * lisp/erc/erc-track.el (erc-track-modified-channels): Fix what is a probable bug when a new insert event happens for a buffer that was not tracked or for which no mode line face was selected: In this case, stop treating the latest buffer's face (first in list) as the previous one, which could be overriden with an older one (in FACES' rest), as if it had happened after. --- lisp/erc/erc-track.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index d63028cfeb..e9bc77dea0 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -811,21 +811,14 @@ erc-track-modified-channels ;; Add buffer, faces and counts (setq erc-modified-channels-alist (cons (cons (current-buffer) - (cons 1 (erc-track-select-mode-line-face - (car faces) - (cdr faces)))) + (cons 1 (erc-track-select-face nil faces))) erc-modified-channels-alist)) ;; Else modify the face for the buffer, if necessary. (when faces (let* ((cell (assq (current-buffer) erc-modified-channels-alist)) (old-face (cddr cell)) - (new-face (if old-face - (erc-track-select-mode-line-face old-face - faces) - (erc-track-select-mode-line-face - (car faces) - (cdr faces))))) + (new-face (erc-track-select-face old-face faces))) (setcdr cell (cons (1+ (cadr cell)) new-face))))) ;; And display it (erc-modified-channels-display))) -- 2.30.0 --nextPart2331168.HzQftjyudI--