Re: [PATCH] emacs: put current query as default value in notmuch-read-query

Subject: Re: [PATCH] emacs: put current query as default value in notmuch-read-query

Date: Tue, 06 May 2014 08:26:41 +0100

To: David Edmondson, notmuch@notmuchmail.org

Cc:

From: Mark Walters


Hi

On Tue, 06 May 2014, David Edmondson <dme@dme.org> wrote:
> On Sat, May 03 2014, Mark Walters wrote:
>> An alternative to putting the logic in notmuch-read-query would be to
>> store the query in a consistently named buffer local variable in all
>> the modes. If we want to show the actually run query in notmuch-show
>> above then this is probably the neatest solution.
>
> Could per-mode query functions not simply pass the default as an
> optional second argument to `notmuch-read-query'?

They could but at the moment notmuch-search and notmuch-tree are both
bound in the global key map and they in turn call notmuch-read-query. 

I guess we could add an argument to notmuch-search and notmuch-tree
for the default argument (which they would pass to
notmuch-read-query). Then calling modes which know a search value
(show,search and tree) could override the global keymap (probably using
remap or something to mean that they keep any customised binding) to
link into something which passes the default value through.

One variant which might be nicer than the current version would be to
have something like
(let ((current-query (case major-mode
                           (notmuch-show-mode (notmuch-show-get-current-query))
                           (notmuch-tree-mode (notmuch-tree-get-current-query))
                           (notmuch-search-mode (notmuch-search-get-current-query))))))

so at least all the logic for calculating the current query can live in
the relevant file.

What do you think?

Best wishes

Mark


Thread: