[PATCH] emacs: Leave blank subjects alone by default.
[notmuch-archives.git] / 97 / f747bf276ca549265722f3f4c6b49d0aaee767
diff --git a/97/f747bf276ca549265722f3f4c6b49d0aaee767 b/97/f747bf276ca549265722f3f4c6b49d0aaee767
new file mode 100644 (file)
index 0000000..ec8b83b
--- /dev/null
@@ -0,0 +1,168 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id DA631431FAF\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Feb 2012 13:30:24 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 7Q2ER3I7K1Be for <notmuch@notmuchmail.org>;\r
+       Mon,  6 Feb 2012 13:30:24 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 18EA5431FAE   for <notmuch@notmuchmail.org>; Mon,  6 Feb 2012 13:30:23 -0800\r
+ (PST)\r
+Received: by wgbdt12 with SMTP id dt12so5834144wgb.2\r
+       for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 13:30:22 -0800 (PST)\r
+Received: by 10.180.81.35 with SMTP id w3mr29907332wix.10.1328563822545;\r
+       Mon, 06 Feb 2012 13:30:22 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+       (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+       by mx.google.com with ESMTPS id l8sm50143014wiy.5.2012.02.06.13.30.20\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 06 Feb 2012 13:30:21 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+       id 55DC1A0484; Mon,  6 Feb 2012 21:30:19 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Leave blank subjects alone by default.\r
+Date: Mon,  6 Feb 2012 21:30:16 +0000\r
+Message-Id: <1328563816-12960-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1327496913-4946-1-git-send-email-dme@dme.org>\r
+References: <1327496913-4946-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Feb 2012 21:30:25 -0000\r
+\r
+Add `notmuch-blank-subject' to control how empty or whitespace only\r
+subjects are treated. The default behaviour is to leave them\r
+alone. The user can choose a string to use as a replacement.\r
+\r
+Modify code that cannot handle blank subjects to use a fixed string.\r
+---\r
+ emacs/notmuch-lib.el   |   20 +++++++++++++++++---\r
+ emacs/notmuch-print.el |    4 ++--\r
+ emacs/notmuch-show.el  |    2 +-\r
+ emacs/notmuch.el       |    4 ++--\r
+ 4 files changed, 22 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index d315f76..2edc868 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -67,6 +67,13 @@\r
+   :type 'boolean\r
+   :group 'notmuch-search)\r
\r
++(defcustom notmuch-blank-subject nil\r
++  "How should subjects that are empty or whitespace only be\r
++treated?"\r
++  :type '(choice (const :tag "Leave them alone" nil)\r
++               (string :tag "Replacement string" "[No Subject]"))\r
++  :group 'notmuch)\r
++\r
+ ;;\r
\r
+ (defvar notmuch-search-history nil\r
+@@ -133,13 +140,20 @@ the user hasn't set this variable with the old or new value."\r
+   (interactive)\r
+   (kill-buffer (current-buffer)))\r
\r
+-(defun notmuch-prettify-subject (subject)\r
++(defun notmuch-pretty-non-empty-subject (subject)\r
++  (let ((subject (notmuch-pretty-subject subject)))\r
++    (if (string-match "^[ \t]*$" subject)\r
++      "no subject"\r
++      subject)))\r
++\r
++(defun notmuch-pretty-subject (subject)\r
+   ;; This function is used by `notmuch-search-process-filter' which\r
+   ;; requires that we not disrupt its' matching state.\r
+   (save-match-data\r
+-    (if (and subject\r
++    (if (and (stringp notmuch-blank-subject)\r
++           subject\r
+            (string-match "^[ \t]*$" subject))\r
+-      "[No Subject]"\r
++      notmuch-blank-subject\r
+       subject)))\r
\r
+ ;;\r
+diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el\r
+index 6653d97..dda082a 100644\r
+--- a/emacs/notmuch-print.el\r
++++ b/emacs/notmuch-print.el\r
+@@ -60,7 +60,7 @@ Optional OUTPUT allows passing a list of flags to muttprint."\r
\r
+ (defun notmuch-print-ps-print (msg)\r
+   "Print a message buffer using the ps-print package."\r
+-  (let ((subject (notmuch-prettify-subject\r
++  (let ((subject (notmuch-pretty-non-empty-subject\r
+                 (plist-get (notmuch-show-get-prop :headers msg) :Subject))))\r
+     (rename-buffer subject t)\r
+     (ps-print-buffer)))\r
+@@ -68,7 +68,7 @@ Optional OUTPUT allows passing a list of flags to muttprint."\r
+ (defun notmuch-print-ps-print/evince (msg)\r
+   "Preview a message buffer using ps-print and evince."\r
+   (let ((ps-file (make-temp-file "notmuch"))\r
+-      (subject (notmuch-prettify-subject\r
++      (subject (notmuch-pretty-non-empty-subject\r
+                 (plist-get (notmuch-show-get-prop :headers msg) :Subject))))\r
+     (rename-buffer subject t)\r
+     (ps-print-buffer ps-file)\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 7469e2e..4a23cc2 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1261,7 +1261,7 @@ Some useful entries are:\r
+   (notmuch-show-get-prop :depth))\r
\r
+ (defun notmuch-show-get-pretty-subject ()\r
+-  (notmuch-prettify-subject (notmuch-show-get-subject)))\r
++  (notmuch-pretty-subject (notmuch-show-get-subject)))\r
\r
+ (defun notmuch-show-set-tags (tags)\r
+   "Set the tags of the current message."\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index cd04ffd..aab6946 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -467,7 +467,7 @@ Complete list of currently available key bindings:\r
+   "Display the currently selected thread."\r
+   (interactive "P")\r
+   (let ((thread-id (notmuch-search-find-thread-id))\r
+-      (subject (notmuch-prettify-subject (notmuch-search-find-subject))))\r
++      (subject (notmuch-pretty-non-empty-subject (notmuch-search-find-subject))))\r
+     (if (> (length thread-id) 0)\r
+       (notmuch-show thread-id\r
+                     (current-buffer)\r
+@@ -850,7 +850,7 @@ non-authors is found, assume that all of the authors match."\r
+                         (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n")))\r
+                     (let ((beg (point)))\r
+                       (notmuch-search-show-result date count authors\r
+-                                                  (notmuch-prettify-subject subject) tags)\r
++                                                  (notmuch-pretty-subject subject) tags)\r
+                       (notmuch-search-color-line beg (point) tag-list)\r
+                       (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
+                       (put-text-property beg (point) 'notmuch-search-authors authors)\r
+-- \r
+1.7.8.3\r
+\r