Emacs Org-Mode:关闭 linum

发布于 2024-10-21 07:54:04 字数 1108 浏览 8 评论 0原文

我最近从 vim 迁移到 Emacs,因为我想使用 org-mode。我在 Emacs23 Org-mode 中打开了约 10000 行、50kb 的文件,然后添加了大约 10 个一级标题。 Ubuntu 10.04/32 位下的 Emacs23 在四核 3GB RAM 上的性能非常慢,以至于无法使用。我发现两个 Org-mode 电子邮件列表中的线程对此进行了讨论。看来启用 linum 会导致性能下降。如果有必要的话,我可以忍受 .org 文件中没有行号,但我不想禁用我编辑的所有文件的行号。如果我要“生活”在“Emacs”中,我需要所有其他文件的行号。

如何仅对部分或全部 .org 文件禁用 linum?如果我在 Emacs 中打开多个文件并在它们之间切换,是否可以执行此操作?我在此处找到了一些关于禁用主要模式行号的讨论,但我没有发现任何内容可以实现(尽管 linum-off.el 脚本提到 看起来很有希望,我(还)不知道(E)Lisp,所以我无法根据需要更改它)。

我将 Org-mode 从 Emacs23 附带的 6.21b 版本更新到了 7.5 版本,但没有什么区别。 Emacs GUI 的性能非常糟糕,以至于应用程序根本无法响应。 -nw 的性能“更好”,但仍然无法使用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

黑白记忆 2024-10-28 07:54:04

尝试将其添加到您的 .emacs 中:

(defun nolinum ()
  (global-linum-mode 0)
)
(add-hook 'org-mode-hook 'nolinum)

这是假设您使用 linum 而不是其他东西来对行进行编号。无论如何,您可以将此钩子添加到 org-mode 中,以禁用任何可能使 org 变慢的东西当您使用 org-mode 时。

免责声明:我没有安装 linum,所以我无法测试它,但它应该可以工作。

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.

计㈡愣 2024-10-28 07:54:04

如果你输入Mxcustomize,进入便利组中的Linum,将Linum Eager更改为关闭,或将Linum Delay更改为打开,这将大大提高性能。

在我的笔记本电脑(3 GB RAM,双核)上,性能缺陷(与关闭 linum 相比)并不明显,但是在我的上网本上,大约 3000 行 130KB 文件(大约 50-150 毫秒)可能仍然存在一些轻微的性能问题寻呼时延迟)。

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

绾颜 2024-10-28 07:54:04

我的问题中提到的 linum-off.el 已经解决了这个问题。文件中包含说明:将文件放入 Emacs 加载路径并将 (require 'linum-off) 添加到 ~/.emacs。此脚本仅关闭指定模式的行编号。我已经测试过它并且工作正常。

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.

不必在意 2024-10-28 07:54:04

使用 nlinum,这是一种更快的替代方案。

Use nlinum, a much faster alternative.

瀟灑尐姊 2024-10-28 07:54:04

你只需要添加(add-hook 'org-mode-hook (lambda () (linum-mode 0)))。

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

若相惜即相离 2024-10-28 07:54:04

我尝试了以下方法,效果很好:

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

当然,您不需要键绑定。我建议您将其保留用于测试目的,如果一切正常则禁用它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文