mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Set alternate faces for some line numbers (bug#27734)
* lisp/faces.el (line-number-major-tick, line-number-minor-tick): New faces. * lisp/cus-start.el (display-line-numbers-major-tick) (display-line-numbers-minor-tick): Add customization info. * lisp/frame.el: Add `display-line-numbers-major-tick' and `display-line-numbers-minor-tick' to list of variables which should trigger redisplay of the current buffer. * src/xdisp.c (syms_of_xdisp) <display-line-numbers-major-tick> <display-line-numbers-major-tick>: Defvar new options. (syms_of_xdisp) <line-number-major-tick, line-number-minor-tick>: Defsym new faces. (maybe_produce_line_number): Use new faces for line numbers that are multiple of `display-line-numbers-major-tick' and `display-line-numbers-minor-tick'. * etc/NEWS (value): Announce new feature. * doc/emacs/display.texi (Display Custom): Describe it. Wording by Robert Pluim <rpluim@gmail.com>
This commit is contained in:
parent
29db34e3e0
commit
8de2e69f02
6 changed files with 87 additions and 1 deletions
|
|
@ -1871,7 +1871,12 @@ The line numbers are displayed in a special face @code{line-number}.
|
|||
The current line number is displayed in a different face,
|
||||
@code{line-number-current-line}, so you can make the current line's
|
||||
number have a distinct appearance, which will help locating the line
|
||||
showing point.
|
||||
showing point. Additional faces @code{line-number-major-tick} and
|
||||
@code{line-number-minor-tick} can be used to highlight the line numbers
|
||||
of lines which are a multiple of certain numbers. Customize
|
||||
@code{display-line-numbers-major-tick} and
|
||||
@code{display-line-numbers-minor-tick} respectively to set those
|
||||
numbers.
|
||||
|
||||
@vindex visible-bell
|
||||
If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
|
||||
|
|
|
|||
7
etc/NEWS
7
etc/NEWS
|
|
@ -558,6 +558,13 @@ network connection information (in addition to the host name).
|
|||
*** When called interactively with a prefix arg 'C-u', 'desktop-read'
|
||||
now prompts the user for the directory containing the desktop file.
|
||||
|
||||
+++
|
||||
** display-line-numbers-mode
|
||||
*** New faces 'line-number-major-tick' and 'line-number-minor-tick',
|
||||
and customizable variables 'display-line-numbers-major-tick' and
|
||||
'display-line-numbers-minor-tick' can be used to highlight the line
|
||||
numbers of lines multiple of certain numbers.
|
||||
|
||||
+++
|
||||
** winner
|
||||
*** A new variable, 'winner-boring-buffers-regexp', has been added.
|
||||
|
|
|
|||
|
|
@ -655,6 +655,20 @@ since it could result in memory overflow and make Emacs crash."
|
|||
(const :tag "Count lines from beginning of narrowed region"
|
||||
:value nil))
|
||||
"26.1")
|
||||
(display-line-numbers-major-tick
|
||||
display-line-numbers
|
||||
(choice
|
||||
(const :tag "No line" 0)
|
||||
(integer :tag "Multiples of"
|
||||
:value 10))
|
||||
"27.1")
|
||||
(display-line-numbers-minor-tick
|
||||
display-line-numbers
|
||||
(choice
|
||||
(const :tag "No line" 0)
|
||||
(integer :tag "Multiples of"
|
||||
:value 5))
|
||||
"27.1")
|
||||
|
||||
(display-fill-column-indicator
|
||||
display-fill-column-indicator
|
||||
|
|
|
|||
|
|
@ -2390,6 +2390,40 @@ unwanted effects."
|
|||
:group 'basic-faces
|
||||
:group 'display-line-numbers)
|
||||
|
||||
(defface line-number-major-tick
|
||||
'((t :inherit line-number))
|
||||
"Face for highlighting \"major ticks\" (as in a ruler).
|
||||
When `display-line-numbers-major-tick' is positive, highlight
|
||||
the line numbers of lines which are a multiple of its value.
|
||||
This face is used when `display-line-numbers' is non-nil.
|
||||
|
||||
If you customize the font of this face, make sure it is a
|
||||
monospaced font, otherwise line numbers will not line up,
|
||||
and text lines might move horizontally as you move through
|
||||
the buffer. Similarly, making this face's font different
|
||||
from that of the `line-number' face could produce such
|
||||
unwanted effects."
|
||||
:version "27.1"
|
||||
:group 'basic-faces
|
||||
:group 'display-line-numbers)
|
||||
|
||||
(defface line-number-minor-tick
|
||||
'((t :inherit line-number))
|
||||
"Face for highlighting \"minor ticks\" (as in a ruler).
|
||||
When `display-line-numbers-minor-tick' is positive, highlight
|
||||
the line numbers of lines which are a multiple of its value.
|
||||
This face is used when `display-line-numbers' is non-nil.
|
||||
|
||||
If you customize the font of this face, make sure it is a
|
||||
monospaced font, otherwise line numbers will not line up,
|
||||
and text lines might move horizontally as you move through
|
||||
the buffer. Similarly, making this face's font different
|
||||
from that of the `line-number' face could produce such
|
||||
unwanted effects."
|
||||
:version "27.1"
|
||||
:group 'basic-faces
|
||||
:group 'display-line-numbers)
|
||||
|
||||
;; Definition stolen from display-line-numbers.
|
||||
(defface fill-column-indicator
|
||||
'((t :inherit shadow :weight normal :slant normal
|
||||
|
|
|
|||
|
|
@ -2724,6 +2724,8 @@ See also `toggle-frame-maximized'."
|
|||
display-line-numbers-width
|
||||
display-line-numbers-current-absolute
|
||||
display-line-numbers-widen
|
||||
display-line-numbers-major-tick
|
||||
display-line-numbers-minor-tick
|
||||
display-fill-column-indicator
|
||||
display-fill-column-indicator-column
|
||||
display-fill-column-indicator-character
|
||||
|
|
|
|||
24
src/xdisp.c
24
src/xdisp.c
|
|
@ -22664,6 +22664,14 @@ maybe_produce_line_number (struct it *it)
|
|||
empty lines beyond EOB. */
|
||||
&& it->what != IT_EOB)
|
||||
tem_it.face_id = current_lnum_face_id;
|
||||
else if (display_line_numbers_major_tick > 0
|
||||
&& (lnum_to_display % display_line_numbers_major_tick == 0))
|
||||
tem_it.face_id = merge_faces (it->w, Qline_number_major_tick,
|
||||
0, DEFAULT_FACE_ID);
|
||||
else if (display_line_numbers_minor_tick > 0
|
||||
&& (lnum_to_display % display_line_numbers_minor_tick == 0))
|
||||
tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,
|
||||
0, DEFAULT_FACE_ID);
|
||||
else
|
||||
tem_it.face_id = lnum_face_id;
|
||||
if (beyond_zv
|
||||
|
|
@ -34125,6 +34133,8 @@ be let-bound around code that needs to disable messages temporarily. */);
|
|||
/* Names of the faces used to display line numbers. */
|
||||
DEFSYM (Qline_number, "line-number");
|
||||
DEFSYM (Qline_number_current_line, "line-number-current-line");
|
||||
DEFSYM (Qline_number_major_tick, "line-number-major-tick");
|
||||
DEFSYM (Qline_number_minor_tick, "line-number-minor-tick");
|
||||
/* Name of a text property which disables line-number display. */
|
||||
DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
|
||||
|
||||
|
|
@ -34760,6 +34770,20 @@ if the font in fill-column-indicator face does not support Unicode characters.
|
|||
DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character");
|
||||
Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character);
|
||||
|
||||
DEFVAR_INT ("display-line-numbers-major-tick", display_line_numbers_major_tick,
|
||||
doc: /* If an integer N > 0, highlight line number of every Nth line.
|
||||
The line number is shown with the `line-number-major-tick' face.
|
||||
Otherwise, no special highlighting is done every Nth line.
|
||||
Note that major ticks take precedence over minor ticks. */);
|
||||
display_line_numbers_major_tick = 0;
|
||||
|
||||
DEFVAR_INT ("display-line-numbers-minor-tick", display_line_numbers_minor_tick,
|
||||
doc: /* If an integer N > 0, highlight line number of every Nth line.
|
||||
The line number is shown with the `line-number-minor-tick' face.
|
||||
Otherwise, no special highlighting is done every Nth line.
|
||||
Note that major ticks take precedence over minor ticks. */);
|
||||
display_line_numbers_minor_tick = 0;
|
||||
|
||||
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…
Add table
Add a link
Reference in a new issue