Search code examples
performanceemacsline-numbers

Emacs line numbering performance


I've tried linum and nlinum. Both have dreadful performance on files with 100k+ lines.

$ for x in {1.100000}; do echo $x; done > 100k.txt
$ emacs -q 100k.txt
M-x load-library linum
M-x linum-mode
M-> ;; it's not too bad to go to end of file
M-< ;; now this completely locks up emacs

The same operation with editors like joe is instantaneous.

Is there any solution other than to turn off line numbers with big files (exactly the type of files that you want to navigate with line numbers - I have in mind locating error lines in concatenated Javascript files)?

Or just use a different editor?


Solution

  • I think you found a bug, and you may report (report-emacs-bug) it. As per Tyler comment, it may have been already solved.

    Things that may help you in the meanwhile... line-number-mode, goto-line, narrow-to-region and this cheapo-number-my-lines-in-a-tmp-buffer trick:

    (shell-command-on-region (point-min) (point-max)
        (concat "grep -n ^ " buffer-file-name)
        (get-buffer-create "*tmp-linum*") nil t)