Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs - how do I automatically enter minor modes when I enter a major mode?

Tags:

emacs

latex

I'm kind of a newb when it comes to emacs. I know about the .emacs file but have very little idea as to do anything more advanced than elementary stuff.

Whenever I enter latex-mode, I'd also like to automatically turn on flyspell-mode, reftex-mode, auto-fill-mode, and also set fill-column to 120. How do I edit my .emacs file to do this?

Thanks!

like image 697
Dang Khoa Avatar asked Nov 23 '10 06:11

Dang Khoa


People also ask

How do I enable minor mode in Emacs?

If you want to enable/disable minor-modes on the whole session, press [e] or [d] on any minor-mode to keep its status even if you change major-modes, buffers, files. It continues until stopping emacs. This enable/disable list is stored in the global of manage-minor-mode-default .

How do I change modes in Emacs?

Usually, the major mode is automatically set by Emacs, when you first visit a file or create a buffer (see Choosing File Modes). You can explicitly select a new major mode by using an M-x command.

What is the default mode in Emacs?

The standard default value is fundamental-mode . If the default value is nil , then whenever Emacs creates a new buffer via a command such as C-x b ( switch-to-buffer ), the new buffer is put in the major mode of the previously current buffer.

How do I enter mode in Emacs?

To get a list of the all the available modes, both major and minor, on your system's version of Emacs, look up "mode" using Emacs' apropos command. Do this by pressing C-h a and entering the word mode .


2 Answers

(add-hook 'latex-mode-hook
    (function (lambda ()
       (flymake-mode)
       (reftex-mode)
       (auto-fill-mode)
       (setq fill-column 120))))

for example should work.

like image 163
darioo Avatar answered Sep 19 '22 12:09

darioo


You can set a so-called hook to a major mode. Have a look at this page of the manual for some examples.

like image 23
Luca Martini Avatar answered Sep 22 '22 12:09

Luca Martini