I've recently moved from vim
to Emacs
because I want to use org-mode
. I opened a ~10000 line, 50kb file in Emacs23
Org-mode
and proceeded to add about 10 first-level headings. Performance on a quad-core with 3GB RAM in Emacs23 under Ubuntu 10.04/32bit was so slow that it was unusable. I found two threads on the Org-mode
email list discussing this. It seems that enabling linum
causes the slow performance. I can live without line numbers in .org
files if I have to, but I don't want to disable line numbers for all files I edit. If I'm going to "live" in `Emacs', I'll want line numbers for all other files.
How can I disable linum
for some or all .org
files only? Is it possible to do this if I have several files open in Emacs
and switch between them? I found some discussion about disabling line numbers for major modes here, but there was nothing that I could implement (although the linum-off.el
script mentioned on the page looks promising, I don't (yet) know (E)Lisp, so I can't change it as I would need).
I updated Org-mode
from version 6.21b which came with Emacs23
to version 7.5, but it made no difference. Performance in Emacs
GUI is so bad that the application fails to respond at all. Performance with -nw
is "better", but still unusable.
Try adding this to your .emacs:
(defun nolinum ()
(global-linum-mode 0)
)
(add-hook 'org-mode-hook 'nolinum)
This is assuming that you use linum and not something else to number lines. Anyway, you can add this hook to org-mode to disable anything that might make org slow only when you're using org-mode.
Disclaimer: I don't have linum installed so I can't test this, but it should work.
If you type M-x customize, go to Linum in the Convenience group, change Linum Eager to off, or change Linum Delay to on, it will improve performance greatly.
On my laptop (3 GB RAM, dual core) the performance drawback (of this versus having linum off) is unnoticeable, however on my netbook there may still be some slight performance issues with a ~3000 line 130KB file (~50-150 ms delay when paging).
linum-off.el
mentioned in my quesiton has solved this. Instructions are in the file: place the file into the Emacs load-path and add (require 'linum-off)
to ~/.emacs. This script turns off line numbering for the modes specified only. I've tested it and it works fine.
Use nlinum, a much faster alternative.
You only need to add (add-hook 'org-mode-hook (lambda () (linum-mode 0))).
I tried the following which worked out pretty well:
(defun nolinum ()
(interactive)
(message "Deactivated linum mode")
(global-linum-mode 0)
(linum-mode 0)
)
(global-set-key (kbd "<f6>") 'nolinum)
(add-hook 'org-mode-hook 'nolinum)
Of course, you do not need the keybinding. I suggest you leave it in for testing purposes and disable it if everything works fine.
来源:https://stackoverflow.com/questions/5229705/emacs-org-mode-turn-off-line-numbers