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: dick
Subject: bug#52676: 28.0.50; [PATCH] Rationalize window-text-pixel-size
Date: Mon, 20 Dec 2021 00:20:55 -0500
User-agent: Gnus/5.14 (Gnus v5.14) Commercial/28.0.50 (gnu/linux)

I am sure there was a way to do what you wanted without resorting to
what you did.  Perhaps I've been too harsh on you.  You've gotten a lot
of poor (but earnest) counsel from emacs-devel.

What sucks is the statute of limitations on function signature changes
is short.  Once released, that jank, incomprehensibly specific parameter
"ignore-line-at-end" is here to stay.

(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"))))))





reply via email to

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