[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/line-numbers 71a7294 10/14: Support a separate fac
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] scratch/line-numbers 71a7294 10/14: Support a separate face for displaying the current line's number |
Date: |
Sat, 24 Jun 2017 13:12:53 -0400 (EDT) |
branch: scratch/line-numbers
commit 71a7294d0a775a8969ec077eb3633da6bdad7c62
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Support a separate face for displaying the current line's number
* lisp/faces.el (line-number-current-line): New face.
* src/xdisp.c (syms_of_xdisp) <line-number-current-line>: New
symbol.
(try_window_id, try_cursor_movement): Disable these optimizations
when the line-number-current-line face is different from
line-number face.
(maybe_produce_line_number): Display the current line in the
line-number-current-line face, if it's different from line-number.
---
lisp/faces.el | 7 +++++++
src/xdisp.c | 29 ++++++++++++++++++++++++-----
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/lisp/faces.el b/lisp/faces.el
index ac2d210..3a40dc9 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2473,6 +2473,13 @@ This face is used when `display-line-numbers' is
non-nil."
:version "26.1"
:group 'basic-faces)
+(defface line-number-current-line
+ '((t :inherit line-number))
+ "Face for displaying the current line number.
+This face is used when `display-line-numbers' is non-nil."
+ :version "26.1"
+ :group 'basic-faces)
+
(defface escape-glyph
'((((background dark)) :foreground "cyan")
;; See the comment in minibuffer-prompt for
diff --git a/src/xdisp.c b/src/xdisp.c
index 8acba25..cf396de 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -15940,6 +15940,13 @@ try_cursor_movement (Lisp_Object window, struct
text_pos startp,
/* When display-line-numbers is in relative mode, moving point
requires to redraw the entire window. */
&& !EQ (Vdisplay_line_numbers, Qrelative)
+ /* When the current line number should be displayed in a
+ distinct face, moving point cannot be handled in optimized
+ way as below. */
+ && !(!NILP (Vdisplay_line_numbers)
+ && NILP (Finternal_lisp_face_equal_p (Qline_number,
+ Qline_number_current_line,
+ w->frame)))
/* This code is not used for mini-buffer for the sake of the case
of redisplaying to replace an echo area message; since in
that case the mini-buffer contents per se are usually
@@ -18445,8 +18452,13 @@ try_window_id (struct window *w)
if (!NILP (BVAR (XBUFFER (w->contents), extra_line_spacing)))
GIVE_UP (23);
- /* Give up if display-line-numbers is in relative mode. */
- if (EQ (Vdisplay_line_numbers, Qrelative))
+ /* Give up if display-line-numbers is in relative mode, or when the
+ current line's number needs to be displayed in a distinct face. */
+ if (EQ (Vdisplay_line_numbers, Qrelative)
+ || (!NILP (Vdisplay_line_numbers)
+ && NILP (Finternal_lisp_face_equal_p (Qline_number,
+ Qline_number_current_line,
+ w->frame))))
GIVE_UP (24);
/* Make sure beg_unchanged and end_unchanged are up to date. Do it
@@ -20739,8 +20751,13 @@ maybe_produce_line_number (struct it *it)
char lnum_buf[INT_STRLEN_BOUND (ptrdiff_t) + 1];
bool beyond_zv = IT_BYTEPOS (*it) >= ZV_BYTE ? true : false;
ptrdiff_t lnum_offset = -1; /* to produce 1-based line numbers */
+ int lnum_face_id = merge_faces (it->f, Qline_number, 0, DEFAULT_FACE_ID);
+ int current_lnum_face_id
+ = merge_faces (it->f, Qline_number_current_line, 0, DEFAULT_FACE_ID);
/* Compute point's line number if needed. */
- if (EQ (Vdisplay_line_numbers, Qrelative) && !it->pt_lnum)
+ if ((EQ (Vdisplay_line_numbers, Qrelative)
+ || lnum_face_id != current_lnum_face_id)
+ && !it->pt_lnum)
{
ptrdiff_t ignored;
if (PT_BYTE > it->lnum_bytepos)
@@ -20803,7 +20820,6 @@ maybe_produce_line_number (struct it *it)
/* Produce glyphs for the line number in a scratch glyph_row. */
int n_glyphs_before;
- int lnum_face_id = merge_faces (it->f, Qline_number, 0, DEFAULT_FACE_ID);
for (const char *p = lnum_buf; *p; p++)
{
/* For continuation lines and lines after ZV, instead of a line
@@ -20811,6 +20827,8 @@ maybe_produce_line_number (struct it *it)
default face for the blank field beyond ZV. */
if (beyond_zv)
tem_it.face_id = it->base_face_id;
+ else if (lnum_face_id != current_lnum_face_id && this_line ==
it->pt_lnum)
+ tem_it.face_id = current_lnum_face_id;
else
tem_it.face_id = lnum_face_id;
if (beyond_zv || it->continuation_lines_width > 0)
@@ -31884,8 +31902,9 @@ They are still logged to the *Messages* buffer. */);
/* Name of the face used to highlight trailing whitespace. */
DEFSYM (Qtrailing_whitespace, "trailing-whitespace");
- /* Name of the face used to display line numbers. */
+ /* Names of the faces used to display line numbers. */
DEFSYM (Qline_number, "line-number");
+ DEFSYM (Qline_number_current_line, "line-number-current-line");
/* Name and number of the face used to highlight escape glyphs. */
DEFSYM (Qescape_glyph, "escape-glyph");
- [Emacs-diffs] scratch/line-numbers updated (7277c0f -> ead4ab6), Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 5b648ac 04/14: Fix problems with line-number updates in Follow mode, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 77f8b86 03/14: Fix display of line numbers with fonts larger than the default, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers bbaf2f3 02/14: Fix background color beyond EOB and cursor display, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 9776d7b 05/14: Don't display line numbers in the minibuffer and in tooltip frames., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers ead4ab6 14/14: Improve documentation in NEWS., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers efedb66 08/14: Rename display-line-width, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 13cc19a 12/14: Partial fix of hscroll of truncated lines with line numbers, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 7d7602c 06/14: Fix crashes on TTY frames due to negative lnum_width., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 55a9298 07/14: Fix tab stops when line numbers are displayed, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 71a7294 10/14: Support a separate face for displaying the current line's number,
Eli Zaretskii <=
- [Emacs-diffs] scratch/line-numbers d4eddb0 01/14: Fix display of indicate-empty-lines when line numbers are displayed, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 0d5c713 13/14: Move additional hscrolling code into a suitable 'if', Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers fa5e84c 09/14: Change display of current line in relative mode, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 6e18841 11/14: Allow Lisp program to disable line-number display for specific lines, Eli Zaretskii, 2017/06/24