From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 239E2431FB6 for ; Sun, 12 Feb 2012 00:50:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 QJj7I8f0jK5w for ; Sun, 12 Feb 2012 00:50:57 -0800 (PST) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 165A8431FAE for ; Sun, 12 Feb 2012 00:50:57 -0800 (PST) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1RwV90-0000EG-37; Sun, 12 Feb 2012 08:50:52 +0000 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1RwV8z-0005jB-HT; Sun, 12 Feb 2012 08:50:49 +0000 From: Mark Walters To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v2] emacs: Leave blank subjects alone by default. In-Reply-To: <1328568490-18473-1-git-send-email-dme@dme.org> References: <1327496913-4946-1-git-send-email-dme@dme.org> <1328568490-18473-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.11.1+172~g6a5d2c5 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Sun, 12 Feb 2012 08:52:08 +0000 Message-ID: <87wr7se8nb.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 94.192.233.223 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 4034b24d4e93177b2872c297aa069a8d (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay * domain * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sun, 12 Feb 2012 08:50:58 -0000 On Mon, 6 Feb 2012 22:48:10 +0000, David Edmondson wrote: > 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))) Hi This LGTM but I wonder whether notmuch-pretty-non-empty-subject should try the defcustom notmuch-blank-subject and only fall back to "no subject" if not set? (Of course then someone will want an option to customise the string in print but not in search....) Best wishes Mark > > ;; > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch