[PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

David Edmondson dme at dme.org
Wed Jan 25 05:08:33 PST 2012


---
 emacs/notmuch-lib.el   |    5 +++++
 emacs/notmuch-print.el |    8 ++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |    5 +----
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..de33575 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,11 @@ the user hasn't set this variable with the old or new value."
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-prettify-subject (subject)
+  (if (string-match "^[ \t]*$" subject)
+      (setq subject "[No Subject]"))
+  subject)
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index 83eb525..51bb740 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: David Edmondson <dme at dme.org>
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-print-mechanism 'notmuch-print-lpr
   "How should printing be done?"
   :group 'notmuch
@@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to muttprint."
 
 (defun notmuch-print-ps-print (msg)
   "Print a message buffer using the ps-print package."
-  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+  (let ((subject (notmuch-prettify-subject
+		  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer)))
 
 (defun notmuch-print-ps-print/evince (msg)
   "Preview a message buffer using ps-print and evince."
   (let ((ps-file (make-temp-file "notmuch"))
-	(subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+	(subject (notmuch-prettify-subject
+		  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer ps-file)
     (notmuch-print-run-evince ps-file)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..c602b3e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -985,7 +985,7 @@ buffer."
       (notmuch-show-next-open-message))
 
     ;; Set the header line to the subject of the first open message.
-    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
+    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
 
     (notmuch-show-mark-read)))
 
@@ -1216,6 +1216,9 @@ Some useful entries are:
 (defun notmuch-show-get-depth ()
   (notmuch-show-get-prop :depth))
 
+(defun notmuch-show-get-pretty-subject ()
+  (notmuch-prettify-subject (notmuch-show-get-subject)))
+
 (defun notmuch-show-set-tags (tags)
   "Set the tags of the current message."
   (notmuch-show-set-prop :tags tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3f6b977..ce1e232 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -440,10 +440,7 @@ Complete list of currently available key bindings:
   "Display the currently selected thread."
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id))
-	(subject (notmuch-search-find-subject)))
-
-    (if (string-match "^[ \t]*$" subject)
-	(setq subject "[No Subject]"))
+	(subject (notmuch-prettify-subject (notmuch-search-find-subject))))
 
     (if (> (length thread-id) 0)
 	(notmuch-show thread-id
-- 
1.7.8.3



More information about the notmuch mailing list