unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: William Gilbert <gilbertw1@gmail.com>
To: 27281@debbugs.gnu.org
Subject: bug#27281: Fix nlinum missing line numbers.
Date: Wed, 7 Jun 2017 17:46:29 -0400	[thread overview]
Message-ID: <CAFHZif5bCS293meZ8NDd6nJFdOai+ZOd0Eb2DdOwrW59FMJCHg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

I've been working to track to down a bug where line numbers are
occasionally missing when using nlinum mode. Currently there is a package
written to workaround the problem that has a picture and description of the
problem: https://github.com/hlissner/emacs-nlinum-hl.

After extensive debugging I've tracked the problem down to the
'nlinum--region' function. Specifically the while loop check that
determines if '(point)' is less than the limit. I've found that the problem
exists when '(point)' is exactly equal to 'limit'. In this scenario the
loop terminates and the last line in the region is not provided with a line
number. I was able to remedy the problem by changing the condition from
'less than' to 'less than or equal to', which will allow the last line in
the region to be properly assigned a line number.

Thank you.

Diff:

diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el
index ca4f949fc..f82b61987 100644
--- a/packages/nlinum/nlinum.el
+++ b/packages/nlinum/nlinum.el
@@ -303,7 +303,7 @@ it may cause the margin to be resized and line numbers
to be recomputed.")
       (remove-overlays (point) limit 'nlinum t)
       (let ((line (nlinum--line-number-at-pos)))
         (while
-            (and (not (eobp)) (< (point) limit)
+            (and (not (eobp)) (<= (point) limit)
                  (let* ((ol (make-overlay (point) (1+ (point))))
                         (str (funcall nlinum-format-function
                                       line nlinum--width))

[-- Attachment #2: Type: text/html, Size: 1895 bytes --]

             reply	other threads:[~2017-06-07 21:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 21:46 William Gilbert [this message]
2017-06-10 11:51 ` bug#27281: Fix nlinum missing line numbers npostavs
2017-06-10 14:35   ` Bryan Gilbert
2017-06-10 17:44   ` Alex
2017-06-10 22:12     ` npostavs
2017-06-11  1:18       ` Alex
2017-06-11  1:37         ` npostavs
2017-06-11  2:37       ` Bryan Gilbert
2017-06-11  2:50         ` Bryan Gilbert
2019-09-29 15:04           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFHZif5bCS293meZ8NDd6nJFdOai+ZOd0Eb2DdOwrW59FMJCHg@mail.gmail.com \
    --to=gilbertw1@gmail.com \
    --cc=27281@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).