From: David Edmondson <dme@dme.org>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
Date: Fri, 10 Feb 2012 10:05:46 +0000 [thread overview]
Message-ID: <cunobt7ypdx.fsf@hotblack-desiato.hh.sledj.net> (raw)
In-Reply-To: <ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani@nikula.org>
[-- 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 --]
next prev parent reply other threads:[~2012-02-10 10:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` David Edmondson [this message]
2012-02-10 10:17 ` [PATCH v2 1/2] emacs: support defining a list of alternative parts to show Jani Nikula
2012-02-12 12:09 ` Jani Nikula
2012-02-12 14:37 ` Tomi Ollila
2012-02-21 7:50 ` Jani Nikula
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=cunobt7ypdx.fsf@hotblack-desiato.hh.sledj.net \
--to=dme@dme.org \
--cc=jani@nikula.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).