unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Don't prompt the user to choose from zero matching addresses.
@ 2011-12-21 12:35 David Edmondson
  2011-12-21 13:20 ` Tomi Ollila
  2011-12-22 11:25 ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: David Edmondson @ 2011-12-21 12:35 UTC (permalink / raw)
  To: notmuch

If the address matching function generates no matches, don't prompt
the user to choose between them (!). Instead, generate a message to
report that there were no matches.
---
 emacs/notmuch-address.el |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1a7c577..8eba7a0 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -54,15 +54,22 @@ line."
 	 (completion-ignore-case t)
 	 (options (notmuch-address-options orig))
 	 (num-options (length options))
-	 (chosen (if (eq num-options 1)
-		     (car options)
+	 (chosen (cond
+		  ((eq num-options 0)
+		   nil)
+		  ((eq num-options 1)
+		   (car options))
+		  (t
 		   (completing-read (format "Address (%s matches): " num-options)
 				    (cdr options) nil nil (car options)
-				    'notmuch-address-history))))
-    (when chosen
-      (push chosen notmuch-address-history)
-      (delete-region beg end)
-      (insert chosen))))
+				    'notmuch-address-history)))))
+    (if chosen
+	(progn
+	  (push chosen notmuch-address-history)
+	  (delete-region beg end)
+	  (insert chosen))
+      (message "No matches.")
+      (ding))))
 
 ;; Copied from `w3m-which-command'.
 (defun notmuch-address-locate-command (command)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Don't prompt the user to choose from zero matching addresses.
  2011-12-21 12:35 [PATCH] emacs: Don't prompt the user to choose from zero matching addresses David Edmondson
@ 2011-12-21 13:20 ` Tomi Ollila
  2011-12-22 11:25 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2011-12-21 13:20 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Wed, 21 Dec 2011 12:35:27 +0000, David Edmondson <dme@dme.org> wrote:
> If the address matching function generates no matches, don't prompt
> the user to choose between them (!). Instead, generate a message to
> report that there were no matches.
> ---

LGTM

>  emacs/notmuch-address.el |   21 ++++++++++++++-------
>  1 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index 1a7c577..8eba7a0 100644
> --- a/emacs/notmuch-address.el
> +++ b/emacs/notmuch-address.el
> @@ -54,15 +54,22 @@ line."
>  	 (completion-ignore-case t)
>  	 (options (notmuch-address-options orig))
>  	 (num-options (length options))
> -	 (chosen (if (eq num-options 1)
> -		     (car options)
> +	 (chosen (cond
> +		  ((eq num-options 0)
> +		   nil)
> +		  ((eq num-options 1)
> +		   (car options))
> +		  (t
>  		   (completing-read (format "Address (%s matches): " num-options)
>  				    (cdr options) nil nil (car options)
> -				    'notmuch-address-history))))
> -    (when chosen
> -      (push chosen notmuch-address-history)
> -      (delete-region beg end)
> -      (insert chosen))))
> +				    'notmuch-address-history)))))
> +    (if chosen
> +	(progn
> +	  (push chosen notmuch-address-history)
> +	  (delete-region beg end)
> +	  (insert chosen))
> +      (message "No matches.")
> +      (ding))))
>  
>  ;; Copied from `w3m-which-command'.
>  (defun notmuch-address-locate-command (command)
> -- 
> 1.7.7.3

Tomi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Don't prompt the user to choose from zero matching addresses.
  2011-12-21 12:35 [PATCH] emacs: Don't prompt the user to choose from zero matching addresses David Edmondson
  2011-12-21 13:20 ` Tomi Ollila
@ 2011-12-22 11:25 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2011-12-22 11:25 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Wed, 21 Dec 2011 12:35:27 +0000, David Edmondson <dme@dme.org> wrote:
> If the address matching function generates no matches, don't prompt
> the user to choose between them (!). Instead, generate a message to
> report that there were no matches.

pushed,

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-22 11:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 12:35 [PATCH] emacs: Don't prompt the user to choose from zero matching addresses David Edmondson
2011-12-21 13:20 ` Tomi Ollila
2011-12-22 11:25 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).