coldnew / linum-relative

display relative line number in the left margin in emacs
169 stars 20 forks source link

Slow navigation when editing big org files #24

Closed Andre0991 closed 8 years ago

Andre0991 commented 8 years ago

Hi. When I open a big file with folded text using org-mode, linum-relative has to calculate the fold line numbers, which is very slow.

ss

Is it possible to add a variable to count only visible lines?

Actually, I don't know if that would make it fast.

Thanks.

coldnew commented 8 years ago

It's not recommand to use linum-mode or linum-relative in big file actually.

What's the speed if you use linum-mode in your big org-mode file? Is it still slow? If yes, the slow performance is due to linum-mode since linum-relative is based on it.

If your file is working ok on linum-mode then I think we can try to find the solution :)

PS: I use linum-off to disable use org-mode with linum-mode.

Andre0991 commented 8 years ago

Thanks for your answer.

Yeap, it is slow because of linum-mode.

I configured to current line to show 0, as you can see in the image, in order to avoid calculating the absolute line number. However, org's folding system makes it calculate a lot of invisible lines.

So I wonder if there's a way to skip all the invisible lines (without any computational cost) and just calculate the relative line numbers using the visible ones, thus making it very efficient.

I'm not sure whether this is possible. If it isn't, that's ok, I can live with that (that is, either disabling the mode or expanding all org folds.)

noctuid commented 8 years ago

@Andre0991 nlinum-mode is a lot faster in large org files. If you just want relative line numbers, you might want to try relative-line-numbers with (setq relative-line-numbers-motion-function #'forward-visible-line) which won't consider invisible lines and doesn't depend on linum

Andre0991 commented 8 years ago

Yeah, I'd read about that option. I'll use it for now.

It would be cool if linum-relative had something like that (I'm using Spacemacs, which uses inum-relative on the default keybinding for relative numbers.)

Thanks for your suggestion.

coldnew commented 8 years ago

It's shame that emacs does not has any builtin line-number display system.

Currently I have no plan to rewrite the linum-relative to use overlay instead of based on linum.el. The root cause is modified the linum.el or fixes this in emacs instead of rewrite linum-relative directly.