* [PATCH] emacs: Show cleaner addresses during message display. @ 2010-11-05 15:04 David Edmondson 2010-11-09 17:34 ` David Edmondson 0 siblings, 1 reply; 9+ messages in thread From: David Edmondson @ 2010-11-05 15:04 UTC (permalink / raw) To: notmuch Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to "foo@bar.com". --- emacs/notmuch-show.el | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 07cf846..2838968 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -26,6 +26,7 @@ (require 'message) (require 'mm-decode) (require 'mailcap) +(require 'mail-parse) (require 'notmuch-lib) (require 'notmuch-query) @@ -204,12 +205,26 @@ same as that of the previous message." 'face 'notmuch-tag-face) ")")))))) +(defun notmuch-show-clean-address (parsed-address) + "Clean a single email address for display." + (let ((address (car parsed-address)) + (name (cdr parsed-address))) + ;; If the address is 'foo@bar.com <foo@bar.com>' then show just + ;; 'foo@bar.com'. + (when (string= name address) + (setq name nil)) + + (if (not name) + address + (concat name " <" address ">")))) + (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." (let ((start (point))) (insert (notmuch-show-spaces-n depth) - (plist-get headers :From) + (notmuch-show-clean-address + (mail-header-parse-address (plist-get headers :From))) " (" date ") (" @@ -220,7 +235,18 @@ message at DEPTH in the current thread." (defun notmuch-show-insert-header (header header-value) "Insert a single header." - (insert header ": " header-value "\n")) + (insert header ": " + (cond + ((or (string= "To" header) + (string= "Cc" header) + (string= "Bcc" header) + (string= "From" header)) + (mapconcat 'notmuch-show-clean-address + (mail-header-parse-addresses header-value) + ", ")) + (t + header-value)) + "\n")) (defun notmuch-show-insert-headers (headers) "Insert the headers of the current message." -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] emacs: Show cleaner addresses during message display. 2010-11-05 15:04 [PATCH] emacs: Show cleaner addresses during message display David Edmondson @ 2010-11-09 17:34 ` David Edmondson 2010-11-09 20:53 ` Jameson Rollins 0 siblings, 1 reply; 9+ messages in thread From: David Edmondson @ 2010-11-09 17:34 UTC (permalink / raw) To: notmuch Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to "foo@bar.com". If the address is of the form "name <foo@bar.com>", show only 'name' with a tooltip of the address. --- More aggressive simplification and tooltips. emacs/notmuch-show.el | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9e5d72d..098146b 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -26,6 +26,7 @@ (require 'message) (require 'mm-decode) (require 'mailcap) +(require 'mail-parse) (require 'notmuch-lib) (require 'notmuch-query) @@ -198,12 +199,25 @@ any given message." 'face 'notmuch-tag-face) ")")))))) +(defun notmuch-show-clean-address (parsed-address) + "Prepare a single email address for display." + (let ((address (car parsed-address)) + (name (cdr parsed-address))) + ;; If the address is 'foo@bar.com <foo@bar.com>' then show just + ;; 'foo@bar.com'. + (when (string= name address) + (setq name nil)) + (if name + (propertize name 'help-echo address) + address))) + (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." (let ((start (point))) (insert (notmuch-show-spaces-n depth) - (plist-get headers :From) + (notmuch-show-clean-address + (mail-header-parse-address (plist-get headers :From))) " (" date ") (" @@ -214,7 +228,18 @@ message at DEPTH in the current thread." (defun notmuch-show-insert-header (header header-value) "Insert a single header." - (insert header ": " header-value "\n")) + (insert header ": " + (cond + ((or (string= "To" header) + (string= "Cc" header) + (string= "Bcc" header) + (string= "From" header)) + (mapconcat 'notmuch-show-clean-address + (mail-header-parse-addresses header-value) + ", ")) + (t + header-value)) + "\n")) (defun notmuch-show-insert-headers (headers) "Insert the headers of the current message." -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: Show cleaner addresses during message display. 2010-11-09 17:34 ` David Edmondson @ 2010-11-09 20:53 ` Jameson Rollins 2010-11-10 7:20 ` Sebastian Spaeth 0 siblings, 1 reply; 9+ messages in thread From: Jameson Rollins @ 2010-11-09 20:53 UTC (permalink / raw) To: David Edmondson, notmuch [-- Attachment #1: Type: text/plain, Size: 616 bytes --] On Tue, 9 Nov 2010 17:34:50 +0000, David Edmondson <dme@dme.org> wrote: > Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to > "foo@bar.com". If the address is of the form "name <foo@bar.com>", > show only 'name' with a tooltip of the address. Hi, David. I am personally not interested in this collapse for a couple of reasons. I really like seeing the full address that the mail comes from. I also don't like tooltips since I don't like using the mouse. Is it possible to make this particular feature an option? I actually frequently yank this whole line to ease filling my address book. jamie. [-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: Show cleaner addresses during message display. 2010-11-09 20:53 ` Jameson Rollins @ 2010-11-10 7:20 ` Sebastian Spaeth 2010-11-10 8:27 ` David Edmondson 0 siblings, 1 reply; 9+ messages in thread From: Sebastian Spaeth @ 2010-11-10 7:20 UTC (permalink / raw) To: Jameson Rollins, David Edmondson, notmuch [-- Attachment #1: Type: text/plain, Size: 981 bytes --] On Tue, 09 Nov 2010 15:53:49 -0500, Jameson Rollins wrote: > Hi, David. I am personally not interested in this collapse for a couple > of reasons. I really like seeing the full address that the mail comes > from. But what is the added benefit of "me@foo.com" <me@foo.com> over me@foo.com ? This is essentially a nonsense name that can just as well be left out... > I also don't like tooltips since I don't like using the mouse. > Is it possible to make this particular feature an option? If you don't use a mouse, how does the existence of tooltips annoy you? > I actually frequently yank this whole line to ease filling my address > book. But what is the point of having "me@foo.com" <me@foo.com> in your address book, can't you just as well say "me@foo.com" without loosing information? Anyway, I don't care strongly either way. I have just gotten very careful in adding new preferences rather than setting sensible defaults :). Sebastian [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: Show cleaner addresses during message display. 2010-11-10 7:20 ` Sebastian Spaeth @ 2010-11-10 8:27 ` David Edmondson 2010-11-10 9:17 ` Sebastian Spaeth 2010-11-10 9:23 ` David Edmondson 0 siblings, 2 replies; 9+ messages in thread From: David Edmondson @ 2010-11-10 8:27 UTC (permalink / raw) To: Sebastian Spaeth, Jameson Rollins, notmuch On Wed, 10 Nov 2010 08:20:29 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote: > On Tue, 09 Nov 2010 15:53:49 -0500, Jameson Rollins wrote: > > Hi, David. I am personally not interested in this collapse for a couple > > of reasons. I really like seeing the full address that the mail comes > > from. > But what is the added benefit of > "me@foo.com" <me@foo.com> > over > me@foo.com > ? This is essentially a nonsense name that can just as well be left > out... > > > I also don't like tooltips since I don't like using the mouse. > > Is it possible to make this particular feature an option? > > If you don't use a mouse, how does the existence of tooltips annoy you? > > > I actually frequently yank this whole line to ease filling my address > > book. > > But what is the point of having "me@foo.com" <me@foo.com> in your > address book, can't you just as well say "me@foo.com" without loosing > information? The latest change goes further - for an address such as: Fred Blogs <fred@fredco.com> it will display only "Fred Blogs". It's to this that Jameson is objecting. I'll update the patch such that you can choose, with the default being the maximum simplification. dme. -- David Edmondson, http://dme.org ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: Show cleaner addresses during message display. 2010-11-10 8:27 ` David Edmondson @ 2010-11-10 9:17 ` Sebastian Spaeth 2010-11-10 9:23 ` David Edmondson 1 sibling, 0 replies; 9+ messages in thread From: Sebastian Spaeth @ 2010-11-10 9:17 UTC (permalink / raw) To: David Edmondson, Jameson Rollins, notmuch On Wed, 10 Nov 2010 08:27:08 +0000, David Edmondson <dme@dme.org> wrote: > The latest change goes further - for an address such as: > Fred Blogs <fred@fredco.com> > it will display only "Fred Blogs". It's to this that Jameson is objecting. Ohh, I see. Sorry then. I can see that someone wants to retain that. Addressbooks are so 20th century anyway, I have notmuch-based address lookup :). Sebastian ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] emacs: Show cleaner addresses during message display. 2010-11-10 8:27 ` David Edmondson 2010-11-10 9:17 ` Sebastian Spaeth @ 2010-11-10 9:23 ` David Edmondson 2010-11-12 1:14 ` Carl Worth 1 sibling, 1 reply; 9+ messages in thread From: David Edmondson @ 2010-11-10 9:23 UTC (permalink / raw) To: notmuch Simplify the display of addresses by setting `notmuch-show-address-simplication' to: - 'full: Only the name component of the address, if present, is shown (the default), - 'partial: Addresses are stripped of redundant information, - 'none: Addresses are shown as-is. --- emacs/notmuch-show.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9e5d72d..054aba1 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -26,6 +26,7 @@ (require 'message) (require 'mm-decode) (require 'mailcap) +(require 'mail-parse) (require 'notmuch-lib) (require 'notmuch-query) @@ -82,6 +83,21 @@ any given message." notmuch-wash-elide-blank-lines notmuch-wash-excerpt-citations)) +(defcustom notmuch-show-address-simplification 'full + "How should addresses be displayed? + +Set `notmuch-show-address-simplication' to: + +- 'full: Only the name component of the address, if present, is + shown, +- 'partial: Addresses are stripped of redundant information, +- 'none: Addresses are shown as-is." + :group 'notmuch + :type '(choice + (const :tag "Full simplification" full) + (const :tag "Partial simplification" partial) + (const :tag "No simplification" none))) + (defmacro with-current-notmuch-show-message (&rest body) "Evaluate body with current buffer set to the text of current message" `(save-excursion @@ -198,12 +214,36 @@ any given message." 'face 'notmuch-tag-face) ")")))))) +(defun notmuch-show-clean-address (parsed-address) + "Prepare a single email address for display." + (let* ((address (car parsed-address)) + (name (cdr parsed-address)) + (displayed-name name)) + + ;; If the address is 'foo@bar.com <foo@bar.com>' then show just + ;; 'foo@bar.com'. + (when (string= displayed-name address) + (setq displayed-name nil)) + + (cond + ((eq notmuch-show-address-simplification 'full) + (if displayed-name + (propertize displayed-name 'help-echo address) + address)) + + ((eq notmuch-show-address-simplification 'partial) + (mail-header-make-address displayed-name address)) + + (t ;; All other settings, but mostly 'none. + (mail-header-make-address name address))))) + (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." (let ((start (point))) (insert (notmuch-show-spaces-n depth) - (plist-get headers :From) + (notmuch-show-clean-address + (mail-header-parse-address (plist-get headers :From))) " (" date ") (" @@ -214,7 +254,18 @@ message at DEPTH in the current thread." (defun notmuch-show-insert-header (header header-value) "Insert a single header." - (insert header ": " header-value "\n")) + (insert header ": " + (cond + ((or (string= "To" header) + (string= "Cc" header) + (string= "Bcc" header) + (string= "From" header)) + (mapconcat 'notmuch-show-clean-address + (mail-header-parse-addresses header-value) + ", ")) + (t + header-value)) + "\n")) (defun notmuch-show-insert-headers (headers) "Insert the headers of the current message." -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: Show cleaner addresses during message display. 2010-11-10 9:23 ` David Edmondson @ 2010-11-12 1:14 ` Carl Worth 2010-11-12 7:58 ` David Edmondson 0 siblings, 1 reply; 9+ messages in thread From: Carl Worth @ 2010-11-12 1:14 UTC (permalink / raw) To: David Edmondson, notmuch [-- Attachment #1: Type: text/plain, Size: 1140 bytes --] On Wed, 10 Nov 2010 09:23:07 +0000, David Edmondson <dme@dme.org> wrote: > Simplify the display of addresses by setting > `notmuch-show-address-simplication' to: > > - 'full: Only the name component of the address, if present, is > shown (the default), > - 'partial: Addresses are stripped of redundant information, > - 'none: Addresses are shown as-is. Now that we've got emacs-based testing, this change needs to update the test suite as well. Personally, I like to see email addresses, and I think that's a sane default, so I'd actually prefer 'partial as the default setting here. I tried changing that and hoped that that would let me not even update the test suite. But then I found that comapred to the current state, adding this patch actually adds unnecessary double-quotation marks around user's names. That's annoying. Can we get that cleaned up? Meanwhile, I just pushed your three patches for cleaning up the display of subjects[*]. So, thanks! -Carl [*] None of these needed test-suite changes, which actually just points out holes in our test suite here. -- carl.d.worth@intel.com [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] emacs: Show cleaner addresses during message display. 2010-11-12 1:14 ` Carl Worth @ 2010-11-12 7:58 ` David Edmondson 0 siblings, 0 replies; 9+ messages in thread From: David Edmondson @ 2010-11-12 7:58 UTC (permalink / raw) To: notmuch Simplify the display of addresses by setting `notmuch-show-address-simplication' to: - 'full: Only the name component of the address, if present, is shown, - 'partial: Addresses are stripped of redundant information (the default), - 'none: Addresses are shown as-is. `mail-header-parse-address' fails for some addresses, in particular "undisclosed-recipients:;". Accommodate this by returning the original address if the parser fails. Adjust the test results accordingly. --- Default is now 'partial (most similar to the old behaviour). Allow for un-parseable addresses. Don't add unnecessary quotes. Oh, and, fix the test suite. Carl: You can ignore the notmuch-lkml.el chunk, as you don't have that yet. emacs/notmuch-lkml.el | 4 +- emacs/notmuch-show.el | 65 +++++++++++++++++++- .../notmuch-show-thread-maildir-storage | 6 +- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-lkml.el b/emacs/notmuch-lkml.el index 750370b..fc04be6 100644 --- a/emacs/notmuch-lkml.el +++ b/emacs/notmuch-lkml.el @@ -29,7 +29,7 @@ (declare-function notmuch-call-notmuch-process "notmuch" (&rest args)) (declare-function notmuch-show "notmuch-show" (&rest args)) (declare-function notmuch-show-strip-re "notmuch-show" (subject)) -(declare-function notmuch-show-clean-address "notmuch-show" (parsed-address)) +(declare-function notmuch-show-clean-address "notmuch-show" (address)) (declare-function notmuch-show-spaces-n "notmuch-show" (n)) (defcustom notmuch-lkml-author-width 30 @@ -71,7 +71,7 @@ (notmuch-lkml-string-width (concat (notmuch-show-spaces-n depth) (notmuch-show-clean-address - (mail-header-parse-address (plist-get headers :From)))) + (plist-get headers :From))) notmuch-lkml-author-width) " " (if (string= notmuch-lkml-previous-subject diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index d8773e6..aa89cfd 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -26,6 +26,7 @@ (require 'message) (require 'mm-decode) (require 'mailcap) +(require 'mail-parse) (require 'notmuch-lib) (require 'notmuch-query) @@ -82,6 +83,21 @@ any given message." notmuch-wash-elide-blank-lines notmuch-wash-excerpt-citations)) +(defcustom notmuch-show-address-simplification 'partial + "How should addresses be displayed? + +Set `notmuch-show-address-simplication' to: + +- 'full: Only the name component of the address, if present, is + shown, +- 'partial: Addresses are stripped of redundant information, +- 'none: Addresses are shown as-is." + :group 'notmuch + :type '(choice + (const :tag "Full simplification" full) + (const :tag "Partial simplification" partial) + (const :tag "No simplification" none))) + (defmacro with-current-notmuch-show-message (&rest body) "Evaluate body with current buffer set to the text of current message" `(save-excursion @@ -198,12 +214,46 @@ any given message." 'face 'notmuch-tag-face) ")")))))) +(defun notmuch-show-clean-address (original-address) + "Prepare a single email address for display." + (let* ((parsed-address (mail-header-parse-address original-address)) + (address (car parsed-address)) + (name (cdr parsed-address)) + (displayed-name name)) + + ;; If the parser failed, use the original string. + (if (not parsed-address) + original-address + + ;; If the address is 'foo@bar.com <foo@bar.com>' then show just + ;; 'foo@bar.com'. + (when (string= displayed-name address) + (setq displayed-name nil)) + + (cond + ((eq notmuch-show-address-simplification 'full) + (if displayed-name + (propertize displayed-name 'help-echo address) + address)) + + ((eq notmuch-show-address-simplification 'partial) + (if displayed-name + ;; `mail-header-make-address' is enthusiastic about + ;; quoting the displayed name if it contains spaces (which + ;; is visually unappealing) so generate the displayed + ;; string directly here. + (concat displayed-name " <" address ">") + address)) + + (t ;; All other settings, but mostly 'none. + original-address))))) + (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." (let ((start (point))) (insert (notmuch-show-spaces-n depth) - (plist-get headers :From) + (notmuch-show-clean-address (plist-get headers :From)) " (" date ") (" @@ -214,7 +264,18 @@ message at DEPTH in the current thread." (defun notmuch-show-insert-header (header header-value) "Insert a single header." - (insert header ": " header-value "\n")) + (insert header ": " + (cond + ((or (string= "To" header) + (string= "Cc" header) + (string= "Bcc" header) + (string= "From" header)) + (mapconcat 'notmuch-show-clean-address + (mail-header-parse-addresses header-value t) + ", ")) + (t + header-value)) + "\n")) (defun notmuch-show-insert-headers (headers) "Insert the headers of the current message." diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage b/test/emacs.expected-output/notmuch-show-thread-maildir-storage index 086f874..2f18924 100644 --- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage +++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage @@ -92,7 +92,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch - "Mikhail Gusarov" <dottedmag@dottedmag.net> (2009-11-17) (inbox unread) + Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Wed, 18 Nov 2009 02:50:48 +0600 @@ -120,7 +120,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp> - "Keith Packard" <keithp@keithp.com> (2009-11-17) (inbox unread) + Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Tue, 17 Nov 2009 13:24:13 -0800 @@ -167,7 +167,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch - "Carl Worth" <cworth@cworth.org> (2009-11-18) (inbox unread) + Carl Worth <cworth@cworth.org> (2009-11-18) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Wed, 18 Nov 2009 02:08:10 -0800 -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-11-12 8:00 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-05 15:04 [PATCH] emacs: Show cleaner addresses during message display David Edmondson 2010-11-09 17:34 ` David Edmondson 2010-11-09 20:53 ` Jameson Rollins 2010-11-10 7:20 ` Sebastian Spaeth 2010-11-10 8:27 ` David Edmondson 2010-11-10 9:17 ` Sebastian Spaeth 2010-11-10 9:23 ` David Edmondson 2010-11-12 1:14 ` Carl Worth 2010-11-12 7:58 ` David Edmondson
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).