[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
Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
Tue, 08 Feb 2022 14:02:25 -0500
mu4e 1.7.5; emacs 29.0.50
I've implemented what you're proposing here (and much more) in a
package you may find useful a couple years ago. I pitched adopting
some of the ideas into org-mode proper and was willing to do the
work. My proposal was met with enthusiastic silence:
- :prepend Normally newly captured information will
be appended at
- the target location (last child, last
- last list item...). Setting this property
- change that.
+ :prepend Normally newly captured information
will be appended at
+ the target location (last child, last
+ last list item...). Setting this
+ change that.
Are the white space changes to unrelated properties necessary?
+(defcustom org-capture-before-view-hook nil
+ "Hook that is run right after the capture buffer is made
+The buffer is still narrowed."
+ :group 'org-capture
+ :version "28.1"
+ :type 'hook)
This functionality is already provided by `org-capture-mode-hook'.
Instead of introducing another hook, that can be utilized. An
illustration using doct's :hook keyword which runs functions
Yodel Report 2022-02-08 14:16:58
:template "* test"
:hook (lambda nil
(message "%S narrowed?: %S"
(org-capture nil "t")))
Clipboard pasted as level 1 subtree
#<buffer CAPTURE-test.org> narrowed?: t
- emacs version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu,
GTK+ Version 3.24.31, cairo version 1.17.4)
- system type: gnu/linux
+ (run-hooks 'org-capture-before-view-hook)
+ (if-let ((bvh (org-capture-get :before-view-hook)))
+ (funcall bvh))
This pattern implies that functions added via template keywords
will be run after the equivalent global hooks. That should be
documented. This pattern could be improved by let-binding each
hook and adding the templates functions. e.g.
(append org-capture-mode-hook (org-capture-get :hook t))))
Note the use of the non-nil LOCAL argument in org-capture-get.
You want to ensure you're accessing the correct plist in the case
of overlapping capture processes.
;; FIXME: This does not do the right thing, we need to remove
;; new stuff by hand it is easy: undo, then kill the buffer
- (let ((org-note-abort t)
- (org-capture-before-finalize-hook nil))
+ (let ((org-note-abort t))
(defun org-capture-goto-last-stored ()
Why was org-capture-before-finalize-hook bound to nil here and
what is the reason for changing that?
- Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann),
No Wayman <=