X-Face snarfing into a bbdb buffer is quite cool, but has problems.

The biggest of them is that `bbdb-fontify-buffer' is constrained to
rendering exactly one face at the very start of the BBDB record. This
means that if a record has a BBDB face in it, and you're using a short
vertically-split window to display BBDB records in, that all you can see
is the face; even the name might be scrolled off and lost.

I'd far prefer to stick the face on the face: line, obscuring the
otherwise useless binary data that's displayed there.

This patch (against bbdb-2.34; if this code has changed in 2.35 I'm
happy to rewrite/respin) implements that.

(I'll probably rewrite it anyway: it's ugly and repetitive. The painful
bug-workaround-filled `hiding stuff with an image' tricks it uses are
XEmacs- specific, but there is of course an Emacs 21 way to do the same
thing --- I think it's the `display' property.)


The patch is rolled against the copy of bbdb in the XEmacs CVS repository,
hence the silly paths. Again, I'm happy to reroll if anyone thinks this
change is worthwhile.

2002-09-24  Nix  <[EMAIL PROTECTED]>

        * lisp/bbdb-gui.el (bbdb-fontify-buffer): Obscure the face: field
        contents with the rendered face, if that field is visible.
        (bbdb-hack-x-face): Permit rendering the image after the extent,
        as well as before it.

Index: packages/xemacs-packages/bbdb/lisp/bbdb-gui.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/bbdb/lisp/bbdb-gui.el,v
retrieving revision 1.3
diff -u -r1.3 bbdb-gui.el
--- packages/xemacs-packages/bbdb/lisp/bbdb-gui.el      2002/02/12 22:56:37     1.3
+++ packages/xemacs-packages/bbdb/lisp/bbdb-gui.el      2002/09/24 21:10:35
@@ -208,7 +208,24 @@
         (bbdb-set-extent-face e 'bbdb-name)
         (bbdb-set-extent-property e 'priority 2)
         (bbdb-set-extent-property e 'highlight t)
-        (if face (bbdb-hack-x-face face e))
+        ;; If we can put the face beside the x-face line, do; it's further
+        ;; down the record on-screen, so avoids wasting space on blankness
+        ;; in a popup buffer.  We *replace* the text of that line with the
+        ;; X-Face (due to XEmacs < 21.5 bugs, we must do this by setting
+        ;; the *end* glyph, not the beginning one.)
+        (if face
+            (save-excursion
+              (goto-char (point-min))
+              (if (search-forward-regexp "^\\s-*face: " (point-max) t)
+                  (let ((face-extent
+                         (make-extent (point)
+                                      (save-excursion
+                                        (end-of-line)
+                                        (point)))))
+                    (bbdb-set-extent-property face-extent 'data 'bbdb)
+                    (bbdb-set-extent-property face-extent 'invisible t)
+                    (bbdb-hack-x-face face face-extent t))
+                (bbdb-hack-x-face face e))))
         (forward-line 1)
         (while (< (point) end)
           (skip-chars-forward " \t")
@@ -231,10 +248,10 @@
 ;;; share the xface cache data with VM if it's around
 (defvar vm-xface-cache (make-vector 29 0))
 
-(defun bbdb-hack-x-face (face extent)
+(defun bbdb-hack-x-face (face extent &optional at-end)
   "Process a face property of a record and honour it.
 Not done for GNU Emacs just yet, since it doesn't have image support
-as of GNU Emacs 20.7"
+as of GNU Emacs 20.7."
   (if (not (or (and (boundp 'highlight-headers-hack-x-face-p)
                     (funcall (intern                               ;; compiler
                               "highlight-headers-hack-x-face-p"))) ;; ick.
@@ -263,7 +280,9 @@
                 (setq g (symbol-value g))
                 (bbdb-set-glyph-face g 'vm-xface))
               (bbdb-set-extent-property extent 'vm-xface t)
-              (bbdb-set-extent-begin-glyph extent g))
+              (if at-end
+                  (bbdb-set-extent-end-glyph extent g)
+                (bbdb-set-extent-begin-glyph extent g)))
           (error nil))) ;; looks like you don't have xface support, d00d
 
        ;; requires lemacs 19.10 version of highlight-headers.el


-- 
`Let's have a round of applause for those daring young men
 and their flying spellcheckers.' --- Meg Worley


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to