* [PATCH 0/2] multipart/alternative display and text/calendar
@ 2012-02-08 16:55 Jani Nikula
2012-02-08 16:55 ` [PATCH 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-08 16:55 UTC (permalink / raw)
To: notmuch
I like to have notmuch-show-all-multipart/alternative-parts nil. I'd also
like to see the text/calendar alternatives that I keep getting that have
the information that the text/plain alternative is missing (like date and
time *sigh*).
Patch 1 allows me to specify the alternative parts I want to always see
(nil and t work as before):
(setq notmuch-show-all-multipart/alternative-parts '("text/calendar"))
Patch 2 parses text/calendar as text/x-vcalendar for me so I don't have to.
BR,
Jani.
Jani Nikula (2):
emacs: support defining a list of alternative parts to show
emacs: regard text/calendar as text/x-vcalendar
emacs/notmuch-show.el | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] emacs: support defining a list of alternative parts to show
2012-02-08 16:55 [PATCH 0/2] multipart/alternative display and text/calendar Jani Nikula
@ 2012-02-08 16:55 ` Jani Nikula
2012-02-08 17:05 ` David Edmondson
2012-02-08 16:55 ` [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar Jani Nikula
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-02-08 16:55 UTC (permalink / raw)
To: notmuch
Make notmuch-show-all-multipart/alternative-parts accept a list of
multipart/alternative types to show in addition to the preferred
types. This allows the user to force display some alternative part
types while normally showing just the preferred ones.
Signed-off-by: Jani Nikula <jani@nikula.org>
---
emacs/notmuch-show.el | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index faa9f9b..1340380 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -97,7 +97,9 @@ any given message."
;; Mostly useful for debugging.
(defcustom notmuch-show-all-multipart/alternative-parts t
"Should all parts of multipart/alternative parts be shown?"
- :type 'boolean
+ :type '(choice (const :tag "Show all" t)
+ (const :tag "Show preferred" nil)
+ (repeat :tag "Show preferred and custom" string))
:group 'notmuch-show)
(defcustom notmuch-show-indent-messages-width 1
@@ -513,7 +515,9 @@ current buffer, if possible."
;; should be chosen if there are more than one that match?
(mapc (lambda (inner-part)
(let ((inner-type (plist-get inner-part :content-type)))
- (if (or notmuch-show-all-multipart/alternative-parts
+ (if (or (equal notmuch-show-all-multipart/alternative-parts t)
+ (member inner-type
+ notmuch-show-all-multipart/alternative-parts)
(string= chosen-type inner-type))
(notmuch-show-insert-bodypart msg inner-part depth)
(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
--
1.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar
2012-02-08 16:55 [PATCH 0/2] multipart/alternative display and text/calendar Jani Nikula
2012-02-08 16:55 ` [PATCH 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
@ 2012-02-08 16:55 ` Jani Nikula
2012-02-08 17:06 ` David Edmondson
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-02-08 16:55 UTC (permalink / raw)
To: notmuch
Treat text/calendar as text/x-vcalendar. At least the following
produce text/calendar that parse as text/x-vcalendar:
PRODID:-//Google Inc//Google Calendar 70.9054//EN
PRODID:Microsoft Exchange Server 2010
Code by David Edmondson <dme@dme.org>
---
I wish I had some references here, other than my own maildirs. Almost
all of the calendar invites I have are text/calendar, and all of them
parse just fine as text/x-vcalendar.
---
emacs/notmuch-show.el | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1340380..f6588b3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -720,6 +720,9 @@ current buffer, if possible."
result)))
t)
+(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type)
+ (notmuch-show-insert-part-text/x-vcalendar msg part content-type nth depth declared-type))
+
(defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)
;; If we can deduce a MIME type from the filename of the attachment,
;; do so and pass it on to the handler for that type.
--
1.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] emacs: support defining a list of alternative parts to show
2012-02-08 16:55 ` [PATCH 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
@ 2012-02-08 17:05 ` David Edmondson
0 siblings, 0 replies; 16+ messages in thread
From: David Edmondson @ 2012-02-08 17:05 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]
On Wed, 8 Feb 2012 16:55:15 +0000, Jani Nikula <jani@nikula.org> wrote:
> Make notmuch-show-all-multipart/alternative-parts accept a list of
> multipart/alternative types to show in addition to the preferred
> types. This allows the user to force display some alternative part
> types while normally showing just the preferred ones.
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---
> emacs/notmuch-show.el | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index faa9f9b..1340380 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -97,7 +97,9 @@ any given message."
> ;; Mostly useful for debugging.
> (defcustom notmuch-show-all-multipart/alternative-parts t
> "Should all parts of multipart/alternative parts be shown?"
> - :type 'boolean
> + :type '(choice (const :tag "Show all" t)
> + (const :tag "Show preferred" nil)
> + (repeat :tag "Show preferred and custom" string))
> :group 'notmuch-show)
It would be convenient if this was a list of regexps.
> (defcustom notmuch-show-indent-messages-width 1
> @@ -513,7 +515,9 @@ current buffer, if possible."
> ;; should be chosen if there are more than one that match?
> (mapc (lambda (inner-part)
> (let ((inner-type (plist-get inner-part :content-type)))
> - (if (or notmuch-show-all-multipart/alternative-parts
> + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> + (member inner-type
> + notmuch-show-all-multipart/alternative-parts)
> (string= chosen-type inner-type))
> (notmuch-show-insert-bodypart msg inner-part depth)
> (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> --
> 1.7.1
>
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar
2012-02-08 16:55 ` [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar Jani Nikula
@ 2012-02-08 17:06 ` David Edmondson
0 siblings, 0 replies; 16+ messages in thread
From: David Edmondson @ 2012-02-08 17:06 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]
On Wed, 8 Feb 2012 16:55:16 +0000, Jani Nikula <jani@nikula.org> wrote:
> Treat text/calendar as text/x-vcalendar. At least the following
> produce text/calendar that parse as text/x-vcalendar:
>
> PRODID:-//Google Inc//Google Calendar 70.9054//EN
> PRODID:Microsoft Exchange Server 2010
>
> Code by David Edmondson <dme@dme.org>
>
> ---
>
> I wish I had some references here, other than my own maildirs. Almost
> all of the calendar invites I have are text/calendar, and all of them
> parse just fine as text/x-vcalendar.
> ---
> emacs/notmuch-show.el | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 1340380..f6588b3 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -720,6 +720,9 @@ current buffer, if possible."
> result)))
> t)
>
> +(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type)
> + (notmuch-show-insert-part-text/x-vcalendar msg part content-type nth depth declared-type))
> +
> (defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)
It seems that "text/calendar" is officially sanctioned and
"text/x-vcalendar" is old and being phased out, so these should really
be the other way around (i.e. text/calendar is the 'real' function that
is called by the text/x-vcalendar variant).
> ;; If we can deduce a MIME type from the filename of the attachment,
> ;; do so and pass it on to the handler for that type.
> --
> 1.7.1
>
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-08 16:55 [PATCH 0/2] multipart/alternative display and text/calendar Jani Nikula
2012-02-08 16:55 ` [PATCH 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-08 16:55 ` [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar Jani Nikula
@ 2012-02-09 14:46 ` Jani Nikula
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
` (2 more replies)
2 siblings, 3 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-09 14:46 UTC (permalink / raw)
To: notmuch
Make notmuch-show-all-multipart/alternative-parts accept a list of
regexps to match the part types to determine which parts to show in
addition to the preferred types. This allows the user to force display
some alternative part types while normally showing just the preferred
ones.
Signed-off-by: Jani Nikula <jani@nikula.org>
---
emacs/notmuch-show.el | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 24fde05..5f643f1 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -94,10 +94,20 @@ any given message."
:group 'notmuch-show
:group 'notmuch-hooks)
-;; Mostly useful for debugging.
(defcustom notmuch-show-all-multipart/alternative-parts t
- "Should all parts of multipart/alternative parts be shown?"
- :type 'boolean
+ "Which parts of multipart/alternative should be shown?
+
+This variable determines which parts of multipart/alternative
+should be displayed. Set to t (the default) to show all
+parts. Set to nil to only show the preferred parts. Set to a list
+of regexps to display the preferred parts, and parts matching any
+of the regexps, for example:
+
+ (setq notmuch-show-all-multipart/alternative-parts
+ '(\"text/.*calendar\" \"text/html\"))"
+ :type '(choice (const :tag "Show all parts" t)
+ (const :tag "Show preferred parts" nil)
+ (repeat :tag "Show preferred and parts matching regexps" string))
:group 'notmuch-show)
(defcustom notmuch-show-indent-messages-width 1
@@ -513,8 +523,11 @@ current buffer, if possible."
;; should be chosen if there are more than one that match?
(mapc (lambda (inner-part)
(let ((inner-type (plist-get inner-part :content-type)))
- (if (or notmuch-show-all-multipart/alternative-parts
- (string= chosen-type inner-type))
+ (if (or (equal notmuch-show-all-multipart/alternative-parts t)
+ (string= chosen-type inner-type)
+ (and
+ notmuch-show-all-multipart/alternative-parts
+ (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
(notmuch-show-insert-bodypart msg inner-part depth)
(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
inner-parts)
--
1.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] emacs: support text/calendar mime type
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
@ 2012-02-09 14:46 ` Jani Nikula
2012-02-10 10:06 ` David Edmondson
` (3 more replies)
2012-02-10 10:05 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show David Edmondson
2012-02-21 7:50 ` Jani Nikula
2 siblings, 4 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-09 14:46 UTC (permalink / raw)
To: notmuch
Replace text/x-vcalendar with text/calendar, while maintaining support
and backwards compatibility for text/x-vcalendar.
Code by David Edmondson <dme@dme.org>
---
emacs/notmuch-show.el | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5f643f1..33a4f18 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -711,7 +711,7 @@ current buffer, if possible."
(run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
t)
-(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)
+(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type)
(notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename))
(insert (with-temp-buffer
(insert (notmuch-show-get-bodypart-content msg part nth))
@@ -729,6 +729,10 @@ current buffer, if possible."
result)))
t)
+;; For backwards compatibility.
+(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)
+ (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type))
+
(defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)
;; If we can deduce a MIME type from the filename of the attachment,
;; do so and pass it on to the handler for that type.
--
1.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
@ 2012-02-10 10:05 ` David Edmondson
2012-02-10 10:17 ` Jani Nikula
2012-02-12 12:09 ` Jani Nikula
2012-02-21 7:50 ` Jani Nikula
2 siblings, 2 replies; 16+ messages in thread
From: David Edmondson @ 2012-02-10 10:05 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 3342 bytes --]
On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:
> Make notmuch-show-all-multipart/alternative-parts accept a list of
> regexps to match the part types to determine which parts to show in
> addition to the preferred types. This allows the user to force display
> some alternative part types while normally showing just the preferred
> ones.
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---
> emacs/notmuch-show.el | 23 ++++++++++++++++++-----
> 1 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 24fde05..5f643f1 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -94,10 +94,20 @@ any given message."
> :group 'notmuch-show
> :group 'notmuch-hooks)
>
> -;; Mostly useful for debugging.
> (defcustom notmuch-show-all-multipart/alternative-parts t
> - "Should all parts of multipart/alternative parts be shown?"
> - :type 'boolean
> + "Which parts of multipart/alternative should be shown?
> +
> +This variable determines which parts of multipart/alternative
> +should be displayed. Set to t (the default) to show all
> +parts. Set to nil to only show the preferred parts. Set to a list
> +of regexps to display the preferred parts, and parts matching any
> +of the regexps, for example:
"If set to `t' (the default), all sub-parts of a
\"multipart/alternative\" part are shown. If set to `nil', only the
preferred part is shown. If set to a list of regexps, the preferred part
and all parts whose type matches one of the regexps will be shown."
> +
> + (setq notmuch-show-all-multipart/alternative-parts
> + '(\"text/.*calendar\" \"text/html\"))"
> + :type '(choice (const :tag "Show all parts" t)
> + (const :tag "Show preferred parts" nil)
> + (repeat :tag "Show preferred and parts matching regexps" string))
> :group 'notmuch-show)
>
> (defcustom notmuch-show-indent-messages-width 1
> @@ -513,8 +523,11 @@ current buffer, if possible."
> ;; should be chosen if there are more than one that match?
> (mapc (lambda (inner-part)
> (let ((inner-type (plist-get inner-part :content-type)))
> - (if (or notmuch-show-all-multipart/alternative-parts
> - (string= chosen-type inner-type))
> + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> + (string= chosen-type inner-type)
> + (and
> + notmuch-show-all-multipart/alternative-parts
> + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
This is quite messy. How about we add a general helper to "notmuch-lib.el":
(defun notmuch-string-match-list-p (regexps string)
(loop for regexp in regexps
if (string-match-p regexp string)
return t))
and then write:
(if (or (string= chosen-type inner-type)
(equal notmuch-show-all-multipart/alternative-parts t)
(notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))
...
?
> (notmuch-show-insert-bodypart msg inner-part depth)
> (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> inner-parts)
> --
> 1.7.1
>
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/2] emacs: support text/calendar mime type
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
@ 2012-02-10 10:06 ` David Edmondson
2012-02-15 15:35 ` Adam Wolfe Gordon
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: David Edmondson @ 2012-02-10 10:06 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 12 bytes --]
Looks good.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-10 10:05 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show David Edmondson
@ 2012-02-10 10:17 ` Jani Nikula
2012-02-12 12:09 ` Jani Nikula
1 sibling, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-10 10:17 UTC (permalink / raw)
To: David Edmondson, notmuch
On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson <dme@dme.org> wrote:
> On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:
> > Make notmuch-show-all-multipart/alternative-parts accept a list of
> > regexps to match the part types to determine which parts to show in
> > addition to the preferred types. This allows the user to force display
> > some alternative part types while normally showing just the preferred
> > ones.
> >
> > Signed-off-by: Jani Nikula <jani@nikula.org>
> > ---
> > emacs/notmuch-show.el | 23 ++++++++++++++++++-----
> > 1 files changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 24fde05..5f643f1 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -94,10 +94,20 @@ any given message."
> > :group 'notmuch-show
> > :group 'notmuch-hooks)
> >
> > -;; Mostly useful for debugging.
> > (defcustom notmuch-show-all-multipart/alternative-parts t
> > - "Should all parts of multipart/alternative parts be shown?"
> > - :type 'boolean
> > + "Which parts of multipart/alternative should be shown?
> > +
> > +This variable determines which parts of multipart/alternative
> > +should be displayed. Set to t (the default) to show all
> > +parts. Set to nil to only show the preferred parts. Set to a list
> > +of regexps to display the preferred parts, and parts matching any
> > +of the regexps, for example:
>
> "If set to `t' (the default), all sub-parts of a
> \"multipart/alternative\" part are shown. If set to `nil', only the
> preferred part is shown. If set to a list of regexps, the preferred part
> and all parts whose type matches one of the regexps will be shown."
Thank you; this is the best kind of comment on improving documentation.
>
> > +
> > + (setq notmuch-show-all-multipart/alternative-parts
> > + '(\"text/.*calendar\" \"text/html\"))"
> > + :type '(choice (const :tag "Show all parts" t)
> > + (const :tag "Show preferred parts" nil)
> > + (repeat :tag "Show preferred and parts matching regexps" string))
> > :group 'notmuch-show)
> >
> > (defcustom notmuch-show-indent-messages-width 1
> > @@ -513,8 +523,11 @@ current buffer, if possible."
> > ;; should be chosen if there are more than one that match?
> > (mapc (lambda (inner-part)
> > (let ((inner-type (plist-get inner-part :content-type)))
> > - (if (or notmuch-show-all-multipart/alternative-parts
> > - (string= chosen-type inner-type))
> > + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> > + (string= chosen-type inner-type)
> > + (and
> > + notmuch-show-all-multipart/alternative-parts
> > + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
>
> This is quite messy. How about we add a general helper to "notmuch-lib.el":
>
> (defun notmuch-string-match-list-p (regexps string)
> (loop for regexp in regexps
> if (string-match-p regexp string)
> return t))
>
> and then write:
>
> (if (or (string= chosen-type inner-type)
> (equal notmuch-show-all-multipart/alternative-parts t)
> (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))
> ...
>
> ?
*sigh* I was so happy to make that mapconcat work. And I guess soon I'll
have to add "code by dme" in this patch too. ;)
But you're right, it will be more readable that way. v3 in a few days.
BR,
Jani.
>
> > (notmuch-show-insert-bodypart msg inner-part depth)
> > (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> > inner-parts)
> > --
> > 1.7.1
> >
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-10 10:05 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show David Edmondson
2012-02-10 10:17 ` Jani Nikula
@ 2012-02-12 12:09 ` Jani Nikula
2012-02-12 14:37 ` Tomi Ollila
1 sibling, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-02-12 12:09 UTC (permalink / raw)
To: David Edmondson, notmuch
On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson <dme@dme.org> wrote:
> On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:
> > Make notmuch-show-all-multipart/alternative-parts accept a list of
> > regexps to match the part types to determine which parts to show in
> > addition to the preferred types. This allows the user to force display
> > some alternative part types while normally showing just the preferred
> > ones.
> >
> > Signed-off-by: Jani Nikula <jani@nikula.org>
> > ---
> > emacs/notmuch-show.el | 23 ++++++++++++++++++-----
> > 1 files changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 24fde05..5f643f1 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -94,10 +94,20 @@ any given message."
> > :group 'notmuch-show
> > :group 'notmuch-hooks)
> >
> > -;; Mostly useful for debugging.
> > (defcustom notmuch-show-all-multipart/alternative-parts t
> > - "Should all parts of multipart/alternative parts be shown?"
> > - :type 'boolean
> > + "Which parts of multipart/alternative should be shown?
> > +
> > +This variable determines which parts of multipart/alternative
> > +should be displayed. Set to t (the default) to show all
> > +parts. Set to nil to only show the preferred parts. Set to a list
> > +of regexps to display the preferred parts, and parts matching any
> > +of the regexps, for example:
>
> "If set to `t' (the default), all sub-parts of a
> \"multipart/alternative\" part are shown. If set to `nil', only the
> preferred part is shown. If set to a list of regexps, the preferred part
> and all parts whose type matches one of the regexps will be shown."
>
> > +
> > + (setq notmuch-show-all-multipart/alternative-parts
> > + '(\"text/.*calendar\" \"text/html\"))"
> > + :type '(choice (const :tag "Show all parts" t)
> > + (const :tag "Show preferred parts" nil)
> > + (repeat :tag "Show preferred and parts matching regexps" string))
> > :group 'notmuch-show)
> >
> > (defcustom notmuch-show-indent-messages-width 1
> > @@ -513,8 +523,11 @@ current buffer, if possible."
> > ;; should be chosen if there are more than one that match?
> > (mapc (lambda (inner-part)
> > (let ((inner-type (plist-get inner-part :content-type)))
> > - (if (or notmuch-show-all-multipart/alternative-parts
> > - (string= chosen-type inner-type))
> > + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> > + (string= chosen-type inner-type)
> > + (and
> > + notmuch-show-all-multipart/alternative-parts
> > + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
>
> This is quite messy. How about we add a general helper to "notmuch-lib.el":
>
> (defun notmuch-string-match-list-p (regexps string)
> (loop for regexp in regexps
> if (string-match-p regexp string)
> return t))
>
> and then write:
>
> (if (or (string= chosen-type inner-type)
> (equal notmuch-show-all-multipart/alternative-parts t)
> (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))
> ...
Hmm. I wrapped the regexps between ^ and $ to not match substrings. I
think that's less surprising and better than having the user add them,
and the user can still use e.g. ".*foo.*" to explicitly match a
substring.
If this is fixed in notmuch-string-match-list-p then it's not general
anymore. But does adding a mapcar to wrap the regexps here make this
messy again...? What if notmuch-string-match-list-p were just a local
specific helper for clarity?
>
> ?
>
> > (notmuch-show-insert-bodypart msg inner-part depth)
> > (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> > inner-parts)
> > --
> > 1.7.1
> >
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-12 12:09 ` Jani Nikula
@ 2012-02-12 14:37 ` Tomi Ollila
0 siblings, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2012-02-12 14:37 UTC (permalink / raw)
To: Jani Nikula, David Edmondson, notmuch
On Sun, 12 Feb 2012 14:09:57 +0200, Jani Nikula <jani@nikula.org> wrote:
> On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson <dme@dme.org> wrote:
> > On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:
[...]
> > > + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> > > + (string= chosen-type inner-type)
> > > + (and
> > > + notmuch-show-all-multipart/alternative-parts
> > > + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
> >
> > This is quite messy. How about we add a general helper to "notmuch-lib.el":
> >
> > (defun notmuch-string-match-list-p (regexps string)
> > (loop for regexp in regexps
> > if (string-match-p regexp string)
> > return t))
> >
> > and then write:
> >
> > (if (or (string= chosen-type inner-type)
> > (equal notmuch-show-all-multipart/alternative-parts t)
> > (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))
> > ...
>
> Hmm. I wrapped the regexps between ^ and $ to not match substrings. I
> think that's less surprising and better than having the user add them,
> and the user can still use e.g. ".*foo.*" to explicitly match a
> substring.
>
> If this is fixed in notmuch-string-match-list-p then it's not general
> anymore. But does adding a mapcar to wrap the regexps here make this
> messy again...? What if notmuch-string-match-list-p were just a local
> specific helper for clarity?
Something like this could work...
(defun notmuch-string-match-list-p (regexps string)
(loop for regexp in regexps
if (string-match-p (concat "^" regexp "$") string)
return t))
But if you-re going to pre-anchor these regexps then it is better to be
documented clearly as the final 'regexp' works in non-standard way.
> >
> > ?
Tomi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/2] emacs: support text/calendar mime type
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
2012-02-10 10:06 ` David Edmondson
@ 2012-02-15 15:35 ` Adam Wolfe Gordon
2012-02-21 7:52 ` Jani Nikula
2012-02-25 13:55 ` David Bremner
3 siblings, 0 replies; 16+ messages in thread
From: Adam Wolfe Gordon @ 2012-02-15 15:35 UTC (permalink / raw)
To: Jani Nikula; +Cc: notmuch
+1 from me. Very handy.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
2012-02-10 10:05 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show David Edmondson
@ 2012-02-21 7:50 ` Jani Nikula
2 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-21 7:50 UTC (permalink / raw)
To: notmuch
On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:
> Make notmuch-show-all-multipart/alternative-parts accept a list of
> regexps to match the part types to determine which parts to show in
> addition to the preferred types. This allows the user to force display
> some alternative part types while normally showing just the preferred
> ones.
Wah, this patch (1/2) is crap, as it also seems to affect the
reply. I'll probably return to this later, after the json reply stuff is
merged or so.
BR,
Jani.
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---
> emacs/notmuch-show.el | 23 ++++++++++++++++++-----
> 1 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 24fde05..5f643f1 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -94,10 +94,20 @@ any given message."
> :group 'notmuch-show
> :group 'notmuch-hooks)
>
> -;; Mostly useful for debugging.
> (defcustom notmuch-show-all-multipart/alternative-parts t
> - "Should all parts of multipart/alternative parts be shown?"
> - :type 'boolean
> + "Which parts of multipart/alternative should be shown?
> +
> +This variable determines which parts of multipart/alternative
> +should be displayed. Set to t (the default) to show all
> +parts. Set to nil to only show the preferred parts. Set to a list
> +of regexps to display the preferred parts, and parts matching any
> +of the regexps, for example:
> +
> + (setq notmuch-show-all-multipart/alternative-parts
> + '(\"text/.*calendar\" \"text/html\"))"
> + :type '(choice (const :tag "Show all parts" t)
> + (const :tag "Show preferred parts" nil)
> + (repeat :tag "Show preferred and parts matching regexps" string))
> :group 'notmuch-show)
>
> (defcustom notmuch-show-indent-messages-width 1
> @@ -513,8 +523,11 @@ current buffer, if possible."
> ;; should be chosen if there are more than one that match?
> (mapc (lambda (inner-part)
> (let ((inner-type (plist-get inner-part :content-type)))
> - (if (or notmuch-show-all-multipart/alternative-parts
> - (string= chosen-type inner-type))
> + (if (or (equal notmuch-show-all-multipart/alternative-parts t)
> + (string= chosen-type inner-type)
> + (and
> + notmuch-show-all-multipart/alternative-parts
> + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))
> (notmuch-show-insert-bodypart msg inner-part depth)
> (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> inner-parts)
> --
> 1.7.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/2] emacs: support text/calendar mime type
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
2012-02-10 10:06 ` David Edmondson
2012-02-15 15:35 ` Adam Wolfe Gordon
@ 2012-02-21 7:52 ` Jani Nikula
2012-02-25 13:55 ` David Bremner
3 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-02-21 7:52 UTC (permalink / raw)
To: notmuch, David Bremner
On Thu, 9 Feb 2012 14:46:03 +0000, Jani Nikula <jani@nikula.org> wrote:
> Replace text/x-vcalendar with text/calendar, while maintaining support
> and backwards compatibility for text/x-vcalendar.
David (B, not E), while 1/2 needs work, this 2/2 is independent and IMHO
could go in.
BR,
Jani.
>
> Code by David Edmondson <dme@dme.org>
> ---
> emacs/notmuch-show.el | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5f643f1..33a4f18 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -711,7 +711,7 @@ current buffer, if possible."
> (run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
> t)
>
> -(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)
> +(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type)
> (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename))
> (insert (with-temp-buffer
> (insert (notmuch-show-get-bodypart-content msg part nth))
> @@ -729,6 +729,10 @@ current buffer, if possible."
> result)))
> t)
>
> +;; For backwards compatibility.
> +(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)
> + (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type))
> +
> (defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)
> ;; If we can deduce a MIME type from the filename of the attachment,
> ;; do so and pass it on to the handler for that type.
> --
> 1.7.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/2] emacs: support text/calendar mime type
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
` (2 preceding siblings ...)
2012-02-21 7:52 ` Jani Nikula
@ 2012-02-25 13:55 ` David Bremner
3 siblings, 0 replies; 16+ messages in thread
From: David Bremner @ 2012-02-25 13:55 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Thu, 9 Feb 2012 14:46:03 +0000, Jani Nikula <jani@nikula.org> wrote:
> Replace text/x-vcalendar with text/calendar, while maintaining support
> and backwards compatibility for text/x-vcalendar.
pushed
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2012-02-26 6:02 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-08 16:55 [PATCH 0/2] multipart/alternative display and text/calendar Jani Nikula
2012-02-08 16:55 ` [PATCH 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-08 17:05 ` David Edmondson
2012-02-08 16:55 ` [PATCH 2/2] emacs: regard text/calendar as text/x-vcalendar Jani Nikula
2012-02-08 17:06 ` David Edmondson
2012-02-09 14:46 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-09 14:46 ` [PATCH v2 2/2] emacs: support text/calendar mime type Jani Nikula
2012-02-10 10:06 ` David Edmondson
2012-02-15 15:35 ` Adam Wolfe Gordon
2012-02-21 7:52 ` Jani Nikula
2012-02-25 13:55 ` David Bremner
2012-02-10 10:05 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show David Edmondson
2012-02-10 10:17 ` Jani Nikula
2012-02-12 12:09 ` Jani Nikula
2012-02-12 14:37 ` Tomi Ollila
2012-02-21 7:50 ` Jani Nikula
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).