Add option to fill paragraphs patch_fill_paragraph
authorDaniel Nagy <danielnagy@posteo.de>
Tue, 13 Jul 2021 10:06:14 +0000 (12:06 +0200)
committerDaniel Nagy <danielnagy@posteo.de>
Tue, 13 Jul 2021 10:06:14 +0000 (12:06 +0200)
elpher.el

index 4c34f52..c57b1c2 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -547,6 +547,9 @@ If LINE is non-nil, replace that line instead."
 (defvar elpher-user-coding-system nil
   "User-specified coding system to use for decoding text responses.")
 
+(defvar elpher-fill-paragraph nil
+  "Whether to fill text paragraphs using `fill-paragraph`.")
+
 (defun elpher-decode (string)
   "Decode STRING using autodetected or user-specified coding system."
   (decode-coding-string string
@@ -1397,6 +1400,10 @@ width defined by elpher-gemini-max-fill-width."
                           (replace-regexp-in-string "[>\*]" " " (match-string 0 text-line))
                         nil)))
     (insert (elpher-process-text-for-display processed-text-line))
+    (when elpher-fill-paragraph
+      (save-restriction
+        (narrow-to-region (line-beginning-position) (line-end-position))
+        (fill-paragraph)))
     (newline)))
 
 (defun elpher-render-gemini-map (data _parameters)