master 0ff6ee371f0: Fix :align-to 'center' when line numbers are displayed
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit 0ff6ee371f03aba3e52469811c7c783e945a03c8 Author: Andrea Alberti <[email protected]> Commit: Eli Zaretskii <[email protected]> Fix :align-to 'center' when line numbers are displayed When line numbers are shown, 'center' was computed as the center of the whole text area, which includes the line-number display, so it landed half the line-number width too far to the right. Center it on the editable text area instead. (Bug#81275) * src/xdisp.c (calc_pixel_width_or_height): Correct the adjustment of 'center' for line-number display, so 'center' is the center of the editable part of the text area. * doc/lispref/display.texi (Pixel Specification): Say that 'center' denotes the center of the editable text area. --- doc/lispref/display.texi | 4 +++- src/xdisp.c | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ae7d314c795..88654af4b09 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -5701,7 +5701,9 @@ edge, center, or right edge of the text area. When the window displays line numbers, and @code{:align-to} is used in display properties of buffer text (as opposed to header line, see below), the @code{left} and the @code{center} positions are offset to account for -the screen space taken by the line-number display. +the screen space taken by the line-number display. In particular, +@code{center} then denotes the center of the editable text area, i.e.@: +the text area excluding the line-number display. Any of the above window elements (except @code{text}) can also be used with @code{:align-to} to specify that the position is relative to diff --git a/src/xdisp.c b/src/xdisp.c index 295a13b99ed..f991adb7d98 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -30506,11 +30506,12 @@ calc_pixel_width_or_height (double *res, struct it *it, /* 'right': right edge of the text area. */ if (EQ (prop, Qright)) return OK_ALIGN_TO (window_box_right_offset (it->w, TEXT_AREA)); - /* 'center': the center of the text area. */ + /* 'center': the center of the editable text area, i.e. the text + area excluding the line-number display. */ if (EQ (prop, Qcenter)) return OK_ALIGN_TO (window_box_left_offset (it->w, TEXT_AREA) - + LNUM_ONCE - + window_box_width (it->w, TEXT_AREA) / 2); + + (LNUM_ONCE + + window_box_width (it->w, TEXT_AREA)) / 2); /* 'left-fringe': left edge of the left fringe. */ if (EQ (prop, Qleft_fringe)) return OK_ALIGN_TO (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)