Adjust Oliver's code to Gnus namespace. Add some
authorReiner Steib <Reiner.Steib@gmx.de>
Tue, 26 Dec 2006 14:37:26 +0000 (14:37 +0000)
committerReiner Steib <Reiner.Steib@gmx.de>
Tue, 26 Dec 2006 14:37:26 +0000 (14:37 +0000)
checks to make it compile with XEmacs.
(gnus-message-citation-mode): New minor mode.
(gnus-message-max-citation-depth, gnus-message-citation-keywords)
(gnus-message-highlight-citation): New variables.
(gnus-message-search-citation-line)
(gnus-message-add-citation-keywords)
(gnus-message-remove-citation-keywords)
(turn-on-gnus-message-citation-mode)
(turn-off-gnus-message-citation-mode): New functions.

lisp/ChangeLog
lisp/gnus-cite.el

index 2011153..cb7b944 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-26  Reiner Steib  <Reiner.Steib@gmx.de>
+
+       * gnus-cite.el: Adjust Oliver's code to Gnus namespace.  Add some
+       checks to make it compile with XEmacs.
+       (gnus-message-citation-mode): New minor mode.
+       (gnus-message-max-citation-depth, gnus-message-citation-keywords)
+       (gnus-message-highlight-citation): New variables.
+       (gnus-message-search-citation-line)
+       (gnus-message-add-citation-keywords)
+       (gnus-message-remove-citation-keywords)
+       (turn-on-gnus-message-citation-mode)
+       (turn-off-gnus-message-citation-mode): New functions.
+
 2006-12-26  Oliver Scholz  <epameinondas@gmx.de>
 
        * gnus-cite.el: Enable highlighting of different citation levels in
index 25d7fdc..bc37399 100644 (file)
@@ -1100,23 +1100,20 @@ See also the documentation for `gnus-article-highlight-citation'."
          (setq found t)))
       found)))
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; From: Oliver Scholz <alkibia...@gmx.de>
-;; Subject: Re: Farblich verschiedene Quoteebenen beim antworten
-;; Newsgroups: de.comm.software.gnus
-;; Date: Fri, 30 May 2003 15:46:56 +0200
-;; Message-ID: <uk7c8o8bz.fsf@ID-87814.user.dfncis.de>
-
-(eval-when-compile
-  (require 'gnus-cite)
-  (require 'message))
-
-(defconst egoge-max-citation-depth
-  (eval-when-compile
-    (length gnus-cite-face-list))
+
+;; Highlighting of different citation levels in message-mode.
+;;
+;; Known bugs:
+;;
+;; - XEmacs compatibility: `font-lock-add-keywords' is missing in XEmacs.
+;;
+;; - message-cite-prefix should not be fontified.
+
+(defconst gnus-message-max-citation-depth
+  (length gnus-cite-face-list)
   "Maximum supported level of citation.")
 
-(defun egoge-search-citation-line (limit)
+(defun gnus-message-search-citation-line (limit)
   "Search for a cited line and set match data accordingly.
 Returns nil if there is no such line before LIMIT, t otherwise."
   (when (re-search-forward (eval-when-compile
@@ -1129,7 +1126,7 @@ Returns nil if there is no such line before LIMIT, t otherwise."
                          (split-string
                           (match-string-no-properties 0)
                           "[ \t [:alnum:]]+"))))
-         (mlist (make-list (* (1+ egoge-max-citation-depth)
+         (mlist (make-list (* (1+ gnus-message-max-citation-depth)
                               2)
                            0)))
       (setcar (nthcdr (* cdepth 2) mlist)
@@ -1139,45 +1136,57 @@ Returns nil if there is no such line before LIMIT, t otherwise."
       (set-match-data mlist))
     t))
 
-(defvar egoge-citation-x-keywords
-  (eval-when-compile
-    `((egoge-search-citation-line
-       ,@(let ((list nil)
-              (count 1))
-          (require 'gnus-cite)
-          (dolist (face gnus-cite-face-list (nreverse list))
-            (push (list count (list 'quote face) 'prepend) list)
-            (setq count (1+ count)))))))
+(defvar gnus-message-citation-keywords
+  ;; eval-when-compile ;; This breaks in XEmacs
+  `((gnus-message-search-citation-line
+     ,@(let ((list nil)
+            (count 1))
+        ;; (require 'gnus-cite)
+        (dolist (face gnus-cite-face-list (nreverse list))
+          (push (list count (list 'quote face) 'prepend) list)
+          (setq count (1+ count)))))) ;;
   "Keywords for highlighting different levels of message citations.")
 
-(defun egoge-add-citation-keywords ()
+(defun gnus-message-add-citation-keywords ()
   "Add font-lock for nested citations to current buffer."
-  (font-lock-add-keywords nil egoge-citation-x-keywords))
+  (if (fboundp 'font-lock-add-keywords)
+      (font-lock-add-keywords nil gnus-message-citation-keywords)
+    (gnus-message 1 "`font-lock-add-keywords' not supported.")))
 
-(defun egoge-remove-citation-keywords ()
+(defun gnus-message-remove-citation-keywords ()
   "Remove font-lock for nested citations from current buffer."
-  (font-lock-remove-keywords nil egoge-citation-x-keywords))
+  (if (fboundp 'font-lock-remove-keywords)
+      (font-lock-remove-keywords nil gnus-message-citation-keywords)
+    (gnus-message 1 "`font-lock-remove-keywords' not supported.")))
 
-(define-minor-mode egoge-citation-x-mode
-  "Toggle egoge-citation-x-mode' in current buffer.
+(define-minor-mode gnus-message-citation-mode
+  "Toggle `gnus-message-citation-mode' in current buffer.
 This buffer local minor mode provides additional font-lock support for
 nested citations.
-With prefix ARG, turn `egoge-citation-x-mode' on if and only if ARG is
+With prefix ARG, turn `gnus-message-citation-mode' on if and only if ARG is
 positive."
-  nil "" nil
-  (if egoge-citation-x-mode
-      (egoge-add-citation-keywords)
-    (egoge-remove-citation-keywords))
+  nil ;; init-value
+  ""  ;; lighter
+  nil ;; keymap
+  (if gnus-message-citation-mode
+      (gnus-message-add-citation-keywords)
+    (gnus-message-remove-citation-keywords))
   (font-lock-fontify-buffer))
 
-(defun egoge-turn-on-citation-x ()
-  "Turn on `egoge-citation-x-mode'."
-  (egoge-citation-x-mode 1))
-
-;; (add-hook 'message-mode-hook 'egoge-turn-on-citation-x)
-
-;; End of Message-ID: <uk7c8o8bz.fsf@ID-87814.user.dfncis.de>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun turn-on-gnus-message-citation-mode ()
+  "Turn on `gnus-message-citation-mode'."
+  (gnus-message-citation-mode 1))
+(defun turn-off-gnus-message-citation-mode ()
+  "Turn on `gnus-message-citation-mode'."
+  (gnus-message-citation-mode -1))
+
+;; (add-hook 'gnus-message-setup-hook 'turn-on-gnus-message-citation-mode)
+(defcustom gnus-message-highlight-citation (fboundp 'font-lock-add-keywords)
+  "Enable highlighting of different citation levels in message-mode."
+  :version "23.0" ;; No Gnus
+  :group 'gnus-cite
+  :group 'gnus-message
+  :type 'boolean)
 
 (gnus-ems-redefine)