Sunday 15 March 2015

emacs - Setting different c-basic-offs for different projects -


I usually use 4 white spaces in indented C programs, but to keep things in line with open source projects , I have

  (setq c-basic-offset 4)  

Currently assigned my indenting style to my .emac file

And when I want to work on those 2-white-space indenting projects, I have to close my MX, value the number Must be Odit and resume. Is there any easy way to do this?

Many thanks.


PS Setting C-Basic Offset Variables Whenever I open a source file, it's a lot of work, is it possible to choose different values ​​depending on the working directory?

Create a file in that directory that you want to designate .dir-localals.el , and to edit it:

  ((C-basic-offset.4))  

Note: This is a new functionality in Emacs 23.1.

This brings benefit from the documentation in the link:

.dir- Localals.el should contain a list made specifically in the file. Goodbye to AMAX mode name (symbols) in this list; Each elite variable Specifies the value for the balls when the respective mode is turned on. The special mode name 'nil' means that its goodbye applies to any mode. Instead of a mode name, you can specify a string that is used for the project The subdirectory of the directory is a name; then this follow up applies to all the files in that subdirectory.

Here is an example of a .dir-localals.el file:

  (void) ((Indent-T Ibs-mode.T. (tab-width 4) (Phil column 80)) (C-mode. ((C-file-style "BSD").) (Java-mode. ("C / file-style." BSD "))) (" src / imported ". ((Zero. (Change-log-default -name. "ChangeLog.local")))))))  

No comments:

Post a Comment