emacs-devel
[Top][All Lists]
Advanced

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

rcirc face updates and bug fixes


From: Ryan Yeske
Subject: rcirc face updates and bug fixes
Date: Thu, 17 Nov 2005 00:13:37 -0800

    > Date: Mon, 14 Nov 2005 01:21:08 -0800
    > From: Ryan Yeske <address@hidden>
    > CC: address@hidden, address@hidden

    > So Eli, I suppose the thing to decide is whether or not to
    > install my patch that make the rcirc faces inherit the font-lock
    > ones or not.

    I'd prefer to leave rcirc faces independent at this point.

Here is a new patch.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.8605
diff -u -r1.8605 ChangeLog
--- ChangeLog   17 Nov 2005 05:32:33 -0000      1.8605
+++ ChangeLog   17 Nov 2005 08:09:42 -0000
@@ -1,3 +1,19 @@
+2005-11-16  Ryan Yeske  <address@hidden>
+
+       * net/rcirc.el (rcirc-mangle-text): Add bold face property without
+       replacing existing properties.
+       (rcirc-my-nick, rcirc-other-nick, rcirc-server)
+       (rcirc-nick-in-message, rcirc-prompt): Use min-colors and remove
+       tty specs.
+       (rcirc-server-prefix): New face.
+       (rcirc-server): New face.
+       (rcirc-url-regexp): Generate with rx macro.
+       (rcirc-last-server-message-time): Add variable.
+       (rcirc-filter): Record time of last message.
+       (rcirc-keepalive): Kill processes that did not send a message
+       since the last ping.
+       (rcirc-mode): Give rcirc-topic a local binding here.
+
 2005-11-16  Luc Teirlinck  <address@hidden>
 
        * rfn-eshadow.el (file-name-shadow-properties)
Index: net/rcirc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/rcirc.el,v
retrieving revision 1.6
diff -u -r1.6 rcirc.el
--- net/rcirc.el        4 Nov 2005 15:05:11 -0000       1.6
+++ net/rcirc.el        17 Nov 2005 08:09:43 -0000
@@ -257,7 +257,7 @@
 (defvar rcirc-process-output nil)
 (defvar rcirc-topic nil)
 (defvar rcirc-keepalive-timer nil)
-(make-variable-buffer-local 'rcirc-topic)
+(defvar rcirc-last-server-message-time nil)
 (defun rcirc-connect (server port nick user-name full-name startup-channels)
   "Return a connection to SERVER on PORT.
 
@@ -290,6 +290,8 @@
       (setq rcirc-process-output nil)
       (make-local-variable 'rcirc-startup-channels)
       (setq rcirc-startup-channels startup-channels)
+      (make-local-variable 'rcirc-last-server-message-time)
+      (setq rcirc-last-server-message-time (current-time))
 
       ;; identify
       (rcirc-send-string process (concat "NICK " nick))
@@ -313,11 +315,16 @@
      ,@body))
 
 (defun rcirc-keepalive ()
-  "Send keep alive pings to active rcirc processes."
+  "Send keep alive pings to active rcirc processes.
+Kill processes that have not received a server message since the
+last ping."
   (if (rcirc-process-list)
       (mapc (lambda (process)
               (with-rcirc-process-buffer process
-                (rcirc-send-string process (concat "PING " rcirc-server))))
+               (if (> (cadr (time-since rcirc-last-server-message-time))
+                      rcirc-keepalive-seconds)
+                   (kill-process process)
+                 (rcirc-send-string process (concat "PING " rcirc-server)))))
             (rcirc-process-list))
     (cancel-timer rcirc-keepalive-timer)
     (setq rcirc-keepalive-timer nil)))
