feat(capture): pass destination file to headline function#1155
Open
alecStewart1 wants to merge 1 commit into
Open
feat(capture): pass destination file to headline function#1155alecStewart1 wants to merge 1 commit into
alecStewart1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Emacs, a function passed
file+functionpassed to a template can technically operate on the destination file before the target is found.In the case of my Emacs configuration, I created the following functions that I pass to
file+function:And passing
(capture:goto-or-create-heading (capture:get-todays-timestamp))as the second argument tofile+functionin a template spec will have the heading created first if it's not there, and then the point of said heading is returned.In nvim-orgmode, there's no real way to do this, so a solution is to pass
OrgFile?(?so it can be ignored by people who don't want to use it) to the function thatheadlinecan receive.Changes
Add
opts.destination_fileas a argument topcallwithtemplate_headlinein_get_refile_vars.Update
OrgCaptureTemplateOptsto includeOrgFile?inheadlinefunction.Update docs to specify optional
OrgFileargument that the function passed toheadlinecan take.Extra Notes
This extra level of power can lead to potential "footgunning" from the user.
The following is an example of me trying to mimic what I've done in Emacs above:
The comments are from what I noticed with doing a simpler version of this
headline_for_todayfunction (not accounting for top-level file attributes like#+TITLE:etc., not accounting for the memoized headline cache).So just something to keep in mind.
Checklist
I confirm that I have:
Conventional Commits
specification (e.g.,
feat: add new feature,fix: correct bug,docs: update documentation).make test.