Skip to content
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

Feat: improve org-ai-insert-snippet related part #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nhannht
Copy link

@nhannht nhannht commented Dec 2, 2023

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 be interactive, user can be suggested to load that function in their config file only 1 time during startup. This commit changes this function name to org-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 as yasnippet-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 with name that match (or contain) the string (or maybe regex) custom variable name org-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-mode


org-ai-pr-2023-12-03_01.33.27.mp4

The name of old function `org-ai-insert-snippets` can be misunderstood
because it just load the snippets to yasnippet collection.Also, it should not
be `interactive`, user can be suggested to load that function in their
config file only 1 time during startup. This commit change this function
name to `org-ai--load-snippets`

Also, this commit add new command org-ai-insert-snippet (snippet not
snippets like old name), it act the same as yasnippet-insert-snippet
command, that mean an interactive snippet picker will pop up and user
will pick one of them to insert to current location. The different is
that this function only filter and load those snippet who match (or
contain) the string (or may be regex) custom variable name
`org-ai-snippet-regex`  (which default is "org-ai")
@nhannht nhannht marked this pull request as ready for review December 2, 2023 18:53
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.

1 participant