I am a emacs-newbie and I'd like to know how to switch to
Auto-Indent-Mode. I just want to write structured code, but switching
to c-mode, as well as the menu option doesn't have the desired effect.
Thanks for help
If by ``auto-indent'' you mean that pressing RET automatically indents the
next line, then press C-j (or LFD, if your keyboard has it) instead of RET.
Or try rebinding RET to call newline-and-indent.
I do the following for eg CC-mode:
(add-hook 'c-mode-hook
#'(lambda ()
(define-key c-mode-map [(return)] 'newline-and-indent)))
I do the define-key in the mode hook because that way RET isn't
rebound for *every* mode, and the c-mode-map may not exist if a c-mode
buffer hasn't been opened yet, but it will when the hook is called. I
have one of these for each mode that I want auto-indentation in. Ie,
one for Lisp-Mode, one for Outline-Mode, one for C++-Mode, etc.
This is easier than pressing C-j all the time, which wears out my
thumb.
'james
--
James A. Crippen <ja...@unlambda.com> ,-./-. Anchorage, Alaska,
Lambda Unlimited: Recursion 'R' Us | |/ | USA, 61.2069 N, 149.766 W,
Y = \f.(\x.f(xx)) (\x.f(xx)) | |\ | Earth, Sol System,
Y(F) = F(Y(F)) \_,-_/ Milky Way.
JAC> Or try rebinding RET to call newline-and-indent.
JAC> I do the following for eg CC-mode:
JAC> (add-hook 'c-mode-hook #'(lambda () (define-key c-mode-map
JAC> [(return)] 'newline-and-indent)))
I use reindent-then-newline-and-indent, and I also bind C-j to newline.
As others have said, in c-mode C-j is bound to `newline-and-indent',
which you can rebind to RET. If you want to try something similar,
you could turn on auto-state with C-c C-a which automatically enters
newlines and indents on some characters.
--
Geoff(rey) Wozniak, Limited Duties Instructor
University of Western Ontario
Computer Science (Graduate) Department
London, Ontario, Canada
http://woz.killdash9.org/
GPG Key: http://woz.killdash9.org/misc/woz.gpg
He who knows best knows how little he knows.
-- Benjamin Franklin