Subject: bug#27281: Fix nlinum missing line numbers.

From: Bryan Gilbert <[email-masked]>
Date: Sat, 10 Jun 2017 22:37:04 -0400

On 06/10/2017 06:12 PM, [email-masked] wrote:
> I suspect the debugger is suppressed while jit-lock occurs.  You would
> need to log things silently and print it later.  I think
> 'jit-lock--run-functions' and 'jit-lock-fontify-now' would be
> interesting targets.  Something easy to check would be if there are
> certain values of 'jit-lock-functions' needed to trigger this (apart
> from nlinum--region of course).  Here's my guess as to a fix (untested):
Applying that fix seemed to solve the problem! I had to make a slight 
modification to put the 'jit-lock-bounds' function call inside the 
'let', but other than that it seems to work well. I've yet to see the 
problem since applying the patch and my 'bad' perspective worked 
properly as well.

Here's the slightly modified diff:

diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el
index ca4f949fc..82872d571 100644
--- a/packages/nlinum/nlinum.el
+++ b/packages/nlinum/nlinum.el
@@ -297,7 +297,8 @@ it may cause the margin to be resized and line 
numbers to be recomputed.")
    (save-excursion
      ;; Text may contain those nasty intangible properties, but
      ;; that shouldn't prevent us from counting those lines.
-    (let ((inhibit-point-motion-hooks t))
+    (let ((inhibit-point-motion-hooks t)
+          (end start))
        (goto-char start)
        (unless (bolp) (forward-line 1))
        (remove-overlays (point) limit 'nlinum t)
@@ -321,9 +322,10 @@ it may cause the margin to be resized and line 
numbers to be recomputed.")
                     ;;   (run-with-idle-timer 0.5 nil 
#'nlinum--flush-overlays
                     ;;                        (current-buffer)))
                     (setq line (1+ line))
-                   (zerop (forward-line 1))))))))
+                   (setq end (line-end-position))
+                   (zerop (forward-line 1))))))
    ;; (setq nlinum--desc (format "-%d" (nlinum--ol-count)))
-  nil)
+  `(jit-lock-bounds ,start . ,end)))

  ;;;###autoload
  (define-globalized-minor-mode global-nlinum-mode nlinum-mode