Re: [PATCH] emacs: Tab completion for notmuch-search and notmuch-search-filter

Subject: Re: [PATCH] emacs: Tab completion for notmuch-search and notmuch-search-filter

Date: Sat, 04 Jun 2011 21:55:13 +0200

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: Daniel Schoepe


On Sat, 4 Jun 2011 11:32:15 -0400, Austin Clements <amdragon@mit.edu> wrote:
> Dynamic scoping is obnoxious, but I think programmed completion is
> steeped in the assumption that you'll use it.  This code would be much
> simpler if notmuch-query-completions took only `string' and used the
> dynamically-bound all-compls (which should probably be renamed
> notmuch-completions or something if you do this).  Then this could be
> just
>   (minibuffer-completion-table (completion-table-dynamic
> #'notmuch-query-completions)))
> and there'd be no need for quasiquoting, comments, and fake lexical scoping.

Sounds reasonable, I guess I really should stop fighting all those ugly
parts of elisp with unreadable constructs like that. I made it a global
variable though to avoid compilation warnings about notmuch-completion
being a free variable. Since it's contents are not dependent on
how/where notmuch-read-query is called, this shouldn't cause any
problems, except my personal discomfort arising from the use of side
effects for something as simple as this. :)

> > +    (define-key keymap (kbd "<tab>") 'minibuffer-complete)
> 
> This probably deserves a comment about why you're doing so much work
> to avoid completing-read (which I assume is because it also binds SPC,
> even if require-match is nil, which is unfortunate).

Yes, that was the reason.

Another thing that bugs me, is that I did not find a better way of doing
the completion: Ideally I'd like to just specify a list of completions
for individual words and have emacs handle separating the input string
into individual words, but I couldn't find any options to accomplish
that.

An updated patch is attached.
part-001.sig (application/pgp-signature)

Thread: