From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 3AEF36DE01EA for ; Fri, 11 Nov 2016 12:29:15 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.532 X-Spam-Level: X-Spam-Status: No, score=0.532 tagged_above=-999 required=5 tests=[AWL=-0.120, SPF_NEUTRAL=0.652] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7M8lm6uTRMUO for ; Fri, 11 Nov 2016 12:29:14 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id A006D6DE012F for ; Fri, 11 Nov 2016 12:29:13 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 13FA510004A; Fri, 11 Nov 2016 22:29:58 +0200 (EET) From: Tomi Ollila To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH v3] completion: complete mimetype: search prefix In-Reply-To: <1478112407-22427-1-git-send-email-jani@nikula.org> References: <87h97t7e47.fsf@dys5r8yycf7d---w7t57y-3.rev.dnainternet.fi> <1478112407-22427-1-git-send-email-jani@nikula.org> User-Agent: Notmuch/0.23.1+30~g980ffa4 (https://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 20:29:15 -0000 On Wed, Nov 02 2016, Jani Nikula 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 < +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