I am using org-mode extensively. I have lots of tables, and big source snippets with:
#+begin_src <whatever>
...
#+end_src
And also:
#+begin_example
...
#+end_example
I have noticed that, for big files (above 1000 lines?), performance is an issue: my emacs gets slow, and typing is not fluid anymore (the editor blocks for several milliseconds every so often).
This is the list of active minor modes M-x describe-mode):
Enabled minor modes: Auto-Compression Auto-Encryption Blink-Cursor
Column-Number Csv-Field-Index Delete-Selection Desktop-Save
Display-Time File-Name-Shadow Font-Lock Global-Font-Lock
Global-Whitespace Icomplete Ido-Everywhere Line-Number Mouse-Wheel
Recentf Server Shell-Dirtrack Show-Paren Tooltip Transient-Mark
Which-Function
I am not sure which mode is responsible for the bad performance, but I guess it is org-mode. Are there any configuration settings that I could tweak to make org-mode more performant?
Related
In Emacs how do I stop the auto-fill minor mode from loading when I start the idlwave major mode?
So far I have been completely unsuccessful at figuring out how to do this. I have tried to use remove-hook for both idl-mode-hook and text-mode-hook without success.
You might have enabled auto-fill-mode as a global minor mode, so it is on in all buffers by default. If that is the case, the task is not so much not turning it on in idlwave-mode but rather turning it off.
Most major modes provide a special hook variable: it's a list containing functions that are called whenever that major mode is invoked. For instance, with the following line you can make sure that auto-fill-mode will get turned off each time a buffer goes into idlwave-mode:
(add-hook 'idlwave-mode-hook (lambda () (auto-fill-mode 0)))
Put the above line in your init file (e.g. ~/.emacs or ~/.emacs.d/init.el) and auto-fill-mode should be turned off in idlwave mode after you restarted Emacs.
I have a window whose mode line at the bottom says "(Text Spc Fill)", probably as a default for *.txt filenames. "Spc" seems to be a minor mode which attempts to preserve English text by, for example, collapsing two spaces to one after a word is removed. However, I don't want that in this buffer.
So, how can I turn off this minor mode?
I don't know the actual name of the mode. I tried M-x spc-mode and M-x space-mode, and I looked through a few help pages.
More generally, is there an easy way to get the list of modes which are active in the current buffer? Or to find out about a mode given its mode-line abbreviation? (These can be unpredictable; for example, M-x visual-line-mode corresponds to (WordWrap).)
This is Aquamacs, Emacs version 23.3.50.1.
To answer your second question, the command describe-mode (C-hm) will list
your major mode, along with
some documentation (usually including keybindings), and
all of the minor modes that are active
You might be surprised how many minor modes are active in a typical setup. Not all active modes have an "indicator."
in your .emacs file add the line
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
Source
I plan to customize mode line in Emacs in near future, and i don't understand the algorithm behind listing minor modes in the mode line.
In section «1.3 The Mode Line» of Emacs manual it says: «MINOR is a list of some of the enabled "minor modes"»
While in section «23.2 Minor Modes» it says: «Most buffer-local minor modes say in the mode line when they are enabled»
However i have ErgoEmacs minor mode listed, which is global. Can somebody explain the mechanism behind this and preferably point at various elisp sources responsible for that?
You can change what is displayed for a specific minor mode by doing something like the following
(setcar (cdr (assq 'yas/minor-mode minor-mode-alist)) " ¥")
which will display " ¥" for yasnippet mode. I do this a lot, especially for modes that I often use since it shortens my mode-line considerably.
This is specified for each individual mode, by the mode's own definition.
If you read on to section 23.3.3 - Defining Minor Modes:
The string LIGHTER says what to display in the mode line when the mode is enabled; if it is `nil', the mode is not displayed in the mode line.
See:
M-: (info "(elisp) Defining Minor Modes") RET
C-hf define-minor-mode RET
See also http://www.emacswiki.org/emacs/DelightedModes which facilitates easy customisation of the mode line display for both major and minor modes.
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.
Emacs has poor handling of auto-indentation in Flex and Bison. In fact, it seems to have no support for flex mode. So, how does an emacs user cope with these? I like VIm but I would prefer not to switch because I am much faster and more comfortable in Emacs.
I had a third party elisp module for Bison a few months ago but when its indentation broke, it would never get fixed. In short, it was a bad hack.
Or is there a way I can turn off auto indentation for .l and .y files (so pressing would do one indent)? How would I also change this elisp setting for just emacs?
A nice and concise guide for elisp would be very helpful too. I wouldn't mind spending a few days to write my own flex and bison modes if I had the right documentation.
Emacs chooses the major mode mainly based on the file name extension. .l is a contended extension: some people use it for lex, others for lisp (and there are a few other rarer uses). Emacs associates .l with lisp, and .lex with lex (for which it uses C mode).
If the .l files you work with are more often lex than lisp, you can change what .l files are associated with the following line in your .emacs:
(add-to-list 'auto-mode-alist '("\\.l\\'" . c-mode))
You can also declare inside a file what mode you want Emacs to use when it opens the file. Put the following snippet on the first line of the file (typically in a comment):
-*-mode: c-mode-*-
This is a more general feature, offering other syntaxes and other possibilities; see “File Variables” in the Emacs manual for more information.
If you would like to get started with Emacs Lisp, read the Emacs Lisp intro (which may be included in your Emacs or OS distribution). Once you've played around with the basics of the language a bit, you can turn to the chapter on modes in the Emacs Lisp reference manual.
Additional tip: You might decide that what you want is Emacs' generic behavior -- what it uses when it doesn't have any special mode for a file format. That's called Fundamental mode in emacs lingo: so you can request it on the fly with M-x fundamental-mode, or put -*- mode: fundamental -*- on the first line of the file, or customize auto-mode-alist like so:
(add-to-list 'auto-mode-alist '("\\.l\\'" . fundamental-mode))
Another thing to try might be indented-text-mode (probably with auto-fill disabled).