From c756f8a8534fdd23fb9756246c1e41050c176997 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 30 Apr 2023 19:12:42 +0200 Subject: [PATCH] org-odt-plain-text: Fix when TEXT is a blank string * lisp/ox-odt.el: Do not re-fill newlines when TEXT only contains spaces. Reported-by: Damien Cassou Link: https://orgmode.org/list/87ttwxphm6.fsf@cassou.me --- lisp/ox-odt.el | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 03c909f78..dd96ed8e0 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2926,24 +2926,25 @@ contextual information." ;; FIXME: The unnecessary spacing may still remain when a newline ;; is at a boundary between Org objects (e.g. italics markup ;; followed by newline). - (setq output - (with-temp-buffer - (save-match-data - (let ((leading (and (string-match (rx bos (1+ blank)) output) - (match-string 0 output))) - (trailing (and (string-match (rx (1+ blank) eos) output) - (match-string 0 output)))) - (insert - (substring - output - (length leading) - (pcase (length trailing) - (0 nil) - (n (- n))))) - ;; Unfill, retaining leading/trailing space. - (let ((fill-column most-positive-fixnum)) - (fill-region (point-min) (point-max))) - (concat leading (buffer-string) trailing)))))) + (when (org-string-nw-p output) ; blank string needs not to be re-filled + (setq output + (with-temp-buffer + (save-match-data + (let ((leading (and (string-match (rx bos (1+ blank)) output) + (match-string 0 output))) + (trailing (and (string-match (rx (1+ blank) eos) output) + (match-string 0 output)))) + (insert + (substring + output + (length leading) + (pcase (length trailing) + (0 nil) + (n (- n))))) + ;; Unfill, retaining leading/trailing space. + (let ((fill-column most-positive-fixnum)) + (fill-region (point-min) (point-max))) + (concat leading (buffer-string) trailing))))))) ;; Return value. output))