X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-address.el;h=5b2beefeb823c906280755ed4da121fe209969ee;hb=0abcad7c0ec2099750720d02b97aa84ce0255f91;hp=10eaab196267bbad86c967e1318ea6083a577b44;hpb=07dff496304d6dc2e8033a18691b095ed9cd212f;p=notmuch diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 10eaab19..5b2beefe 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -98,6 +98,17 @@ to know how address selection is made by default." :group 'notmuch-send :group 'notmuch-external) +(defcustom notmuch-address-post-completion-functions nil + "Functions called after completing address. + +The completed address is passed as an argument to each function. +Note that this hook will be invoked for completion in headers +matching `notmuch-address-completion-headers-regexp'. +" + :type 'hook + :group 'notmuch-address + :group 'notmuch-hooks) + (defun notmuch-address-selection-function (prompt collection initial-input) "Call (`completing-read' PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)" @@ -194,12 +205,20 @@ 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) (delete-region beg end) - (insert chosen)) + (insert chosen) + (run-hook-with-args 'notmuch-address-post-completion-functions chosen)) (message "No matches.") (ding)))) (t nil)))