diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/textmodes/pixel-fill.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/textmodes/pixel-fill.el b/lisp/textmodes/pixel-fill.el index 1115ba303ea..86fdd3c2ff4 100644 --- a/lisp/textmodes/pixel-fill.el +++ b/lisp/textmodes/pixel-fill.el @@ -90,10 +90,17 @@ prefix on subsequent lines." (goto-char (point-min)) ;; First replace all whitespace with space. (while (re-search-forward "[ \t\n]+" nil t) - (if (or (= (match-beginning 0) start) - (= (match-end 0) end)) - (delete-region (match-beginning 0) (match-end 0)) - (replace-match " "))) + (cond + ((or (= (match-beginning 0) start) + (= (match-end 0) end)) + (delete-region (match-beginning 0) (match-end 0))) + ;; If there's just a single space here, don't replace. + ((not (and (= (- (match-end 0) (match-beginning 0)) 1) + (= (char-after (match-beginning 0)) ?\s))) + (replace-match + ;; We need to use a space that has an appropriate width. + (propertize " " 'face + (get-text-property (match-beginning 0) 'face)))))) (goto-char start) (pixel-fill--fill-line pixel-width indentation) (goto-char (point-max)) |