diff options
| author | Chong Yidong | 2012-01-06 18:53:41 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-01-06 18:53:41 +0800 |
| commit | 89bd9ccd5bf4c2553bb1403ba71f4ed51dbb09b5 (patch) | |
| tree | b2015490fad1c12f4b1504ae299f1f4bcb173ab3 | |
| parent | 8034735f6fac4719a402face6d31e97f6c067803 (diff) | |
| download | emacs-89bd9ccd5bf4c2553bb1403ba71f4ed51dbb09b5.tar.gz emacs-89bd9ccd5bf4c2553bb1403ba71f4ed51dbb09b5.zip | |
More customization-related documentation updates.
* doc/emacs/custom.texi (Specifying File Variables): The mode: keyword
doesn't have to be first anymore. Add example of specifying minor
modes.
(Directory Variables): Simplify example. Mention application to
non-file buffers.
(Disabling): Use "initialization file" terminology.
(Init Examples): Fix hook example.
* doc/lispref/variables.texi (Directory Local Variables): Document
hack-dir-local-variables-non-file-buffer.
* lisp/files.el (hack-dir-local-variables-non-file-buffer): Add doc.
(hack-one-local-variable-eval-safep): Allow 0 arg for minor mode
functions, along with 1 and -1.
| -rw-r--r-- | admin/FOR-RELEASE | 2 | ||||
| -rw-r--r-- | doc/emacs/ChangeLog | 10 | ||||
| -rw-r--r-- | doc/emacs/custom.texi | 245 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/variables.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 6 |
8 files changed, 162 insertions, 123 deletions
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE index 337425530f0..a08f5e76b0e 100644 --- a/admin/FOR-RELEASE +++ b/admin/FOR-RELEASE | |||
| @@ -135,7 +135,7 @@ calendar.texi | |||
| 135 | cal-xtra.texi | 135 | cal-xtra.texi |
| 136 | cmdargs.texi | 136 | cmdargs.texi |
| 137 | commands.texi cyd | 137 | commands.texi cyd |
| 138 | custom.texi | 138 | custom.texi cyd |
| 139 | dired.texi cyd | 139 | dired.texi cyd |
| 140 | dired-xtra.texi | 140 | dired-xtra.texi |
| 141 | display.texi cyd | 141 | display.texi cyd |
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index eef7c79b819..cecde83bb72 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-01-06 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * custom.texi (Specifying File Variables): The mode: keyword | ||
| 4 | doesn't have to be first anymore. Add example of specifying minor | ||
| 5 | modes. | ||
| 6 | (Directory Variables): Simplify example. Mention application to | ||
| 7 | non-file buffers. | ||
| 8 | (Disabling): Use "initialization file" terminology. | ||
| 9 | (Init Examples): Fix hook example. | ||
| 10 | |||
| 1 | 2012-01-06 Eli Zaretskii <eliz@gnu.org> | 11 | 2012-01-06 Eli Zaretskii <eliz@gnu.org> |
| 2 | 12 | ||
| 3 | * cmdargs.texi (MS-Windows Registry): Shorten the index entry. | 13 | * cmdargs.texi (MS-Windows Registry): Shorten the index entry. |
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 57fdeefec7e..69e74ffd50c 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -30,7 +30,7 @@ Reference Manual}. | |||
| 30 | * Key Bindings:: The keymaps say what command each key runs. | 30 | * Key Bindings:: The keymaps say what command each key runs. |
| 31 | By changing them, you can "redefine keys". | 31 | By changing them, you can "redefine keys". |
| 32 | * Init File:: How to write common customizations in the | 32 | * Init File:: How to write common customizations in the |
| 33 | @file{.emacs} file. | 33 | initialization file. |
| 34 | @end menu | 34 | @end menu |
| 35 | 35 | ||
| 36 | @node Easy Customization | 36 | @node Easy Customization |
| @@ -1008,7 +1008,7 @@ explicitly. For example, here's how to obtain the default value of | |||
| 1008 | @cindex local variables in files | 1008 | @cindex local variables in files |
| 1009 | @cindex file local variables | 1009 | @cindex file local variables |
| 1010 | 1010 | ||
| 1011 | A file can specify local variable values for use when you edit the | 1011 | A file can specify local variable values to use when editing the |
| 1012 | file with Emacs. Visiting the file checks for local variable | 1012 | file with Emacs. Visiting the file checks for local variable |
| 1013 | specifications; it automatically makes these variables local to the | 1013 | specifications; it automatically makes these variables local to the |
| 1014 | buffer, and sets them to the values specified in the file. | 1014 | buffer, and sets them to the values specified in the file. |
| @@ -1031,21 +1031,20 @@ first line: | |||
| 1031 | 1031 | ||
| 1032 | @noindent | 1032 | @noindent |
| 1033 | You can specify any number of variable/value pairs in this way, each | 1033 | You can specify any number of variable/value pairs in this way, each |
| 1034 | pair with a colon and semicolon as shown above. The special | 1034 | pair with a colon and semicolon. The special variable/value pair |
| 1035 | variable/value pair @code{mode: @var{modename};}, if present, | 1035 | @code{mode: @var{modename};}, if present, specifies a major mode. The |
| 1036 | specifies a major mode, and should come first in the line. The | ||
| 1037 | @var{value}s are used literally, and not evaluated. | 1036 | @var{value}s are used literally, and not evaluated. |
| 1038 | 1037 | ||
| 1039 | @findex add-file-local-variable-prop-line | 1038 | @findex add-file-local-variable-prop-line |
| 1040 | @findex delete-file-local-variable-prop-line | 1039 | @findex delete-file-local-variable-prop-line |
| 1041 | @findex copy-dir-locals-to-file-locals-prop-line | 1040 | @findex copy-dir-locals-to-file-locals-prop-line |
| 1042 | You can use the command @code{add-file-local-variable-prop-line} | 1041 | Instead of adding variable/value pairs by hand, you can use the |
| 1043 | instead of adding entries by hand. It prompts for a variable | 1042 | command @kbd{M-x add-file-local-variable-prop-line}. This prompts for |
| 1044 | and value, and adds them to the first line in the appropriate way. | 1043 | a variable and value, and adds them to the first line in the |
| 1045 | The command @code{delete-file-local-variable-prop-line} deletes a | 1044 | appropriate way. @kbd{M-x delete-file-local-variable-prop-line} |
| 1046 | variable from the line. The command | 1045 | prompts for a variable, and deletes its entry from the line. @kbd{M-x |
| 1047 | @code{copy-dir-locals-to-file-locals-prop-line} copies directory-local | 1046 | copy-dir-locals-to-file-locals-prop-line} copies directory-local |
| 1048 | variables (@pxref{Directory Variables}) to the first line. | 1047 | variables to the first line (@pxref{Directory Variables}). |
| 1049 | 1048 | ||
| 1050 | Here is an example first line that specifies Lisp mode and sets two | 1049 | Here is an example first line that specifies Lisp mode and sets two |
| 1051 | variables with numeric values: | 1050 | variables with numeric values: |
| @@ -1069,7 +1068,7 @@ same is true for man pages which start with the magic string | |||
| 1069 | @samp{'\"} to specify a list of troff preprocessors (not all do, | 1068 | @samp{'\"} to specify a list of troff preprocessors (not all do, |
| 1070 | however). | 1069 | however). |
| 1071 | 1070 | ||
| 1072 | Instead of using a @samp{-*-} line, you can define file local | 1071 | Apart from using a @samp{-*-} line, you can define file local |
| 1073 | variables using a @dfn{local variables list} near the end of the file. | 1072 | variables using a @dfn{local variables list} near the end of the file. |
| 1074 | The start of the local variables list should be no more than 3000 | 1073 | The start of the local variables list should be no more than 3000 |
| 1075 | characters from the end of the file, and must be on the last page if | 1074 | characters from the end of the file, and must be on the last page if |
| @@ -1088,10 +1087,10 @@ part of their initialization. | |||
| 1088 | per line, like this: | 1087 | per line, like this: |
| 1089 | 1088 | ||
| 1090 | @example | 1089 | @example |
| 1091 | /* Local Variables: */ | 1090 | /* Local Variables: */ |
| 1092 | /* mode:c */ | 1091 | /* mode: c */ |
| 1093 | /* comment-column:0 */ | 1092 | /* comment-column: 0 */ |
| 1094 | /* End: */ | 1093 | /* End: */ |
| 1095 | @end example | 1094 | @end example |
| 1096 | 1095 | ||
| 1097 | @noindent | 1096 | @noindent |
| @@ -1102,23 +1101,23 @@ the first line of the list; it then automatically discards them from | |||
| 1102 | the other lines of the list. The usual reason for using a prefix | 1101 | the other lines of the list. The usual reason for using a prefix |
| 1103 | and/or suffix is to embed the local variables list in a comment, so it | 1102 | and/or suffix is to embed the local variables list in a comment, so it |
| 1104 | won't confuse other programs that the file is intended for. The | 1103 | won't confuse other programs that the file is intended for. The |
| 1105 | example above is for the C programming language, where comment lines | 1104 | example above is for the C programming language, where comments start |
| 1106 | start with @samp{/*} and end with @samp{*/}. | 1105 | with @samp{/*} and end with @samp{*/}. |
| 1107 | 1106 | ||
| 1108 | @findex add-file-local-variable | 1107 | @findex add-file-local-variable |
| 1109 | @findex delete-file-local-variable | 1108 | @findex delete-file-local-variable |
| 1110 | @findex copy-dir-locals-to-file-locals | 1109 | @findex copy-dir-locals-to-file-locals |
| 1111 | You can construct the local variables list yourself, or use the | 1110 | Instead of typing in the local variables list directly, you can use |
| 1112 | command @code{add-file-local-variable}. This prompts for a variable | 1111 | the command @kbd{M-x add-file-local-variable}. This prompts for a |
| 1113 | and value, and adds them to the list. If necessary, it also adds the | 1112 | variable and value, and adds them to the list, adding the @samp{Local |
| 1114 | start and end markers. The command @code{delete-file-local-variable} | 1113 | Variables:} string and start and end markers as necessary. The |
| 1115 | deletes a variable from the list. The command | 1114 | command @kbd{M-x delete-file-local-variable} deletes a variable from |
| 1116 | @code{copy-dir-locals-to-file-locals} copies directory-local variables | 1115 | the list. @kbd{M-x copy-dir-locals-to-file-locals} copies |
| 1117 | (@pxref{Directory Variables}) to the list. | 1116 | directory-local variables to the list (@pxref{Directory Variables}). |
| 1118 | 1117 | ||
| 1119 | As with the @samp{-*-} line, the variables in a local variables list | 1118 | As with the @samp{-*-} line, the variables in a local variables list |
| 1120 | are used literally, and are not evaluated first. If you want to split | 1119 | are used literally, and are not evaluated first. If you want to split |
| 1121 | a long string across multiple lines of the file, you can use | 1120 | a long string value across multiple lines of the file, you can use |
| 1122 | backslash-newline, which is ignored in Lisp string constants; you | 1121 | backslash-newline, which is ignored in Lisp string constants; you |
| 1123 | should put the prefix and suffix on each line, even lines that start | 1122 | should put the prefix and suffix on each line, even lines that start |
| 1124 | or end within the string, as they will be stripped off when processing | 1123 | or end within the string, as they will be stripped off when processing |
| @@ -1152,24 +1151,35 @@ value is @code{t}. @xref{Enabling Multibyte}. | |||
| 1152 | @end itemize | 1151 | @end itemize |
| 1153 | 1152 | ||
| 1154 | @noindent | 1153 | @noindent |
| 1155 | These four ``variables'' are not really variables; setting them in any | 1154 | These four keywords are not really variables; setting them in any |
| 1156 | other context has no special meaning. | 1155 | other context has no special meaning. |
| 1157 | 1156 | ||
| 1158 | You can use the @code{mode} ``variable'' to enable minor modes as | 1157 | Do not use the @code{mode} keyword for minor modes. To enable or |
| 1159 | well as the major modes; in fact, you can use it more than once, first | 1158 | disable a minor mode in a local variables list, use the @code{eval} |
| 1160 | to set the major mode and then to enable minor modes which are | 1159 | keyword with a Lisp expression that runs the mode command |
| 1161 | specific to particular buffers. Using @code{mode} for minor modes | 1160 | (@pxref{Minor Modes}). For example, the following local variables |
| 1162 | is deprecated, though---instead, use @code{eval: (minor-mode 1)}. | 1161 | list enables Eldoc mode (@pxref{Lisp Doc}) by calling |
| 1163 | 1162 | @code{eldoc-mode} with no argument (calling it with an argument of 1 | |
| 1164 | Often, however, it is a mistake to enable minor modes in file local | 1163 | would do the same), and disables Font Lock mode (@pxref{Font Lock}) by |
| 1165 | variables. Most minor modes, like Auto Fill mode, represent individual user | 1164 | calling @code{font-lock-mode} with an argument of -1. |
| 1166 | preferences. If you want to use a minor mode, it is better to set up | 1165 | |
| 1167 | major mode hooks with your init file to turn that minor mode on for | 1166 | @example |
| 1168 | yourself alone (@pxref{Init File}), instead of using a local variable | 1167 | ;; Local Variables: |
| 1169 | list to impose your taste on everyone. | 1168 | ;; eval: (eldoc-mode) |
| 1170 | 1169 | ;; eval: (font-lock-mode -1) | |
| 1171 | Use the command @code{normal-mode} to reset the local variables and | 1170 | ;; End: |
| 1172 | major mode of a buffer according to the file name and contents, | 1171 | @end example |
| 1172 | |||
| 1173 | @noindent | ||
| 1174 | Note, however, that it is often a mistake to specify minor modes this | ||
| 1175 | way. Minor modes represent individual user preferences, and it may be | ||
| 1176 | inappropriate to impose your preferences on another user who might | ||
| 1177 | edit the file. If you wish to automatically enable or disable a minor | ||
| 1178 | mode in a situation-dependent way, it is often better to do it in a | ||
| 1179 | major mode hook (@pxref{Hooks}). | ||
| 1180 | |||
| 1181 | Use the command @kbd{M-x normal-mode} to reset the local variables | ||
| 1182 | and major mode of a buffer according to the file name and contents, | ||
| 1173 | including the local variables list if any. @xref{Choosing Modes}. | 1183 | including the local variables list if any. @xref{Choosing Modes}. |
| 1174 | 1184 | ||
| 1175 | @node Safe File Variables | 1185 | @node Safe File Variables |
| @@ -1237,85 +1247,81 @@ confirmation about processing @code{eval} variables. | |||
| 1237 | @node Directory Variables | 1247 | @node Directory Variables |
| 1238 | @subsection Per-Directory Local Variables | 1248 | @subsection Per-Directory Local Variables |
| 1239 | @cindex local variables, for all files in a directory | 1249 | @cindex local variables, for all files in a directory |
| 1240 | @cindex directory local variables | 1250 | @cindex directory-local variables |
| 1241 | @cindex per-directory local variables | 1251 | @cindex per-directory local variables |
| 1242 | 1252 | ||
| 1243 | A @dfn{project} is a collection of files on which you work together. | 1253 | Sometimes, you may wish to define the same set of local variables to |
| 1244 | Usually, the project's files are kept in one or more directories. | 1254 | all the files in a certain directory and its subdirectories, such as |
| 1245 | Occasionally, you may wish to define Emacs settings that are common to | 1255 | the directory tree of a large software project. This can be |
| 1246 | all the files that belong to the project. | 1256 | accomplished with @dfn{directory-local variables}. |
| 1247 | |||
| 1248 | Emacs provides two ways to specify settings that are applicable to | ||
| 1249 | files in a specific directory: you can put a special file in that | ||
| 1250 | directory, or you can define a @dfn{project class} for that directory. | ||
| 1251 | 1257 | ||
| 1252 | @cindex @file{.dir-locals.el} file | 1258 | @cindex @file{.dir-locals.el} file |
| 1253 | If you put a file with a special name @file{.dir-locals.el}@footnote{ | 1259 | The usual way to define directory-local variables is to put a file |
| 1254 | On MS-DOS, the name of this file should be @file{_dir-locals.el}, due | 1260 | named @file{.dir-locals.el}@footnote{ On MS-DOS, the name of this file |
| 1255 | to limitations of the DOS filesystems. If the filesystem is limited | 1261 | should be @file{_dir-locals.el}, due to limitations of the DOS |
| 1256 | to 8+3 file names, the name of the file will be truncated by the OS to | 1262 | filesystems. If the filesystem is limited to 8+3 file names, the name |
| 1257 | @file{_dir-loc.el}. | 1263 | of the file will be truncated by the OS to @file{_dir-loc.el}. } in a |
| 1258 | } in a directory, Emacs will read it when it visits any file in that | 1264 | directory. Whenever Emacs visits any file in that directory or any of |
| 1259 | directory or any of its subdirectories, and apply the settings it | 1265 | its subdirectories, it will apply the directory-local variables |
| 1260 | specifies to the file's buffer. Emacs searches for | 1266 | specified in @file{.dir-locals.el}, as though they had been defined as |
| 1261 | @file{.dir-locals.el} starting in the directory of the visited file, | 1267 | file-local variables for that file (@pxref{File Variables}). Emacs |
| 1262 | and moving up the directory tree. (To avoid slowdown, this search is | 1268 | searches for @file{.dir-locals.el} starting in the directory of the |
| 1263 | skipped for remote files.) | 1269 | visited file, and moving up the directory tree. To avoid slowdown, |
| 1270 | this search is skipped for remote files. | ||
| 1264 | 1271 | ||
| 1265 | The @file{.dir-locals.el} file should hold a specially-constructed | 1272 | The @file{.dir-locals.el} file should hold a specially-constructed |
| 1266 | list. This list maps Emacs mode names (symbols) to alists; each alist | 1273 | list, which maps major mode names (symbols) to alists |
| 1267 | specifies values for variables to use when the respective mode is | 1274 | (@pxref{Association Lists,,, elisp, The Emacs Lisp Reference Manual}). |
| 1268 | turned on. The special mode name @samp{nil} means that its alist | 1275 | Each alist entry consists of a variable name and the directory-local |
| 1269 | applies to any mode. Instead of a mode name, you can specify a string | 1276 | value to assign to that variable, when the specified major mode is |
| 1270 | that is a name of a subdirectory of the project's directory; then the | 1277 | enabled. Instead of a mode name, you can specify @samp{nil}, which |
| 1271 | corresponding alist applies to all the files in that subdirectory. | 1278 | means that the alist applies to any mode; or you can specify a |
| 1279 | subdirectory name (a string), in which case the alist applies to all | ||
| 1280 | files in that subdirectory. | ||
| 1272 | 1281 | ||
| 1273 | Here's an example of a @file{.dir-locals.el} file: | 1282 | Here's an example of a @file{.dir-locals.el} file: |
| 1274 | 1283 | ||
| 1275 | @example | 1284 | @example |
| 1276 | ((nil . ((indent-tabs-mode . t) | 1285 | ((nil . ((indent-tabs-mode . t) |
| 1277 | (tab-width . 4) | ||
| 1278 | (fill-column . 80))) | 1286 | (fill-column . 80))) |
| 1279 | (c-mode . ((c-file-style . "BSD"))) | 1287 | (c-mode . ((c-file-style . "BSD"))) |
| 1280 | (java-mode . ((c-file-style . "BSD") | 1288 | (subdirs . nil))) |
| 1281 | (subdirs . nil))) | ||
| 1282 | ("src/imported" | 1289 | ("src/imported" |
| 1283 | . ((nil . ((change-log-default-name . | 1290 | . ((nil . ((change-log-default-name |
| 1284 | "ChangeLog.local")))))) | 1291 | . "ChangeLog.local")))))) |
| 1285 | @end example | 1292 | @end example |
| 1286 | 1293 | ||
| 1287 | @noindent | 1294 | @noindent |
| 1288 | This example shows some settings for a hypothetical project. It sets | 1295 | This sets @samp{indent-tabs-mode} and @code{fill-column} for any file |
| 1289 | @samp{indent-tabs-mode}, @code{tab-width}, and @code{fill-column} for | 1296 | in the directory tree, and the indentation style for any C source |
| 1290 | any file in the project's directory tree, and it sets the indentation | 1297 | file. The special @code{subdirs} element is not a variable, but a |
| 1291 | style for any C or Java source file. The special @code{subdirs} element | 1298 | special keyword which indicates that the C mode settings are only to |
| 1292 | indicates that the Java mode settings are only to be applied in the | 1299 | be applied in the current directory, not in any subdirectories. |
| 1293 | current directory, not in any subdirectories. Finally, it specifies a | 1300 | Finally, it specifies a different @file{ChangeLog} file name for any |
| 1294 | different @file{ChangeLog} file name for any file in the @file{src/imported} | 1301 | file in the @file{src/imported} subdirectory. |
| 1295 | subdirectory of the directory where you put the @file{.dir-locals.el} | ||
| 1296 | file. | ||
| 1297 | 1302 | ||
| 1298 | @findex add-dir-local-variable | 1303 | @findex add-dir-local-variable |
| 1299 | @findex delete-dir-local-variable | 1304 | @findex delete-dir-local-variable |
| 1300 | @findex copy-file-locals-to-dir-locals | 1305 | @findex copy-file-locals-to-dir-locals |
| 1301 | You can edit the @file{.dir-locals.el} file by hand, or use the | 1306 | Instead of editing the @file{.dir-locals.el} file by hand, you can |
| 1302 | command @code{add-dir-local-variable}. This prompts for a mode (or | 1307 | use the command @kbd{M-x add-dir-local-variable}. This prompts for a |
| 1303 | subdirectory), variable and value, and adds an entry to the file. | 1308 | mode or subdirectory name, and for variable and value, and adds the |
| 1304 | The command @code{delete-dir-local-variable} deletes an entry. The | 1309 | entry defining the directory-local variable. @kbd{M-x |
| 1305 | command @code{copy-file-locals-to-dir-locals} copies file local | 1310 | delete-dir-local-variable} deletes an entry. @kbd{M-x |
| 1306 | variables (@pxref{File Variables}) to the @file{.dir-locals.el} file. | 1311 | copy-file-locals-to-dir-locals} copies the file-local variables in the |
| 1312 | current file into @file{.dir-locals.el}. | ||
| 1307 | 1313 | ||
| 1308 | @findex dir-locals-set-class-variables | 1314 | @findex dir-locals-set-class-variables |
| 1309 | @findex dir-locals-set-directory-class | 1315 | @findex dir-locals-set-directory-class |
| 1310 | Another method of specifying directory-local variables is to explicitly | 1316 | Another method of specifying directory-local variables is to define |
| 1311 | define a project class using @code{dir-locals-set-class-variables}, and | 1317 | a group of variables/value pairs in a @dfn{directory class}, using the |
| 1312 | then tell Emacs which directories correspond to that class, using | 1318 | @code{dir-locals-set-class-variables} function; then, tell Emacs which |
| 1313 | @code{dir-locals-set-directory-class}. You can put calls to these functions | 1319 | directories correspond to the class by using the |
| 1314 | in your @file{~/.emacs} init file; this can be useful when you can't put | 1320 | @code{dir-locals-set-directory-class} function. These function calls |
| 1315 | @file{.dir-locals.el} in the directory for some reason, or if you want | 1321 | normally go in your initialization file (@pxref{Init File}). This |
| 1316 | to keep in a single place settings for several directories that don't | 1322 | method is useful when you can't put @file{.dir-locals.el} in a |
| 1317 | have a common parent. For example, you could apply settings to an | 1323 | directory for some reason. For example, you could apply settings to |
| 1318 | unwritable directory this way: | 1324 | an unwritable directory this way: |
| 1319 | 1325 | ||
| 1320 | @example | 1326 | @example |
| 1321 | (dir-locals-set-class-variables 'unwritable-directory | 1327 | (dir-locals-set-class-variables 'unwritable-directory |
| @@ -1325,8 +1331,14 @@ unwritable directory this way: | |||
| 1325 | "/usr/include/" 'unwritable-directory) | 1331 | "/usr/include/" 'unwritable-directory) |
| 1326 | @end example | 1332 | @end example |
| 1327 | 1333 | ||
| 1328 | Unsafe directory-local variables are handled in the same way as | 1334 | If a variable has both a directory-local and file-local value |
| 1329 | unsafe file-local variables (@pxref{Safe File Variables}). | 1335 | specified, the file-local value takes effect. Unsafe directory-local |
| 1336 | variables are handled in the same way as unsafe file-local variables | ||
| 1337 | (@pxref{Safe File Variables}). | ||
| 1338 | |||
| 1339 | Directory-local variables also take effect in certain buffers that | ||
| 1340 | do not visit a file directly but perform work within a directory, such | ||
| 1341 | as Dired buffers (@pxref{Dired}). | ||
| 1330 | 1342 | ||
| 1331 | @node Key Bindings | 1343 | @node Key Bindings |
| 1332 | @section Customizing Key Bindings | 1344 | @section Customizing Key Bindings |
| @@ -1343,7 +1355,7 @@ init file (@pxref{Init Rebinding}). | |||
| 1343 | * Local Keymaps:: Major and minor modes have their own keymaps. | 1355 | * Local Keymaps:: Major and minor modes have their own keymaps. |
| 1344 | * Minibuffer Maps:: The minibuffer uses its own local keymaps. | 1356 | * Minibuffer Maps:: The minibuffer uses its own local keymaps. |
| 1345 | * Rebinding:: How to redefine one key's meaning conveniently. | 1357 | * Rebinding:: How to redefine one key's meaning conveniently. |
| 1346 | * Init Rebinding:: Rebinding keys with your init file, @file{.emacs}. | 1358 | * Init Rebinding:: Rebinding keys with your initialization file. |
| 1347 | * Modifier Keys:: Using modifier keys in key bindings. | 1359 | * Modifier Keys:: Using modifier keys in key bindings. |
| 1348 | * Function Keys:: Rebinding terminal function keys. | 1360 | * Function Keys:: Rebinding terminal function keys. |
| 1349 | * Named ASCII Chars:: Distinguishing @key{TAB} from @kbd{C-i}, and so on. | 1361 | * Named ASCII Chars:: Distinguishing @key{TAB} from @kbd{C-i}, and so on. |
| @@ -1993,7 +2005,7 @@ input saying whether to execute the command as requested, enable it | |||
| 1993 | and execute it, or cancel. If you decide to enable the command, you | 2005 | and execute it, or cancel. If you decide to enable the command, you |
| 1994 | must then answer another question---whether to do this permanently, or | 2006 | must then answer another question---whether to do this permanently, or |
| 1995 | just for the current session. (Enabling permanently works by | 2007 | just for the current session. (Enabling permanently works by |
| 1996 | automatically editing your @file{.emacs} file.) You can also type | 2008 | automatically editing your initialization file.) You can also type |
| 1997 | @kbd{!} to enable @emph{all} commands, for the current session only. | 2009 | @kbd{!} to enable @emph{all} commands, for the current session only. |
| 1998 | 2010 | ||
| 1999 | The direct mechanism for disabling a command is to put a | 2011 | The direct mechanism for disabling a command is to put a |
| @@ -2014,15 +2026,16 @@ is included in the message displayed when the command is used: | |||
| 2014 | 2026 | ||
| 2015 | @findex disable-command | 2027 | @findex disable-command |
| 2016 | @findex enable-command | 2028 | @findex enable-command |
| 2017 | You can make a command disabled either by editing the @file{.emacs} | 2029 | You can make a command disabled either by editing the initialization |
| 2018 | file directly, or with the command @kbd{M-x disable-command}, which edits | 2030 | file directly, or with the command @kbd{M-x disable-command}, which |
| 2019 | the @file{.emacs} file for you. Likewise, @kbd{M-x enable-command} | 2031 | edits the initialization file for you. Likewise, @kbd{M-x |
| 2020 | edits @file{.emacs} to enable a command permanently. @xref{Init File}. | 2032 | enable-command} edits the initialization file to enable a command |
| 2033 | permanently. @xref{Init File}. | ||
| 2021 | 2034 | ||
| 2022 | If Emacs was invoked with the @option{-q} or @option{--no-init-file} | 2035 | If Emacs was invoked with the @option{-q} or @option{--no-init-file} |
| 2023 | options (@pxref{Initial Options}), it will not edit your | 2036 | options (@pxref{Initial Options}), it will not edit your |
| 2024 | @file{~/.emacs} init file. Doing so could lose information | 2037 | initialization file. Doing so could lose information because Emacs |
| 2025 | because Emacs has not read your init file. | 2038 | has not read your initialization file. |
| 2026 | 2039 | ||
| 2027 | Whether a command is disabled is independent of what key is used to | 2040 | Whether a command is disabled is independent of what key is used to |
| 2028 | invoke it; disabling also applies if the command is invoked using | 2041 | invoke it; disabling also applies if the command is invoked using |
| @@ -2030,7 +2043,7 @@ invoke it; disabling also applies if the command is invoked using | |||
| 2030 | as a function from Lisp programs. | 2043 | as a function from Lisp programs. |
| 2031 | 2044 | ||
| 2032 | @node Init File | 2045 | @node Init File |
| 2033 | @section The Init File, @file{~/.emacs} | 2046 | @section The Emacs Initialization File |
| 2034 | @cindex init file | 2047 | @cindex init file |
| 2035 | @cindex .emacs file | 2048 | @cindex .emacs file |
| 2036 | @cindex ~/.emacs file | 2049 | @cindex ~/.emacs file |
| @@ -2262,21 +2275,13 @@ Turn off Line Number mode, a global minor mode. | |||
| 2262 | 2275 | ||
| 2263 | @need 1500 | 2276 | @need 1500 |
| 2264 | @item | 2277 | @item |
| 2265 | Turn on Auto Fill mode automatically in Text mode and related modes. | 2278 | Turn on Auto Fill mode automatically in Text mode and related modes |
| 2279 | (@pxref{Hooks}). | ||
| 2266 | 2280 | ||
| 2267 | @example | 2281 | @example |
| 2268 | (add-hook 'text-mode-hook 'auto-fill-mode) | 2282 | (add-hook 'text-mode-hook 'auto-fill-mode) |
| 2269 | @end example | 2283 | @end example |
| 2270 | 2284 | ||
| 2271 | This shows how to add a hook function to a normal hook variable | ||
| 2272 | (@pxref{Hooks}). The function we supply is a list starting with | ||
| 2273 | @code{lambda}, with a single-quote in front of it to make it a list | ||
| 2274 | constant rather than an expression. | ||
| 2275 | |||
| 2276 | It's beyond the scope of this manual to explain Lisp functions, but | ||
| 2277 | for this example it is enough to know that the effect is to execute | ||
| 2278 | the @code{auto-fill-mode} function when Text mode is entered. | ||
| 2279 | |||
| 2280 | @item | 2285 | @item |
| 2281 | Load the installed Lisp library named @file{foo} (actually a file | 2286 | Load the installed Lisp library named @file{foo} (actually a file |
| 2282 | @file{foo.elc} or @file{foo.el} in a standard Emacs directory). | 2287 | @file{foo.elc} or @file{foo.el} in a standard Emacs directory). |
| @@ -2296,7 +2301,7 @@ Load the compiled Lisp file @file{foo.elc} from your home directory. | |||
| 2296 | (load "~/foo.elc") | 2301 | (load "~/foo.elc") |
| 2297 | @end example | 2302 | @end example |
| 2298 | 2303 | ||
| 2299 | Here an absolute file name is used, so no searching is done. | 2304 | Here a full file name is used, so no searching is done. |
| 2300 | 2305 | ||
| 2301 | @item | 2306 | @item |
| 2302 | @cindex loading Lisp libraries automatically | 2307 | @cindex loading Lisp libraries automatically |
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 883eaf13356..1365e016cca 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-01-06 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * variables.texi (Directory Local Variables): Document | ||
| 4 | hack-dir-local-variables-non-file-buffer. | ||
| 5 | |||
| 1 | 2012-01-06 Glenn Morris <rgm@gnu.org> | 6 | 2012-01-06 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * maps.texi (Standard Keymaps): Refer to Info-edit by name | 8 | * maps.texi (Standard Keymaps): Refer to Info-edit by name |
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 243da9f373d..5bc9c1157e2 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi | |||
| @@ -1829,6 +1829,15 @@ function works by calling @code{dir-locals-set-class-variables} and | |||
| 1829 | @code{dir-locals-set-directory-class}, described below. | 1829 | @code{dir-locals-set-directory-class}, described below. |
| 1830 | @end defun | 1830 | @end defun |
| 1831 | 1831 | ||
| 1832 | @defun hack-dir-local-variables-non-file-buffer | ||
| 1833 | This function looks for directory-local variables, and immediately | ||
| 1834 | applies them in the current buffer. It is intended to be called in | ||
| 1835 | the mode commands for non-file buffers, such as Dired buffers, to let | ||
| 1836 | them obey directory-local variable settings. For non-file buffers, | ||
| 1837 | Emacs looks for directory-local variables in @code{default-directory} | ||
| 1838 | and its parent directories. | ||
| 1839 | @end defun | ||
| 1840 | |||
| 1832 | @defun dir-locals-set-class-variables class variables | 1841 | @defun dir-locals-set-class-variables class variables |
| 1833 | This function defines a set of variable settings for the named | 1842 | This function defines a set of variable settings for the named |
| 1834 | @var{class}, which is a symbol. You can later assign the class to one | 1843 | @var{class}, which is a symbol. You can later assign the class to one |
| @@ -363,7 +363,7 @@ the remote file-name cache is used for read access. | |||
| 363 | Add an element (subdirs . nil) to the alist portion of any variables | 363 | Add an element (subdirs . nil) to the alist portion of any variables |
| 364 | settings to indicate that the section should not apply to | 364 | settings to indicate that the section should not apply to |
| 365 | subdirectories. | 365 | subdirectories. |
| 366 | 366 | +++ | |
| 367 | *** Directory local variables can apply to some file-less buffers. | 367 | *** Directory local variables can apply to some file-less buffers. |
| 368 | Affected modes include dired, vc-dir, and log-edit. For example, | 368 | Affected modes include dired, vc-dir, and log-edit. For example, |
| 369 | adding "(diff-mode . ((mode . whitespace)))" to .dir-locals.el will | 369 | adding "(diff-mode . ((mode . whitespace)))" to .dir-locals.el will |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 39007b7e0d4..ec3eacfbc38 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-01-06 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * files.el (hack-dir-local-variables-non-file-buffer): Add doc. | ||
| 4 | (hack-one-local-variable-eval-safep): Allow 0 arg for minor mode | ||
| 5 | functions, along with 1 and -1. | ||
| 6 | |||
| 1 | 2012-01-06 Eli Zaretskii <eliz@gnu.org> | 7 | 2012-01-06 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * time.el (display-time-load-average) | 9 | * time.el (display-time-load-average) |
diff --git a/lisp/files.el b/lisp/files.el index 588fda43f5c..d4b06146090 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3294,7 +3294,7 @@ It is dangerous if either of these conditions are met: | |||
| 3294 | (and (symbolp (car exp)) | 3294 | (and (symbolp (car exp)) |
| 3295 | ;; Allow (minor)-modes calls with no arguments. | 3295 | ;; Allow (minor)-modes calls with no arguments. |
| 3296 | ;; This obsoletes the use of "mode:" for such things. (Bug#8613) | 3296 | ;; This obsoletes the use of "mode:" for such things. (Bug#8613) |
| 3297 | (or (and (member (cdr exp) '(nil (1) (-1))) | 3297 | (or (and (member (cdr exp) '(nil (1) (0) (-1))) |
| 3298 | (string-match "-mode\\'" (symbol-name (car exp)))) | 3298 | (string-match "-mode\\'" (symbol-name (car exp)))) |
| 3299 | (let ((prop (get (car exp) 'safe-local-eval-function))) | 3299 | (let ((prop (get (car exp) 'safe-local-eval-function))) |
| 3300 | (cond ((eq prop t) | 3300 | (cond ((eq prop t) |
| @@ -3577,6 +3577,10 @@ and `file-local-variables-alist', without applying them." | |||
| 3577 | (hack-local-variables-filter variables dir-name))))))) | 3577 | (hack-local-variables-filter variables dir-name))))))) |
| 3578 | 3578 | ||
| 3579 | (defun hack-dir-local-variables-non-file-buffer () | 3579 | (defun hack-dir-local-variables-non-file-buffer () |
| 3580 | "Apply directory-local variables to a non-file buffer. | ||
| 3581 | For non-file buffers, such as Dired buffers, directory-local | ||
| 3582 | variables are looked for in `default-directory' and its parent | ||
| 3583 | directories." | ||
| 3580 | (hack-dir-local-variables) | 3584 | (hack-dir-local-variables) |
| 3581 | (hack-local-variables-apply)) | 3585 | (hack-local-variables-apply)) |
| 3582 | 3586 | ||