[Top][All Lists]

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

Re: Lisp hints with VM, BBDB and Personality Crisis

From: Ivan Kanis
Subject: Re: Lisp hints with VM, BBDB and Personality Crisis
Date: 18 Sep 2003 15:07:13 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

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."
  (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
          "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()
  (if (save-excursion
         (concat "\n" mail-header-separator "\n")
         nil t))
  (next-line 1))

(defun my-mail-text-and-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 |
|                                                      |    |

reply via email to

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