emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/line-numbers fa5e84c 09/14: Change display of curr


From: Eli Zaretskii
Subject: [Emacs-diffs] scratch/line-numbers fa5e84c 09/14: Change display of current line in relative mode
Date: Sat, 24 Jun 2017 13:12:53 -0400 (EDT)

branch: scratch/line-numbers
commit fa5e84cccd31cf94074255180d6ff3a44d4f8f89
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Change display of current line in relative mode
    
    * src/xdisp.c (maybe_produce_line_number): In relative mode
    display the current line number as its absolute value, not as zero.
---
 src/xdisp.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index d23b176..8acba25 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20763,13 +20763,7 @@ maybe_produce_line_number (struct it *it)
             matrix.  */
          ptrdiff_t max_lnum;
 
-         if (EQ (Vdisplay_line_numbers, Qrelative))
-           /* We subtract one more because the current line is
-              always zero under relative line-number display.  */
-           max_lnum = it->w->desired_matrix->nrows - 2;
-         else
-           max_lnum =
-             this_line + it->w->desired_matrix->nrows - 1 - it->vpos;
+         max_lnum = this_line + it->w->desired_matrix->nrows - 1 - it->vpos;
          max_lnum = max (1, max_lnum);
          it->lnum_width = log10 (max_lnum) + 1;
        }
@@ -20778,12 +20772,18 @@ maybe_produce_line_number (struct it *it)
   if (EQ (Vdisplay_line_numbers, Qrelative))
     lnum_offset = it->pt_lnum;
 
+  /* Under 'relative', display the absolute line number for the
+     current line, as displaying zero gives zero useful information.  */
+  ptrdiff_t lnum_to_display = eabs (this_line - lnum_offset);
+  if (EQ (Vdisplay_line_numbers, Qrelative)
+      && lnum_to_display == 0)
+    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
      called when no display elements were produced from the
      following line, so the paragraph direction might be unknown.
      Therefore we cheat and add 2 blanks, one on either side.  */
-  pint2str (lnum_buf, it->lnum_width + 1, eabs (this_line - lnum_offset));
+  pint2str (lnum_buf, it->lnum_width + 1, lnum_to_display);
   strcat (lnum_buf, " ");
 
   /* Setup for producing the glyphs.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]