Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
(Trying to send this w/o Mark in To: -- in the hope also Mark receive this email to his gmail account...) On Sun, Nov 13 2016, Mark Walterswrote: > On Sat, 12 Nov 2016, David Bremner wrote: >> Tomi Ollila writes: >> >>> 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 >>> >> >> Well, I guess the -functions convention should be followed, but >> notmuch-address-completion-functions seems a bit vague. > > Maybe notmuch-address-post-completion-functions ? > > Alternatively maybe we can end in -hook-functions to indicate it is a > function which is like a hook? I found *-hook-functions format mystically familiar but could not found any references in emacs 24.5 (nor now latest git) elisp source; there has been loadhist-hook-functions and vc-backend-hook-functions in the source but those have been removed/replaced later (w/o explanation why). otoh there are plenty of *-hook-function references (which value seem to be expected to be symbol to function). Then I recognized I have had such definitions in my *own* elisp configuration files something like 25 years... ;) (copied from someone in my early emacs days). So, after more grepping it looks to me that this notmuch-address-post-completion-functions is pretty good suggestion. (Grepping through elisp source distributed with emacs there are quite a few lines like (run-hook-with-args '...-hook args..). it is easy to end up being incompliant with the emacs convention. But other code not being compliant is not good reason to do the same (and thanks to Matt (in id:qf537j3hu4p@marmstrong-linux.kir.corp.google.com) for rest of us to recognize this early enough)) BTW: I just noticed that the message subject said: emacs: add notmuch-address-post-completion-hook but the currently used variable name lacked this -post- part -- caused a bit of confusion of what/why am I suggesting here ;) Tomi > > Best wishes > > Mark ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
On Sat, 12 Nov 2016, David Bremnerwrote: > Tomi Ollila writes: > >> 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 >> > > Well, I guess the -functions convention should be followed, but > notmuch-address-completion-functions seems a bit vague. Maybe notmuch-address-post-completion-functions ? Alternatively maybe we can end in -hook-functions to indicate it is a function which is like a hook? Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
Tomi Ollilawrites: > 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 > Well, I guess the -functions convention should be followed, but notmuch-address-completion-functions seems a bit vague. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
On Fri, Nov 04 2016, David Bremnerwrote: > 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))) ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
David Bremnerwrites: > 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. pushed to master d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook
This version looks good to me +1 Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch