[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rcirc-color ad61546d52 2/6: * rcirc-color.el (rcirc-col
From: |
Philip Kaludercic |
Subject: |
[elpa] externals/rcirc-color ad61546d52 2/6: * rcirc-color.el (rcirc-color-mode): Add minor mode |
Date: |
Fri, 30 Sep 2022 08:37:46 -0400 (EDT) |
branch: externals/rcirc-color
commit ad61546d5291279fc54eb15b1ee43ea1e5040aad
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
* rcirc-color.el (rcirc-color-mode): Add minor mode
---
rcirc-color.el | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/rcirc-color.el b/rcirc-color.el
index 02bcd3f616..9e0ab14c31 100644
--- a/rcirc-color.el
+++ b/rcirc-color.el
@@ -96,7 +96,6 @@ used to determine the color: #rrrrggggbbbb.")
"Other attributes to use for nicks.
Example: (setq rcirc-color-other-attributes '(:weight bold))")
-(advice-add 'rcirc-facify :around #'rcirc-color--facify)
(defun rcirc-color--facify (orig-fun string face &rest args)
"Add colors to other nicks based on `rcirc-colors'."
(when (and (eq face 'rcirc-other-nick)
@@ -122,8 +121,6 @@ This ignores SENDER and RESPONSE."
(when face
(rcirc-add-face (match-beginning 0) (match-end 0) face))))))
-(add-hook 'rcirc-markup-text-functions #'rcirc-markup-nick-colors)
-
(rcirc-define-command color (nick color)
"Change one of the nick colors."
(rcirc-do-color nick color process target))
@@ -157,7 +154,6 @@ commands."
(random (length rcirc-colors))))
rcirc-color-mapping)))
-(advice-add 'rcirc-handler-NICK :before #'rcirc-color--handler-NICK)
(defun rcirc-color--handler-NICK (_process sender args _text)
"Update colors in `rcirc-color-mapping'."
(let* ((old-nick (rcirc-user-nick sender))
@@ -167,6 +163,26 @@ commands."
(when cell
(puthash new-nick cell rcirc-color-mapping))))
+;;;###autoload
+(define-minor-mode rcirc-color-mode
+ "Enable the highlighting of nicknames."
+ (cond
+ (rcirc-color-mode
+ (advice-add 'rcirc-facify :around #'rcirc-color--facify)
+ (advice-add 'rcirc-handler-NICK :before #'rcirc-color--handler-NICK)
+ (add-hook 'rcirc-markup-text-functions #'rcirc-markup-nick-colors))
+ (t ;disable `rcirc-color-mode'
+ (advice-remove 'rcirc-facify #'rcirc-color--facify)
+ (advice-remove 'rcirc-handler-NICK #'rcirc-color--handler-NICK)
+ (remove-hook 'rcirc-markup-text-functions #'rcirc-markup-nick-colors))))
+
+;; FIXME: Traditionally rcirc-color initialises itself when loaded, so
+;; we preserve this behaviour even after the addition of
+;; `rcirc-color-mode'. Eventually we should move from this kind of
+;; implicit to an explicit initialisation via the minor mode. But for
+;; now we just enable the minor mode to avoid breaking stuff.
+(rcirc-color-mode t)
+
(provide 'rcirc-color)
;;; rcirc-color.el ends here
- [elpa] externals/rcirc-color updated (c50cfdf02e -> e40b6d1ba0), Philip Kaludercic, 2022/09/30
- [elpa] externals/rcirc-color 8bb2d6d630 1/6: rcirc-color: Select a random color on `/color nick', Philip Kaludercic, 2022/09/30
- [elpa] externals/rcirc-color ad61546d52 2/6: * rcirc-color.el (rcirc-color-mode): Add minor mode,
Philip Kaludercic <=
- [elpa] externals/rcirc-color 2c3dd9fd10 3/6: Revert "* rcirc-color.el (color): Use `rcirc-define-command'", Philip Kaludercic, 2022/09/30
- [elpa] externals/rcirc-color e40b6d1ba0 6/6: * rcirc-color.el (rcirc-do-color): Respect color-other-attributes, Philip Kaludercic, 2022/09/30
- [elpa] externals/rcirc-color 6c69994cb8 5/6: * rcirc-color.el (rcirc-do-color): Use a let* to make random choice, Philip Kaludercic, 2022/09/30
- [elpa] externals/rcirc-color a6edf362fa 4/6: Add group information to rcirc-color, Philip Kaludercic, 2022/09/30