lisp/my-mail.el
changeset 1 a234a7579958
equal deleted inserted replaced
0:df7496e40bee 1:a234a7579958
       
     1 (require 'browse-url)
       
     2 
       
     3 ;;;_ Custom functions
       
     4 
       
     5 ; Redefine browse-url-mail for ?subject=SUBJECT support.
       
     6 
       
     7 (defun browse-url-mail (url &optional new-window)
       
     8   "Open a new mail message buffer within Emacs.
       
     9 Default to using the mailto: URL around or before point as the
       
    10 recipient's address.  Supplying a non-nil interactive prefix argument
       
    11 will cause the mail to be composed in another window rather than the
       
    12 current one.
       
    13 
       
    14 When called interactively, if variable `browse-url-new-window-flag' is
       
    15 non-nil use `compose-mail-other-window', othserwise `compose-mail'.  A
       
    16 non-nil interactive prefix argument reverses the effect of
       
    17 `browse-url-new-window-flag'.
       
    18 
       
    19 When called non-interactively, optional second argument NEW-WINDOW is
       
    20 used instead of `browse-url-new-window-flag'."
       
    21   (interactive (browse-url-interactive-arg "Mailto URL: "))
       
    22   (save-excursion
       
    23     (let ((to (if (string-match "^mailto:" url)
       
    24 		  (substring url 7)
       
    25 		url))
       
    26 	  (subject nil))
       
    27       (if (string-match "\\?subject=" to)
       
    28 	  (setq subject (substring to (match-end 0))
       
    29 		to (substring to 0 (match-beginning 0))))
       
    30       (if (browse-url-maybe-new-window new-window)
       
    31 	  (compose-mail-other-window to subject nil nil
       
    32 				     (list 'insert-buffer (current-buffer)))
       
    33 	(compose-mail to subject nil nil nil
       
    34 		      (list 'insert-buffer (current-buffer)))))))
       
    35 
       
    36 ;;;_ Wanderlust settings
       
    37 
       
    38 (autoload 'wl-user-agent-compose "wl-draft" nil t)
       
    39 (if (boundp 'mail-user-agent)
       
    40     (setq mail-user-agent 'wl-user-agent))
       
    41 (if (fboundp 'define-mail-user-agent)
       
    42     (define-mail-user-agent
       
    43       'wl-user-agent
       
    44       'wl-user-agent-compose
       
    45       'wl-draft-send
       
    46       'wl-draft-kill
       
    47       'mail-send-hook))
       
    48 (setq wl-draft-init-config-alist
       
    49       '((reply "^\\(To\\|CC\\): .*@alteranode.com" 
       
    50 	       ("From" . "Fabien Ninoles <fabien@alteranode.com>")) 
       
    51 	(reply "^\\(To\\|CC\\): .*fabien@flipr.com" 
       
    52 	       ("From" . "Fabien Ninoles <fabien@flipr.com>"))))
       
    53 (setq wl-draft-send-config-alist 
       
    54       '(("^From: .*fabien\\(\\+.*\\)?@tzone.org"
       
    55 	 ("BCC" . "fabien+sentmail@tzone.org"))
       
    56 	("From: .*fabien\\(\\+.*\\)?@alteranode.com" 
       
    57 	 ("Organisation" . "Alteranode, inc.")
       
    58 	 ("BCC" . "fabien+sentmail@alteranode.com")) 
       
    59 	("From: .*fabien\\(\\+.*\\)?@flipr.com" 
       
    60 	 ("BCC" . "fabien+sentmail@alteranode.com"))))
       
    61 (add-hook 'wl-mail-setup-hook
       
    62 	  '(lambda ()
       
    63 	     (wl-draft-config-exec wl-draft-init-config-alist)
       
    64 	     (setq wl-draft-config-exec-flag t)))
       
    65 (add-hook 'wl-draft-send-hook
       
    66 	  '(lambda ()
       
    67 	     (setq wl-draft-config-exec-flag t)
       
    68 	     (wl-draft-config-exec wl-draft-send-config-alist)
       
    69 	     ))
       
    70 
       
    71 ;;;_ BBDB configuration
       
    72 
       
    73 (require 'bbdb-wl)
       
    74 (bbdb-wl-setup)
       
    75 ;; exceptional folders against auto collection
       
    76 (setq bbdb-wl-ignore-folder-regexp "^@")
       
    77 (setq signature-use-bbdb t)
       
    78 ;; automatically add mailing list fields
       
    79 (setq bbdb-ignore-selected-messages-confirmation t)
       
    80 
       
    81 (provide 'my-mail)