aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-01-06 18:53:41 +0800
committerChong Yidong2012-01-06 18:53:41 +0800
commit89bd9ccd5bf4c2553bb1403ba71f4ed51dbb09b5 (patch)
treeb2015490fad1c12f4b1504ae299f1f4bcb173ab3
parent8034735f6fac4719a402face6d31e97f6c067803 (diff)
downloademacs-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-RELEASE2
-rw-r--r--doc/emacs/ChangeLog10
-rw-r--r--doc/emacs/custom.texi245
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/variables.texi9
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/files.el6
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
135cal-xtra.texi 135cal-xtra.texi
136cmdargs.texi 136cmdargs.texi
137commands.texi cyd 137commands.texi cyd
138custom.texi 138custom.texi cyd
139dired.texi cyd 139dired.texi cyd
140dired-xtra.texi 140dired-xtra.texi
141display.texi cyd 141display.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 @@
12012-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
12012-01-06 Eli Zaretskii <eliz@gnu.org> 112012-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
1012file with Emacs. Visiting the file checks for local variable 1012file with Emacs. Visiting the file checks for local variable
1013specifications; it automatically makes these variables local to the 1013specifications; it automatically makes these variables local to the
1014buffer, and sets them to the values specified in the file. 1014buffer, and sets them to the values specified in the file.
@@ -1031,21 +1031,20 @@ first line:
1031 1031
1032@noindent 1032@noindent
1033You can specify any number of variable/value pairs in this way, each 1033You can specify any number of variable/value pairs in this way, each
1034pair with a colon and semicolon as shown above. The special 1034pair with a colon and semicolon. The special variable/value pair
1035variable/value pair @code{mode: @var{modename};}, if present, 1035@code{mode: @var{modename};}, if present, specifies a major mode. The
1036specifies 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
1043instead of adding entries by hand. It prompts for a variable 1042command @kbd{M-x add-file-local-variable-prop-line}. This prompts for
1044and value, and adds them to the first line in the appropriate way. 1043a variable and value, and adds them to the first line in the
1045The command @code{delete-file-local-variable-prop-line} deletes a 1044appropriate way. @kbd{M-x delete-file-local-variable-prop-line}
1046variable from the line. The command 1045prompts 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 1046copy-dir-locals-to-file-locals-prop-line} copies directory-local
1048variables (@pxref{Directory Variables}) to the first line. 1047variables 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
1051variables with numeric values: 1050variables 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,
1070however). 1069however).
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
1073variables using a @dfn{local variables list} near the end of the file. 1072variables using a @dfn{local variables list} near the end of the file.
1074The start of the local variables list should be no more than 3000 1073The start of the local variables list should be no more than 3000
1075characters from the end of the file, and must be on the last page if 1074characters from the end of the file, and must be on the last page if
@@ -1088,10 +1087,10 @@ part of their initialization.
1088per line, like this: 1087per 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
1102the other lines of the list. The usual reason for using a prefix 1101the other lines of the list. The usual reason for using a prefix
1103and/or suffix is to embed the local variables list in a comment, so it 1102and/or suffix is to embed the local variables list in a comment, so it
1104won't confuse other programs that the file is intended for. The 1103won't confuse other programs that the file is intended for. The
1105example above is for the C programming language, where comment lines 1104example above is for the C programming language, where comments start
1106start with @samp{/*} and end with @samp{*/}. 1105with @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
1112command @code{add-file-local-variable}. This prompts for a variable 1111the command @kbd{M-x add-file-local-variable}. This prompts for a
1113and value, and adds them to the list. If necessary, it also adds the 1112variable and value, and adds them to the list, adding the @samp{Local
1114start and end markers. The command @code{delete-file-local-variable} 1113Variables:} string and start and end markers as necessary. The
1115deletes a variable from the list. The command 1114command @kbd{M-x delete-file-local-variable} deletes a variable from
1116@code{copy-dir-locals-to-file-locals} copies directory-local variables 1115the list. @kbd{M-x copy-dir-locals-to-file-locals} copies
1117(@pxref{Directory Variables}) to the list. 1116directory-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
1120are used literally, and are not evaluated first. If you want to split 1119are used literally, and are not evaluated first. If you want to split
1121a long string across multiple lines of the file, you can use 1120a long string value across multiple lines of the file, you can use
1122backslash-newline, which is ignored in Lisp string constants; you 1121backslash-newline, which is ignored in Lisp string constants; you
1123should put the prefix and suffix on each line, even lines that start 1122should put the prefix and suffix on each line, even lines that start
1124or end within the string, as they will be stripped off when processing 1123or 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
1155These four ``variables'' are not really variables; setting them in any 1154These four keywords are not really variables; setting them in any
1156other context has no special meaning. 1155other 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
1159well as the major modes; in fact, you can use it more than once, first 1158disable a minor mode in a local variables list, use the @code{eval}
1160to set the major mode and then to enable minor modes which are 1159keyword with a Lisp expression that runs the mode command
1161specific to particular buffers. Using @code{mode} for minor modes 1160(@pxref{Minor Modes}). For example, the following local variables
1162is deprecated, though---instead, use @code{eval: (minor-mode 1)}. 1161list 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 1163would do the same), and disables Font Lock mode (@pxref{Font Lock}) by
1165variables. Most minor modes, like Auto Fill mode, represent individual user 1164calling @code{font-lock-mode} with an argument of -1.
1166preferences. If you want to use a minor mode, it is better to set up 1165
1167major mode hooks with your init file to turn that minor mode on for 1166@example
1168yourself alone (@pxref{Init File}), instead of using a local variable 1167;; Local Variables:
1169list 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:
1172major mode of a buffer according to the file name and contents, 1171@end example
1172
1173@noindent
1174Note, however, that it is often a mistake to specify minor modes this
1175way. Minor modes represent individual user preferences, and it may be
1176inappropriate to impose your preferences on another user who might
1177edit the file. If you wish to automatically enable or disable a minor
1178mode in a situation-dependent way, it is often better to do it in a
1179major mode hook (@pxref{Hooks}).
1180
1181 Use the command @kbd{M-x normal-mode} to reset the local variables
1182and major mode of a buffer according to the file name and contents,
1173including the local variables list if any. @xref{Choosing Modes}. 1183including 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
1244Usually, the project's files are kept in one or more directories. 1254all the files in a certain directory and its subdirectories, such as
1245Occasionally, you may wish to define Emacs settings that are common to 1255the directory tree of a large software project. This can be
1246all the files that belong to the project. 1256accomplished with @dfn{directory-local variables}.
1247
1248 Emacs provides two ways to specify settings that are applicable to
1249files in a specific directory: you can put a special file in that
1250directory, 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
1254On MS-DOS, the name of this file should be @file{_dir-locals.el}, due 1260named @file{.dir-locals.el}@footnote{ On MS-DOS, the name of this file
1255to limitations of the DOS filesystems. If the filesystem is limited 1261should be @file{_dir-locals.el}, due to limitations of the DOS
1256to 8+3 file names, the name of the file will be truncated by the OS to 1262filesystems. If the filesystem is limited to 8+3 file names, the name
1257@file{_dir-loc.el}. 1263of 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 1264directory. Whenever Emacs visits any file in that directory or any of
1259directory or any of its subdirectories, and apply the settings it 1265its subdirectories, it will apply the directory-local variables
1260specifies to the file's buffer. Emacs searches for 1266specified 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, 1267file-local variables for that file (@pxref{File Variables}). Emacs
1262and moving up the directory tree. (To avoid slowdown, this search is 1268searches for @file{.dir-locals.el} starting in the directory of the
1263skipped for remote files.) 1269visited file, and moving up the directory tree. To avoid slowdown,
1270this 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
1266list. This list maps Emacs mode names (symbols) to alists; each alist 1273list, which maps major mode names (symbols) to alists
1267specifies values for variables to use when the respective mode is 1274(@pxref{Association Lists,,, elisp, The Emacs Lisp Reference Manual}).
1268turned on. The special mode name @samp{nil} means that its alist 1275Each alist entry consists of a variable name and the directory-local
1269applies to any mode. Instead of a mode name, you can specify a string 1276value to assign to that variable, when the specified major mode is
1270that is a name of a subdirectory of the project's directory; then the 1277enabled. Instead of a mode name, you can specify @samp{nil}, which
1271corresponding alist applies to all the files in that subdirectory. 1278means that the alist applies to any mode; or you can specify a
1279subdirectory name (a string), in which case the alist applies to all
1280files 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
1288This example shows some settings for a hypothetical project. It sets 1295This 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 1296in the directory tree, and the indentation style for any C source
1290any file in the project's directory tree, and it sets the indentation 1297file. The special @code{subdirs} element is not a variable, but a
1291style for any C or Java source file. The special @code{subdirs} element 1298special keyword which indicates that the C mode settings are only to
1292indicates that the Java mode settings are only to be applied in the 1299be applied in the current directory, not in any subdirectories.
1293current directory, not in any subdirectories. Finally, it specifies a 1300Finally, it specifies a different @file{ChangeLog} file name for any
1294different @file{ChangeLog} file name for any file in the @file{src/imported} 1301file in the @file{src/imported} subdirectory.
1295subdirectory of the directory where you put the @file{.dir-locals.el}
1296file.
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
1302command @code{add-dir-local-variable}. This prompts for a mode (or 1307use the command @kbd{M-x add-dir-local-variable}. This prompts for a
1303subdirectory), variable and value, and adds an entry to the file. 1308mode or subdirectory name, and for variable and value, and adds the
1304The command @code{delete-dir-local-variable} deletes an entry. The 1309entry defining the directory-local variable. @kbd{M-x
1305command @code{copy-file-locals-to-dir-locals} copies file local 1310delete-dir-local-variable} deletes an entry. @kbd{M-x
1306variables (@pxref{File Variables}) to the @file{.dir-locals.el} file. 1311copy-file-locals-to-dir-locals} copies the file-local variables in the
1312current 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
1311define a project class using @code{dir-locals-set-class-variables}, and 1317a group of variables/value pairs in a @dfn{directory class}, using the
1312then 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 1319directories correspond to the class by using the
1314in 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 1321normally go in your initialization file (@pxref{Init File}). This
1316to keep in a single place settings for several directories that don't 1322method is useful when you can't put @file{.dir-locals.el} in a
1317have a common parent. For example, you could apply settings to an 1323directory for some reason. For example, you could apply settings to
1318unwritable directory this way: 1324an 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
1329unsafe file-local variables (@pxref{Safe File Variables}). 1335specified, the file-local value takes effect. Unsafe directory-local
1336variables 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
1340do not visit a file directly but perform work within a directory, such
1341as 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
1993and execute it, or cancel. If you decide to enable the command, you 2005and execute it, or cancel. If you decide to enable the command, you
1994must then answer another question---whether to do this permanently, or 2006must then answer another question---whether to do this permanently, or
1995just for the current session. (Enabling permanently works by 2007just for the current session. (Enabling permanently works by
1996automatically editing your @file{.emacs} file.) You can also type 2008automatically 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
2018file directly, or with the command @kbd{M-x disable-command}, which edits 2030file directly, or with the command @kbd{M-x disable-command}, which
2019the @file{.emacs} file for you. Likewise, @kbd{M-x enable-command} 2031edits the initialization file for you. Likewise, @kbd{M-x
2020edits @file{.emacs} to enable a command permanently. @xref{Init File}. 2032enable-command} edits the initialization file to enable a command
2033permanently. @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}
2023options (@pxref{Initial Options}), it will not edit your 2036options (@pxref{Initial Options}), it will not edit your
2024@file{~/.emacs} init file. Doing so could lose information 2037initialization file. Doing so could lose information because Emacs
2025because Emacs has not read your init file. 2038has 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
2028invoke it; disabling also applies if the command is invoked using 2041invoke 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
2030as a function from Lisp programs. 2043as 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
2265Turn on Auto Fill mode automatically in Text mode and related modes. 2278Turn 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
2271This 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
2274constant rather than an expression.
2275
2276It's beyond the scope of this manual to explain Lisp functions, but
2277for this example it is enough to know that the effect is to execute
2278the @code{auto-fill-mode} function when Text mode is entered.
2279
2280@item 2285@item
2281Load the installed Lisp library named @file{foo} (actually a file 2286Load 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
2299Here an absolute file name is used, so no searching is done. 2304Here 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 @@
12012-01-06 Chong Yidong <cyd@gnu.org>
2
3 * variables.texi (Directory Local Variables): Document
4 hack-dir-local-variables-non-file-buffer.
5
12012-01-06 Glenn Morris <rgm@gnu.org> 62012-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
1833This function looks for directory-local variables, and immediately
1834applies them in the current buffer. It is intended to be called in
1835the mode commands for non-file buffers, such as Dired buffers, to let
1836them obey directory-local variable settings. For non-file buffers,
1837Emacs looks for directory-local variables in @code{default-directory}
1838and 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
1833This function defines a set of variable settings for the named 1842This 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
diff --git a/etc/NEWS b/etc/NEWS
index a37456fbc25..0b0e5e571aa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -363,7 +363,7 @@ the remote file-name cache is used for read access.
363Add an element (subdirs . nil) to the alist portion of any variables 363Add an element (subdirs . nil) to the alist portion of any variables
364settings to indicate that the section should not apply to 364settings to indicate that the section should not apply to
365subdirectories. 365subdirectories.
366 366+++
367*** Directory local variables can apply to some file-less buffers. 367*** Directory local variables can apply to some file-less buffers.
368Affected modes include dired, vc-dir, and log-edit. For example, 368Affected modes include dired, vc-dir, and log-edit. For example,
369adding "(diff-mode . ((mode . whitespace)))" to .dir-locals.el will 369adding "(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 @@
12012-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
12012-01-06 Eli Zaretskii <eliz@gnu.org> 72012-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.
3581For non-file buffers, such as Dired buffers, directory-local
3582variables are looked for in `default-directory' and its parent
3583directories."
3580 (hack-dir-local-variables) 3584 (hack-dir-local-variables)
3581 (hack-local-variables-apply)) 3585 (hack-local-variables-apply))
3582 3586