Open eval-exec opened 3 months ago
When using a region as a prompt, I suggest extract it to independent function:gptel--get-prompt-from-region.
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))))
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: