]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: add notmuch-address-post-completion-hook
authorDavid Bremner <david@tethera.net>
Fri, 4 Nov 2016 01:02:43 +0000 (22:02 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 4 Nov 2016 15:51:50 +0000 (12:51 -0300)
This hook can be used to update the message based on the results of
address completion. For example using message-templ or gnus-alias to set
the From address based on the To address just completed.

The post-completion command is added to the notmuch-company backend to
ensure that the hook is also called company completion is started
without going through notmuch-address-expand-name. See the docstring of
`company-backends' for more information.

emacs/notmuch-address.el
emacs/notmuch-company.el

index b2e1fba797592869de3628d088e28f8f2aac9b53..36c796f9e34d11145dda5162a3360cf5db2f31c6 100644 (file)
@@ -98,6 +98,17 @@ to know how address selection is made by default."
   :group 'notmuch-send
   :group 'notmuch-external)
 
+(defcustom notmuch-address-completion-hook 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)"
@@ -206,7 +217,8 @@ external commands."
          (progn
            (push chosen notmuch-address-history)
            (delete-region beg end)
-           (insert chosen))
+           (insert chosen)
+           (run-hook-with-args 'notmuch-address-completion-hook chosen))
        (message "No matches.")
        (ding))))
    (t nil)))
index 168315ff225fb68034979ad38cab1ebd976cde33..91c4804f4a086c95a1f755e10b43eaf4fd421929 100644 (file)
@@ -86,6 +86,7 @@
       (match (if (string-match notmuch-company-last-prefix arg)
                 (match-end 0)
               0))
+      (post-completion (run-hook-with-args 'notmuch-address-completion-hook arg))
       (no-cache t))))