From: No Wayman <iarchivedmywholelife@gmail.com>
To: emacs-orgmode@gnu.org
Cc: emacs-orgmode-request@gnu.org
Subject: Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)
Date: Tue, 08 Feb 2022 14:02:25 -0500 [thread overview]
Message-ID: <87a6f1no7e.fsf@gmail.com> (raw)
In-Reply-To: <mailman.61.1644253327.32758.emacs-orgmode@gnu.org>
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
> - :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.
> + :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
> #<buffer CAPTURE-test.org> 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?
next parent reply other threads:[~2022-02-08 19:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.61.1644253327.32758.emacs-orgmode@gnu.org>
2022-02-08 19:02 ` No Wayman [this message]
2022-02-09 4:10 ` [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann) Ihor Radchenko
2022-02-09 7:11 ` No Wayman
2022-03-20 10:43 ` Ihor Radchenko
2022-02-10 19:32 ` Greg Minshall
2022-02-05 11:54 Lazy load of org-protocol Max Nikulin
2022-02-05 18:27 ` Jim Porter
2022-02-06 16:42 ` Max Nikulin
2022-02-06 19:40 ` Jim Porter
2022-02-07 14:57 ` Max Nikulin
2022-02-07 19:06 ` Jim Porter
2022-02-09 16:46 ` Max Nikulin
2022-02-09 19:22 ` Jim Porter
2022-02-10 14:44 ` Max Nikulin
2022-02-08 10:44 ` Emacs-orgmode Digest, Vol 192, Issue 8 Tianshu Wang
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=87a6f1no7e.fsf@gmail.com \
--to=iarchivedmywholelife@gmail.com \
--cc=emacs-orgmode-request@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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).