From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 463056DE024A for ; Tue, 27 Sep 2016 08:45:35 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.008 X-Spam-Level: X-Spam-Status: No, score=-0.008 tagged_above=-999 required=5 tests=[AWL=-0.138, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6BTh9SwLgZmz for ; Tue, 27 Sep 2016 08:45:34 -0700 (PDT) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 528226DE0173 for ; Tue, 27 Sep 2016 08:45:34 -0700 (PDT) Received: by mail-wm0-f68.google.com with SMTP id b184so1795214wma.3 for ; Tue, 27 Sep 2016 08:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=eNy4sivPdmOtnMf8gxzZe7ZhB8sr/JW7JoXsdkZAYr4=; b=rjxc6OnyHHYu+qyROVjGGGfyhjgVzjxCgd2Nu9bPYdrK5BKahPNRBNe78+6yAp+cXY WV30cyA4M0J5dQPZwCkigpVpDl0Iau8sPIq6aG73zB0us69713OZiozaD/svDf8MvzpD waRNBFRQ97BGyhd9WEpEGp9cTZsvBeJTjwHBvQw9NpWmVssMJrVaA/aVvvZYlxPIp+Bm bpN87UHmBHwPyAhNIGDTRBnIA9rt0tjgUzoLM70ktYq6sMZ4N2sqVfF8fWP6KwkcaFvO zjvBxrYhHERkxQ2JLm9udO6a6DS6sxzHHzXvx4wyKZUmlckRrMaRj+rO0KbdIiGm3alU Ygog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eNy4sivPdmOtnMf8gxzZe7ZhB8sr/JW7JoXsdkZAYr4=; b=Ly1ZEYGVUcwtZGu2ebZEyeNmsBYInkA8SDqFMuTANw5X0ZeNu6DLx3ub8AP2XP7O6B qF6H+UXcr4avWpcqVEcW8v803JymojOf8JlaO1PDdhLq4aQZDL6znB21EN1huMgd4vqc UTI54zAxGo1W6yJ5dGgBvpi40HrFvPT7qzpowl4pL8Z/gfbzKyglWF2DPLXnLQ7kpU2P tdQq92b/PKKg4iYm88Q02XS6alMnvp8g6c4nVRFkKQwUHaa+eA/5Q6OkWLFK6IG8wLnM 7ljOJdZAKDMp1RxuF1341DZWhXkXSU40qxxgOkcO7bZ+JKj292EQkQVoNm42hxSn6Nwk oTPw== X-Gm-Message-State: AA6/9RmWAx3hobXbJI3OjGR/OifLi1+lT4mdAqFBqr5tIjwLNCpVmGyHUlpJIeMDEcf+aw== X-Received: by 10.28.72.10 with SMTP id v10mr3749051wma.52.1474991131162; Tue, 27 Sep 2016 08:45:31 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id t202sm17339609wmt.22.2016.09.27.08.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 08:45:30 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] emacs: include first match in address completion Date: Tue, 27 Sep 2016 16:45:27 +0100 Message-Id: <1474991127-15864-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 2.1.4 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Tue, 27 Sep 2016 15:45:35 -0000 The current code for address completion takes the list of possible completions (whether generated internally or externally), makes the first match the initial value for the completion, and puts all the others (but not the first match) into the possible completions. This has the nice effect that the key takes you immediately to the next completion (whereas if the first match were included in the possible completions it would take you to the first match again). However, it has two side effects. First, once you have completed to the full match you find it says and try completing again you get told "no match" not "sole completion". Secondly, if you delete some of the text and try completing you don't get the first match as an option. This tries to get round most of these problems by including the full list of possible completions, but with the first match moved to the very end of the list. --- Jani found this bug/odd behaviour on irc: it shows up particularly when resending/bouncing a message as we don't have a company mode option for that yet. It seems that the bahaviour dates back to the first introduction of address completion in 2010. I don't think this there is a perfect solution but this seems like an improvement. Best wishes Mark emacs/notmuch-address.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 10eaab1..b2e1fba 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -194,7 +194,14 @@ external commands." (t (funcall notmuch-address-selection-function (format "Address (%s matches): " num-options) - (cdr options) (car options)))))) + ;; We put the first match as the initial + ;; input; we put all the matches as + ;; possible completions, moving the + ;; first match to the end of the list + ;; makes cursor up/down in the list work + ;; better. + (append (cdr options) (list (car options))) + (car options)))))) (if chosen (progn (push chosen notmuch-address-history) -- 2.1.4