mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-28 10:56:36 +00:00
Support displaying zero as the number of the current line
* src/xdisp.c (syms_of_xdisp) <display-line-numbers-current-absolute>: New variable. <display-line-numbers>: Doc fix. (maybe_produce_line_number): Support nil value of display-line-numbers-current-absolute. * lisp/cus-start.el (standard): Add customization form for display-line-numbers-current-absolute. * etc/NEWS: Document recently introduced features.
This commit is contained in:
parent
0e4f2e01af
commit
7a762fbbfc
14
etc/NEWS
14
etc/NEWS
@ -384,8 +384,18 @@ buffer-local variable 'display-line-numbers' to activate this optional
|
||||
display. If set to t, Emacs will display the number of each line
|
||||
before the line. If set to 'relative', Emacs will display the line
|
||||
number relative to the line showing point, with that line's number
|
||||
displayed as absolute. The default is nil, which doesn't display the
|
||||
line numbers.
|
||||
displayed as absolute. If set to 'visual', Emacs will display a
|
||||
relative number for every screen line, i.e. it will count screen lines
|
||||
rather than buffer lines. The default is nil, which doesn't display
|
||||
the line numbers.
|
||||
|
||||
In 'relative' and 'visual' modes, the variable
|
||||
'display-line-numbers-current-absolute' controls what number is
|
||||
displayed for the line showing point. By default, this variable's
|
||||
value is t, which means display the absolute line number for the line
|
||||
showing point. Customizing this variable to a nil value will cause
|
||||
Emacs to show zero instead, which preserves horizontal space of the
|
||||
window in large buffers.
|
||||
|
||||
Line numbers are not displayed at all in minibuffer windows and in
|
||||
tooltips, as they are not useful there.
|
||||
|
@ -602,6 +602,13 @@ since it could result in memory overflow and make Emacs crash."
|
||||
:value 2
|
||||
:format "%v"))
|
||||
"26.1")
|
||||
(display-line-numbers-current-absolute
|
||||
(choice
|
||||
(const :tag "Display actual number of current line"
|
||||
:value t)
|
||||
(const :tag "Display zero as number of current line"
|
||||
:value nil))
|
||||
"26.1")
|
||||
;; xfaces.c
|
||||
(scalable-fonts-allowed display boolean "22.1")
|
||||
;; xfns.c
|
||||
|
26
src/xdisp.c
26
src/xdisp.c
@ -20874,7 +20874,13 @@ maybe_produce_line_number (struct it *it)
|
||||
matrix. */
|
||||
ptrdiff_t max_lnum;
|
||||
|
||||
if (EQ (Vdisplay_line_numbers, Qvisual))
|
||||
if (NILP (Vdisplay_line_numbers_current_absolute)
|
||||
&& (EQ (Vdisplay_line_numbers, Qrelative)
|
||||
|| EQ (Vdisplay_line_numbers, Qvisual)))
|
||||
/* We subtract one more because the current line is always
|
||||
zero in this mode. */
|
||||
max_lnum = it->w->desired_matrix->nrows - 2;
|
||||
else if (EQ (Vdisplay_line_numbers, Qvisual))
|
||||
max_lnum = it->pt_lnum + it->w->desired_matrix->nrows - 1;
|
||||
else
|
||||
max_lnum = this_line + it->w->desired_matrix->nrows - 1 - it->vpos;
|
||||
@ -20889,11 +20895,12 @@ maybe_produce_line_number (struct it *it)
|
||||
lnum_offset = 0;
|
||||
|
||||
/* Under 'relative', display the absolute line number for the
|
||||
current line, as displaying zero gives zero useful information. */
|
||||
current line, unless the user requests otherwise. */
|
||||
ptrdiff_t lnum_to_display = eabs (this_line - lnum_offset);
|
||||
if ((EQ (Vdisplay_line_numbers, Qrelative)
|
||||
|| EQ (Vdisplay_line_numbers, Qvisual))
|
||||
&& lnum_to_display == 0)
|
||||
&& lnum_to_display == 0
|
||||
&& !NILP (Vdisplay_line_numbers_current_absolute))
|
||||
lnum_to_display = it->pt_lnum + 1;
|
||||
/* In L2R rows we need to append the blank separator, in R2L
|
||||
rows we need to prepend it. But this function is usually
|
||||
@ -32557,8 +32564,10 @@ To add a prefix to continuation lines, use `wrap-prefix'. */);
|
||||
|
||||
DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers,
|
||||
doc: /* Non-nil means display line numbers.
|
||||
Line numbers are displayed before each non-continuation line, i.e.
|
||||
after each newline that comes from buffer text. */);
|
||||
By default, line numbers are displayed before each non-continuation
|
||||
line that displays buffer text, i.e. after each newline that came
|
||||
from buffer text. However, if the value is `visual', every screen
|
||||
line will have a number. */);
|
||||
Vdisplay_line_numbers = Qnil;
|
||||
DEFSYM (Qdisplay_line_numbers, "display-line-numbers");
|
||||
Fmake_variable_buffer_local (Qdisplay_line_numbers);
|
||||
@ -32575,6 +32584,13 @@ Any other value is treated as nil. */);
|
||||
DEFSYM (Qdisplay_line_number_width, "display-line-number-width");
|
||||
Fmake_variable_buffer_local (Qdisplay_line_number_width);
|
||||
|
||||
DEFVAR_LISP ("display-line-numbers-current-absolute",
|
||||
Vdisplay_line_numbers_current_absolute,
|
||||
doc: /* Non-nil means display absolute number of current line.
|
||||
This variable has effect only when `display-line-numbers' is
|
||||
either `relative' or `visual'. */);
|
||||
Vdisplay_line_numbers_current_absolute = Qt;
|
||||
|
||||
DEFVAR_BOOL ("inhibit-eval-during-redisplay", inhibit_eval_during_redisplay,
|
||||
doc: /* Non-nil means don't eval Lisp during redisplay. */);
|
||||
inhibit_eval_during_redisplay = false;
|
||||
|
Loading…
Reference in New Issue
Block a user