Feat: improve org-ai-insert-snippet related part #96
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.
First, thank you for the good package, I hope my contribution can help you in some way. If I do something wrong, feel free to fix this 😄.
These commits focus on the part where we can insert snippets based on yasnippet package. The feat is located in org-ai-useful.el. I focus on this part because I think it can act like a strategy to quick filter and insert prompt as user want. (It is actually more flexible than just prompts search and insert. )
The name of the old function
org-ai-insert-snippets
can be misunderstood and cause frustration because it just loads the snippets to the snippets collection - without any output to the user interface 😕. Also, it should not beinteractive
, user can be suggested to load that function in their config file only 1 time during startup. This commit changes this function name toorg-ai-load-snippets
.I suggested we should add a tip to README file to call this function . I think this is not a nice idea to force users to load any function if they don't want to. User can choose to load or not load snippets on the "snippets/" directory which stay in the package source code, they simply can create any new snippet with a suitable name in the traditional way of yasnippet. I hope we can create a new repo just to store snippets, which is similar to the
Wolfram prompt repository
idea. If put a directory that stores snippet template files directly in source code of this package, we may accidentally create a bad habit for users by pointing them to create new snippet template files in source code location. But this is another story, I should not go further. 🙇Also, this commit adds a new command
org-ai-insert-snippet
(snippet not snippets like the old renamed one), it acts the same asyasnippet-insert-snippet
command, which means an interactive snippet picker will pop up and the user will pick one of them to insert to the current location. The difference is that this function only filter and load those snippets withname
that match (or contain) the string (or maybe regex) custom variable nameorg-ai-snippet-regex
(which default is "org-ai").Notes: we can inform the users more clearly that only snippets related to
org-mode
will be filtered. These are just edge cases, I don't think someone will use this package outside org-modeorg-ai-pr-2023-12-03_01.33.27.mp4