Skip to content

feat(apis): add new useful methods to OrgApiFile and OrgApiHeadline#1127

Open
ar-at-localhost wants to merge 6 commits intonvim-orgmode:masterfrom
ar-at-localhost:feat/apis
Open

feat(apis): add new useful methods to OrgApiFile and OrgApiHeadline#1127
ar-at-localhost wants to merge 6 commits intonvim-orgmode:masterfrom
ar-at-localhost:feat/apis

Conversation

@ar-at-localhost
Copy link
Copy Markdown

@ar-at-localhost ar-at-localhost commented Apr 14, 2026

Summary

This PR adds new API methods to OrgApiFile and OrgAPIHeadline for programmatic uses.

Changes

Non-Breaking

  • Headline:clock_in and Headline:clock_out now accepts optional opts to enable silent behavior (useful for programmatic uses).

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 (I've been using methods already in my personal project.)
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

- Add OrgHeadline:clock_in(opts) - clock in headline with optional silent event
- Add OrgHeadline:clock_out(opts) - clock out headline with optional silent event
- Add OrgHeadline:toggle_clock(opts) - toggle clock state (in if out, out if in)
- Add OrgHeadline:is_clocked_in() - check if headline is clocked in
- Add OrgHeadline:cancel_active_clock() - cancel active clock without event
- Add OrgHeadline:set_todo(keyword) - set todo keyword on headline
Comment thread doc/orgmode_api.txt
@return string


OrgFile:insert_headline() *OrgFile:insert_headline*
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@kristijanhusak I'm not familiar with lemmy-help, so I generated these blindly. Please have a careful look. Thanks

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.

These are auto generated from annotations, no need to add anything.

end)
end

---Clock-out in the headline
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

typo

assert.is.Nil(closest_headline)
end)

describe('insert_headline', function()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@kristijanhusak AI generated. Have a careful look. Thanks

@ar-at-localhost ar-at-localhost changed the title feat(apis): add new useful methods to OrgApiFile and `OrgApiHeadline feat(apis): add new useful methods to OrgApiFile and OrgApiHeadline Apr 14, 2026
Comment thread doc/orgmode_api.txt
@return string


OrgFile:insert_headline() *OrgFile:insert_headline*
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.

These are auto generated from annotations, no need to add anything.

Comment thread lua/orgmode/api/file.lua
--- Insert a headline to the file
--- @param headline OrgApiHeadline | OrgHeadline | { level: integer, keyword?: string, text: string } Headline to be inserted
--- @param after? OrgApiHeadline | OrgHeadline Optional headline to put after
function OrgFile:insert_headline(headline, after)
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.

We don't need this in the API. You can use capture flow to insert headlines. If you need this level of programmatic insertion you can create your own function.

Comment thread nix/nixvim.nix
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.

Please remove all these new files that does not relate to the plugin.

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