* src/dispextern.h (struct it): New flag 'align_visually_p'.
* src/xdisp.c (handle_line_prefix): Set the 'align_visually_p'
flag for 'wrap-prefix'.
(produce_stretch_glyph): If 'align_visually_p' flag is set, count
the :align-to offset from the beginning of the screen line, not
from BOL. (Bug#71605)
* doc/lispref/display.texi (Truncation, Specified Space): Document
the special handling of ':align-to' in 'wrap-prefix'.
(cherry picked from commit
775aeabcfbf84c950610738cd130bf652c77bfa5)
Display Specs}), or a stretch of whitespace such as specified by the
@code{:width} or @code{:align-to} display properties (@pxref{Specified
Space}). The value is interpreted in the same way as a @code{display}
-text property. @xref{Display Property}.
+text property, with one important difference: the horizontal position
+specified by @code{:align-to} is measured from the visual beginning of
+the screen line. @xref{Display Property}.
A wrap prefix may also be specified for regions of text, using the
@code{wrap-prefix} text or overlay property. This takes precedence
line, not from the visual beginning of the screen line. This way,
alignment produced by @code{:align-to} is consistent with functions
that count columns, such as @code{current-column} and
-@code{move-to-column} (@pxref{Columns}).
+@code{move-to-column} (@pxref{Columns}). (There's a single exception
+from this rule: when @code{:align-to} is used to specify whitespace of
+the @code{wrap-prefix} variable or text property, @pxref{Truncation}.)
@end table
You should use one and only one of the above properties. You can
the current row. */
bool_bf line_number_produced_p : 1;
+ /* If true, the :align-to argument should be counted relative to the
+ beginning of the screen line, not the logical line. Used by
+ 'wrap-prefix'. */
+ bool_bf align_visually_p : 1;
+
enum line_wrap_method line_wrap;
/* The ID of the default face to use. One of DEFAULT_FACE_ID,
prefix = get_line_prefix_it_property (it, Qwrap_prefix);
if (NILP (prefix))
prefix = Vwrap_prefix;
+ /* Interpreting :align-to relative to the beginning of the logical
+ line effectively renders this feature unusable, so we make an
+ exception for this use of :align-to. */
+ if (!NILP (prefix))
+ it->align_visually_p = true;
}
else
{
&& calc_pixel_width_or_height (&tem, it, prop, font, true,
&align_to))
{
- int x = it->current_x + it->continuation_lines_width;
+ int x = it->current_x + (it->align_visually_p
+ ? 0
+ : it->continuation_lines_width);
int x0 = x;
/* Adjust for line numbers, if needed. */
if (!NILP (Vdisplay_line_numbers) && it->line_number_produced_p)