aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/buffer-tests.el
diff options
context:
space:
mode:
authorDaniel Mendler2026-01-07 17:39:16 +0100
committerEli Zaretskii2026-01-24 13:32:44 +0200
commite8f26d554b64ed63fe2b7f110d5247648b7322ed (patch)
treee2ccf11382272f44ee1bca37eac42858b1180bb8 /test/src/buffer-tests.el
parent21455197343ff912d9544b4663ad383009a816e5 (diff)
downloademacs-e8f26d554b64ed63fe2b7f110d5247648b7322ed.tar.gz
emacs-e8f26d554b64ed63fe2b7f110d5247648b7322ed.zip
Support cons cell for 'line-spacing'
* etc/NEWS: Announce the change. * src/dispextern.h (struct glyph_row): Add 'extra_line_spacing_above' member. (struct it): Add 'extra_line_spacing_above' member. * src/frame.h (struct frame): Add 'extra_line_spacing_above' member. Update comment for 'extra_line_spacing.' * src/buffer.c (syms_of_buffer): Update the docstring of 'line-spacing' to describe the cons cell usage. * src/buffer.h (struct buffer): Update comment for 'extra_line_spacing'. * src/frame.c (gui_set_line_spacing): Handle cons cell value for 'line-spacing'. Calculate and set 'extra_line_spacing_above' for both integer and float pairs. * src/xdisp.c (init_iterator): Initialize 'extra_line_spacing_above' from buffer or frame 'line-spacing', handling cons cells for both integer and float values. (gui_produce_glyphs): Use 'extra_line_spacing_above' to distribute spacing between ascent and descent. Update 'max_extra_line_spacing' calculation. (resize_mini_window): Take line spacing into account when resizing the mini window. Pass height of a single line to 'grow_mini_window' and 'shrink_mini_window'. * src/window.c (grow_mini_window, shrink_mini_window): Add unit argument which defines height of a single line. * src/window.h (grow_mini_window, shrink_mini_window): Adjust function prototypes accordingly with unit argument. * lisp/subr.el (total-line-spacing): New function to calculate total spacing from a number or cons cell. (posn-col-row): Use total-line-spacing. * lisp/simple.el (default-line-height): Use 'total-line-spacing'. * lisp/textmodes/picture.el (picture-mouse-set-point): Use 'total-line-spacing'. * lisp/window.el (window-default-line-height): Use 'total-line-spacing'. (window--resize-mini-window): Take 'line-spacing' into account. * test/lisp/subr-tests.el (total-line-spacing): New test. * test/src/buffer-tests.el (test-line-spacing): New test. * doc/emacs/display.texi (Display Custom): Document that 'line-spacing' can be a cons cell. (Line Height): Document the new cons cell format for 'line-spacing' to allow vertical centering. Co-authored-by: Przemysław Alexander Kamiński <alexander@kaminski.se> Co-authored-by: Daniel Mendler <mail@daniel-mendler.de>
Diffstat (limited to 'test/src/buffer-tests.el')
-rw-r--r--test/src/buffer-tests.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 9ed76a42603..5f534ed513a 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -8650,4 +8650,22 @@ Finally, kill the buffer and its temporary file."
8650 (should (= (point-min) 1)) 8650 (should (= (point-min) 1))
8651 (should (= (point-max) 5001)))) 8651 (should (= (point-max) 5001))))
8652 8652
8653(ert-deftest test-line-spacing ()
8654 "Test `line-spacing' impact on text size"
8655 (skip-unless (display-graphic-p))
8656 (let*
8657 ((size-with-text (lambda (ls)
8658 (with-temp-buffer
8659 (setq-local line-spacing ls)
8660 (insert "X\nX")
8661 (cdr (buffer-text-pixel-size))))))
8662 (cl-loop for x from 0 to 50
8663 for y from 0 to 50
8664 do
8665 (ert-info ((format "((linespacing '(%d . %d)) == (linespacing %d)" x y (+ x y))
8666 :prefix "Linespace check: ")
8667 (should (=
8668 (funcall size-with-text (+ x y))
8669 (funcall size-with-text (cons x y))))))))
8670
8653;;; buffer-tests.el ends here 8671;;; buffer-tests.el ends here