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

2011-11-02 Thread David Bremner
On Tue,  9 Aug 2011 19:32:49 +0200, Daniel Schoepe 
 wrote:
> This patch adds completion with  in the minibuffer for
> notmuch-search and notmuch-search-filter.

Finally pushed. 

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-08-09 Thread Jameson Graef Rollins
On Tue, 09 Aug 2011 19:31:44 +0200, Daniel Schoepe 
 wrote:
> Turns out, I just used `read-from-minibuffer' incorrectly, here's an
> updated version.

Hey, Daniel.  Thanks so much for the quick fix!  This new patch seems to
work great.

Signed-off-by: Jameson Graef Rollins 

jamie.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-08-09 Thread Daniel Schoepe
On Fri, 05 Aug 2011 23:09:23 -0700, Jameson Graef Rollins 
 wrote:
> Hey, Daniel.  I actually just ran into a little bug with this patch.
> After applying this patch, if I try to scroll/search through my
> mini-buffer history after a search I get the following error:
> 
> previous-history-element: Wrong type argument: symbolp, "tag:signed"
> 
> I get this error no matter what my search terms were.
> 
> Unfortunately I've always found these error messages confusing, so I'm
> not quite sure where it's coming from.  I clearly has something to do
> with how searches are now stored in the mini-buffer history (symbol
> instead of string?).

Turns out, I just used `read-from-minibuffer' incorrectly, here's an
updated version. 


pgpJKsQBe7uJ9.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-08-05 Thread Jameson Graef Rollins
Hey, Daniel.  I actually just ran into a little bug with this patch.
After applying this patch, if I try to scroll/search through my
mini-buffer history after a search I get the following error:

previous-history-element: Wrong type argument: symbolp, "tag:signed"

I get this error no matter what my search terms were.

Unfortunately I've always found these error messages confusing, so I'm
not quite sure where it's coming from.  I clearly has something to do
with how searches are now stored in the mini-buffer history (symbol
instead of string?).

jamie.


pgpj5kDh11UbQ.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-08-05 Thread Jameson Graef Rollins
On Fri, 05 Aug 2011 17:17:56 +0200, Daniel Schoepe 
 wrote:
> On Mon, 06 Jun 2011 18:32:41 +0200, Daniel Schoepe 
>  wrote:
> I've been using this patch for the past two months now and it has been
> working fine. Are there any more suggestions or criticisms about this?

Hey, Daniel.  This is a really great patch.  I've been looking for this
functionality for a while.  Thanks for implementing it.

Following this email I am sending a slightly-tweaked and signed-off
version of this patch that includes a couple of minor tweaks (diff
below).  The first tweak removes an errant white space, and the other
modifies the tag-retrieval command to use the "search --output=tags"
command instead of the "search-tags" command which was recently
deprecated.

jamie.

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e9b0ef8..053f0be 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -882,12 +882,12 @@ characters as well as `_.+-'.
 
 PROMPT is the string to prompt with."
   (lexical-let
-  ((completions 
+  ((completions
(append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
  "subject:" "attachment:")
(mapcar (lambda (tag)
  (concat "tag:" tag))
-   (process-lines "notmuch" "search-tags")
+   (process-lines "notmuch" "search" "--output=tags" 
"*")
 (let ((keymap (copy-keymap minibuffer-local-map))
  (minibuffer-completion-table
   (completion-table-dynamic


pgpO0Vp67jx3X.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-08-05 Thread Daniel Schoepe
On Mon, 06 Jun 2011 18:32:41 +0200, Daniel Schoepe 
 wrote:
> [..]

I've been using this patch for the past two months now and it has been
working fine. Are there any more suggestions or criticisms about this?

Cheers,
Daniel


pgpoxgMn2II98.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-06-06 Thread Daniel Schoepe
I accidentally left a, now unnecessary, defvar in the patch from one of
the previous attempts, here is the updated version (thanks Austin for
noticing).

From f3bc7376edc66e947d8fdf5931a9aa697b9be5cf Mon Sep 17 00:00:00 2001
From: Daniel Schoepe 
Date: Sat, 4 Jun 2011 14:17:44 +0200
Subject: [PATCH] emacs: Tab completion for notmuch-search and
 notmuch-search-filter

This patch adds completion with  in the minibuffer for
notmuch-search and notmuch-search-filter.
---
 emacs/notmuch.el |   33 +++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3311fe8..7ffbc3a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -882,6 +882,35 @@ characters as well as `_.+-'.
 	   (concat "*notmuch-search-" query "*"))
 	  )))
 
