mutt

Mutt Tip: Safe Delete

27 Mar 2008, posted on mutt

Update (Mar 27, 2008): I discovered that the previous version of these macros did not not work with collapsed threads. I’ve updated the code and now it should work under all cases.

In its default configuration, mutt behaves as man’s best friend and does what it is told without any further question. Press the “D” key and down the drain goes your email. No way out.

To solve this problem, edit your .muttrc file and add the following:

## Safe deletion macros apply for all folders, EXCEPT the 'deleted' folder.
## "Y" is set to 'unsafe delete' (useful over slow imap links).
## Also note the slight difference between 'index' and 'pager' for thread
## delete. The "\ni" will cause mutt to briefly switch to pager mode and
## back to index, causing the thread to uncollapse. It's a trick but as
## a trick goes, it works really well (for me, at least) :)

bind  index   y   delete-message
bind  pager   y   delete-message

folder-hook . 'macro index d  <copy-message>=deleted\ny<delete-message>  "Safe Delete"'
folder-hook . 'macro pager d  <copy-message>=deleted\ny<delete-message>  "Safe Delete"'
folder-hook . 'macro index \ed \ni<tag-thread><copy-message>=deleted\ny<delete-message> "Safe delete Thread"'
folder-hook . 'macro pager \ed <tag-thread><copy-message>=deleted\ny<delete-message>    "Safe delete Thread"'

## Really erase if we're using the 'deleted' mail folder.

folder-hook 'deleted' 'macro index d   <delete-message> "Delete Message"'
folder-hook 'deleted' 'macro index \ed <delete-thread>  "Delete Thread"'
folder-hook 'deleted' 'macro pager d   <delete-message> "Delete Message"'
folder-hook 'deleted' 'macro pager d   <delete-message> "Delete Message"'

From this glorious moment on, pressing “D” will no longer delete messages, but rather move them to a mail folder called deleted. The same applies for Control-D, which moves entire threads to that folder.

If you want to permanently delete a message, bypassing all the chicanery described above, just use the “Y” key.


[Permalink] | [Digg Me] | [Add to del.icio.us] | [Submit to reddit] | [Submit to ma.gnolia.com] | [Submit to FURL]

[ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 ] next ->>