From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ivan Kanis Newsgroups: gmane.emacs.help Subject: Re: Lisp hints with VM, BBDB and Personality Crisis Date: 18 Sep 2003 15:07:13 +0200 Organization: Guest of TISCALI - FRANCE Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87llsmmeim.fsf@juliva.com> References: <87znh7aue5.fsf@dell.i-did-not-set--mail-host-address--so-shoot-me> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1063899627 328 80.91.224.253 (18 Sep 2003 15:40:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 18 Sep 2003 15:40:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 18 17:40:25 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A00tN-00087y-00 for ; Thu, 18 Sep 2003 17:40:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A00kD-00061W-IK for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Sep 2003 11:30:57 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!news.tiscali.fr!127.0.0.1!nobody Original-Newsgroups: gnu.emacs.help Original-Lines: 78 Original-NNTP-Posting-Host: 212.83.186.176 Original-X-Trace: news.tiscali.fr 1063898041 482 212.83.186.176 (18 Sep 2003 15:14:01 GMT) Original-X-Complaints-To: abuse@libertysurf.fr Original-NNTP-Posting-Date: Thu, 18 Sep 2003 15:14:01 +0000 (UTC) Original-Sender: spam@juliva.com User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:116702 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12624 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12624 Thanks for all the info! Here is the code cleaned up. It is really handy used in conjunction with Personality Crisis to decide on what your "from" address should be. In the example given below my friend have the string "efriend" in the bbdb note field. They will get my personal address when I write them. As usual comments on style or anything are welcome. (defun my-check-bbdb-note(note-keyword) "Return non-nil when recipent has `note-keyword' in BBDB. This function is used in a VM composition buffer. It fetches the recpipient addres from the buffer. It looks up in bbdb for the given address. It looks in the note field and check that it contains `note-keyword'. It is useful with Personality Crisis to generate a different sender address depending on the recipient name." (interactive) (let ((header (vmpc-get-current-header-contents "to"))) (when header (when (string-match "<\\(.*\\)>" header) (let* ((email (match-string 1 header)) (record (bbdb-search-simple "" email))) (when record (let ((note (bbdb-record-notes record))) (when note (string-match note-keyword note))))))))) ;; Personal crisis settings (setq vmpc-conditions '(("to friend" (my-check-bbdb-note "efriend")) )) (setq vmpc-actions '(("personal" (vmpc-substitute-header "From" (concat "Ivan Kanis <" my-personal-email ">")) (vmpc-pre-signature "\nIvan") (vmpc-signature "~/.signature.friend"))) ) (setq vmpc-automorph-alist '(("to friend" "personal") ("to job" "job") )) ;; Hooks to put in vm compose buffer (defun my-mail-down-and-automorph() (interactive) (if (save-excursion (search-forward (concat "\n" mail-header-separator "\n") nil t)) (vmpc-automorph)) (next-line 1)) (defun my-mail-text-and-automorph () (interactive) (mail-text) (vmpc-automorph)) (defun my-define-vm-mail-key() (define-key vm-mail-mode-map "\C-c\C-i" 'ispell-message) (define-key vm-mail-mode-map "\C-c\C-s" nil) (define-key vm-mail-mode-map [down] 'my-mail-down-and-automorph) (define-key vm-mail-mode-map "\C-n" 'my-mail-down-and-automorph) (define-key vm-mail-mode-map "\C-c\C-t" 'my-mail-text-and-automorph) (define-key vm-mail-mode-map "\C-ca" 'vm-mime-attach-file) ) (add-hook 'vm-mail-mode-hook 'my-define-vm-mail-key) -- /-----------------------------------------------------------------------------* | "Do not try to live forever. You will not succeed." | Ivan Kanis | | (George Bernard Shaw) | Software Developper | | | www.kanis.cc | *-----------------------------------------------------------------------------/