Bob Tanner wrote:
> Anyone know how to config emacs per "project"? Like a .emacs for each project
> you work on?
>
> I ask because I just had 1 of the open source project I work on switch from tabs
> to spaces for indenting -and- from 2 space indent to 4 space indent.
>
> It would be no big deal, but another project I work on is 2 space indent.
>
> Get's annoying having to change my .emacs files depending on which project I
> work on.
>
>
emacs has indent style thingy accessed by C-c. you can either use one
of the predefined ones or make your own. I believe you can use the -*-
mode select to tell it to load for that file or you can set up directory
rules in your .emacs file to say that files loaded from that directory
have a particular indent style.
I use 20.7.2 and it has these different indent styles already defined:
bsd cc-mode
ellemtel gnu
java k&r
linux python
stroustrup user
whitesmith
a good example of how to do this is in the kernel docs:
add to your .emacs
; linux kernel c mode
(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux kernel."
(interactive)
(c-mode)
(c-set-style "K&R")
(setq c-basic-offset 8))
; set linux kernel mode for anything in /usr/src/linux*
(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)
auto-mode-alist))
Hope this helps,
Eric