unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>,
	Mark Walters <markwalters1009@gmail.com>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
Date: Sat, 12 Nov 2016 21:07:31 +0200	[thread overview]
Message-ID: <m2y40o1pqk.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20161104010243.23316-1-david@tethera.net>

On Fri, Nov 04 2016, David Bremner <david@tethera.net> wrote:

> 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.
> ---
>
> Updates from Mark's second review
>  emacs/notmuch-address.el | 14 +++++++++++++-
>  emacs/notmuch-company.el |  1 +
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index b2e1fba..36c796f 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-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))

Like someone (whose message I cannot find just now) mentioned in another
thread, just now it is right time to mention here too...

https://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks.html

... that when hook name ends with `-hook` it is supposed to be "normal hook"
-- a function which does not take arguments nor return values.

So, I'd like to suggest that this variable is renamed to 
notmuch-address-completion-functions


Tomi


>  	(message "No matches.")
>  	(ding))))
>     (t nil)))

  parent reply	other threads:[~2016-11-12 19:06 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
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 [this message]
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=m2y40o1pqk.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=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).