On Thu, 01 Jul 2004, Wes Hardaker yowled:
>>>>>> On Thu, 01 Jul 2004 21:43:18 +0100, Nix <[EMAIL PROTECTED]> said:
>
> nix> Alas, I can't do that: BBDB is triggered immediately *after* Gnus
> nix> prepares the article buffer and hides the headers, following
> nix> which `bbdb-extract-field-value' can't find the header (because
> nix> it's hidden).
>
> Using a gnus function to find the header instead should work. I
> forget the function to use though.
There is none, as far as I can tell: the header structure used doesn't
store all headers, only some of them, and there's no way to get at the
other headers without laying out the article afresh (using
`gnus-request-article' in a temporary buffer).
But that's not terribly slow (2.3 minutes on this 500MHz UltraSPARC IIi
for 100,000 calls, including 100,000 fetches of the news article in
question over a 100Mb/s network; about ten milliseconds per call), so
I've done that.
Have a patch (against bbdb-2.34, but this function is unchanged for
donkeys' years, so the only problem applying it should be slop).
I've tested it against Gnus 5.8.8 and 5.10.6: I see no reason why it
shouldn't work with 5.6 as well. (I can't remember enough about earlier
versions to know if it'll work there.)
2004-07-02 Nix <[EMAIL PROTECTED]>
* lisp/bbdb-hooks.el (bbdb-extract-field-value):
Handle fields hidden by Gnus by re-extracting into a temporary
buffer.
Index: bbdb/lisp/bbdb-hooks.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/bbdb/lisp/bbdb-hooks.el,v
retrieving revision 1.5
diff -u -r1.5 bbdb-hooks.el
--- bbdb/lisp/bbdb-hooks.el 2002/02/12 22:56:38 1.5
+++ bbdb/lisp/bbdb-hooks.el 2004/07/02 20:59:09
@@ -118,22 +117,38 @@
;; we can't special-case VM here to use its cache, because the cache has
;; divided real-names from addresses; the actual From: and Subject: fields
;; exist only in the message.
- (setq field-name (concat (regexp-quote field-name) "[ \t]*:[ \t]*"))
- (let ((case-fold-search t)
- done)
- (while (not (or done
- (looking-at "\n") ; we're at BOL
- (eobp)))
- (if (looking-at field-name)
- (progn
- (goto-char (match-end 0))
- (setq done (buffer-substring (point)
- (progn (end-of-line) (point))))
- (while (looking-at "\n[ \t]")
- (setq done (concat done " "
- (buffer-substring (match-end 0)
- (progn (end-of-line 2) (point))))))))
- (forward-line 1))
+ (let ((temp-buffer-name)
+ (orig-major-mode major-mode)
+ done)
+ (save-excursion
+ (if (memq major-mode
+ '(gnus-summary-mode gnus-article-mode gnus-tree-mode))
+ (let ((temp-buffer-name (generate-new-buffer-name " *bbdb-extract temp*"))
+ (current-article (with-current-buffer gnus-summary-buffer
+ gnus-current-article))
+ (current-group gnus-newsgroup-name))
+ (set-buffer (get-buffer-create temp-buffer-name))
+ (gnus-request-article current-article current-group (current-buffer))))
+ (setq field-name (concat (regexp-quote field-name) "[ \t]*:[ \t]*"))
+ (let ((case-fold-search t))
+ (while (not (or done
+ (looking-at "\n") ; we're at BOL
+ (eobp)))
+ (if (looking-at field-name)
+ (progn
+ (goto-char (match-end 0))
+ (setq done (buffer-substring (point)
+ (progn (end-of-line) (point))))
+ (while (looking-at "\n[ \t]")
+ (setq done (concat done " "
+ (buffer-substring (match-end 0)
+ (progn (end-of-line 2) (point))))))))
+ (forward-line 1))))
+ (if (memq orig-major-mode
+ '(gnus-summary-mode gnus-article-mode gnus-tree-mode))
+ (let ((kill-buffer-hook nil)
+ (kill-buffer-query-functions nil))
+ (kill-buffer temp-buffer-name)))
done))
--
`Some people find it difficult to accept that it is not always possible
to explain things which should be explicable.'
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/