@@ -380,6 +387,7 @@
   "Called when PROCESS receives OUTPUT."
   (rcirc-debug process output)
   (with-rcirc-process-buffer process
+    (setq rcirc-last-server-message-time (current-time))
     (setq rcirc-process-output (concat rcirc-process-output output))
     (when (= (aref rcirc-process-output
                    (1- (length rcirc-process-output))) ?\n)
@@ -582,6 +590,8 @@
   (setq rcirc-process process)
   (make-local-variable 'rcirc-target)
   (setq rcirc-target target)
+  (make-local-variable 'rcirc-topic)
+  (setq rcirc-topic nil)
 
   (make-local-variable 'rcirc-short-buffer-name)
   (setq rcirc-short-buffer-name nil)
@@ -850,8 +860,8 @@
       (process-buffer process))))
 
 (defun rcirc-format-response-string (process sender response target text)
-  (concat (when rcirc-time-format
-            (format-time-string rcirc-time-format (current-time)))
+  (concat (rcirc-facify (format-time-string rcirc-time-format (current-time))
+                       'rcirc-timestamp)
           (cond ((or (string= response "PRIVMSG")
                      (string= response "NOTICE")
                      (string= response "ACTION"))
@@ -880,14 +890,15 @@
                 (t
                  (rcirc-mangle-text
                   process
-                  (rcirc-facify
-                   (concat "*** "
-                          (when (not (string= sender (rcirc-server process)))
-                            (concat (rcirc-user-nick sender) " "))
-                          (when (zerop (string-to-number response))
-                            (concat response " "))
-                           text)
-                   'rcirc-server))))))
+                 (concat (rcirc-facify "*** " 'rcirc-server-prefix)
+                         (rcirc-facify
+                          (concat
+                           (when (not (string= sender (rcirc-server process)))
+                             (concat (rcirc-user-nick sender) " "))
+                           (when (zerop (string-to-number response))
+                             (concat response " "))
+                           text)
+                          'rcirc-server)))))))
 
 (defvar rcirc-activity-type nil)
 (make-variable-buffer-local 'rcirc-activity-type)
@@ -1446,11 +1457,16 @@
   "Return a copy of STRING with FACE property added."
   (propertize (or string "") 'face face 'rear-nonsticky t))
 
-;; shy grouping must be used within this regexp
 (defvar rcirc-url-regexp
-  "\\b\\(?:\\(?:www\\.\\|\\(?:s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\
-\\|wais\\|mailto\\):\\)\\(?://[-a-zA-Z0-9_.]+:[0-9]*\\)?\\(?:[-a-zA-Z0-9_=!?#$\
address@hidden&*+|\\/:;.,]\\|\\w\\)+\\(?:address@hidden&*+|\\/]\\|\\w\\)\\)"
+  (rx word-boundary 
+      (or "www."
+         (and (or "http" "https" "ftp" "file" "gopher" "news" "telnet" "wais" 
+                  "mailto")
+              "://"
+              (1+ (char "a-zA-Z0-9_."))
+              (optional ":" (1+ (char "0-9")))))
+      (1+ (char "address@hidden&*+|\\/:;.,"))
+      (char "address@hidden&*+|\\/:;"))
   "Regexp matching URL's.  Set to nil to disable URL features in rcirc.")
 
 (defun rcirc-browse-url (&optional arg)
@@ -1498,14 +1514,21 @@
   "Return TEXT with properties added based on various patterns."
   ;; ^B
   (setq text
-        (rcirc-map-regexp (lambda (start end string)
-                            (add-text-properties
-                             start end
-                             (list 'face 'bold 'rear-nonsticky t)
-                             string))
-                          ".*?"
-                          text))
-  (while (string-match "\\(.*\\)[]\\(.*\\)" text) ; deal with 
+        (rcirc-map-regexp 
+        (lambda (start end string)
+          (let ((orig-face (get-text-property start 'face string)))
+              (add-text-properties
+               start end
+               (list 'face (if (listp orig-face)
+                               (append orig-face 
+                                       (list 'bold))
+                             (list orig-face 'bold))
+                     'rear-nonsticky t)
+               string)))
+          ".*?"
+          text))
+  ;; TODO: deal with ^_ and ^C colors sequences
+  (while (string-match "\\(.*\\)[]\\(.*\\)" text) 
     (setq text (concat (match-string 1 text)
                        (match-string 2 text))))
   ;; my nick
@@ -1527,7 +1550,10 @@
         (lambda (start end string)
           (let ((orig-face (get-text-property start 'face string)))
             (add-text-properties start end
-                                 (list 'face (list orig-face 'bold)
+                                 (list 'face (if (listp orig-face)
+                                                 (append orig-face 
+                                                         (list 'bold))
+                                               (list orig-face 'bold))
                                        'rear-nonsticky t
                                        'mouse-face 'highlight
                                        'keymap rcirc-browse-url-map)
@@ -1836,51 +1862,82 @@
   :group 'rcirc
   :group 'faces)
 
-(defface rcirc-my-nick
-  '((((type tty) (class color)) (:foreground "blue" :weight bold))
-    (((class color) (background light)) (:foreground "Blue"))
-    (((class color) (background dark)) (:foreground "LightSkyBlue"))
-    (t (:inverse-video t :bold t)))
+(defface rcirc-my-nick                 ; font-lock-function-name-face
+  '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+    (((class color) (min-colors 88) (background dark)) (:foreground 
"LightSkyBlue"))
+    (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
+    (((class color) (min-colors 16) (background dark)) (:foreground 
"LightSkyBlue"))
+    (((class color) (min-colors 8)) (:foreground "blue" :weight bold))
+    (t (:inverse-video t :weight bold)))
   "The face used to highlight my messages."
   :group 'rcirc-faces)
 
-(defface rcirc-other-nick
-  '((((type tty) (class color)) (:foreground "yellow" :weight light))
-    (((class grayscale) (background light))
-     (:foreground "Gray90" :bold t :italic t))
+(defface rcirc-other-nick           ; font-lock-variable-name-face
+  '((((class grayscale) (background light))
+     (:foreground "Gray90" :weight bold :slant italic))
     (((class grayscale) (background dark))
-     (:foreground "DimGray" :bold t :italic t))
-    (((class color) (background light)) (:foreground "DarkGoldenrod"))
-    (((class color) (background dark)) (:foreground "LightGoldenrod"))
-    (t (:bold t :italic t)))
+     (:foreground "DimGray" :weight bold :slant italic))
+    (((class color) (min-colors 88) (background light)) (:foreground 
"DarkGoldenrod"))
+    (((class color) (min-colors 88) (background dark)) (:foreground 
"LightGoldenrod"))
+    (((class color) (min-colors 16) (background light)) (:foreground 
"DarkGoldenrod"))
+    (((class color) (min-colors 16) (background dark)) (:foreground 
"LightGoldenrod"))
+    (((class color) (min-colors 8)) (:foreground "yellow" :weight light))
+    (t (:weight bold :slant italic)))
   "The face used to highlight other messages."
   :group 'rcirc-faces)
 
-(defface rcirc-server
-  '((((type tty pc) (class color) (background light)) (:foreground "red"))
-    (((type tty pc) (class color) (background dark)) (:foreground "red1"))
-    (((class grayscale) (background light))
-     (:foreground "DimGray" :bold t :italic t))
+(defface rcirc-server                  ; font-lock-comment-face
+  '((((class grayscale) (background light))
+     (:foreground "DimGray" :weight bold :slant italic))
     (((class grayscale) (background dark))
-     (:foreground "LightGray" :bold t :italic t))
-    (((class color) (background light)) (:foreground "gray40"))
-    (((class color) (background dark)) (:foreground "chocolate1"))
-    (t (:bold t :italic t)))
+     (:foreground "LightGray" :weight bold :slant italic))
+    (((class color) (min-colors 88) (background light))
+     (:foreground "Firebrick"))
+    (((class color) (min-colors 88) (background dark))
+     (:foreground "chocolate1"))
+    (((class color) (min-colors 16) (background light))
+     (:foreground "red"))
+    (((class color) (min-colors 16) (background dark))
+     (:foreground "red1"))
+    (((class color) (min-colors 8) (background light))
+     )
+    (((class color) (min-colors 8) (background dark))
+     )
+    (t (:weight bold :slant italic)))
   "The face used to highlight server messages."
   :group 'rcirc-faces)
 
-(defface rcirc-nick-in-message
-  '((((type tty) (class color)) (:foreground "cyan" :weight bold))
-    (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
-    (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
-    (((class color) (background light)) (:foreground "Purple"))
-    (((class color) (background dark)) (:foreground "Cyan"))
-    (t (:bold t)))
+(defface rcirc-server-prefix    ; font-lock-comment-delimiter-face
+  '((default :inherit font-lock-comment-face)
+    (((class grayscale)))
+    (((class color) (min-colors 16)))
+    (((class color) (min-colors 8) (background light))
+     :foreground "red")
+    (((class color) (min-colors 8) (background dark))
+     :foreground "red1"))
+  "The face used to highlight server prefixes."
+  :group 'rcirc-faces)
+
+(defface rcirc-timestamp
+  '((t (:inherit default)))
+  "The face used to highlight timestamps."
+  :group 'rcirc-faces)
+
+(defface rcirc-nick-in-message         ; font-lock-keyword-face
+  '((((class grayscale) (background light)) (:foreground "LightGray" :weight 
bold))
+    (((class grayscale) (background dark)) (:foreground "DimGray" :weight 
bold))
+    (((class color) (min-colors 88) (background light)) (:foreground "Purple"))
+    (((class color) (min-colors 88) (background dark)) (:foreground "Cyan1"))
+    (((class color) (min-colors 16) (background light)) (:foreground "Purple"))
+    (((class color) (min-colors 16) (background dark)) (:foreground "Cyan"))
+    (((class color) (min-colors 8)) (:foreground "cyan" :weight bold))
+    (t (:weight bold)))
   "The face used to highlight instances of nick within messages."
   :group 'rcirc-faces)
 
-(defface rcirc-prompt
-  '((((background dark)) (:foreground "cyan"))
+(defface rcirc-prompt                  ; comint-highlight-prompt
+  '((((min-colors 88) (background dark)) (:foreground "cyan1"))
+    (((background dark)) (:foreground "cyan"))
     (t (:foreground "dark blue")))
   "The face to use to highlight prompts."
   :group 'rcirc-faces)




reply via email to

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