Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
No Wayman writes: >> I think Nicolas gave some reasonable comments, didn't he? He >> suggested >> to incorporate some of the ideas into the existing Org mode >> code. >> >> https://orgmode.org/list/87wo66t8i7@gmail.com > > I believe you're referring to: > > https://list.orgmode.org/87y2qlgq33@nicolasgoaziou.fr/ > > He had some reasonable questions about the design, but said he > only uses very basic capture templates, and could not comment > beyond that on the design. The hope was that people who use more > of org-capture's features would chime in. That didn't happen. I just pinged that thread again. Note that I strongly support adding doct to Org. > Of course doct's features could be added to org-capture in a > piecemeal fashion, but I'm not too keen on contributing anything > non-trivial to Org these days. Too much back and forth coupled > with discussion that can stall due to lack of interest. > e.g. > https://list.orgmode.org/87h7e6dluc@gmail.com/ > https://list.orgmode.org/87tuit73ij@gmail.com/ I cannot comment on the lexical binding thing. I do not really know lexical binding internals enough to judge what kind of problem that patch is trying to solve. However, Bastien commented on the second patch. I do find it useful as well. I think the only problem with that patch is that it is not listed in updates.orgmode.org and Bastien missed your last reply. Best, Ihor
Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
fwiw... > 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: > > https://www.github.com/progfolio/doct i've been using doct for a while, and have been very happy with it. (thanks for implementing it.) cheers, Greg
Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
Ihor Radchenko writes: No Wayman writes: 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: https://www.github.com/progfolio/doct I think Nicolas gave some reasonable comments, didn't he? He suggested to incorporate some of the ideas into the existing Org mode code. https://orgmode.org/list/87wo66t8i7@gmail.com Best, Ihor I believe you're referring to: https://list.orgmode.org/87y2qlgq33@nicolasgoaziou.fr/ He had some reasonable questions about the design, but said he only uses very basic capture templates, and could not comment beyond that on the design. The hope was that people who use more of org-capture's features would chime in. That didn't happen. Of course doct's features could be added to org-capture in a piecemeal fashion, but I'm not too keen on contributing anything non-trivial to Org these days. Too much back and forth coupled with discussion that can stall due to lack of interest. e.g. https://list.orgmode.org/87h7e6dluc@gmail.com/ https://list.orgmode.org/87tuit73ij@gmail.com/
Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
No Wayman writes: > 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: > > https://www.github.com/progfolio/doct I think Nicolas gave some reasonable comments, didn't he? He suggested to incorporate some of the ideas into the existing Org mode code. https://orgmode.org/list/87wo66t8i7@gmail.com Best, Ihor
Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
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: https://www.github.com/progfolio/doct - :prependNormally newly captured information will be appended at - the target location (last child, last table line, - last list item...). Setting this property will - change that. + :prepend Normally newly captured information will be appended at +the target location (last child, last table line, +last list item...). Setting this property will +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 current. +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 during org-capture-mode-hook: Yodel[1] Report 2022-02-08 14:16:58 === --8<---cut here---start->8--- (yodel :save "org-capture-mode-hook-example" :packages* doct :post* (require 'org-capture) (require 'doct) (let ((org-capture-templates (doct `("test" :keys "t" :file "/tmp/test.org" :template "* test" :immediate-finish t :hook (lambda nil (message "%S narrowed?: %S" (current-buffer) (buffer-narrowed-p))) (org-capture nil "t"))) --8<---cut here---end--->8--- STDOUT == Loading /tmp/org-capture-mode-hook-example/straight-bootstrap-snippet.el (source)... Clipboard pasted as level 1 subtree # narrowed?: t Environment === - emacs version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-01-13 - system type: gnu/linux Packages - doct https://github.com/progfolio/doct/commit/9ed9b8c7f7e2ea2d2fb739d65ae4626a1cf16b9f [1] https://www.github.com/progfolio/yodel + +(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. (let ((org-capture-mode-hook (append org-capture-mode-hook (org-capture-get :hook t (run-hooks 'org-capture-mode-hook)) 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 the ;; 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)) (org-capture-finalize))) (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?