Allow kagi-summarize-buffer to be used non-interactively
This commit is contained in:
parent
f086fd433a
commit
28793401df
|
@ -225,6 +225,8 @@ There's also a [[https://github.com/casey/just][justfile]] which allows you to e
|
|||
|
||||
- =kagi-proofread= asks FastGPT to proofread the region, a buffer or a text input.
|
||||
|
||||
- =kagi-summarize-buffer= returns the summary when called non-interactively.
|
||||
|
||||
- Unit tests added.
|
||||
|
||||
*** Fixes
|
||||
|
|
15
kagi.el
15
kagi.el
|
@ -631,7 +631,7 @@ this when PROMPT-INSERT-P is non-nil."
|
|||
#'string=))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun kagi-summarize-buffer (buffer &optional insert language engine format)
|
||||
(defun kagi-summarize-buffer (buffer &optional insert language engine format interactive-p)
|
||||
"Summarize the BUFFER's content and show it in a new window.
|
||||
|
||||
By default, the summary is shown in a new buffer.
|
||||
|
@ -654,16 +654,17 @@ With a single universal prefix argument (`C-u'), the user is
|
|||
prompted whether the summary has to be inserted at point, which
|
||||
target LANGUAGE to use, which summarizer ENGINE to use and which
|
||||
summary FORMAT to use."
|
||||
(interactive (cons
|
||||
(read-buffer (format-prompt "Buffer" "") nil t)
|
||||
(kagi--get-summarizer-parameters t)))
|
||||
(interactive (append
|
||||
(list (read-buffer (format-prompt "Buffer" "") nil t))
|
||||
(kagi--get-summarizer-parameters t)
|
||||
(list t)))
|
||||
(let ((summary (with-current-buffer buffer
|
||||
(kagi-summarize (buffer-string) language engine format)))
|
||||
(summary-buffer-name (with-current-buffer buffer
|
||||
(kagi--summary-buffer-name (buffer-name)))))
|
||||
(if (and insert (not buffer-read-only))
|
||||
(kagi--insert-summary summary)
|
||||
(kagi--display-summary summary summary-buffer-name))))
|
||||
(cond ((and insert (not buffer-read-only)) (kagi--insert-summary summary))
|
||||
(interactive-p (kagi--display-summary summary summary-buffer-name))
|
||||
(t summary))))
|
||||
|
||||
;;;###autoload
|
||||
(defun kagi-summarize-region (begin end &optional language engine format)
|
||||
|
|
Loading…
Reference in a new issue