diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 52275a11b86..893ce9269c1 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -22512,10 +22512,22 @@ maybe_produce_line_number (struct it *it) | |||
| 22512 | ptrdiff_t start_from, bytepos; | 22512 | ptrdiff_t start_from, bytepos; |
| 22513 | ptrdiff_t this_line; | 22513 | ptrdiff_t this_line; |
| 22514 | bool first_time = false; | 22514 | bool first_time = false; |
| 22515 | ptrdiff_t beg_byte = display_line_numbers_widen ? BEG_BYTE : BEGV_BYTE; | 22515 | ptrdiff_t beg_byte; |
| 22516 | ptrdiff_t z_byte = display_line_numbers_widen ? Z_BYTE : ZV_BYTE; | 22516 | ptrdiff_t z_byte; |
| 22517 | bool line_numbers_wide; | ||
| 22517 | void *itdata = bidi_shelve_cache (); | 22518 | void *itdata = bidi_shelve_cache (); |
| 22518 | 22519 | ||
| 22520 | if (display_line_numbers_offset | ||
| 22521 | && !display_line_numbers_widen | ||
| 22522 | && !EQ (Vdisplay_line_numbers, Qvisual) | ||
| 22523 | && !EQ (Vdisplay_line_numbers, Qrelative)) | ||
| 22524 | line_numbers_wide = true; | ||
| 22525 | else | ||
| 22526 | line_numbers_wide = display_line_numbers_widen; | ||
| 22527 | |||
| 22528 | beg_byte = line_numbers_wide ? BEG_BYTE : BEGV_BYTE; | ||
| 22529 | z_byte = line_numbers_wide ? Z_BYTE : ZV_BYTE; | ||
| 22530 | |||
| 22519 | if (EQ (Vdisplay_line_numbers, Qvisual)) | 22531 | if (EQ (Vdisplay_line_numbers, Qvisual)) |
| 22520 | this_line = display_count_lines_visually (it); | 22532 | this_line = display_count_lines_visually (it); |
| 22521 | else | 22533 | else |
| @@ -22530,7 +22542,7 @@ maybe_produce_line_number (struct it *it) | |||
| 22530 | numbers, so we cannot use its data if the user wants | 22542 | numbers, so we cannot use its data if the user wants |
| 22531 | line numbers that disregard narrowing, or if the | 22543 | line numbers that disregard narrowing, or if the |
| 22532 | buffer's narrowing has just changed. */ | 22544 | buffer's narrowing has just changed. */ |
| 22533 | && !(display_line_numbers_widen | 22545 | && !(line_numbers_wide |
| 22534 | && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE)) | 22546 | && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE)) |
| 22535 | && !current_buffer->clip_changed) | 22547 | && !current_buffer->clip_changed) |
| 22536 | { | 22548 | { |
| @@ -22620,6 +22632,8 @@ maybe_produce_line_number (struct it *it) | |||
| 22620 | lnum_offset = it->pt_lnum; | 22632 | lnum_offset = it->pt_lnum; |
| 22621 | else if (EQ (Vdisplay_line_numbers, Qvisual)) | 22633 | else if (EQ (Vdisplay_line_numbers, Qvisual)) |
| 22622 | lnum_offset = 0; | 22634 | lnum_offset = 0; |
| 22635 | else if (display_line_numbers_offset) | ||
| 22636 | lnum_offset -= display_line_numbers_offset; | ||
| 22623 | 22637 | ||
| 22624 | /* Under 'relative', display the absolute line number for the | 22638 | /* Under 'relative', display the absolute line number for the |
| 22625 | current line, unless the user requests otherwise. */ | 22639 | current line, unless the user requests otherwise. */ |
| @@ -34711,12 +34725,18 @@ To add a prefix to continuation lines, use `wrap-prefix'. */); | |||
| 34711 | 34725 | ||
| 34712 | DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers, | 34726 | DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers, |
| 34713 | doc: /* Non-nil means display line numbers. | 34727 | doc: /* Non-nil means display line numbers. |
| 34728 | |||
| 34714 | If the value is t, display the absolute number of each line of a buffer | 34729 | If the value is t, display the absolute number of each line of a buffer |
| 34715 | shown in a window. Absolute line numbers count from the beginning of | 34730 | shown in a window. Absolute line numbers count from the beginning of |
| 34716 | the current narrowing, or from buffer beginning. If the value is | 34731 | the current narrowing, or from buffer beginning. The variable |
| 34717 | `relative', display for each line not containing the window's point its | 34732 | `display-line-numbers-offset', if non-zero, is a signed offset added |
| 34718 | relative number instead, i.e. the number of the line relative to the | 34733 | to each absolute line number; it also forces line numbers to be counted |
| 34719 | line showing the window's point. | 34734 | from the beginning of the buffer, as if `display-line-numbers-wide' |
| 34735 | were non-nil. It has no effect when line numbers are not absolute. | ||
| 34736 | |||
| 34737 | If the value is `relative', display for each line not containing the | ||
| 34738 | window's point its relative number instead, i.e. the number of the line | ||
| 34739 | relative to the line showing the window's point. | ||
| 34720 | 34740 | ||
| 34721 | In either case, line numbers are displayed at the beginning of each | 34741 | In either case, line numbers are displayed at the beginning of each |
| 34722 | non-continuation line that displays buffer text, i.e. after each newline | 34742 | non-continuation line that displays buffer text, i.e. after each newline |
| @@ -34757,6 +34777,15 @@ either `relative' or `visual'. */); | |||
| 34757 | DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); | 34777 | DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); |
| 34758 | Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); | 34778 | Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); |
| 34759 | 34779 | ||
| 34780 | DEFVAR_INT ("display-line-numbers-offset", display_line_numbers_offset, | ||
| 34781 | doc: /* A signed integer added to each absolute line number. | ||
| 34782 | When this variable is non-zero, line numbers are always counted from | ||
| 34783 | the beginning of the buffer even if `display-line-numbers-widen' is nil. | ||
| 34784 | It has no effect when set to 0, or when line numbers are not absolute. */); | ||
| 34785 | display_line_numbers_offset = 0; | ||
| 34786 | DEFSYM (Qdisplay_line_numbers_offset, "display-line-numbers-offset"); | ||
| 34787 | Fmake_variable_buffer_local (Qdisplay_line_numbers_offset); | ||
| 34788 | |||
| 34760 | DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator, | 34789 | DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator, |
| 34761 | doc: /* Non-nil means display the fill column indicator. */); | 34790 | doc: /* Non-nil means display the fill column indicator. */); |
| 34762 | Vdisplay_fill_column_indicator = false; | 34791 | Vdisplay_fill_column_indicator = false; |