bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Eli Zaretskii
Subject: bug#52676: 28.0.50; [PATCH] Rationalize window-text-pixel-size
Date: Mon, 20 Dec 2021 19:11:45 +0200

> From: dick <dick.r.chiang@gmail.com>
> Date: Mon, 20 Dec 2021 00:20:55 -0500
> Cc: 52676-done@debbugs.gnu.org
> 
> (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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]