mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-27 07:41:28 -08:00
Make pixel-fill-region handle space regions better
* lisp/textmodes/pixel-fill.el (pixel-fill-region): Preserve the face on the replacement spaces.
This commit is contained in:
parent
ddaedb1910
commit
6348ca1a88
1 changed files with 11 additions and 4 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue