Open benthamite opened 3 weeks ago
Looks good! I'll test it when I can and merge.
I just noticed this in the docstring of this function (emphasis added):
If a region is selected, add the selected region to the context. If there is already a gptel context at point, remove it instead.
I may not be understanding what this means, but as far as I can tell the function does not behave in the manner described: if I select a region, add it to the context, then re-select it and call gptel-add
again, the region is not removed from the context. (The docstring talks about the "context at point" rather than the region, but I am not sure what that means in this, er, context. 😛)
I may not be understanding what this means, but as far as I can tell the function does not behave in the manner described: if I select a region, add it to the context, then re-select it and call
gptel-add
again, the region is not removed from the context.
It could probably be worded better. Here is an updated description, let me know if it makes more sense:
gptel-add is an alias for ‘gptel-context-add’ in ‘gptel-context.el’.
(gptel-add &optional ARG)
Add context to gptel in a DWIM fashion.
- If a region is selected, add the selected region to the
context. If point is in a context region already, it
is removed first -- overlapping context regions are not
supported.
- If there is already a gptel context at point, remove it
instead.
- If in Dired, add marked files or file at point to the context.
With negative prefix ARG, remove them from the context instead.
- Otherwise add the current buffer to the context. With positive
prefix ARG, prompt for a buffer name and add it to the context.
- With negative prefix ARG, remove all gptel contexts from the
current buffer.
We should also add the ability to add directories to the context when running gptel-add-file
, shouldn't we?
We should also add the ability to add directories to the context when running
gptel-add-file
, shouldn't we?
I wasn’t familiar with this command, but yeah, it seems it should mirror the behavior of gptel-add
when the latter is used with a file or directory. Would you like me to make the changes?
Perhaps we should change gptel-context-add-file
so that this is the function called by gptel-add
in Dired mode. Currently, the former doesn’t take a prefix argument.
Currently, attempting to add directories to the context in Dired will throw an error. This PR provides support for adding files in directories to the context: if there is a directory at point, or the marked files include one or more directories, their files will recursively be added to the context.