diff options
| author | Daniel Mendler | 2026-01-07 17:39:16 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2026-01-24 13:32:44 +0200 |
| commit | e8f26d554b64ed63fe2b7f110d5247648b7322ed (patch) | |
| tree | e2ccf11382272f44ee1bca37eac42858b1180bb8 /src/buffer.c | |
| parent | 21455197343ff912d9544b4663ad383009a816e5 (diff) | |
| download | emacs-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 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c index fec30d4f0e9..3d85d784f1c 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5875,12 +5875,15 @@ cursor's appearance is instead controlled by the variable | |||
| 5875 | `cursor-in-non-selected-windows'. */); | 5875 | `cursor-in-non-selected-windows'. */); |
| 5876 | 5876 | ||
| 5877 | DEFVAR_PER_BUFFER ("line-spacing", | 5877 | DEFVAR_PER_BUFFER ("line-spacing", |
| 5878 | &BVAR (current_buffer, extra_line_spacing), Qnumberp, | 5878 | &BVAR (current_buffer, extra_line_spacing), Qnil, |
| 5879 | doc: /* Additional space to put between lines when displaying a buffer. | 5879 | doc: /* Additional space to put between lines when displaying a buffer. |
| 5880 | The space is measured in pixels, and put below lines on graphic displays, | 5880 | The space is measured in pixels, and put below lines on graphic displays, |
| 5881 | see `display-graphic-p'. | 5881 | see `display-graphic-p'. |
| 5882 | If value is a floating point number, it specifies the spacing relative | 5882 | If value is a floating point number, it specifies the spacing relative |
| 5883 | to the default frame line height. A value of nil means add no extra space. */); | 5883 | to the default frame line height. |
| 5884 | If value is a cons cell containing a pair of floats or integers, | ||
| 5885 | it is interpreted as space above and below the line, respectively. | ||
| 5886 | A value of nil means add no extra space. */); | ||
| 5884 | 5887 | ||
| 5885 | DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", | 5888 | DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", |
| 5886 | &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil, | 5889 | &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil, |