feat(apis): add new useful methods to OrgApiFile and OrgApiHeadline#1127
feat(apis): add new useful methods to OrgApiFile and OrgApiHeadline#1127ar-at-localhost wants to merge 17 commits into
OrgApiFile and OrgApiHeadline#1127Conversation
- 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
| @return string | ||
|
|
||
|
|
||
| OrgFile:insert_headline() *OrgFile:insert_headline* |
There was a problem hiding this comment.
@kristijanhusak I'm not familiar with lemmy-help, so I generated these blindly. Please have a careful look. Thanks
There was a problem hiding this comment.
These are auto generated from annotations, no need to add anything.
| assert.is.Nil(closest_headline) | ||
| end) | ||
|
|
||
| describe('insert_headline', function() |
There was a problem hiding this comment.
@kristijanhusak AI generated. Have a careful look. Thanks
OrgApiFile and `OrgApiHeadlineOrgApiFile and OrgApiHeadline
| @return string | ||
|
|
||
|
|
||
| OrgFile:insert_headline() *OrgFile:insert_headline* |
There was a problem hiding this comment.
These are auto generated from annotations, no need to add anything.
| --- 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Please remove all these new files that does not relate to the plugin.
There was a problem hiding this comment.
This is something I’d prefer to keep. These files are intentionally committed so Nix users can contribute easily without needing to set up the environment manually.
That said, I’ve cleaned up and simplified the setup by switching to a more standard approach (Flakes instead of Devenv), which reduces the number of files and improves familiarity for existing Nix users.
The added files are effectively no-ops for non-Nix users, while still being valuable for contributors using Nix. In practice, if a future Nix user wanted to contribute, they would most likely end up adding a similar flake setup before making any actual changes anyway.
That said, I’ll still respect the decision if you’d prefer to remove it regardless.
There was a problem hiding this comment.
We don't need this file.
|
|
||
| # Lock file | ||
| .org-ts-lock.json | ||
|
|
There was a problem hiding this comment.
These are mostly nix specific stuff that you can ignore in your global gitignore. Please remove them.
| @@ -0,0 +1,63 @@ | |||
| { | |||
There was a problem hiding this comment.
We don't need nix specific stuff in repo.
| end | ||
| logbook:add_clock_in() | ||
| EventManager.dispatch(events.ClockedIn:new(self)) | ||
| if not opts or not opts.silent then |
There was a problem hiding this comment.
What is the use case for the silent version?
|
|
||
| ---Get closest internal OrgHeadline for the headline | ||
| ---@return OrgPromise<OrgHeadline> | ||
| function OrgHeadline:get_closest_headline() |
There was a problem hiding this comment.
This method should not live on the OrgHeadline. It should be either in the api/init.lua or api/file.lua
Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
Summary
This PR adds new API methods to
OrgAPIHeadlinefor programmatic uses.Changes
Non-Breaking
Headline:clock_inandHeadline:clock_outnow accepts optional opts to enable silent behavior (useful for programmatic uses).Checklist
I confirm that I have:
Conventional Commits
specification (e.g.,
feat: add new feature,fix: correct bug,docs: update documentation).make test.