Avoid signaling errors from 'pixel-fill-region'

* lisp/textmodes/pixel-fill.el (pixel-fill-region): Make sure the
selected window displays the current buffer.  This is important
when this function is called inside 'with-current-buffer' or
similar forms which temporarily change the buffer displayed in the
selected window.  (Bug#67791)
This commit is contained in:
Eli Zaretskii 2024-02-03 11:09:36 +02:00
parent a398712761
commit d49124fc14

View file

@ -73,6 +73,8 @@ lines that are visually wider than PIXEL-WIDTH.
If START isn't at the start of a line, the horizontal position of If START isn't at the start of a line, the horizontal position of
START, converted to pixel units, will be used as the indentation START, converted to pixel units, will be used as the indentation
prefix on subsequent lines." prefix on subsequent lines."
(save-window-excursion
(set-window-buffer nil (current-buffer))
(save-excursion (save-excursion
(goto-char start) (goto-char start)
(let ((indentation (let ((indentation
@ -105,7 +107,7 @@ prefix on subsequent lines."
(pixel-fill--fill-line pixel-width indentation) (pixel-fill--fill-line pixel-width indentation)
(goto-char (point-max)) (goto-char (point-max))
(when newline-end (when newline-end
(insert "\n")))))) (insert "\n")))))))
(defun pixel-fill--goto-pixel (width) (defun pixel-fill--goto-pixel (width)
(vertical-motion (cons (/ width (frame-char-width)) 0))) (vertical-motion (cons (/ width (frame-char-width)) 0)))