Subject: Re: bug#23777: 25.0.95; Throwing (error "Selecting deleted buffer") in timer

From: [email-masked]
Date: Sat, 09 Jul 2016 17:34:15 -0400

Jiege Chen <[email-masked]> writes:

> I removed that call in my init code, and the error is gone,
> at the price of some display inconsistency which is acceptable.
> There is room for improvement in nlinum--flush. 

How about this instead:

(defun my-nlinum-mode-hook ()
  (when nlinum-mode
    (setq-local nlinum-format
                (concat "%" (number-to-string
                             (ceiling (log (max 1 (count-lines (point-min)
                                                               (point-max)))
                                           10)))
                        "d"))))
(add-hook 'nlinum-mode-hook #'my-nlinum-mode-hook)

Actually, I think count-lines will be slow on big files, so you may want
to approximate with something like

(defun my-nlinum-mode-hook ()
  (when nlinum-mode
    (setq-local nlinum-format
                (concat "%" (number-to-string
                             (ceiling (log (max 1 (/ (buffer-size) 80)) 10)))
                        "d"))))