info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help writing predicate function


From: Bob Newell
Subject: Re: Need help writing predicate function
Date: Mon, 04 Dec 2023 14:17:09 -1000
User-agent: Safari/6.5

I do something similar to change identity and/or input
language based on addressee.  I just put it in a hook
  
(add-hook 'message-setup-hook 'rjn-change-stuff-by-addressee t)

and that works for me; the appropriate identity gets chosen
via gnus-alias-use-identity when the message reply is set up.

My complete code is this.  It is not the same as you ask but
easily modified.  You'd only need the upper half.

(defun rjn-change-stuff-by-addressee ()
  (interactive)
  (let ((addressee (message-fetch-field "To"))
        netaddr person smtppref)
    (if addressee
        (setq netaddr (cadr (mail-extract-address-components addressee))))
    (if netaddr
          (setq person (car (bbdb-search (bbdb-records) :mail netaddr))))
    (if person
        (setq smtppref (bbdb-record-field person 'smtp)))
    (if smtppref
           (gnus-alias-use-identity smtppref))
              ) 

  (let ((addressee (message-fetch-field "To"))
        netaddr person langpref)
    (if addressee
        (setq netaddr (cadr (mail-extract-address-components addressee))))
    (if netaddr
        (progn
          (setq person (car (bbdb-search (bbdb-records) :mail netaddr)))))
            (if person
                (setq langpref (bbdb-record-field person 'language)))
    (if langpref
        (set-input-method langpref)))
  )

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB



reply via email to

[Prev in Thread] Current Thread [Next in Thread]