-
-
Notifications
You must be signed in to change notification settings - Fork 162
feat(api): Allow to insert links through API #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@kristijanhusak Please see my PR in Telescope-orgmode as an example, how this change can be used. I actually need this change for that feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just abstract the logic in different place and use it on both places accordingly.
--- Insert a link to a given location at the current cursor position | ||
--- @param link_location string | ||
--- @return boolean | ||
function OrgApi.insert_link(link_location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's abstract all this logic in Hyperlinks
and then require that one here. I'm trying not to depend on orgmode.api
in the core, but vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit, that I just looked at other functions, which had similar calling schemes, but I agree, that it would be cleaner to move them into Hyperlinks
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the code as you suggested.
To give plugins like Telescope-orgmode the ability to insert links, the API needs an extension. The refactoring moves some methods from org.mappings into modules, where they should belong anyway, so they can be used from the new api method. The new API method api.insert_link is mostly existing code moved from org.mappings.insert_link, which now just calls api.insert_link.
To have clean module dependencies, insert_link is now a method of Hyperlinks and is exposed over the api but also called from mappings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
* feat(api): Allow to insert links through API To give plugins like Telescope-orgmode the ability to insert links, the API needs an extension. The refactoring moves some methods from org.mappings into modules, where they should belong anyway, so they can be used from the new api method. The new API method api.insert_link is mostly existing code moved from org.mappings.insert_link, which now just calls api.insert_link. * refactor: move link insertion into Hyperlinks To have clean module dependencies, insert_link is now a method of Hyperlinks and is exposed over the api but also called from mappings. --------- Co-authored-by: Sebastian Flügge <sebastian.fluegge@dnv.com>
To give plugins like Telescope-orgmode the ability to insert links, the API needs an extension.
The refactoring moves some methods from org.mappings into modules, where they should belong anyway, so they can be used from the new api method.
The new API method api.insert_link is mostly existing code moved from org.mappings.insert_link, which now just calls api.insert_link.