aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMichael Olson2008-05-19 22:36:09 +0000
committerMichael Olson2008-05-19 22:36:09 +0000
commit1b21ee065d77baee6da0c46a207bfb44d7cc0a95 (patch)
treeac173ee06682f6fe2d09403c2be5d246b9d26558 /doc
parentad97b375e8189e1826d562898ea78e4f3bb94bda (diff)
downloademacs-1b21ee065d77baee6da0c46a207bfb44d7cc0a95.tar.gz
emacs-1b21ee065d77baee6da0c46a207bfb44d7cc0a95.zip
Implement Project-local variables.
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/custom.texi60
1 files changed, 60 insertions, 0 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index e270f863253..a85925c0f05 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -796,6 +796,7 @@ here we describe other aspects of Emacs variables.
796 of Emacs to run on particular occasions. 796 of Emacs to run on particular occasions.
797* Locals:: Per-buffer values of variables. 797* Locals:: Per-buffer values of variables.
798* File Variables:: How files can specify variable values. 798* File Variables:: How files can specify variable values.
799* Directory Variables:: How variable values can be specified by directory.
799@end menu 800@end menu
800 801
801@node Examining 802@node Examining
@@ -1262,6 +1263,65 @@ customizable list of eval forms which are safe. Emacs does not ask
1262for confirmation when it finds these forms for the @code{eval} 1263for confirmation when it finds these forms for the @code{eval}
1263variable. 1264variable.
1264 1265
1266@node Directory Variables
1267@subsection Per-Directory Local Variables
1268@cindex local variables in directories
1269@cindex directory local variables
1270
1271 Emacs provides a way to specify local variable values per-directory.
1272This can be done one of two ways.
1273
1274 The first approach is to put a special file, named
1275@file{.dir-settings.el}, in a directory. When opening a file, Emacs
1276searches for @file{.dir-settings.el} starting in the file's directory
1277and then moving up the directory hierarchy. If
1278@file{.dir-settings.el} is found, Emacs applies variable settings from
1279the file to the new buffer. If the file is remote, Emacs skips this
1280search, because it would be too slow.
1281
1282 The file should hold a specially-constructed list. This list maps
1283Emacs mode names (symbols) to alists; each alist maps variable names
1284to values. The special mode name @samp{nil} means that the alist
1285should be applied to all buffers. Finally, a string key can be used
1286to specify an alist which applies to a relative subdirectory in the
1287project.
1288
1289@example
1290((nil . ((indent-tabs-mode . t)
1291 (tab-width . 4)
1292 (fill-column . 80)))
1293 (c-mode . ((c-file-style . "BSD")))
1294 (java-mode . ((c-file-style . "BSD")))
1295 ("src/imported"
1296 . ((nil . ((change-log-default-name . "ChangeLog.local"))))))
1297@end example
1298
1299 This example shows some settings for a hypothetical project. This
1300sets @samp{indent-tabs-mode} to @samp{t} for any file in the source
1301tree, and it sets the indentation style for any C or Java source file
1302to @samp{BSD}. Finally, it specifies a different @file{ChangeLog}
1303file name for any file in the project that appears beneath the
1304directory @file{src/imported}.
1305
1306 The second approach to directory-local settings is to explicitly
1307define a project class using @code{define-project-bindings}, and then
1308to tell Emacs which directory roots correspond to that class, using
1309@code{set-directory-project}. You can put calls to these functions in
1310your @file{.emacs}; this can useful when you can't put
1311@file{.dir-settings.el} in the directory for some reason. For
1312example, you could apply settings to an unwriteable directory this
1313way:
1314
1315@example
1316(define-project-bindings 'unwriteable-directory
1317 '((nil . ((some-useful-setting . value)))))
1318
1319(set-directory-project "/usr/include/" 'unwriteable-directory)
1320@end example
1321
1322 Unsafe directory-local variables are handled in the same way as
1323unsafe file-local variables.
1324
1265@node Key Bindings 1325@node Key Bindings
1266@section Customizing Key Bindings 1326@section Customizing Key Bindings
1267@cindex key bindings 1327@cindex key bindings