Gnus development mailing list
 help / color / mirror / Atom feed
From: d.bell@motorola.com (E. David Bell)
Subject: Re: Supercite, BBDB, Gnus, and attributions
Date: 17 Oct 1999 18:16:36 +0200	[thread overview]
Message-ID: <ke7lkmm07v.fsf@msil.sps.mot.com> (raw)
In-Reply-To: john s jacobs anderson's message of "Sat, 16 Oct 1999 23:13:43 MST"

>>>>> "john" == john s jacobs anderson <jacobs@genehack.org> writes:

  john> I can tell (or at least I think) that I need to set
  john> "sc-consult" as the first (or second) entry in
  john> sc-preferred-attribution-list, and that I should set up
  john> sc-attrib-selection-list to return the value from BBDB. I also
  john> think that bbdb/sc-consult-attr is going to be in there
  john> somewhere.

It took me a while to get this working.  This is what I've got:

\f
In my .emacsrc:

(custom-set-variables
 '(sc-preferred-attribution-list (quote ("sc-consult" "x-attribution"  "firstname" "lastname" "initials")))
 '(sc-attrib-selection-list 
                '(("sc-from-address"
          	 ((".*"  (bbdb/sc-consult-attr
          		   (sc-mail-field "sc-from-address")))))))

 '(sc-mail-glom-frame 
         '((begin                        (setq sc-mail-headers-start (point)))
          ("^x-attribution:[ \t]+.*$"   (sc-mail-fetch-field t) nil t)
          ("^\\S +:.*$"                 (sc-mail-fetch-field) nil t)
          ("^$"                         (progn (bbdb/sc-default)
                                        (list 'abort '(step . 0))))
          ("^[ \t]+"                    (sc-mail-append-field))
          (sc-mail-warn-if-non-rfc822-p (sc-mail-error-in-mail-field))
          (end                          (setq sc-mail-headers-end (point)))))
 '(sc-citation-leader ""))

(bbdb-initialize 'gnus 'message 'sc)

(bbdb-insinuate-sc)  

\f
And in my gnus:



;; Not sure where these two functions came from originally...
;; Override sc-get-address with something that's less picky about what it's
;; willing to consider an address (supercite's default truncates the address
;; at the first odd-looking character).
(defun sc-get-address (from author)
  "Get the full email address path from FROM.
AUTHOR is the author's name (which is removed from the address)."
  (let ((eos (length from)))
    (if (string-match (concat "\\(^\\|^\"\\)" (regexp-quote author)
                              "\\(\\s +\\|\"\\s +\\)") from 0)
        (let ((address (substring from (match-end 0) eos)))
          (if (and (= (aref address 0) ?<)
                   (= (aref address (1- (length address))) ?>))
              (substring address 1 (1- (length address)))
            address))
      (if (string-match
           "[   ]*<?\\([^       (>]+@[^         (>]+\\)" from 0)
          (sc-submatch 1 from)
        ""))))
 

 
;; Override sc-attribs-extract-namestring so that it will correctly cope
;; with From headers that contain no address (which is becoming more common
;; with munging, even if it's technically illegal).
(defun sc-attribs-extract-namestring (from)
  "Extract the name string from FROM.
This should be the author's full name minus an optional title."
  (let ((namestring
         (or
          ;; If there is a <...> in the name,
          ;; treat everything before that as the full name.
          ;; Even if it contains parens, use the whole thing.
          ;; On the other hand, we do look for quotes in the usual way.
          (and (string-match " *<.*>" from 0)
               (let ((before-angles
                      (sc-name-substring from 0 (match-beginning 0) 0)))
                 (if (string-match "\".*\"" before-angles 0)
                     (sc-name-substring
                      before-angles (match-beginning 0) (match-end 0) 1)
                   before-angles)))
          (sc-name-substring
           from (string-match "(.*)" from 0) (match-end 0) 1)
          (sc-name-substring
           from (string-match "\".*\"" from 0) (match-end 0) 1)
          (sc-name-substring
           from (string-match "\\([-.a-zA-Z0-9_]+\\s *\\)+" from 0)
           (match-end 0) 0)
          (sc-attribs-emailname from))))
    ;; strip off any leading or trailing whitespace
    (if namestring
        (let ((bos 0)
              (eos (1- (length namestring))))
          (while (and (<= bos eos)
                      (memq (aref namestring bos) '(32 ?\t)))
            (setq bos (1+ bos)))
          (while (and (> eos bos)
                      (memq (aref namestring eos) '(32 ?\t)))
            (setq eos (1- eos)))
          (substring namestring bos (1+ eos))))))
;;; End Supercite stuff





  reply	other threads:[~1999-10-17 16:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-17  6:12 john s jacobs anderson
1999-10-17 16:16 ` E. David Bell [this message]
1999-10-17 21:28   ` john s jacobs anderson
1999-10-17 23:19     ` Jack Twilley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ke7lkmm07v.fsf@msil.sps.mot.com \
    --to=d.bell@motorola.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).