emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 5209ffb: rcirc-color: make compatible with latest rcirc


From: Alex Schroeder
Subject: [elpa] master 5209ffb: rcirc-color: make compatible with latest rcirc
Date: Mon, 6 Aug 2018 03:49:21 -0400 (EDT)

branch: master
commit 5209ffb8e03af003e5b26d2816c3f5fc406f41df
Author: Stefan Monnier <address@hidden>
Commit: Alex Schroeder <address@hidden>

    rcirc-color: make compatible with latest rcirc
    
    rcirc-color no longer worked with the latest versions of rcirc which
    uses lexical-scoping because rcirc-color's defadvice relies on dynamic
    scoping to access the advised functions's arguments. Changed that to
    add-advice.
---
 packages/rcirc-color/rcirc-color.el | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/packages/rcirc-color/rcirc-color.el 
b/packages/rcirc-color/rcirc-color.el
index 134b6c5..d00a279 100644
--- a/packages/rcirc-color/rcirc-color.el
+++ b/packages/rcirc-color/rcirc-color.el
@@ -1,10 +1,11 @@
-;;; rcirc-color.el --- color nicks
+;;; rcirc-color.el --- color nicks  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2005-2018  Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: Alex Schroeder <address@hidden>
-;; Version: 0.4
+;; Version: 0.4.1
+;; Package-Requires: ((emacs "24.4"))
 ;; Keywords: comm
 
 ;; This file is part of GNU Emacs.
@@ -90,21 +91,24 @@ used to determine the color: #rrrrggggbbbb.")
   "Other attributes to use for nicks.
 Example: (setq rcirc-color-other-attributes '(:weight bold))")
 
-(defadvice rcirc-facify (before rcirc-facify-colors last activate)
+(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)
-             (not (string= string "")))
-    (let ((cell (gethash string rcirc-color-mapping)))
-      (unless cell
-       (setq cell (nconc (list :foreground
-                               (if rcirc-color-is-deterministic
+             (> (length string) 0))
+    (let ((cell (or (gethash string rcirc-color-mapping)
+                    (puthash (substring-no-properties string)
+                             `(:foreground
+                              ,(if rcirc-color-is-deterministic
                                    (concat "#" (substring (md5 string) 0 12))
-                                 (elt rcirc-colors (random (length 
rcirc-colors)))))
-                          rcirc-color-other-attributes))
-        (puthash (substring-no-properties string) cell rcirc-color-mapping))
-      (setq face (list cell)))))
-
-(defun rcirc-markup-nick-colors (sender response)
+                                 (elt rcirc-colors
+                                       (random (length rcirc-colors))))
+                              ,@rcirc-color-other-attributes)
+                             rcirc-color-mapping))))
+      (setq face (list cell))))
+  (apply orig-fun string face args))
+
+(defun rcirc-markup-nick-colors (_sender _response)
   "Add a face to all known nicks in `rcirc-color-mapping'.
 This ignores SENDER and RESPONSE."
   (with-syntax-table rcirc-nick-syntax-table
@@ -113,7 +117,7 @@ This ignores SENDER and RESPONSE."
        (when face
          (rcirc-add-face (match-beginning 0) (match-end 0) face))))))
 
-(add-to-list 'rcirc-markup-text-functions 'rcirc-markup-nick-colors)
+(add-hook 'rcirc-markup-text-functions #'rcirc-markup-nick-colors)
 
 (defun-rcirc-command color (args)
   "Change one of the nick colors."
@@ -146,7 +150,8 @@ commands."
       (error "Use what color?"))
     (puthash nick (cons 'foreground-color color) rcirc-color-mapping)))
 
-(defadvice rcirc-handler-NICK (before rcirc-handler-NICK-colors activate)
+(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))
          (cell (gethash old-nick rcirc-color-mapping))



reply via email to

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