From: Tomi Ollila <tomi.ollila@iki.fi>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v3] completion: complete mimetype: search prefix
Date: Fri, 11 Nov 2016 22:29:57 +0200 [thread overview]
Message-ID: <m21syh92uy.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <1478112407-22427-1-git-send-email-jani@nikula.org>
On Wed, Nov 02 2016, Jani Nikula <jani@nikula.org> wrote:
> Use /etc/mime.types if available, parsed using a sed one-liner, and
> fall back to a handful of common types otherwise.
>
> ---
>
> v2: smarter sed thanks to Lucas Hoffmann
>
> v3: use Tomi's sed... though I'm not sure what the improvement is...
LGTM.
The difference is that using '\t' is GNU sed extension -- other seds just
consider that being 't' -- Using [[:space:]] works also on macOS, *BSD...
> ---
> completion/notmuch-completion.bash | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
> index 78047b5f424d..d44b2a2811f0 100644
> --- a/completion/notmuch-completion.bash
> +++ b/completion/notmuch-completion.bash
> @@ -58,6 +58,34 @@ _notmuch_email()
> sed 's/[^<]*<\([^>]*\)>/\1/' | tr "[:upper:]" "[:lower:]" | sort -u
> }
>
> +_notmuch_mimetype()
> +{
> + # use mime types from mime-support package if available, and fall
> + # back to a handful of common ones otherwise
> + if [ -r "/etc/mime.types" ]; then
> + sed -n '/^[[:alpha:]]/{s/[[:space:]].*//;p;}' /etc/mime.types
> + else
> + cat <<EOF
> +application/gzip
> +application/msword
> +application/pdf
> +application/zip
> +audio/mpeg
> +audio/ogg
> +image/gif
> +image/jpeg
> +image/png
> +message/rfc822
> +text/calendar
> +text/html
> +text/plain
> +text/vcard
> +text/x-diff
> +text/x-vcalendar
> +EOF
> + fi
> +}
> +
> _notmuch_search_terms()
> {
> local cur prev words cword split
> @@ -85,6 +113,10 @@ _notmuch_search_terms()
> COMPREPLY=( $(compgen -d "$path/${cur##folder:}" | \
> sed "s|^$path/||" | grep -v "\(^\|/\)\(cur\|new\|tmp\)$" ) )
> ;;
> + mimetype:*)
> + compopt -o nospace
> + COMPREPLY=( $(compgen -P "mimetype:" -W "`_notmuch_mimetype ${cur}`" -- ${cur##mimetype:}) )
> + ;;
> *)
> local search_terms="from: to: subject: attachment: mimetype: tag: id: thread: folder: path: date: lastmod:"
> compopt -o nospace
> --
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
next prev parent reply other threads:[~2016-11-11 20:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-22 18:55 [PATCH] completion: complete mimetype: search prefix Jani Nikula
2016-10-23 18:39 ` [PATCH v2] " Jani Nikula
2016-10-25 14:55 ` Tomi Ollila
2016-10-30 9:52 ` Jani Nikula
2016-10-30 20:53 ` Tomi Ollila
2016-11-02 18:46 ` [PATCH v3] " Jani Nikula
2016-11-11 20:29 ` Tomi Ollila [this message]
2016-11-12 11:43 ` David Bremner
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=m21syh92uy.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--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).