: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)"
(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)))