+(defun notmuch-read-query (prompt)
+  "Read a notmuch-query from the minibuffer with completion.
+
+PROMPT is the string to prompt with."
+  (lexical-let
+  ((completions 
+	(append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
+		  "subject:" "attachment:")
+		(mapcar (lambda (tag)
+			  (concat "tag:" tag))
+			(process-lines "notmuch" "search-tags")
+(let ((keymap (copy-keymap minibuffer-local-map))
+	  (minibuffer-completion-table
+	   (completion-table-dynamic
+	(lambda (string)
+	  ;; generate a list of possible completions for the current input
+	  (cond
+	   ;; this ugly regexp is used to get the last word of the input
+	   ;; possibly preceded by a '('
+	   ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
+		(mapcar (lambda (compl)
+			  (concat (match-string-no-properties 1 string) compl))
+			(all-completions (match-string-no-properties 2 string)
+	 completions)))
+	   (t (list string)))
+  ;; this was simpler than convincing completing-read to accept spaces:
+  (define-key keymap (kbd "") 'minibuffer-complete)
+  (read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -893,7 +922,7 @@ The optional parameters are used as follows:
  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
appear in the search results."
-  (interactive "sNotmuch search: ")
+  (interactive (list (notmuch-read-query "Notmuch search: ")))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
 (notmuch-search-mode)
@@ -991,7 +1020,7 @@ search."
 
 Runs a new search matching only messages that match both the
 current search results AND the additional query string provided."
-  (interactive "sFilter search: ")
+  (interactive (list (notmuch-read-query "Filter search: ")))
   (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)
 			   (concat "( " query " )")
 			 query)))
-- 
1.7.5.3



pgpNfSijOMaXX.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-06-04 Thread Daniel Schoepe
On Sat, 4 Jun 2011 17:55:24 -0400, Austin Clements  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.

From 7768f41ac44213c5e2c1dc3b0f13e3edf1d97a26 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe 
Date: Sat, 4 Jun 2011 14:17:44 +0200
Subject: [PATCH] emacs: Tab completion for notmuch-search and
 notmuch-search-filter

This patch adds completion with  in the minibuffer for
notmuch-search and notmuch-search-filter.
---
 emacs/notmuch.el |   36 ++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3311fe8..33c34bd 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -72,6 +72,9 @@ For example:
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch)
 
+(defvar notmuch-completions nil
+  "List of completions used in notmuch-query-completions")
+
 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
   (let ((tag-list
 	 (with-output-to-string
@@ -882,6 +885,35 @@ characters as well as `_.+-'.
 	   (concat "*notmuch-search-" query "*"))
 	  )))
 
+(defun notmuch-read-query (prompt)
+  "Read a notmuch-query from the minibuffer with completion.
+
+PROMPT is the string to prompt with."
+  (lexical-let
+  ((completions 
+	(append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
+		  "subject:" "attachment:")
+		(mapcar (lambda (tag)
+			  (concat "tag:" tag))
+			(process-lines "notmuch" "search-tags")
+(let ((keymap (copy-keymap minibuffer-local-map))
+	  (minibuffer-completion-table
+	   (completion-table-dynamic
+	(lambda (string)
+	  ;; generate a list of possible completions for the current input
+	  (cond
+	   ;; this ugly regexp is used to get the last word of the input
+	   ;; possibly preceded by a '('
+	   ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
+		(mapcar (lambda (compl)
+			  (concat (match-string-no-properties 1 string) compl))
+			(all-completions (match-string-no-properties 2 string)
+	 completions)))
+	   (t (list string)))
+  ;; this was simpler than convincing completing-read to accept spaces:
+  (define-key keymap (kbd "") 'minibuffer-complete)
+  (read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -893,7 +925,7 @@ The optional parameters are used as follows:
  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
appear in the search results."
-  (interactive "sNotmuch search: ")
+  (interactive (list (notmuch-read-query "Notmuch search: ")))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
 (notmuch-search-mode)
@@ -991,7 +1023,7 @@ search."
 
 Runs a new search matching only messages that match both the
 current search results AND the additional query string provided."
-  (interactive "sFilter search: ")
+  (interactive (list (notmuch-read-query "Filter search: ")))
   (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)
 			   (concat "( " query " )")
 			 query)))
-- 
1.7.5.3



pgpjYvXqoOxMf.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-06-04 Thread Austin Clements
Quoth Daniel Schoepe on Jun 04 at  9:55 pm:
> On Sat, 4 Jun 2011 11:32:15 -0400, Austin Clements  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. :)

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.

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:

(defun notmuch-read-query (prompt)
  "Read a notmuch-query from the minibuffer with completion.

PROMPT is the string to prompt with."
  (lexical-let ((completions
 (append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
   "subject:" "attachment:")
 (mapcar (lambda (tag)
   (concat "tag:" tag))
 (process-lines "notmuch" "search-tags")
(let ((minibuffer-completion-table
   (completion-table-dynamic
(lambda (string)
  (cond
   ;; this ugly regexp is used to get the last word of the
   ;; input possibly preceded by a '('
   ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
(mapcar (lambda (compl)
  (concat (match-string-no-properties 1 string) compl))
(all-completions (match-string-no-properties 2 string)
 completions)))
   (t (list string))
  (keymap (copy-keymap minibuffer-local-map)))
  ;; this was simpler than convincing completing-read to accept spaces:
  (define-key keymap (kbd "") 'minibuffer-complete)
(read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil

> > > +(define-key keymap (kbd "") '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.

Yeah, I futzed with it for a bit, swearing that there had to be a
better way, but didn't find one either.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-06-04 Thread Daniel Schoepe
Sorry, forgot to actually test notmuch-search entirely with this change
and not just the completion.
From cb172efc1dea2507566db587f960c073373e0159 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe 
Date: Sat, 4 Jun 2011 14:17:44 +0200
Subject: [PATCH] emacs: Tab completion for notmuch-search and
 notmuch-search-filter

This patch adds completion with  in the minibuffer for
notmuch-search and notmuch-search-filter.
---
 emacs/notmuch.el |   35 +--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3311fe8..a2db852 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -72,6 +72,9 @@ For example:
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch)
 
+(defvar notmuch-completions nil
+  "List of completions used in notmuch-query-completions")
+
 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
   (let ((tag-list
 	 (with-output-to-string
@@ -882,6 +885,34 @@ characters as well as `_.+-'.
 	   (concat "*notmuch-search-" query "*"))
 	  )))
 
+(defun notmuch-query-completions (string)
+  "Return possible completions for STRING."
+  (cond
+   ;; this ugly regexp is used to get the last word of the input
+   ;; possibly preceded by a '('
+   ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
+(mapcar (lambda (compl)
+	  (concat (match-string-no-properties 1 string) compl))
+	(all-completions (match-string-no-properties 2 string)
+			 notmuch-completions)))
+   (t (list string
+
+(defun notmuch-read-query (prompt)
+  "Read a notmuch-query from the minibuffer with completion.
+
+PROMPT is the string to prompt with."
+  (let ((keymap (copy-keymap minibuffer-local-map))
+	(minibuffer-completion-table (completion-table-dynamic #'notmuch-query-completions)))
+;; this was simpler than convincing completing-read to accept spaces:
+(define-key keymap (kbd "") 'minibuffer-complete)
+(setq notmuch-completions
+	  (append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
+			"subject:" "attachment:")
+		  (mapcar (lambda (tag)
+			(concat "tag:" tag))
+			  (process-lines "notmuch" "search-tags"
+(read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil)))
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -893,7 +924,7 @@ The optional parameters are used as follows:
  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
appear in the search results."
-  (interactive "sNotmuch search: ")
+  (interactive (list (notmuch-read-query "Notmuch search: ")))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
 (notmuch-search-mode)
@@ -991,7 +1022,7 @@ search."
 
 Runs a new search matching only messages that match both the
 current search results AND the additional query string provided."
-  (interactive "sFilter search: ")
+  (interactive (list (notmuch-read-query "Filter search: ")))
   (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)
 			   (concat "( " query " )")
 			 query)))
-- 
1.7.5.3



pgpPRWlpziEvE.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-06-04 Thread Daniel Schoepe
On Sat, 4 Jun 2011 11:32:15 -0400, Austin Clements  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 "") '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.
From 70642aecbf63428d9bcedc108c55f65574a792e7 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe 
Date: Sat, 4 Jun 2011 14:17:44 +0200
Subject: [PATCH] emacs: Tab completion for notmuch-search and
 notmuch-search-filter

This patch adds completion with  in the minibuffer for
notmuch-search and notmuch-search-filter.
---
 emacs/notmuch.el |   35 +--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3311fe8..17c214c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -72,6 +72,9 @@ For example:
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch)
 
+(defvar notmuch-completions nil
+  "List of completions used in notmuch-query-completions")
+
 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
   (let ((tag-list
 	 (with-output-to-string
@@ -882,6 +885,34 @@ characters as well as `_.+-'.
 	   (concat "*notmuch-search-" query "*"))
 	  )))
 
+(defun notmuch-query-completions (string)
+  "Return possible completions for STRING."
+  (cond
+   ;; this ugly regexp is used to get the last word of the input
+   ;; possibly preceded by a '('
+   ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
+(mapcar (lambda (compl)
+	  (concat (match-string-no-properties 1 string) compl))
+	(all-completions (match-string-no-properties 2 string)
+			 notmuch-completions)))
+   (t (list string
+
+(defun notmuch-read-query (prompt)
+  "Read a notmuch-query from the minibuffer with completion.
+
+PROMPT is the string to prompt with."
+  (let ((keymap (copy-keymap minibuffer-local-map))
+	(minibuffer-completion-table (completion-table-dynamic #'notmuch-query-completions)))
+;; this was simpler than convincing completing-read to accept spaces:
+(define-key keymap (kbd "") 'minibuffer-complete)
+(setq notmuch-completions
+	  (append (list "folder:" "thread:" "id:" "date:" "from:" "to:"
+			"subject:" "attachment:")
+		  (mapcar (lambda (tag)
+			(concat "tag:" tag))
+			  (process-lines "notmuch" "search-tags"
+(read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil)))
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -893,7 +924,7 @@ The optional parameters are used as follows:
  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
appear in the search results."
-  (interactive "sNotmuch search: ")
+  (interactive (notmuch-read-query "Notmuch search: "))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
 (notmuch-search-mode)
@@ -991,7 +1022,7 @@ search."
 
 Runs a new search matching only messages that match both the
 current search results AND the additional query string provided."
-  (interactive "sFilter search: ")
+  (interactive (notmuch-read-query "Filter search: "))
   (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)
 			   (concat "( " query " )")
 			 query)))
-- 
1.7.5.3



pgpZUqPb2jMu2.pgp
Description: PGP signature
___
notmuch mailing list
n

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

2011-06-04 Thread Austin Clements
Nifty!

On Sat, Jun 4, 2011 at 8:19 AM, Daniel Schoepe
 wrote:
> +        (minibuffer-completion-table (completion-table-dynamic
> +                                      `(lambda (s) (notmuch-query-completions
> +                                               (quote ,all-compls) s)
> +    ;; ^ emulate a closure to avoid recomputing the completion list each time

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.

> +(define-key keymap (kbd "") '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).
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch