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

Add gptel--get-prompt-from-region function #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eval-exec
Copy link

When using a region as a prompt, I suggest extract it to independent function:gptel--get-prompt-from-region.

Then user will be convinient to hack the function.
For example, I can add markdown code fence symbol around prompt by:

  (defun exec/major-mod-to-markdown-lang()
	(let* ((major
			(car (split-string (symbol-name major-mode) "-"))))
	  (cond ((string= major "emacs")
			 "elisp")
			(t major))))

  (require 'gptel-transient)

  (defun gptel--get-prompt-from-region()
	"Get the prompt from the region."
	(format "\n```%s\n%s\n```\n"
			;; major mode symbol, if rust-ts-mode, then rust
			(exec/major-mod-to-markdown-lang)
			(buffer-substring-no-properties
			 (region-beginning) (region-end))))

@eval-exec eval-exec force-pushed the exec/prompt-from-region branch from f6b07fc to be20c81 Compare August 9, 2024 12:35
@eval-exec eval-exec force-pushed the exec/prompt-from-region branch from 2c96404 to 8fd679b Compare September 8, 2024 03:33
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