Subject: Re: bug#52676: 28.0.50; [PATCH] Rationalize window-text-pixel-size

From: Eli Zaretskii <[email-masked]>
Date: Mon, 20 Dec 2021 19:11:45 +0200

> From: dick <[email-masked]>
> Date: Mon, 20 Dec 2021 00:20:55 -0500
> Cc: [email-masked]
> 
> (defmacro xdisp-tests--visible-buffer (&rest body)
>   (declare (debug t) (indent 0))
>   `(progn
>      (switch-to-buffer "his-fooness")
>      (unwind-protect
>          (progn ,@body)
>        (let (kill-buffer-query-functions)
>          (kill-buffer "his-fooness")))))
> 
> (xdisp-tests--visible-buffer
>   (cl-flet ((test-it
>               (what from to)
>               (erase-buffer)
>               (save-excursion
>                 (insert what))
>               (let ((dims (window-text-pixel-size nil from to nil nil nil t))
>                     (dims* (window-text-pixel-size nil from to)))
>                 (cl-assert
>                  dims
>                  (cons (car dims*)
>                        (- (cdr dims*)
>                           (save-excursion
>                             (goto-char to)
>                             (if (> (line-end-position) (line-beginning-position))
>                                 (line-pixel-height)
>                               0))))))))
>     (let ((text "foo\nbar"))
>       (test-it text 1 (1+ (length text))))
>     (let ((text "foo\nbar\n"))
>       (test-it text 1 (1+ (length text))))
>     (let ((text "foo\nbar\nbaz"))
>       (test-it text 1 (1+ (length text))))
>     (let ((text "foo\nbar\n"))
>       (test-it text 1 (1+ (length "foo\nbar"))))))

This produces no assertions here (with the current master), if that's
what you wanted to hear.