branch: elpa/aidermacs commit b8f2180176522cda27862d7a1083649abce8926e Author: Kang Tu <kang...@apple.com> Commit: Kang Tu (aider) <kang...@apple.com>
feat: replace new-line characters with spaces in user input while preserving the final new-line in aider-read-string function --- aider.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aider.el b/aider.el index 94ab272b97..acb07917e8 100644 --- a/aider.el +++ b/aider.el @@ -26,7 +26,12 @@ (defun aider-read-string (prompt &optional initial-input) "Read a string from the user with PROMPT and optional INITIAL-INPUT. This function can be customized or redefined by the user." - (read-string prompt initial-input)) + (let ((input (read-string prompt initial-input))) + ;; Replace all newline characters with spaces, except for the last one + (setq input (replace-regexp-in-string "\n" " " input)) + (when (string-match-p "\n" input) + (setq input (concat (string-trim input) "\n"))) ;; Add a newline at the end + input)) ;; Transient menu for Aider commands (transient-define-prefix aider-transient-menu ()