emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture


From: Ihor Radchenko
Subject: Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture
Date: Sun, 24 Apr 2022 12:57:23 +0800

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 via email to

[Prev in Thread] Current Thread [Next in Thread]