Mutt patches

Editing threads patch

With this patch, Mutt has the ability to dynamically restructure threads that are broken either by misconfigured software or bad behaviour from some correspondents. This allows to clean your mailboxes from these annoyances which make it hard to follow a discussion.

Linking threads

Some mailers tend to "forget" to correctly set the In-Reply-To: and References: headers when replying to a message. This results in broken discussions because the recipient software has not enough information to guess the correct threading.

You can fix this by tagging the reply, then moving to the parent message and using the link-threads function (bound to & by default). The reply will then be connected to this "parent" message.

You can also connect multiple childs at once, tagging them and using the tag-prefix command (';') or the auto_tag option.

Breaking threads

On mailing lists, some people are in the bad habit of starting a new discussion by hitting "reply" to any message from the list and changing the subject to a totally unrelated one.

You can fix such threads by using the break-thread function (bound by default to #), which will turn the subthread starting from the current message into a whole different thread.


  • To use the rethreading functions with IMAP folders, you need to compile Mutt with the --enable-imap-edit-threads configure switch.

Trash folder patch

With this patch, if the trash variable is set to a path (unset by default), the deleted mails will be moved to a trash folder instead of being irremediably purged when syncing the mailbox.

For instance, set trash="~/Mail/trash" will cause every deleted mail to go to this folder.

Note that the append to the trash folder doesn't occur until the resync is done. This allows you to change your mind and undo deletes, and thus the moves to the trash folder are unnecessary.


  • You might also want to have a look at the purge message feature below which is related to this patch.
  • IMAP is now supported. To retain the previous behavior, add this to your muttrc:
    folder-hook ^imap:// 'unset trash'


Every once in a while, someone asks what are the advantages of this patch over a macro based solution. Here's an attempt to answer this question:

  • The folder history doesn't clutter up with unwanted trash entries.
  • Delayed move to the trash allows to change one's mind.
  • No need to treat the case of "normal folders" and trash folders separately with folder-hooks, and to create two sets of macros (one for the index, one for the pager).
  • Works not only with delete-message, but also with every deletion functions like delete-pattern, delete-thread or delete-subthread.

To sum up, it's more integrated and transparent to the user.

My_list patch

This patch adds a new command, my_list, which allows you to create your own (or add to an existing) list of items (single strings or regular expressions). These lists can then be used in ~ patterns, and the following commands: folder-hook, mailboxes, (un)lists and (un)subscribe.

Some examples:

my_list   debian_lists
my_list   debian_lists
my_list   oe_users 

save-hook '~C %debian_lists' +archives/debian
fcc-hook  '~t %debian_lists' +sent/debian

send-hook .                  'unset signature'
send-hook '~C %debian_lists' 'set signature=~/.signature_debian'

send-hook .                  'set pgp_create_traditional=no'
send-hook '~t %oe_users'     'set pgp_create_traditional=yes'

subscribe %debian_lists
my_list   mutt_folders      =mutt_users =mutt_dev =mutt_announce
my_list   debian_folders    =debian_user =debian_devel

mailboxes =inbox %mutt_folders %debian_folders

folder-hook .               'set sort=date'
folder-hook %debian_folders 'set sort=score'
folder-hook %mutt_folders   'set sort=threads'

Signatures menu patch

If you have a large collection of signatures, you might want to be able to easily find the right quote, the one which suits well what you just wrote in your mail. If so, this patch is for you.

First set the signatures_directory option in your ~/.muttrc to the path where the files containing your signatures are located.

For instance:
set signatures_directory="~/.signatures/"

When you call the signatures menu (bound by default to <ESC>s in the compose menu), an index showing the files in this directory appears.

From there, you can use:

When you hit / or <return>, a new menu displays the signatures : you can then select one (possibly at random with r) which will be appended to your mail.

Ifdef patch ("feature hook")

This command allows to test if a feature has been compiled in before actually attempting to configure / use it.


ifdef <item> <command>

where <item> can be the name of a variable or a function.


ifdef  imap-fetch-mail  'source ~/.mutt/imap_setup'
ifdef  trash  set trash=~/Mail/trash

Purge message patch (requires trash folder)

This patch adds the purge-message function, which, unlike delete-message, will bypass the trash folder and really delete the mail.

You can bind this function to <esc>D, for instance, by adding the following lines to your muttrc:

bind index \eD purge-message
bind pager \eD purge-message

Please be very careful with this function, and try to use it as less as possible. The risk resides in getting into the habit of always using purge-message instead of delete-message, which would really defeat the purpose of having a trash folder feature.


Pattern for duplicated messages patch

This patch implements the ~= pattern, which matches the duplicated messages. For this to work, you need the following settings:

set sort=threads
set duplicate_threads=yes


  • This patch has been included in 1.3.26, so you don't need to apply it if you are using a recent Mutt release.

Pattern for broken threads patch

Similar to the previous patch, this one implements the ~# pattern, which matches the messages where threads are broken. This requires:

set sort=threads
unset strict_threads

If you want to bind a key (let's say <esc>#) which will take you to the next broken post, I would suggest these macros:

macro index \e\# "<search>~#<enter>"
macro pager \e\# "<exit><search>~#<enter><display-message>"

Multiple source patch

This patch extends the source command, making it possible to source multiple files at once. For instance,

source ~/.mutt/aliases ~/.mutt/hooks ~/.mutt/colors

One interesting application is that it allows the use of wildcard expansion. Example of use:

source `echo ~/.mutt/*`

to source every file in your ~/.mutt/ directory.

How to apply a patch?

Assuming you've downloaded the patch and the mutt sources in the same directory, just make:

$ gunzip -c mutt-x.y.zi.tar.gz | tar -xvf -    (1)
$ cd mutt-x.y.z
$ patch -p1 < ../patch-x.y.z.name_of_the_patch
$ ./configure    (2)
$ make
$ make update-doc    (3)
$ su -c "make install"

It's that simple!

(1) or simply tar -xvzf mutt-x.y.zi.tar.gz with GNU tar.
(2) ./configure --help for all options. For instance, you may use

$ ./configure --prefix=~/mutt/ --exec-prefix=~/ --sysconfdir=/etc

to install the binaries in ~/bin (then don't forget to add it to your $PATH), the other files in a ~/mutt sub-hierarchy and use the global /etc/Muttrc. Otherwise mutt will be installed in /usr/local.

(3) Optional, but some of these patches include documentation, so you may wish to update your manual.


Some of these patches are already applied by several Linux and BSD vendors. Here's a list for some I'm aware of:

What's new?

© Cedric Duval  

Valid XHTML 1.0!