emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Valentin Herrmann <herr.valentin.mann@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture
Date: Sun, 24 Apr 2022 12:57:23 +0800	[thread overview]
Message-ID: <87fsm313kc.fsf@localhost> (raw)
In-Reply-To: <20220206140551.1263130-1-herr.valentin.mann@gmail.com>

Valentin Herrmann <herr.valentin.mann@gmail.com> writes:

> * lisp/org-capture.el:
> (org-capture-templates): Document the new template options.
> (org-capture-before-view-hook): Add new hook for parity with the
> template options.
> (org-capture): Implement the new template options.
> (org-capture-finalize): Implement the new template options.
> (org-capture-kill): Remove unneeded line.
> * doc/org-manual.org (Template elements): Document the new template options

> This change comes from my personal config, where I use e.g. the option
> `:before-finalize-hook' to capture an task automatically, whenever I
> capture using a certain template.

Thanks! This addition looks reasonable.

> +        (if-let ((bvh (org-capture-get :before-view-hook)))
> +            (funcall bvh))
> ...
> +  (when-let ((pfh (org-capture-get :prepare-finalize-hook)))
> +    (funcall pfh))
> ...
> +        (when-let ((bfh (org-capture-get :before-finalize-hook)))
> +          (funcall bfh))))
> ...
> +    (when-let ((afh (org-capture-get :after-finalize-hook)))
> +      (funcall afh))

You should use run-hooks, not funcall. Hook must be a list of functions,
not a single function. By definition.

Also, do not use if-let/when-let. They are not loaded by default in
Emacs 26, which is still supported.

> -      (run-hooks 'org-capture-before-finalize-hook))
> +      (unless org-note-abort
> +        (run-hooks 'org-capture-before-finalize-hook)
> ...
> -  (let ((org-note-abort t)
> -	(org-capture-before-finalize-hook nil))
> +  (let ((org-note-abort t))
>      (org-capture-finalize)))

> (org-capture-finalize): Implement the new template options.
> (org-capture-kill): Remove unneeded line.

This change looks reasonable, but please document the rationale better
in the commit message. The current message is not clear.


  reply	other threads:[~2022-04-24  4:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06 14:05 Valentin Herrmann
2022-04-24  4:57 ` Ihor Radchenko [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-06  9:22 Valentin Herrmann

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:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsm313kc.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=herr.valentin.mann@gmail.com \
    --subject='Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


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).