From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 77F2B6DE0AAB for ; Sat, 12 Nov 2016 11:06:49 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.531 X-Spam-Level: X-Spam-Status: No, score=0.531 tagged_above=-999 required=5 tests=[AWL=-0.121, SPF_NEUTRAL=0.652] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9WSbAXGGCwvP for ; Sat, 12 Nov 2016 11:06:48 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id A49296DE0999 for ; Sat, 12 Nov 2016 11:06:46 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id CDF0310004A; Sat, 12 Nov 2016 21:07:31 +0200 (EET) From: Tomi Ollila To: David Bremner , Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook In-Reply-To: <20161104010243.23316-1-david@tethera.net> References: <87k2ckl9zb.fsf@tesseract.cs.unb.ca> <20161104010243.23316-1-david@tethera.net> User-Agent: Notmuch/0.23.1+44~gfdccb81 (https://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2016 19:06:49 -0000 On Fri, Nov 04 2016, David Bremner 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)))