diff options
| author | Eli Zaretskii | 2024-06-20 12:52:06 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-06-20 12:52:06 +0300 |
| commit | 775aeabcfbf84c950610738cd130bf652c77bfa5 (patch) | |
| tree | 47dfa62d256fe3389f6eb205c7d25fc59eee7eee | |
| parent | b8affdb7b5760b3681ada9dcba78dd3c07405b61 (diff) | |
| download | emacs-775aeabcfbf84c950610738cd130bf652c77bfa5.tar.gz emacs-775aeabcfbf84c950610738cd130bf652c77bfa5.zip | |
Fix use of ':align-to' in 'wrap-prefix'
* 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'.
| -rw-r--r-- | doc/lispref/display.texi | 8 | ||||
| -rw-r--r-- | src/dispextern.h | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 9 |
3 files changed, 19 insertions, 3 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index d5c96d13e02..34096196df4 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -192,7 +192,9 @@ never used.) Its value may be a string or an image (@pxref{Other | |||
| 192 | Display Specs}), or a stretch of whitespace such as specified by the | 192 | Display Specs}), or a stretch of whitespace such as specified by the |
| 193 | @code{:width} or @code{:align-to} display properties (@pxref{Specified | 193 | @code{:width} or @code{:align-to} display properties (@pxref{Specified |
| 194 | Space}). The value is interpreted in the same way as a @code{display} | 194 | Space}). The value is interpreted in the same way as a @code{display} |
| 195 | text property. @xref{Display Property}. | 195 | text property, with one important difference: the horizontal position |
| 196 | specified by @code{:align-to} is measured from the visual beginning of | ||
| 197 | the screen line. @xref{Display Property}. | ||
| 196 | 198 | ||
| 197 | A wrap prefix may also be specified for regions of text, using the | 199 | A wrap prefix may also be specified for regions of text, using the |
| 198 | @code{wrap-prefix} text or overlay property. This takes precedence | 200 | @code{wrap-prefix} text or overlay property. This takes precedence |
| @@ -5354,7 +5356,9 @@ Scrolling}), @var{hpos} is measured from the beginning of the logical | |||
| 5354 | line, not from the visual beginning of the screen line. This way, | 5356 | line, not from the visual beginning of the screen line. This way, |
| 5355 | alignment produced by @code{:align-to} is consistent with functions | 5357 | alignment produced by @code{:align-to} is consistent with functions |
| 5356 | that count columns, such as @code{current-column} and | 5358 | that count columns, such as @code{current-column} and |
| 5357 | @code{move-to-column} (@pxref{Columns}). | 5359 | @code{move-to-column} (@pxref{Columns}). (There's a single exception |
| 5360 | from this rule: when @code{:align-to} is used to specify whitespace of | ||
| 5361 | the @code{wrap-prefix} variable or text property, @pxref{Truncation}.) | ||
| 5358 | @end table | 5362 | @end table |
| 5359 | 5363 | ||
| 5360 | You should use one and only one of the above properties. You can | 5364 | You should use one and only one of the above properties. You can |
diff --git a/src/dispextern.h b/src/dispextern.h index 85012130689..51dc354d37c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2629,6 +2629,11 @@ struct it | |||
| 2629 | the current row. */ | 2629 | the current row. */ |
| 2630 | bool_bf line_number_produced_p : 1; | 2630 | bool_bf line_number_produced_p : 1; |
| 2631 | 2631 | ||
| 2632 | /* If true, the :align-to argument should be counted relative to the | ||
| 2633 | beginning of the screen line, not the logical line. Used by | ||
| 2634 | 'wrap-prefix'. */ | ||
| 2635 | bool_bf align_visually_p : 1; | ||
| 2636 | |||
| 2632 | enum line_wrap_method line_wrap; | 2637 | enum line_wrap_method line_wrap; |
| 2633 | 2638 | ||
| 2634 | /* The ID of the default face to use. One of DEFAULT_FACE_ID, | 2639 | /* The ID of the default face to use. One of DEFAULT_FACE_ID, |
diff --git a/src/xdisp.c b/src/xdisp.c index 0148cd76ada..5987813cd28 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -24494,6 +24494,11 @@ handle_line_prefix (struct it *it) | |||
| 24494 | prefix = get_line_prefix_it_property (it, Qwrap_prefix); | 24494 | prefix = get_line_prefix_it_property (it, Qwrap_prefix); |
| 24495 | if (NILP (prefix)) | 24495 | if (NILP (prefix)) |
| 24496 | prefix = Vwrap_prefix; | 24496 | prefix = Vwrap_prefix; |
| 24497 | /* Interpreting :align-to relative to the beginning of the logical | ||
| 24498 | line effectively renders this feature unusable, so we make an | ||
| 24499 | exception for this use of :align-to. */ | ||
| 24500 | if (!NILP (prefix)) | ||
| 24501 | it->align_visually_p = true; | ||
| 24497 | } | 24502 | } |
| 24498 | else | 24503 | else |
| 24499 | { | 24504 | { |
| @@ -31972,7 +31977,9 @@ produce_stretch_glyph (struct it *it) | |||
| 31972 | && calc_pixel_width_or_height (&tem, it, prop, font, true, | 31977 | && calc_pixel_width_or_height (&tem, it, prop, font, true, |
| 31973 | &align_to)) | 31978 | &align_to)) |
| 31974 | { | 31979 | { |
| 31975 | int x = it->current_x + it->continuation_lines_width; | 31980 | int x = it->current_x + (it->align_visually_p |
| 31981 | ? 0 | ||
| 31982 | : it->continuation_lines_width); | ||
| 31976 | int x0 = x; | 31983 | int x0 = x; |
| 31977 | /* Adjust for line numbers, if needed. */ | 31984 | /* Adjust for line numbers, if needed. */ |
| 31978 | if (!NILP (Vdisplay_line_numbers) && it->line_number_produced_p) | 31985 | if (!NILP (Vdisplay_line_numbers) && it->line_number_produced_p) |