Skip to content

feat(capture): Support for %^g and %^G expansions in capture templates.#1132

Open
alecStewart1 wants to merge 6 commits into
nvim-orgmode:masterfrom
alecStewart1:capture-g-expansions
Open

feat(capture): Support for %^g and %^G expansions in capture templates.#1132
alecStewart1 wants to merge 6 commits into
nvim-orgmode:masterfrom
alecStewart1:capture-g-expansions

Conversation

@alecStewart1
Copy link
Copy Markdown
Contributor

@alecStewart1 alecStewart1 commented Apr 21, 2026

Summary

Add capture expansions for:

%^g:

  • Prompt for tags, with completion on tags in target file.

%^G:

  • Prompt for tags, with completion all tags in all agenda files.

Changes

Added functions:

  • uniq_tags
  • get_target_tags (for %^g)
  • get_all_tags (for %^G)

For getting tags for %^g / %^G expansions.

Added prompt_tags to prompt on %^g / %^G expansions.

The above are used in expansions in lua/orgmode/capture/template/init.lua.

Addressed LuaLS warning in lua/orgmode/capture/templates.lua regarding templates or config.org_capture_templates.

Added plenary tests, update test helper create_agenda_files to return files for template tests.

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

@alecStewart1 alecStewart1 changed the title feat(capture): Start of support for %^g and %^G expansions in capture templates. feat(capture): Support for %^g and %^G expansions in capture templates. Apr 21, 2026
@alecStewart1 alecStewart1 force-pushed the capture-g-expansions branch from fb38130 to ac275b0 Compare April 30, 2026 15:14
Comment thread lua/orgmode/capture/template/init.lua Outdated
@alecStewart1 alecStewart1 force-pushed the capture-g-expansions branch from bfdd2cd to 7fab341 Compare May 2, 2026 15:49
Copy link
Copy Markdown
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! It is much better, but there are still few things to address before merging.

Comment thread lua/orgmode/capture/template/init.lua Outdated
Comment thread lua/orgmode/capture/template/init.lua Outdated
Comment thread lua/orgmode/capture/template/init.lua Outdated
local prepared_inputs = {}
for exp in content:gmatch('%%%^%b{}') do
-- Match %^{...} with optional g/G suffix for tag prompts
for exp in content:gmatch('%%%^%b{}[gG]?') do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check, but I was running into some issue with g/G still being with the resulting tag(s).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: without this, tests were failing and the outputted tags when I tested would include g/G.

Comment thread tests/plenary/helpers.lua
@alecStewart1
Copy link
Copy Markdown
Contributor Author

The CI failures on macos/ubuntu are 4 refile tests in api_spec.lua. I don't think I touched anything related to those.

@alecStewart1 alecStewart1 force-pushed the capture-g-expansions branch from 629b123 to d7eac0e Compare May 4, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants