On Tue, May 06 2014, Mark Walters wrote: > 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. I would probably replace the global keymap bindings, but others should chime in. > 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? This is nicer than the current patch.