Emacs Org-Mode: Turn off line numbers

2019-02-01 20:21发布

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.

6条回答
趁早两清
2楼-- · 2019-02-01 20:53

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

查看更多
甜甜的少女心
3楼-- · 2019-02-01 20:58

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.

查看更多
趁早两清
4楼-- · 2019-02-01 21:10

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.

查看更多
啃猪蹄的小仙女
5楼-- · 2019-02-01 21:12

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.

查看更多
做个烂人
6楼-- · 2019-02-01 21:18

Use nlinum, a much faster alternative.

查看更多
来,给爷笑一个
7楼-- · 2019-02-01 21:19

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

查看更多
登录 后发表回答