From 4ee9ff2ee401e05d6c5950f7bd31e710e1becf59 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Sat, 13 Jan 2018 23:00:08 -0600 Subject: [PATCH] Smarter filling of text in `jupyter-repl-fontify-according-to-mode` --- jupyter-repl-client.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jupyter-repl-client.el b/jupyter-repl-client.el index df2cae9..e49a9bb 100644 --- a/jupyter-repl-client.el +++ b/jupyter-repl-client.el @@ -220,9 +220,17 @@ string, which can then be inserted into a Jupyter REPL buffer." new-prop)))) (setq pos next)))) (jupyter-repl-add-font-lock-properties (point-min) (point-max)) - (unless (memq fill-forward-paragraph-function - '(forward-paragraph)) - (fill-region (point-min) (point-max) t t t)) + (cond + ((and fill-paragraph-function + (not (eq fill-paragraph-function t))) + (goto-char (point-min)) + (fill-paragraph) + (while (and (= (fill-forward-paragraph 1) 0) + (/= (point) (point-max))) + (fill-paragraph))) + ((not (memq fill-forward-paragraph-function + '(forward-paragraph))) + (fill-region (point-min) (point-max)))) (buffer-string))) (defun jupyter-repl-insert (&rest args)