wanderlust iii


I have been using the Wanderlust E-mail client for almost a year now, and I am very happy with it. In previous postings I already discussed setup and some tips and tricks; and I also had somewhat related posts on bbdb (the address book) and warning you about new mail. But I think it's time for an update.


One question that I have received quite a few times was about the maintenance of Wanderlust; it's may be a nice e-mail client, but little seems to have happened in the last few years. It's reasonable concern.

Fortunately, it seems the situation has improved significantly. There's more traffic on the mailing lists, both from old and new users. Various improvements are circulating; the place to get the latest stuff is in David Abrahams' git-repository: semi, flim, apel and wanderlust. The plan is to gradually apply the changes to the upstream (CVS) repository.


Although I have been quite happy with Wanderlust, there was one bug #5534 that has bitten me a few times, causing occasional hangs when saving (draft) messages with non-ascii characters. It seemed finally to be a bug in emacs itself, which is triggered by something in Wanderlust. A fix will probably be available for the next emacs version; until then, you can work around this by using an external MIME-encoder. To do this, add the following to your WL initialization code (thanks to various helpful people on the WL mailing list):

(setq mel-b-ccl-module nil)
(setq mel-q-ccl-module nil)
(setq base64-external-encoder '("mimencode"))
(setq base64-external-decoder '("mimencode" "-u"))
(setq base64-external-decoder-option-to-specify-file '("-o"))
(setq quoted-printable-external-encoder '("mimencode" "-q"))
(setq quoted-printable-external-decoder '("mimencode" "-q" "-u"))
(setq quoted-printable-external-decoder-option-to-specify-file '("-o"))
(setq base64-internal-decoding-limit 0)
(setq base64-internal-encoding-limit 0)
(setq quoted-printable-internal-decoding-limit 0)
(setq quoted-printable-internal-encoding-limit 0)

(setq-default mime-transfer-level 8)
(setq mime-header-accept-quoted-encoded-words t)

This requires the mimencode-program, which is part of the metamail-package. For the time being, this seems to be the best solution when using Wanderlust with Emacs 23.

one more trick: reformatting

Let's finish with one more trick. Sometimes, incoming mail is formatted quite badly; in particular, the new lines are too long for comfortable reading. From the WL-mailing list, here's a trick to deal with that:

(require 'filladapt)

;; from a WL mailing list post by Per b. Sederber
;; Re-fill messages that arrive poorly formatted
(defun wl-summary-refill-message (all)
  (interactive "P")
  (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
        (wl-summary-toggle-disp-msg 'on)
          (set-buffer wl-message-buffer)
          (goto-char (point-min))
          (re-search-forward "^$")
          (while (or (looking-at "^\\[[1-9]") (looking-at "^$"))
            (forward-line 1))
          (let* ((buffer-read-only nil)
                 (find (lambda (regexp)
                           (if (re-search-forward regexp nil t)
                               (match-beginning 0)
                 (start (point))
                 (end (if all
                        (min (funcall find "^[^>\n]* wrote:[ \n]+")
                             (funcall find "^>>>>>")
                             (funcall find "^ *>.*\n *>")
                             (funcall find "^-----Original Message-----")))))
              (narrow-to-region start end)
              (filladapt-mode 1)
              (fill-region (point-min) (point-max)))))
        (message "Message re-filled"))
    (message "No message to re-fill")))

(define-key wl-summary-mode-map "\M-q" 'wl-summary-refill-message)

Now, you can refill your messages with M-q when in the Summary.

If you have any other nifty WL-tricks that could be useful for others, please share them in the comments, thanks!


dealing with many buffers: ibuffer

If you are like me, you'll open a lot of buffers in emacs. There may be a couple of buffers with source code, a few for e-mail. org-mode will open buffers for all your agenda files. Then, maybe an info page, a few ERC-channels, a couple of special emacs buffers such as **Messages** and **scratch**. So, in a moderately busy emacs session there may 30-40 buffers open, and after a day or so there can be many more.

With so many buffers, it can be hard to quickly find the one you are looking for - and clearly a one-tab-per-buffer (like Firefox uses) would not work very well either.

So, what can we do instead? Here, on emacs-fu, we discussed this a couple of
times already:

  • using ido-mode, you can quickly switch to buffers by typing a subset of
    their name
  • using elscreen to step through buffer configurations (this comes close to a
    workable tab-like solution)

These are really useful tools. What's still missing though, is a way to get an overview of all buffers. For that, emacs provide buffer-menu, normally bound to C-x C-b. It lists all your buffers, and you can interact with them in a way similar to dired, e.g. you can switch to a buffer by moving the point (cursor) to the buffer and pressing Return. Or you mark buffers for deletion by pressing d when point is on the buffer, and then press x to kill them all.

Very useful. But if you really have a lot of buffers, just having a long list of them may still be a bit hard to deal with. For that, there is ibuffer, which allows you to put your buffers in different categories -- which can even overlap. Emacs ships ibuffer since version 22, so you'll probably already have it.

Using a setup like the following, you can put your buffers in categories; each buffer is shown only once (apparently, the first match), and you can match on mode (the Emacs-mode of the buffer), name (the buffer name), filename (the full path to the file being visited, if any), and a couple of others (see EmacsWiki).

(require 'ibuffer) 
(setq ibuffer-saved-filter-groups
  (quote (("default"      
            ("Org" ;; all org-related buffers
              (mode . org-mode))  
              (or  ;; mail-related buffers
               (mode . message-mode)
               (mode . mail-mode)
               ;; etc.; all your mail related modes
              (filename . "src/myproject1/"))
              (filename . "src/myproject2/"))
            ("Programming" ;; prog stuff not already in MyProjectX
                (mode . c-mode)
                (mode . perl-mode)
                (mode . python-mode)
                (mode . emacs-lisp-mode)
                ;; etc
            ("ERC"   (mode . erc-mode))))))

(add-hook 'ibuffer-mode-hook
  (lambda ()
    (ibuffer-switch-to-saved-filter-groups "default")))
If you like ibuffer, you can even override the buffer-menu key binding for
(global-set-key (kbd "C-x C-b") 'ibuffer)
As with buffer-menu, you can do various funky things with those buffers, and also filter them further; see the documentation. I am mostly using it for its buffer-navigational qualities, and it's good at that.


interactive replacement

I recently found an interesting little package called iedit.el, which allows
you to interactive replacements on multiple strings at the same time. That is,
as you do one replace, you can see how all the same matches being replaced as
you type. It's hard to explain in words, you just have to try it out.

So, how to install this package?

  • First, download the package (see the link above)
  • Put it in a directory where emacs can find it; for example,
    ~/.emacs.d/elisp. If you haven't done so already, you can tell emacs to look in that directory by adding to your .emacs:
    (setq load-path (cons "~/emacs.d/elisp/" load-path))
  • Then, tell emacs to load this specific module; you can add
    (require 'iedit)
    to your .emacs to load it (alternatively, you could use the autoload facility)
  • then, define a key binding for this:
    (define-key global-map (kbd "C-;") 'iedit-mode)
  • Now, search for some strings that appears multiple times in your buffer, select it,
    press C-; (Ctrl+;), and watch how all other matching strings are
    changing at the same time.

Very nice.