Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C023B431E84 for ; Wed, 25 Jan 2012 05:48:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4J1xtZSQl3pU for ; Wed, 25 Jan 2012 05:48:41 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id EBFCA431FBC for ; Wed, 25 Jan 2012 05:48:40 -0800 (PST) Received: by wgbdt12 with SMTP id dt12so4808711wgb.2 for ; Wed, 25 Jan 2012 05:48:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.80.68 with SMTP id p4mr7402594wix.21.1327499319700; Wed, 25 Jan 2012 05:48:39 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id m8sm1603917wia.11.2012.01.25.05.48.37 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jan 2012 05:48:38 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 205569FF26; Wed, 25 Jan 2012 13:48:36 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects. Date: Wed, 25 Jan 2012 13:48:34 +0000 Message-Id: <1327499314-7887-4-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327499314-7887-1-git-send-email-dme@dme.org> References: <1327496913-4946-1-git-send-email-dme@dme.org> <1327499314-7887-1-git-send-email-dme@dme.org> X-Gm-Message-State: ALoCoQmXJJoAuC69naV/UWVKiehNgFoW/D2mSP9FOIOcxf2Bsq0SbGRVtUN+wH+g6IMVi6QoZgLe X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jan 2012 13:48:42 -0000 --- emacs/notmuch-lib.el | 6 ++++++ emacs/notmuch-print.el | 8 ++++++-- emacs/notmuch-show.el | 5 ++++- emacs/notmuch.el | 5 +---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 241fe8c..5b8a41c 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -130,6 +130,12 @@ the user hasn't set this variable with the old or new value." (interactive) (kill-buffer (current-buffer))) +(defun notmuch-prettify-subject (subject) + (if (and subject + (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 +(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