Executive summary:

As supplied, the appended patch to gnus.el (tested only on XEmacs)
causes articles in the *Summary* window which BBDB recognises as from
a 'known' author to be highlighted.

Details:

The situation is this:  gnus provides a section in the *Summary*
window called the 'Optional Header'.  It is the part surrounded by [].

By default this area is used to tell you the author and size of the
article.  BBDB can be persuaded to improve on this information by
marking the articles of 'known' authors with a "*".

However, I find the "*" rather hard to spot at a glance - there is
already much other line noise in the *Summary* window.  So I have
provided a mechansim to tell gnus to _highlight_ the 'known' authors
that BBDB spots by using a bold face.  The mechansim is actually
completely independent of BBDB, and could be used to highlight any
'special' Optional Header you care to define...

The mechanism is by two variables:

   gnus-special-optional-header-regex

and

  gnus-special-optional-header-face.

gnus-special-optional-header-regex provides a way to tell gnus that a
specific Optional Header is 'special' in some way and should be
highlighted.  The default value of this regex picks up BBDB's 'known
author' mark.

gnus-special-optional-header-face is the face used to highlight the
special Optional Header.  By default, the 'bold' face is used.

(The only thing that worries me about this code is that it creates
 lots of 'extents'.  Do these ever get cleaned up? Do they _need_ to be?)

Hope this pleases someone... any suggestions for improvements welcomed!

Martin.

(using:

 bbdb-version
 "1.51; 21-may-96."
 gnus-version
 "GNUS 4.1.3 XEmacs"
 emacs-version
 "19.13 XEmacs Lucid"
)

----------------------patch to gnus.el--------------------------------

*** /usr/local/lib/xemacs-19.13/lisp/gnus/gnus.el       Sat Mar 25 09:55:52 1995
--- /home/mgregory/share/lisp/gnus.el   Wed May 29 16:46:56 1996
***************
*** 295,300 ****
--- 295,324 ----
  mode buffer.  The function is called with an article HEADER. The
  result must be a string excluding `[' and `]'.")
  
+ ;; 'special optional header highlighting' by 
+ ;;  [EMAIL PROTECTED] (Martin J. Gregory)
+ ;; (intended for BBDB interface, but actually quite general)
+ 
+ (defvar gnus-special-optional-header-face 
+   (get-face (copy-face 'bold 'gnus-special-optional-header-face))
+   "\
+ A face used to display optional headers that are recognised as special
+ (see gnus-special-optional-header-regex).
+ ")
+ 
+ (defvar gnus-special-optional-header-regex "\\\[\\\*"
+   "If an optional header displayed by gnus (see gnus-optional-headers)
+ matches this regular expression then it will be displayed in the
+ 'gnus-special-optional-header-face'.
+ 
+ Note that the opening '[' is included in the regex test.
+ 
+ The default value of this regex matches the mark that BBDB places by articles
+ written by 'known' authors.
+ ")
+ 
+ ;; end MJG additions.
+ 
  (defvar gnus-auto-extend-newsgroup t
    "*Extend visible articles to forward and backward if non-nil.")
  
***************
*** 2442,2447 ****
--- 2466,2473 ----
  
  ;; Basic ideas by Paul Dworkin <[EMAIL PROTECTED]>
  ;; Subject bug fix by [EMAIL PROTECTED] (Joe Wells)
+ ;; 'special optional header highlighting' by 
+ ;;  [EMAIL PROTECTED] (Martin J. Gregory)
  
  (defun gnus-summary-prepare-threads (threads level &optional parent-subject
                                                               ;; XEmacs change
***************
*** 2506,2511 ****
--- 2532,2560 ----
                               (make-string (window-width) ? ))
                             subject)
                     ))
+           ;; try to highlight the optional header area...
+           ;; opt-start and opt-end _include_ the '[' so that you can match
+           ;; on them if you want to.  The '[' and ']' are not highlighted,
+           ;; however, as this looks tacky.
+           (let (opt-start opt-end opt-extent)
+             (and
+              (setq opt-start 
+                    (save-excursion
+                      (if (search-backward "[" 0 t)
+                          (point)
+                        nil )))
+              (setq opt-end
+                    (save-excursion
+                      (if (search-backward "]" 0 t)
+                          (+ (point) 1)
+                        nil )))
+              (if (string-match gnus-special-optional-header-regex
+                                (buffer-substring opt-start opt-end) )
+                  (progn
+                    (setq opt-extent (make-extent (+ 1 opt-start)
+                                                  (- opt-end 1)) )
+                    (set-extent-face opt-extent
+                                     'gnus-special-optional-header-face) ))))
            ))
        ;; Print subthreads.
        (and (consp thread)


Reply via email to