Uday Reddy
2012-10-30 20:51:21 UTC
Here are a couple of tricks for playing with summary lines, which might help
other people in managing their email with similar issues.
You might have noticed that VM has two variables
vm-subject-ignored-prefix
vm-subject-ignored-suffix
These are meant for stripping out prefixes like "Re: " and suffixes like
"(fwd)" that various mail clients add to the subject line. It is the
stripped-out subject string that is used for things like sorting, threading,
making search folders etc.
Here is a somewhat unusual application of these features. I participate in
various research-y discussions on StackExchange and subscribe to some topics
so that I am alerted whenever there is a new question or answer posted.
Unfortunately, StackExchange sends out a summary of posts on a daily basis.
(They don't have anything less frequent.) Once I have subscribed to some 10
topics, my mail box was getting swamped with these alerts. Each alert
message has a subject line like so:
New category-theory questions for Sep 16 - Stack Exchange
So, I thought, why don't I strip out the suffix
"for Sep 16 - StackExchange"
and then all "New category-theory questions" messages will get grouped
together in the Summary window? So, I defined:
(setq vm-subject-ignored-suffix
(concat " for \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)"
" [0-9]* - Stack Exchange\\|"
vm-subject-ignored-suffix))
and reloaded the folder. Bingo, I now have a few hundred lines in the
Summary window rather than thousands, and I get to see the other important
email that was getting swamped out by these alerts.
-----
This second trick might be useful if you get a lot of email via mailing
lists or bug trackers that add "subject tags". For example, the subject
line for a new bug report on the Launchpad looks something like this:
[Bug 1072069] [NEW] summary crashes for international characters (8.1.0)
The stuff in brackets "[Bug 1072069]" and "[NEW]" were added by the
Launchpad mailer. They were not part of the original subject of the bug
report. In our parlance, these are "subject tags".
Given that I allocate something like 25 characters for the subject in my
Summary window, these subject tags were crowding out the real subject. This
problem annoyed me enough that I ended up adding a feature to VM. There is
now a new variable
vm-subject-tag-prefix
using which you can describe the format of the subject tags, and a way to
turn on or off the inclusion of subject tags in the Summary window using a
variable `vm-summary-strip-subject-tags'. My `vm-subject-tag-prefix' is as
follows:
(setq vm-subject-tag-prefix
(concat
"\\[[^]:]*][: \n\t]*" ; mailing-list tags
"\\|bug#[0-9]*:[ \n\t]*" ; emacs debbugs
))
This removes all square-bracketed subject tags and also message from the
Emacs debbugs tracker which uses a different convention for adding its
subject tag.
That was good. But I still wanted the subject tags retained in the INBOX
folders, because the mail comes from a variety of sources and I want to be
able to quickly eyeball it for important stuff. However, once I have filed
away the mail in archival folders, I wanted the subject tags to disappear.
The solution was to make a buffer-local version of the variable
`vm-summary-strip-subject-tags' and turn it on/off based on the name of the
folder. So, I added vm-visit-folder-hook as follows:
(defun retain-subject-tags-for-inbox ()
"Setq `vm-summay-strip-subject-tags' to nil for all IMAP folders
named \"inbox\"."
(when (and vm-folder-access-data (vm-folder-imap-maildrop-spec))
(cond ((equal
(downcase
(vm-imap-folder-for-spec (vm-folder-imap-maildrop-spec)))
"inbox")
(set (make-local-variable 'vm-summary-strip-subject-tags) nil)))))
(add-hook 'vm-visit-folder-hook 'retain-subject-tags-for-inbox)
I think the problem is solved now.
Cheers,
Uday
other people in managing their email with similar issues.
You might have noticed that VM has two variables
vm-subject-ignored-prefix
vm-subject-ignored-suffix
These are meant for stripping out prefixes like "Re: " and suffixes like
"(fwd)" that various mail clients add to the subject line. It is the
stripped-out subject string that is used for things like sorting, threading,
making search folders etc.
Here is a somewhat unusual application of these features. I participate in
various research-y discussions on StackExchange and subscribe to some topics
so that I am alerted whenever there is a new question or answer posted.
Unfortunately, StackExchange sends out a summary of posts on a daily basis.
(They don't have anything less frequent.) Once I have subscribed to some 10
topics, my mail box was getting swamped with these alerts. Each alert
message has a subject line like so:
New category-theory questions for Sep 16 - Stack Exchange
So, I thought, why don't I strip out the suffix
"for Sep 16 - StackExchange"
and then all "New category-theory questions" messages will get grouped
together in the Summary window? So, I defined:
(setq vm-subject-ignored-suffix
(concat " for \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)"
" [0-9]* - Stack Exchange\\|"
vm-subject-ignored-suffix))
and reloaded the folder. Bingo, I now have a few hundred lines in the
Summary window rather than thousands, and I get to see the other important
email that was getting swamped out by these alerts.
-----
This second trick might be useful if you get a lot of email via mailing
lists or bug trackers that add "subject tags". For example, the subject
line for a new bug report on the Launchpad looks something like this:
[Bug 1072069] [NEW] summary crashes for international characters (8.1.0)
The stuff in brackets "[Bug 1072069]" and "[NEW]" were added by the
Launchpad mailer. They were not part of the original subject of the bug
report. In our parlance, these are "subject tags".
Given that I allocate something like 25 characters for the subject in my
Summary window, these subject tags were crowding out the real subject. This
problem annoyed me enough that I ended up adding a feature to VM. There is
now a new variable
vm-subject-tag-prefix
using which you can describe the format of the subject tags, and a way to
turn on or off the inclusion of subject tags in the Summary window using a
variable `vm-summary-strip-subject-tags'. My `vm-subject-tag-prefix' is as
follows:
(setq vm-subject-tag-prefix
(concat
"\\[[^]:]*][: \n\t]*" ; mailing-list tags
"\\|bug#[0-9]*:[ \n\t]*" ; emacs debbugs
))
This removes all square-bracketed subject tags and also message from the
Emacs debbugs tracker which uses a different convention for adding its
subject tag.
That was good. But I still wanted the subject tags retained in the INBOX
folders, because the mail comes from a variety of sources and I want to be
able to quickly eyeball it for important stuff. However, once I have filed
away the mail in archival folders, I wanted the subject tags to disappear.
The solution was to make a buffer-local version of the variable
`vm-summary-strip-subject-tags' and turn it on/off based on the name of the
folder. So, I added vm-visit-folder-hook as follows:
(defun retain-subject-tags-for-inbox ()
"Setq `vm-summay-strip-subject-tags' to nil for all IMAP folders
named \"inbox\"."
(when (and vm-folder-access-data (vm-folder-imap-maildrop-spec))
(cond ((equal
(downcase
(vm-imap-folder-for-spec (vm-folder-imap-maildrop-spec)))
"inbox")
(set (make-local-variable 'vm-summary-strip-subject-tags) nil)))))
(add-hook 'vm-visit-folder-hook 'retain-subject-tags-for-inbox)
I think the problem is solved now.
Cheers,
Uday