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: Sun, 05 Jun 2011 00:54:38 +0200

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: Daniel Schoepe


On Sat, 4 Jun 2011 17:55:24 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
> Oh, sorry, I wasn't suggesting setq'ing a global.  I agree that that's
> really ugly.  Rather, something like
> 
> (defun notmuch-query-completions (string)
>   ... as you have it now ...)
> 
> (defun notmuch-read-query (prompt)
>   (let ((notmuch-completions (append (list "folder:" ...)))
>         (keymap ...)
>         (minibuffer-completion-table ...))
>     (read-from-minibuffer ...)))
> 
> Unfortunately, you still need the global defvar to avoid compilation
> warnings, but this at least avoids the side-effects, and is probably
> how programmed completion was intended to be used.

Both alternatives seem about equally ugly to me, since the one using
dynamic scoping still uses side-effects, because it still passes the
completion information around without using it as an argument to
notmuch-query-completions. At least defvar-ing a global variable and
then never actually using it, seems somewhat unclean as well.

> Alternatively, here's a completely different way to structure this
> that avoids globals and dynamic scoping entirely.  This is how some of
> the standard completing read functions appear to work:

Ah right, I forgot that using macros from cl is fine even in library
code.

part-001.sig (application/pgp-signature)

Thread: