Emacs Org-Mode: Turn off linum
Asked Answered
O

6

25

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.

Option answered 8/3, 2011 at 7:43 Comment(2)
+1. +1. +1. (Apparently the SO has a bug where +1 works only the first time). I cannot stress enough how much has this helped me.Cryptology
linum slows down pasting into any mode. :(Sandisandidge
O
6

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.

Option answered 13/5, 2012 at 10:37 Comment(2)
Simpler to use (global-linum-mode) and (add-hook 'org-mode-hook (lambda () (linenum-mode 0))) in your ~/.emacs.el.Electret
@bzg: Thanks for your comment, which addresses my question directly. However, "linum-off.el" allows line numbers to be disabled in several modes, which is useful [(defcustom linum-disabled-modes-list '(eshell-mode wl-summary-mode compilation-mode org-mode dired-mode)].Option
D
9

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.

Divider answered 8/3, 2011 at 7:59 Comment(4)
Thanks. I added the lines to .emacs and opened a .org file (which automatically puts Emacs into org-mode), but line numbers are still present. The same is true if I open some other file and then visit a .org file -- the line numbers are still present. I might try the linum-off.el script mentioned in my question.Option
I changed your script to read "nil" instead of "0" and when opening a .org file, Emacs reports "Toggling global-linum-mode off; better pass an explicit argument.", but line numbers remain. This text is not shown when the line contains "0" instead of "nil" (as I said, I don't know Elisp).Option
Solved. See "Update" in question.Option
Global minor modes tend not to cooperate with the usual way of doing things with mode hooks -- the standard macros for defining global minor modes use after-change-major-mode-hook to turn the mode on, and that hook runs after the mode hook. So your mode hook briefly switches the mode off, and then it gets switched back on again.Moye
C
8

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).

Consonantal answered 6/5, 2011 at 3:34 Comment(1)
Actually, reading the code of linum, it's one or the other, not both. ` (if linum-eager (add-hook 'post-command-hook (if linum-delay 'linum-schedule 'linum-update-current) nil t)`Oly
O
6

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.

Option answered 13/5, 2012 at 10:37 Comment(2)
Simpler to use (global-linum-mode) and (add-hook 'org-mode-hook (lambda () (linenum-mode 0))) in your ~/.emacs.el.Electret
@bzg: Thanks for your comment, which addresses my question directly. However, "linum-off.el" allows line numbers to be disabled in several modes, which is useful [(defcustom linum-disabled-modes-list '(eshell-mode wl-summary-mode compilation-mode org-mode dired-mode)].Option
S
5

Use nlinum, a much faster alternative.

Sandisandidge answered 24/4, 2014 at 18:2 Comment(0)
T
4

You only need to add (add-hook 'org-mode-hook (lambda () (linum-mode 0))).

Thibault answered 24/4, 2015 at 17:17 Comment(1)
Have you tested this? In my case (with global-linum-mode on) it doesn't work.Fortenberry
N
2

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.

Nobility answered 9/3, 2011 at 19:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.