unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2] emacs: Leave blank subjects alone by default.
Date: Sun, 12 Feb 2012 08:52:08 +0000	[thread overview]
Message-ID: <87wr7se8nb.fsf@qmul.ac.uk> (raw)
In-Reply-To: <1328568490-18473-1-git-send-email-dme@dme.org>

On Mon,  6 Feb 2012 22:48:10 +0000, David Edmondson <dme@dme.org> 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

      reply	other threads:[~2012-02-12  8:50 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25 13:08 [PATCH 0/3] minor cleanup and improvements David Edmondson
2012-01-25 13:08 ` [PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness David Edmondson
2012-01-25 13:08 ` [PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing David Edmondson
2012-01-25 13:08 ` [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects David Edmondson
2012-01-25 13:13   ` David Edmondson
2012-01-25 13:48 ` [PATCH 0/3 v2] minor cleanup and improvements David Edmondson
2012-01-25 13:48   ` [PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness David Edmondson
2012-01-28  5:09     ` Austin Clements
2012-01-30  9:16       ` David Edmondson
2012-01-25 13:48   ` [PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing David Edmondson
2012-01-27 12:04     ` David Bremner
2012-01-27 12:05     ` David Bremner
2012-01-25 13:48   ` [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects David Edmondson
     [not found]     ` <874nvh5tro.fsf@qmul.ac.uk>
2012-01-27 10:28       ` David Edmondson
2012-01-27 13:31         ` Mark Walters
2012-01-27 13:39           ` David Edmondson
2012-01-27 10:32     ` Mark Walters
2012-01-28  5:22     ` Austin Clements
2012-01-27  9:26   ` [PATCH 0/3 v2] minor cleanup and improvements David Edmondson
2012-01-30 10:15 ` [PATCH 0/2 " David Edmondson
2012-01-30 10:16   ` [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness David Edmondson
2012-01-30 23:46     ` Austin Clements
2012-01-31  6:15       ` David Edmondson
2012-01-30 10:16   ` [PATCH 2/2 v2] emacs: Prefer '[No Subject]' to blank subjects David Edmondson
2012-01-30 23:48     ` Austin Clements
2012-02-06  7:07     ` Jameson Graef Rollins
2012-02-06  7:47       ` David Edmondson
2012-02-06  8:06         ` Jameson Graef Rollins
2012-02-06  8:56           ` David Edmondson
2012-02-06 19:19             ` Jameson Graef Rollins
2012-02-06 19:34               ` David Edmondson
2012-02-06 19:50       ` Antoine Beaupré
2012-02-28  1:52     ` David Bremner
2012-01-30 10:18   ` [PATCH 0/2 v2] minor cleanup and improvements David Edmondson
2012-02-04 12:39   ` David Bremner
2012-02-06 21:30 ` [PATCH] emacs: Leave blank subjects alone by default David Edmondson
2012-02-12 20:51   ` Jameson Graef Rollins
2012-02-06 22:48 ` [PATCH v2] " David Edmondson
2012-02-12  8:52   ` Mark Walters [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wr7se8nb.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).