]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: include first match in address completion
authorMark Walters <markwalters1009@gmail.com>
Tue, 27 Sep 2016 15:45:27 +0000 (16:45 +0100)
committerDavid Bremner <david@tethera.net>
Sun, 9 Oct 2016 11:50:32 +0000 (08:50 -0300)
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 <down> 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.

emacs/notmuch-address.el

index 10eaab196267bbad86c967e1318ea6083a577b44..b2e1fba797592869de3628d088e28f8f2aac9b53 100644 (file)
@@ -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)