Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id CB55B429E28 for ; Wed, 21 Dec 2011 04:35:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EF6vs-pbQCxg for ; Wed, 21 Dec 2011 04:35:34 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 32D05431FB6 for ; Wed, 21 Dec 2011 04:35:34 -0800 (PST) Received: by werm12 with SMTP id m12so3310882wer.26 for ; Wed, 21 Dec 2011 04:35:31 -0800 (PST) Received: by 10.216.131.223 with SMTP id m73mr8785155wei.52.1324470931323; Wed, 21 Dec 2011 04:35:31 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id en20sm13113526wid.10.2011.12.21.04.35.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 04:35:30 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 68BB0A024F; Wed, 21 Dec 2011 12:35:28 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Don't prompt the user to choose from zero matching addresses. Date: Wed, 21 Dec 2011 12:35:27 +0000 Message-Id: <1324470927-15353-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2011 12:35:34 -0000 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