summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2012-10-01 10:40:26 +0200
committerJani Nikula <jani@nikula.org>2012-10-01 10:40:26 +0200
commit3b430fc8fb45f08ad64e5efc4613e0346f76e0f7 (patch)
tree81ba0a5184d2d36ebdcc8147475b2a8e69e2ff99
parentcc2a074c714f142a1ea6f62583d111575fb95995 (diff)
emacs tip: replace tabs with spaces in subject and header
-rw-r--r--emacstips.mdwn27
1 files changed, 27 insertions, 0 deletions
diff --git a/emacstips.mdwn b/emacstips.mdwn
index e63ab31..2cc8aac 100644
--- a/emacstips.mdwn
+++ b/emacstips.mdwn
@@ -579,3 +579,30 @@ buffer.
(setq notmuch-hello-refresh-count new-count))))
(add-hook 'notmuch-hello-refresh-hook 'notmuch-hello-refresh-status-message)
+
+## Replacing tabs with spaces in subject and header
+
+Mailman mailing list software rewrites and rewraps long message subjects in
+a way that causes TABs to appear in the middle of the subject and header
+lines. Add this to your .emacs to replace tabs with spaces in subject
+lines:
+
+ (defun notmuch-show-subject-tabs-to-spaces ()
+ "Replace tabs with spaces in subject line."
+ (goto-char (point-min))
+ (when (re-search-forward "^Subject:" nil t)
+ (while (re-search-forward "\t" (line-end-position) t)
+ (replace-match " " nil nil))))
+
+ (add-hook 'notmuch-show-markup-headers-hook 'notmuch-show-subject-tabs-to-spaces)
+
+And in header lines (this will only work with the yet to be released
+notmuch version 0.15):
+
+ (defun notmuch-show-header-tabs-to-spaces ()
+ "Replace tabs with spaces in header line."
+ (setq header-line-format
+ (notmuch-show-strip-re
+ (replace-regexp-in-string "\t" " " (notmuch-show-get-subject)))))
+
+ (add-hook 'notmuch-show-hook 'notmuch-show-header-tabs-to-spaces)