1
0
Fork 0

Rename function, adjust docstrings

This commit is contained in:
Bram Schoenmakers 2024-02-09 12:51:54 +01:00
parent cbb82bdca6
commit 852e7bd210
Signed by: bram
GPG key ID: 0CCD19DFDC63258F

15
kagi.el
View file

@ -451,14 +451,17 @@ PROMPT is passed to the corresponding parameters of
kagi--language-history kagi--language-history
"English")) "English"))
;; TODO rename (defun kagi--get-text-for-prompt ()
(defun kagi--get-buffer-or-text () "Return the text to insert in a prompt.
"Return the text to operate on.
The text is obtained interactively. Typically this is the user
text that gets inserted in a prompt (e.g. translate the
following, proofread the following, etc.).
If the region is active, return the corresponding text. If the region is active, return the corresponding text.
Otherwise, the user is requested to enter a buffer name or enter Otherwise, the user is requested to enter a buffer name or enter
its own text manually." the text manually."
(if (use-region-p) (if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end)) (buffer-substring-no-properties (region-beginning) (region-end))
(let ((buffer-or-text (read-buffer (format-prompt "Buffer name or text" nil)))) (let ((buffer-or-text (read-buffer (format-prompt "Buffer name or text" nil))))
@ -482,7 +485,7 @@ When non-nil, the translation is shown in the echo area when the
result is short, otherwise it is displayed in a new buffer." result is short, otherwise it is displayed in a new buffer."
(interactive (interactive
(list (list
(kagi--get-buffer-or-text) (kagi--get-text-for-prompt)
(kagi--read-language (format-prompt "Target language" nil)) (kagi--read-language (format-prompt "Target language" nil))
(when (equal current-prefix-arg '(4)) (when (equal current-prefix-arg '(4))
(kagi--read-language (format-prompt "Source language" nil))) (kagi--read-language (format-prompt "Source language" nil)))
@ -507,7 +510,7 @@ When `kagi-proofread' is called non-interactively (INTERACTIVE-P is
nil), the function should return the string 'OK' when there are nil), the function should return the string 'OK' when there are
no issues." no issues."
(interactive (interactive
(list (kagi--get-buffer-or-text) t)) (list (kagi--get-text-for-prompt) t))
(let ((prompt (format "Proofread the following text. %s (let ((prompt (format "Proofread the following text. %s
%s" %s"