Subject: bug#44100: Patch

From: Amin Bandali <[email-masked]>
Date: Sat, 31 Oct 2020 22:16:54 -0400

Hello again,

I did some more investigation, and was able to reproduce the issue.

However, I came up with a potentially more proper different fix: I think
the presence of the dotted pair with a non-nil cdr is the main problem,
since it means `erc-modified-channels-alist' does not fully adhere to
the documented structure in its docstring.  So I addressed the issue in
`erc-track-modified-channels' by wrapping up single faces in lists too,
ensuring that `erc-modified-channels-alist' never ends in a non-nil cdr.

Something along the lines of the following patch.  Thoughts?

From 9cccb6b00fea837c9d28305db30b21353134b990 Mon Sep 17 00:00:00 2001
From: Amin Bandali <[email-masked]>
Date: Sat, 31 Oct 2020 21:41:38 -0400
Subject: [PATCH] Maintain the documented structure for
 'erc-modified-channels-alist'

* lisp/erc/erc-track.el (erc-track-modified-channels): Wrap the single
face in a list to avoid a non-nil final cdr in
`erc-modified-channels-alist', making its value adhere more closely to
its stated structure in its docstring.  Also unbreaks erc-ibuffer.
* lisp/erc/erc-status-sidebar.el (erc-status-sidebar-default-chan-format):
Account for the change in structure of `erc-modified-channels-alist'
due to this fix.
---
 lisp/erc/erc-status-sidebar.el |  2 +-
 lisp/erc/erc-track.el          | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/erc/erc-status-sidebar.el b/lisp/erc/erc-status-sidebar.el
index 08dc8d6015..4fc9b4fc30 100644
--- a/lisp/erc/erc-status-sidebar.el
+++ b/lisp/erc/erc-status-sidebar.el
@@ -191,7 +191,7 @@ erc-status-sidebar-default-chan-format
     (setq channame (format "%s [%d]" channame num-messages)))
   (when erc-face
     (put-text-property 0 (length channame) 'face erc-face channame)
-    (when (eq erc-face 'erc-default-face)
+    (when (eq (car erc-face) 'erc-default-face)
       (add-face-text-property 0 (length channame) 'bold t channame)))
   channame)
 
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index 60f0cfa942..3618df6568 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -815,10 +815,13 @@ erc-track-modified-channels
 			      (throw 'found t))))))
 	    (if (not (assq (current-buffer) erc-modified-channels-alist))
 		;; Add buffer, faces and counts
-		(setq erc-modified-channels-alist
-		      (cons (cons (current-buffer)
-				  (cons 1 (erc-track-find-face faces)))
-			    erc-modified-channels-alist))
+                (let ((new-face (erc-track-find-face faces)))
+                  (setq erc-modified-channels-alist
+                        (cons (cons (current-buffer)
+                                    (cons 1 (if (listp new-face)
+                                                new-face
+                                              (list new-face))))
+                              erc-modified-channels-alist)))
 	      ;; Else modify the face for the buffer, if necessary.
 	      (when faces
 		(let* ((cell (assq (current-buffer)
@@ -828,7 +831,10 @@ erc-track-modified-channels
 				  (if old-face
 				      (cons old-face faces)
 				    faces))))
-		  (setcdr cell (cons (1+ (cadr cell)) new-face)))))
+		  (setcdr cell (cons (1+ (cadr cell))
+                                     (if (listp new-face)
+                                         new-face
+                                       (list new-face)))))))
 	    ;; And display it
 	    (erc-modified-channels-display)))
       ;; Else if the active buffer is the current buffer, remove it
@@ -863,7 +869,7 @@ erc-track-last-non-erc-buffer
 `erc-track-switch-buffer'.")
 
 (defun erc-track-sort-by-activest ()
-  "Sort erc-modified-channels-alist by activity.
+  "Sort `erc-modified-channels-alist' by activity.
 That means the number of unseen messages in a channel."
   (setq erc-modified-channels-alist
 	(sort erc-modified-channels-alist
-- 
2.17.1