Colin Rafferty <[EMAIL PROTECTED]> writes:

> Micha Wiedenmann wrote:
>
>> bbdb automatically adds the x-face to the bbdb-records, but I don't know
>> how to add several xfaces to the face-field. A new xface is appended via
>> ", " this destroys both, the old and the new x-faces. 
>
> (put 'face 'field-separator "\n")

I always wondered how to do this in Emacs 21.  Rather than messing
with bbdb-gui.el, which I had some difficulties in understanding
because it uses lots of low-level stuff from vm (which I do not know),
and is written for XEmacs (which I do not use), I went a different
route.  Integrating this back into bbdb-gui is probably messy and
would ideally involve some refactoring as well.  :(

This uses the bbdb-list-hook, and adds a little defun there that
contains some code ripped from the gnus files, and which requires the
gnus file gnus-ems and its dependencies.  I use Oort Gnus, so YMMV.

When you want to add somebody's face, you must first use `t' to show
the headers, and then stuff after the X-Face: header.  For a BBDB
record, create a new field named `face' and paste the copied cruft.
If you want several faces, separate them via a comma and a space.  I
think the space is invalid within an X-Face, but I could be wrong.

(add-hook 'bbdb-list-hook 'bbdb/gnus-display-xface)

(defun bbdb/gnus-display-xface ()
  "Search for face properties and display the faces."
  (when (or (gnus-image-type-available-p 'xface)
            (gnus-image-type-available-p 'pbm))
    (save-excursion
      (goto-char (point-min))
      (let ((inhibit-read-only t); edit the BBDB buffer
            (default-enable-multibyte-characters nil); prevents corruption
            pbm faces)
      (while (re-search-forward "^           face: \\(.*\\)" nil t)
        (setq faces (match-string 1))
        (replace-match "" t t nil 1)
        (dolist (data (split-string faces ", "))
          (setq pbm (uncompface data))
          (if (gnus-image-type-available-p 'xface)
              (insert-image
               (gnus-create-image
                (concat "X-Face: " data)
                'xface t :ascent 'center :face 'gnus-x-face))
            (when pbm
              (insert-image
               (gnus-create-image
                pbm 'pbm t :ascent 'center :face 'gnus-x-face))))
          (insert " ")))))))

It works for me.  If you want to experiment with the elisp, here is
the piece of code I needed to get started.

(let ((default-enable-multibyte-characters nil))
  (insert-image
   (gnus-create-image
    (uncompface 
"^BC$`[IcggstLPyen&dqF+b2'zyK#r.mU*'Nms}@&4zw%SJ#5!/7SMVjBS7'lb;QK)|IPU5U'o1'522W4TyzB3Ab*IBo^iw]l4|kUbdZuUDO6=Um-.4IzhNiV'B\"@K#jy_(wW|Zbk[34flKY^|PrQ?$u2\\fKg^]AY>wOX#H32i")
    'pbm t :ascent 'center :face 'gnus-x-face)))

Does anybody have a nice piece of code, that will let me add a face to
a record when I hit `:' on a message?

Alex.


-------------------------------------------------------
This sf.net email is sponsored by:
Access Your PC Securely with GoToMyPC. Try Free Now
https://www.gotomypc.com/s/OSND/DD
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to