From 3d16da720e0ae9e5d4c8987b317fb7f25e46bc56 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Mon, 6 Feb 2012 21:30:16 +0000 Subject: [PATCH] [PATCH] emacs: Leave blank subjects alone by default. --- 97/f747bf276ca549265722f3f4c6b49d0aaee767 | 168 ++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 97/f747bf276ca549265722f3f4c6b49d0aaee767 diff --git a/97/f747bf276ca549265722f3f4c6b49d0aaee767 b/97/f747bf276ca549265722f3f4c6b49d0aaee767 new file mode 100644 index 000000000..ec8b83ba7 --- /dev/null +++ b/97/f747bf276ca549265722f3f4c6b49d0aaee767 @@ -0,0 +1,168 @@ +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 DA631431FAF + for ; Mon, 6 Feb 2012 13:30:24 -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 7Q2ER3I7K1Be for ; + Mon, 6 Feb 2012 13:30:24 -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 + 18EA5431FAE for ; Mon, 6 Feb 2012 13:30:23 -0800 + (PST) +Received: by wgbdt12 with SMTP id dt12so5834144wgb.2 + for ; Mon, 06 Feb 2012 13:30:22 -0800 (PST) +Received: by 10.180.81.35 with SMTP id w3mr29907332wix.10.1328563822545; + Mon, 06 Feb 2012 13:30:22 -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 l8sm50143014wiy.5.2012.02.06.13.30.20 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 06 Feb 2012 13:30:21 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id 55DC1A0484; Mon, 6 Feb 2012 21:30:19 +0000 (GMT) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: Leave blank subjects alone by default. +Date: Mon, 6 Feb 2012 21:30:16 +0000 +Message-Id: <1328563816-12960-1-git-send-email-dme@dme.org> +X-Mailer: git-send-email 1.7.8.3 +In-Reply-To: <1327496913-4946-1-git-send-email-dme@dme.org> +References: <1327496913-4946-1-git-send-email-dme@dme.org> +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: Mon, 06 Feb 2012 21:30:25 -0000 + +Add `notmuch-blank-subject' to control how empty or whitespace only +subjects are treated. The default behaviour is to leave them +alone. The user can choose a string to use as a replacement. + +Modify code that cannot handle blank subjects to use a fixed string. +--- + emacs/notmuch-lib.el | 20 +++++++++++++++++--- + emacs/notmuch-print.el | 4 ++-- + emacs/notmuch-show.el | 2 +- + emacs/notmuch.el | 4 ++-- + 4 files changed, 22 insertions(+), 8 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index d315f76..2edc868 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -67,6 +67,13 @@ + :type 'boolean + :group 'notmuch-search) + ++(defcustom notmuch-blank-subject nil ++ "How should subjects that are empty or whitespace only be ++treated?" ++ :type '(choice (const :tag "Leave them alone" nil) ++ (string :tag "Replacement string" "[No Subject]")) ++ :group 'notmuch) ++ + ;; + + (defvar notmuch-search-history nil +@@ -133,13 +140,20 @@ the user hasn't set this variable with the old or new value." + (interactive) + (kill-buffer (current-buffer))) + +-(defun notmuch-prettify-subject (subject) ++(defun notmuch-pretty-non-empty-subject (subject) ++ (let ((subject (notmuch-pretty-subject subject))) ++ (if (string-match "^[ \t]*$" subject) ++ "no subject" ++ subject))) ++ ++(defun notmuch-pretty-subject (subject) + ;; This function is used by `notmuch-search-process-filter' which + ;; requires that we not disrupt its' matching state. + (save-match-data +- (if (and subject ++ (if (and (stringp notmuch-blank-subject) ++ subject + (string-match "^[ \t]*$" subject)) +- "[No Subject]" ++ notmuch-blank-subject + subject))) + + ;; +diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el +index 6653d97..dda082a 100644 +--- a/emacs/notmuch-print.el ++++ b/emacs/notmuch-print.el +@@ -60,7 +60,7 @@ 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 (notmuch-prettify-subject ++ (let ((subject (notmuch-pretty-non-empty-subject + (plist-get (notmuch-show-get-prop :headers msg) :Subject)))) + (rename-buffer subject t) + (ps-print-buffer))) +@@ -68,7 +68,7 @@ Optional OUTPUT allows passing a list of flags to muttprint." + (defun notmuch-print-ps-print/evince (msg) + "Preview a message buffer using ps-print and evince." + (let ((ps-file (make-temp-file "notmuch")) +- (subject (notmuch-prettify-subject ++ (subject (notmuch-pretty-non-empty-subject + (plist-get (notmuch-show-get-prop :headers msg) :Subject)))) + (rename-buffer subject t) + (ps-print-buffer ps-file) +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 7469e2e..4a23cc2 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1261,7 +1261,7 @@ Some useful entries are: + (notmuch-show-get-prop :depth)) + + (defun notmuch-show-get-pretty-subject () +- (notmuch-prettify-subject (notmuch-show-get-subject))) ++ (notmuch-pretty-subject (notmuch-show-get-subject))) + + (defun notmuch-show-set-tags (tags) + "Set the tags of the current message." +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index cd04ffd..aab6946 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -467,7 +467,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-prettify-subject (notmuch-search-find-subject)))) ++ (subject (notmuch-pretty-non-empty-subject (notmuch-search-find-subject)))) + (if (> (length thread-id) 0) + (notmuch-show thread-id + (current-buffer) +@@ -850,7 +850,7 @@ non-authors is found, assume that all of the authors match." + (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n"))) + (let ((beg (point))) + (notmuch-search-show-result date count authors +- (notmuch-prettify-subject subject) tags) ++ (notmuch-pretty-subject subject) tags) + (notmuch-search-color-line beg (point) tag-list) + (put-text-property beg (point) 'notmuch-search-thread-id thread-id) + (put-text-property beg (point) 'notmuch-search-authors authors) +-- +1.7.8.3 + -- 2.26.2