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.

Best,
Ihor


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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06 14:05 [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture Valentin Herrmann
2022-04-24  4:57 ` Ihor Radchenko [this message]
2022-10-31  5:49 ` Ihor Radchenko
  -- strict thread matches above, loose matches on Subject: below --
2022-02-06  9:22 Valentin Herrmann
2022-10-31  5:50 ` Ihor Radchenko

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://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 \
    /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://git.savannah.gnu.org/cgit/emacs/org-mode.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).