erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][master] erc-track: Don't let buttons in notices tr


From: mwolson
Subject: [Erc-commit] [commit][master] erc-track: Don't let buttons in notices trump normal text.
Date: Wed, 16 Jan 2008 22:30:07 -0500

commit e6638bbf2e2e0314c2b0c1d73bd50be5da5b1f40
Author: Michael W. Olson <address@hidden>
Date:   Wed Jan 16 22:26:34 2008 -0500

    erc-track: Don't let buttons in notices trump normal text.

diff --git a/ChangeLog b/ChangeLog
index 485f993..b2e6598 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,13 @@
 2008-01-17  Michael Olson  <address@hidden>
 
+       * erc-networks.el (erc-server-alist): Add Rizon network.
+
        * erc-services.el (erc-nickserv-passwords): Add Rizon to options.
        (erc-nickserv-alist): Add support for Rizon.
 
-       * erc-networks.el (erc-server-alist): Add Rizon network.
+       * erc-track.el (erc-track-find-face): Don't let buttons in notices
+       trump default text.  Use catch/throw.  Default to first element of
+       FACES is nothing is found.
 
        * erc-xdcc.el: Add local variables for proper indentation setup.
 
diff --git a/erc-track.el b/erc-track.el
index 76a6922..4512be2 100644
--- a/erc-track.el
+++ b/erc-track.el
@@ -821,15 +821,26 @@ Use `erc-make-mode-line-buffer-name' to create buttons."
 (defun erc-track-find-face (faces)
   "Return the face to use in the modeline 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."
+first in that list will be used.
+
+If `erc-track-faces-priority-list' is not set, the first element
+in FACES will be used.
+
+One exception is made for the `erc-button' face.  It is only
+allowed to take priority over other faces if it is paired with
+`erc-default-face' in the cdr of FACES."
   (let ((candidates erc-track-faces-priority-list)
-       candidate face)
-    (while (and candidates (not face))
-      (setq candidate (car candidates)
-           candidates (cdr candidates))
-      (when (memq candidate faces)
-       (setq face candidate)))
-    face))
+       candidate)
+    ;; Remove erc-button unless it is paired with erc-default-face
+    (when (and (memq 'erc-button (cdr faces))
+              (not (memq 'erc-default-face (cdr faces))))
+      (setq faces (cons (car faces) (remq 'erc-button (cdr faces)))))
+    ;; Take the highest priority face remaining
+    (or (catch 'face
+         (dolist (candidate erc-track-faces-priority-list)
+           (when (memq candidate faces)
+             (throw 'face candidate))))
+       (car faces))))
 
 (defun erc-track-modified-channels ()
   "Hook function for `erc-insert-post-hook' to check if the current




reply via email to

[Prev in Thread] Current Thread [Next in Thread]