From: David Bremner <david@tethera.net>
To: Mark Walters <markwalters1009@gmail.com>,
David Bremner <david@tethera.net>,
notmuch@notmuchmail.org
Subject: [PATCH] emacs: add notmuch-address-post-completion-hook
Date: Thu, 3 Nov 2016 08:38:13 -0300 [thread overview]
Message-ID: <20161103113813.29596-1-david@tethera.net> (raw)
In-Reply-To: <878tt09amd.fsf@qmul.ac.uk>
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 | 7 +++++++
emacs/notmuch-company.el | 1 +
2 files changed, 8 insertions(+)
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index b2e1fba..5324c92 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -98,6 +98,12 @@ 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"
+ :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)"
@@ -205,6 +211,7 @@ external commands."
(if chosen
(progn
(push chosen notmuch-address-history)
+ (run-hook-with-args 'notmuch-address-completion-hook return-value)
(delete-region beg end)
(insert chosen))
(message "No matches.")
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 168315f..91c4804 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -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))))
--
2.10.1
next prev parent reply other threads:[~2016-11-03 11:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 0:36 [PATCH] emacs: add notmuch-address-post-completion-hook David Bremner
2016-11-03 9:27 ` Mark Walters
2016-11-03 11:38 ` David Bremner [this message]
2016-11-03 11:56 ` [PATCH v3] " David Bremner
2016-11-03 17:08 ` Mark Walters
2016-11-03 18:00 ` David Bremner
2016-11-04 1:02 ` [PATCH v4] " David Bremner
2016-11-04 6:33 ` Mark Walters
2016-11-04 15:53 ` David Bremner
2016-11-12 19:07 ` Tomi Ollila
2016-11-12 21:39 ` David Bremner
2016-11-13 7:34 ` Mark Walters
2016-11-13 12:39 ` Tomi Ollila
2016-11-13 13:03 ` [PATCH] emacs: rename notmuch-address-completion-hook to notmuch-address-post-completion-functions David Bremner
2016-11-13 17:28 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161103113813.29596-1-david@tethera.net \
--to=david@tethera.net \
--cc=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).