28 April, 2010

 

My Wanderlust setup

Wanderlust is a pain to set up, but the flexibility you get is worth it. I've been using it for a month now and (thanks to various posts and trawling through the cutomisation groups for wl, bbdb, mu-cite) this is what my wanderlust setup has grown to:


;; mode:-*-emacs-lisp-*-
;; wanderlust


(setq wl-summary-always-sticky-folder-list t)
(setq wl-summary-line-format "%n%T%P %D/%M (%W) %h:%m %t%[%25(%c %f%) %] %s")
(setq wl-summary-width 150)
(setq wl-user-mail-address-list (quote ("j.shuttleworth@coventry.ac.uk" "csx239@coventry.ac.uk")))

(setq bbdb-use-pop-up nil)

;;Initial Wanderlust setup
;; autoload configuration
(autoload 'wl "wl" "Wanderlust" t)
(autoload 'wl-other-frame "wl" "Wanderlust on new frame." t)
(autoload 'wl-draft "wl-draft" "Write draft with Wanderlust." t)

;; If we wanted to we can set the init file to be something different
;; (setq wl-init-file "~/.emacs.d/wl.el")


;; This should allow us to compose mail using C-x m
(autoload 'wl-user-agent-compose "wl-draft" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'wl-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'wl-user-agent
'wl-user-agent-compose
'wl-draft-send
'wl-draft-kill
'mail-send-hook))

;; BBDB for harvesting Email addresses.
;; THe rest in in my WL file
(add-to-list 'load-path "/usr/share/emacs23/site-lisp/bbdb/")
(setq bbdb-file "~/Documents/portables/bbdb") ;; keep ~/ clean; set before loading
(require 'bbdb)
(bbdb-initialize)

(setq
bbdb-offer-save 1 ;; 1 means save-without-asking

bbdb-use-pop-up t ;; allow popups for addresses
bbdb-electric-p t ;; be disposable with SPC
bbdb-popup-target-lines 1 ;; very small

bbdb-dwim-net-address-allow-redundancy t ;; always use full name
bbdb-quiet-about-name-mismatches 2 ;; show name-mismatches 2 secs

bbdb-always-add-address t ;; add new addresses to existing...
;; ...contacts automatically
bbdb-canonicalize-redundant-nets-p t ;; x@foo.bar.cx => x@bar.cx

bbdb-completion-type nil ;; complete on anything

bbdb-complete-name-allow-cycling t ;; cycle through matches
;; this only works partially

bbbd-message-caching-enabled t ;; be fast
bbdb-use-alternate-names t ;; use AKA


bbdb-elided-display t ;; single-line addresses

;; auto-create addresses from mail
bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook
;; bbdb-ignore-some-messages-alist ;; don't ask about fake addresses
;; NOTE: there can be only one entry per header (such as To, From)
;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html

;; '(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter")))

)


(add-to-list 'load-path "/usr/share/emacs23/site-lisp/mu-cite/")
(require 'mu-cite)
(add-hook 'mail-citation-hook 'mu-cite-original)
(setq mu-cite-top-format
'("On " date "," full-name " spake thus:\n"))





(setq signature-file-name "~/.signature"
signature-insert-at-eof t
signature-delete-blank-lines-at-eof t
mu-cite-prefix-format (quote ("> ")) ; default to >, no questions asked, rather than name
)



(add-hook
'wl-init-hook
'(lambda ()
;; Add support for (signature . "filename")
(unless (assq 'signature wl-draft-config-sub-func-alist)
(wl-append wl-draft-config-sub-func-alist
'((signature . wl-draft-config-sub-signature))))

(defun mime-edit-insert-signature (&optional arg)
"Redefine to insert a signature file directly, not as a tag."
(interactive "P")
(insert-signature arg))

;; Keep track of recently used Email addresses
;;(recent-addresses-mode 1)
))


(defun wl-draft-config-sub-signature (content)
"Insert the signature at the end of the MIME message."
(let ((signature-insert-at-eof nil)
(signature-file-name content))
(goto-char (mime-edit-content-end))
(insert-signature)))



(setq
elmo-maildir-folder-path "~/Maildir" ;; where i store my mail

wl-stay-folder-window t ;; show the folder pane (left)
wl-folder-window-width 25 ;; toggle on/off with 'i'

wl-smtp-posting-server "mail.coventry.ac.uk" ;; put the smtp server here

;wl-smtp-posting-server
;The initial setting is nil. This is the SMTP server name for mail transmission.
;wl-smtp-posting-port
;The initial setting is nil. This is the SMTP port number for mail transmission. If nil, default SMTP port number (25) is used.
wl-smtp-posting-user "csx239"
;The initial setting is nil. This is the user name for SMTP AUTH authentication.
wl-smtp-authenticate-type "login"
;The initial setting is nil. This string-valued variable specifies the authentication method for SMTP AUTH authentication. You may specify plain, cram-md5, digest-md5, login, etc. If nil, authentication will not be carried out.



wl-local-domain "ng43-1.coventry.ac.uk" ;; put something here...
wl-message-id-domain "coventry.ac.uk" ;; ...

wl-from "James Shuttleworth " ;; my From:

;; note: all below are dirs (Maildirs) under elmo-maildir-folder-path
;; the '.'-prefix is for marking them as maildirs
wl-fcc ".sent" ;; sent msgs go to the "sent"-folder
wl-fcc-force-as-read t ;; mark sent messages as read
wl-default-folder ".inbox" ;; my main inbox
wl-draft-folder ".drafts" ;; store drafts in 'postponed'
wl-trash-folder ".trash" ;; put trash in 'trash'
wl-spam-folder ".trash" ;; ...spam as well
wl-queue-folder ".queue" ;; we don't use this

;; check this folder periodically, and update modeline
wl-biff-check-folder-list '(".todo") ;; check every 180 seconds
;; (default: wl-biff-check-interval)





;; hide many fields from message buffers
wl-message-ignored-field-list '("^.*:")
wl-message-visible-field-list
'("^\\(To\\|Cc\\):"

"^Subject:"
"^\\(From\\|Reply-To\\):"
"^Organization:"
"^Message-Id:"
"^\\(Posted\\|Date\\):"
"^[xX]-[Ff]ace:"
)
wl-message-sort-field-list
'("^From"

"^Organization:"
"^X-Attribution:"
"^Subject"
"^Date"
"^To"
"^Cc")
)

;;Get BBDB workiing
(require 'bbdb-wl)
(bbdb-wl-setup)
(define-key wl-draft-mode-map (kbd "") 'bbdb-complete-name)

(setq
wl-forward-subject-prefix "Fwd: " ) ;; use "Fwd: " not "Forward: "


;; Invert behaviour of with and without argument replies.
;; just the author
(setq wl-draft-reply-without-argument-list
'(("Reply-To" ("Reply-To") nil nil)
("Mail-Reply-To" ("Mail-Reply-To") nil nil)
("From" ("From") nil nil)))


;; bombard the world
(setq wl-draft-reply-with-argument-list
'(("Followup-To" nil nil ("Followup-To"))
("Mail-Followup-To" ("Mail-Followup-To") nil ("Newsgroups"))
("Reply-To" ("Reply-To") ("To" "Cc" "From") ("Newsgroups"))
("From" ("From") ("To" "Cc") ("Newsgroups"))))


(defun djcb-wl-draft-subject-check ()
"check whether the message has a subject before sending"
(if (and (< (length (std11-field-body "Subject")) 1)
(null (y-or-n-p "No subject! Send current draft?")))
(error "Abort.")))


;; note, this check could cause some false positives; anyway, better
;; safe than sorry...
(defun djcb-wl-draft-attachment-check ()
"if attachment is mention but none included, warn the the user"
(save-excursion
(goto-char 0)
(unless ;; don't we have an attachment?

(re-search-forward "^Content-Disposition: attachment" nil t)
(when ;; no attachment; did we mention an attachment?
(re-search-forward "attach" nil t)
(unless (y-or-n-p "Possibly missing an attachment. Send current draft?")
(error "Abort."))))))

(add-hook 'wl-mail-send-pre-hook 'djcb-wl-draft-subject-check)
(add-hook 'wl-mail-send-pre-hook 'djcb-wl-draft-attachment-check)

;; don't ****ing split large messages
(setq mime-edit-split-message nil)


;For printing on black and white printer...
(setq wl-ps-print-buffer-function 'ps-print-buffer)



;Auto add signature on draft edit
(remove-hook 'wl-draft-send-hook 'wl-draft-config-exec)
(add-hook 'wl-mail-setup-hook 'wl-draft-config-exec)
(setq wl-draft-config-alist
'(((string-match "1" "1")
(bottom . "\n--\n") (bottom-file . "~/.signature"))
))



;; Wanderlust compose becomes bound to C-x m
(autoload 'wl-user-agent-compose "wl-draft" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'wl-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'wl-user-agent
'wl-user-agent-compose
'wl-draft-send
'wl-draft-kill
'mail-send-hook))


;; Fetchmail bount to C-x M-m

(defun fetchmail-fetch ()
(interactive)
(shell-command "fetchmail")
)
(global-set-key "\C-x\M-m" 'fetchmail-fetch)


;Stop mime errors when sending to AOL/others?
; osdir.com/ml/mail.wanderlust.general/2006-10/msg00007.html
;(setq-default mime-transfer-level 8)
(setq smtp-use-8bitmime nil)


;Swap a and A in summary mode, so citing original message is on a and no-cite on A.
;I want the most common action (for me) to be the one with fewer keypresses
(define-key wl-summary-mode-map (kbd "A") 'wl-summary-reply)
(define-key wl-summary-mode-map (kbd "a") 'wl-summary-reply-with-citation)


11 April, 2010

 

This blog has moved


This blog is now located at http://dis-dot-dat.blogspot.com/.
You will be automatically redirected in 30 seconds or you may click here.

For feed subscribers, please update your feed subscriptions to
http://dis-dot-dat.blogspot.com/feeds/posts/default.


07 April, 2010

 

Customising Wanderlust

I've used a combination of Mutt, Emacs, Fetchmail, Procmail and Nullmailer for a long time now. Nearly a decade. But since most of the rest of my computer life is spentfi inside Emacs and I've swapped from paper-based task tracking to remember-mode, I thought I'd give Wanderlust a try.

The articles on getting started with Wanderlust at emacs-fu are great (Part 1 Part 2 Part 3) and left me with a working mail client. Unfortunately, it worked in a way I didn't quite like as much as Mutt.

Here's how I fixed it.

All of the lisp bits in this post can go in your .wl file, so you don't have to pollute your .emacs.

Summary lines

The first thing that bothered me about Wanderlust was the short summary lines. I have a fairly high-resolution monitor, and there was a lot of wasted space in the summary buffer. Even on my low-resolution laptop, I had empty space to the right of the truncated subjects. Here's the solution:

I was also a bit miffed by the date format and spacing of the elements in the summary lines, so I swapped those around to be correct (that is, British):


(setq wl-summary-line-format "%n%T%P %D/%M (%W) %h:%m %t%[%25(%c %f%) %] %s")
(setq wl-summary-width 150)


Stickiness

Being used to Mutt, I kept pressing "q" to close the message preview. In Wanderlust, when shoeing an e-mail, you don't actually jump into its buffer, so all this kept doing was closing the summary. If you had any marks on messages or operations that hadn't been executed, this could be a real pain because they were all forgotten. I found that you could make a summary "sticky" with M-s, which makes the contents of the summary persistent in a Wanderlust session, but you have to remember to actually do that when you open a summary buffer. Then I found out how to make all summaries sticky by default:

 (setq wl-summary-always-sticky-folder-list t)


Virtual Folders

One of the things I liked most about Mutt was the powerful searching functions. Wanderlust has something even better: virtual folders.

Use V to create one. You can search by body, from, to, etc., but also by Flag, so a search for Flag of Unread shows all new mails. You can also use ! to invert the search: !Flag, for example.

V can be used in a summary or from the Folders buffer. If you press it at your Desktop item, the virtual folder pulls mails from everything beneath it.

Even better, if you use "m f" to make a virtual folder in the folders view, it becomes a new mailbox. And, if you save the folder buffer, it updates your .folders file. You can put nicer names on them, too. I have these two items in my .folders:

 /flag:unread/.inbox    "Unread/inbox"
/!flag:unread/.inbox "Read/inbox"


Which got me out of the habit of moving read mail into a separate mailbox, as I used to have done automagically in Mutt - in-box zero makes me feel good. This is a good thing, because if you're using the brilliant remember-mode, the e-mails don't move around after you've added to-do items that link to them.

Automatic signature

I know you can press a few keystrokes and insert your signature in a draft e-mail, but I don't like it. Mutt used to append the signature automatically.

Using mu-cite, I added this behaviour again. Notice how bad at lisp I am - I cobbled this together from bits I found on the Internet. 1=1 /is/ true, though :)


(require 'mu-cite)
(add-hook 'mail-citation-hook 'mu-cite-original)

(setq signature-file-name "~/.signature"
signature-insert-at-eof t
signature-delete-blank-lines-at-eof t)


(add-hook
'wl-init-hook
'(lambda ()
;; Add support for (signature . "filename")
(unless (assq 'signature wl-draft-config-sub-func-alist)
(wl-append wl-draft-config-sub-func-alist
'((signature . wl-draft-config-sub-signature))))

(defun mime-edit-insert-signature (&optional arg)
"Redefine to insert a signature file directly, not as a tag."
(interactive "P")
(insert-signature arg))

;; Keep track of recently used Email addresses
;;(recent-addresses-mode 1)
))


(defun wl-draft-config-sub-signature (content)
"Insert the signature at the end of the MIME message."
(let ((signature-insert-at-eof nil)
(signature-file-name content))
(goto-char (mime-edit-content-end))
(insert-signature)))


Cite the way I like it

I also always had a custom line at the start of any replies/forwards. Here's how to do that in Wanderlust.

 (setq mu-cite-top-format '("On " date "," from " spake thus:\n"))


Black and white printing

I haven't tried this yet, but I found a note in the Wanderlust docs about printing to a black and white printer.

 (setq wl-ps-print-buffer-function 'ps-print-buffer)


Calling fetchmail

At first I was doing this in an eshell buffer. I don't like to have it run automatically, because sometimes I want to read my mail on the web, but ultimately like to download my mail to local Maildirs. You'd understand if you had to live with the regular mail service fubars here at Coventry University :)

I've bound it to C-x M-m, so it matches up with C-x m (write e-mail).

 (defun fetchmail-fetch ()
(interactive)
(shell-command "fetchmail")
)
(global-set-key "\C-x\M-m" 'fetchmail-fetch)


X-Face

Just for the fun of it, I have X-Face support. I've checked my e-mail for the past month and not a single other person inserts an X-Face header line, so there's not much point other than to see my own grinning face when I look in my sent mail folder. Still, that's enough reason for me.

First add X-Face to the visible field list:

 (setq  wl-message-visible-field-list
'("^\\(To\\|Cc\\):"
"^Subject:"
"^\\(From\\|Reply-To\\):"
"^Organization:"
"^Message-Id:"
"^\\(Posted\\|Date\\):"
"^[xX]-[Ff]ace:"
))


And then just make sure you have a suitable ~/.xface file. By default, wl-auto-insert-x-face is set to t, so it should just work.

Feel free to e-mail me at csx239 AT coventry DOT ac DOT uk if you want to have someone to e-mail that uses x-face. It would make my day.


01 April, 2010

 

eshell

Why didn't someone tell me about this a long time ago? I've been using shell or ansi-term for years - all that time, I could have been using eshell. World: try harder.

Labels:


This page is powered by Blogger. Isn't yours?

Social bookmarks

Delicious

Bookmark this on Delicious

Links

Support The Commons









This site:

Free your code:

archives