From 4bcfc7412c16f8ef09ed7eea771b18538ceb8b27 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Mon, 6 Feb 2012 22:48:10 +0000 Subject: [PATCH] [PATCH v2] emacs: Leave blank subjects alone by default. --- 83/623eec1ed1f0b53c88fe4bf01f4ab7e7503009 | 175 ++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 83/623eec1ed1f0b53c88fe4bf01f4ab7e7503009 diff --git a/83/623eec1ed1f0b53c88fe4bf01f4ab7e7503009 b/83/623eec1ed1f0b53c88fe4bf01f4ab7e7503009 new file mode 100644 index 000000000..54d8ffdb0 --- /dev/null +++ b/83/623eec1ed1f0b53c88fe4bf01f4ab7e7503009 @@ -0,0 +1,175 @@ +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 F0D20431FAE + for ; Mon, 6 Feb 2012 14:48:16 -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 JQr78VRo6hQP for ; + Mon, 6 Feb 2012 14:48:16 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 24DE5431FAF + for ; Mon, 6 Feb 2012 14:48:16 -0800 (PST) +Received: by wibhi8 with SMTP id hi8so5233207wib.26 + for ; Mon, 06 Feb 2012 14:48:14 -0800 (PST) +MIME-Version: 1.0 +Received: by 10.180.83.72 with SMTP id o8mr15738278wiy.22.1328568494828; + Mon, 06 Feb 2012 14:48:14 -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 q7sm28301251wix.5.2012.02.06.14.48.12 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 06 Feb 2012 14:48:13 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id AECCDA0484; Mon, 6 Feb 2012 22:48:11 +0000 (GMT) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: Leave blank subjects alone by default. +Date: Mon, 6 Feb 2012 22:48:10 +0000 +Message-Id: <1328568490-18473-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-Gm-Message-State: + ALoCoQnJ5S+zRen+b2BZ+tnZ1DuejA+lTXRrTPrwrOy79c+Lda1w0T4Pgld6f7CNtsPK/ZLcblXV +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 22:48:17 -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. +--- + +Fix the non-string subject case (again, sigh). + + emacs/notmuch-lib.el | 21 ++++++++++++++++++--- + emacs/notmuch-print.el | 4 ++-- + emacs/notmuch-show.el | 2 +- + emacs/notmuch.el | 4 ++-- + 4 files changed, 23 insertions(+), 8 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index d315f76..95e3c29 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,21 @@ 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 (and subject ++ (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