Go to the first, previous, next, last section, table of contents.

17. Text mode

17.1. How can I enable auto-indent?

Put the following line in your `.emacs'.

(setq indent-line-function 'indent-relative-maybe)

If you want to get fancy, try `filladapt' and `fa-extras', available from the Emacs Lisp Archive at Ohio State University. Get them at ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive/packages/

17.2. How can I get XEmacs to come up in text mode (auto-fill) by default?

Try the following lisp in your `.emacs' file

(setq default-major-mode 'text-mode)
(setq text-mode-hook 'turn-on-auto-fill)

WARNING: note that changing default-major-mode from fundamental-mode can break a large amount of built-in code that expects newly created buffers to be in fundamental-mode. (Changing from fundamental-mode to auto-fill text-mode might not wreak too much havoc, but changing to something more exotic like a lisp-mode would break many Emacs packages.

Note that Emacs defaultly starts up in buffer *scratch* in initial-major-mode, which defaults to lisp-interaction-mode. Thus adding the following form to your Emacs init file will cause the initial *scratch* buffer to be put into auto-fill'ed text-mode.

(setq initial-major-mode
      (function (lambda ()
        (text-mode)
        (turn-on-auto-fill))))

Note that after your init file is loaded, if inhibit-startup-message is null (the default) and the startup buffer is *scratch* then the startup message will be inserted into *scratch*; it will be removed after a timeout by erasing the entire *scratch* buffer. Keep in mind this default usage of *scratch* if you desire any prior manipulation of *scratch* from within your Emacs init file. In particular, anything you insert into *scratch* from your init file will be later erased. Also, if you change the mode of *scratch* be sure that this will not interfere with possible later insertion of the startup message (e.g. if you put *scratch* into a nonstandard mode that has automatic font lock rules, then the startup message might get fontified in a strange foreign manner, e.g. as code in some programming language).


Go to the first, previous, next, last section, table of contents.