diff options
| author | Eli Zaretskii | 2018-09-22 12:06:51 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-09-22 12:06:51 +0300 |
| commit | 8b8a4c0aeb21692970fe919e96ad4b832fe1078b (patch) | |
| tree | d478f8fce235112b74b0b9a7a086e2168bc45c61 | |
| parent | c9c9756d21d19da8b7c265c1e9d6766e42ccfbfe (diff) | |
| download | emacs-8b8a4c0aeb21692970fe919e96ad4b832fe1078b.tar.gz emacs-8b8a4c0aeb21692970fe919e96ad4b832fe1078b.zip | |
Improve documentation of directory-local variables
* lisp/files.el (hack-local-variables, normal-mode)
(after-find-file, find-file-hook): Mention directory-local
variables in the doc strings. Suggested by Marcin Borkowski
<mbork@mbork.pl>.
* doc/emacs/custom.texi (File Variables, Directory Variables):
Clarify that directory-local variables are overridden by
file-local ones.
| -rw-r--r-- | doc/emacs/custom.texi | 11 | ||||
| -rw-r--r-- | lisp/files.el | 9 |
2 files changed, 16 insertions, 4 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 141fa045b63..b93009ad216 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -1059,6 +1059,10 @@ local variable specifications; it automatically makes these variables | |||
| 1059 | local to the buffer, and sets them to the values specified in the | 1059 | local to the buffer, and sets them to the values specified in the |
| 1060 | file. | 1060 | file. |
| 1061 | 1061 | ||
| 1062 | File local variables override directory local variables | ||
| 1063 | (@pxref{Directory Variables}), if any are specified for a file's | ||
| 1064 | directory. | ||
| 1065 | |||
| 1062 | @menu | 1066 | @menu |
| 1063 | * Specifying File Variables:: Specifying file local variables. | 1067 | * Specifying File Variables:: Specifying file local variables. |
| 1064 | * Safe File Variables:: Making sure file local variables are safe. | 1068 | * Safe File Variables:: Making sure file local variables are safe. |
| @@ -1309,7 +1313,12 @@ confirmation about processing @code{eval} variables. | |||
| 1309 | Sometimes, you may wish to define the same set of local variables to | 1313 | Sometimes, you may wish to define the same set of local variables to |
| 1310 | all the files in a certain directory and its subdirectories, such as | 1314 | all the files in a certain directory and its subdirectories, such as |
| 1311 | the directory tree of a large software project. This can be | 1315 | the directory tree of a large software project. This can be |
| 1312 | accomplished with @dfn{directory-local variables}. | 1316 | accomplished with @dfn{directory-local variables}. File local |
| 1317 | variables override directory local variables, so if some of the files | ||
| 1318 | in a directory need specialized settings, you can specify the settings | ||
| 1319 | for the majority of the directory's files in directory variables, and | ||
| 1320 | then define file local variables in a few files which need the general | ||
| 1321 | settings overridden. | ||
| 1313 | 1322 | ||
| 1314 | @cindex @file{.dir-locals.el} file | 1323 | @cindex @file{.dir-locals.el} file |
| 1315 | The usual way to define directory-local variables is to put a file | 1324 | The usual way to define directory-local variables is to put a file |
diff --git a/lisp/files.el b/lisp/files.el index 4eb1560a20d..a3e72e2ce9c 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -493,7 +493,8 @@ The functions are called in the order given until one of them returns non-nil.") | |||
| 493 | (defcustom find-file-hook nil | 493 | (defcustom find-file-hook nil |
| 494 | "List of functions to be called after a buffer is loaded from a file. | 494 | "List of functions to be called after a buffer is loaded from a file. |
| 495 | The buffer's local variables (if any) will have been processed before the | 495 | The buffer's local variables (if any) will have been processed before the |
| 496 | functions are called." | 496 | functions are called. This includes directory-local variables, if any, |
| 497 | for the file's directory." | ||
| 497 | :group 'find-file | 498 | :group 'find-file |
| 498 | :type 'hook | 499 | :type 'hook |
| 499 | :options '(auto-insert) | 500 | :options '(auto-insert) |
| @@ -2369,7 +2370,7 @@ the file contents into it using `insert-file-contents-literally'." | |||
| 2369 | _after-find-file-from-revert-buffer | 2370 | _after-find-file-from-revert-buffer |
| 2370 | nomodes) | 2371 | nomodes) |
| 2371 | "Called after finding a file and by the default revert function. | 2372 | "Called after finding a file and by the default revert function. |
| 2372 | Sets buffer mode, parses local variables. | 2373 | Sets buffer mode, parses file-local and directory-local variables. |
| 2373 | Optional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an | 2374 | Optional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an |
| 2374 | error in reading the file. WARN non-nil means warn if there | 2375 | error in reading the file. WARN non-nil means warn if there |
| 2375 | exists an auto-save file more recent than the visited file. | 2376 | exists an auto-save file more recent than the visited file. |
| @@ -2454,7 +2455,7 @@ unless NOMODES is non-nil." | |||
| 2454 | 2455 | ||
| 2455 | (defun normal-mode (&optional find-file) | 2456 | (defun normal-mode (&optional find-file) |
| 2456 | "Choose the major mode for this buffer automatically. | 2457 | "Choose the major mode for this buffer automatically. |
| 2457 | Also sets up any specified local variables of the file. | 2458 | Also sets up any specified local variables of the file or its directory. |
| 2458 | Uses the visited file name, the -*- line, and the local variables spec. | 2459 | Uses the visited file name, the -*- line, and the local variables spec. |
| 2459 | 2460 | ||
| 2460 | This function is called automatically from `find-file'. In that case, | 2461 | This function is called automatically from `find-file'. In that case, |
| @@ -3485,6 +3486,8 @@ DIR-NAME is the name of the associated directory. Otherwise it is nil." | |||
| 3485 | 3486 | ||
| 3486 | (defun hack-local-variables (&optional handle-mode) | 3487 | (defun hack-local-variables (&optional handle-mode) |
| 3487 | "Parse and put into effect this buffer's local variables spec. | 3488 | "Parse and put into effect this buffer's local variables spec. |
| 3489 | For buffers visitying files, also puts into effect directory-local | ||
| 3490 | variables. | ||
| 3488 | Uses `hack-local-variables-apply' to apply the variables. | 3491 | Uses `hack-local-variables-apply' to apply the variables. |
| 3489 | 3492 | ||
| 3490 | If HANDLE-MODE is nil, we apply all the specified local | 3493 | If HANDLE-MODE is nil, we apply all the specified local |