aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-03-12 10:09:45 +0800
committerSean Whitton2025-03-12 10:09:45 +0800
commit22db8a2c2aacc3c6e774c0338af3863ed668d087 (patch)
tree489779413e41aa5a522471c9e2fdd6ab3f923bd9
parentaa545fea2d10ac61c0628a5dee9a0953f4b21c58 (diff)
parent202910460538401ec585e9be80c05adb55279573 (diff)
downloademacs-22db8a2c2aacc3c6e774c0338af3863ed668d087.tar.gz
emacs-22db8a2c2aacc3c6e774c0338af3863ed668d087.zip
Merge from origin/emacs-30
20291046053 Correct some outdated docs for hack-local-variables
-rw-r--r--doc/lispref/variables.texi32
-rw-r--r--lisp/files.el8
2 files changed, 30 insertions, 10 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index f8a361aa7ce..39f3095bb9c 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -2015,14 +2015,21 @@ function does not look for the @samp{mode:} local variable in the
2015@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking 2015@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking
2016@code{enable-local-variables} into account (@pxref{Auto Major Mode}). 2016@code{enable-local-variables} into account (@pxref{Auto Major Mode}).
2017 2017
2018This function works by walking the alist stored in 2018This function also puts into effect directory-local variables as
2019@code{file-local-variables-alist} and applying each local variable in 2019specified in @file{.dir-locals.el}. If the buffer is not visiting any
2020turn. It calls @code{before-hack-local-variables-hook} and 2020file, then the directory-local variables that apply are those which
2021would be applicable to files in the @code{default-directory}
2022(@pxref{Directory Local Variables}).
2023
2024This function works by walking the alists stored in
2025@code{file-local-variables-alist} and @code{dir-local-variables-alist}
2026and applying each local variable in turn. It calls
2027@code{before-hack-local-variables-hook} and
2021@code{hack-local-variables-hook} before and after applying the 2028@code{hack-local-variables-hook} before and after applying the
2022variables, respectively. It only calls the before-hook if the alist 2029variables, respectively. It only calls the before-hook if
2023is non-@code{nil}; it always calls the other hook. This 2030@code{file-local-variables-alist} is non-@code{nil}; it always calls the
2024function ignores a @samp{mode} element if it specifies the same major 2031other hook. This function ignores a @samp{mode} element if it specifies
2025mode as the buffer already has. 2032the same major mode as the buffer already has.
2026 2033
2027If the optional argument @var{handle-mode} is @code{t}, then all this 2034If the optional argument @var{handle-mode} is @code{t}, then all this
2028function does is return a symbol specifying the major mode, if the 2035function does is return a symbol specifying the major mode, if the
@@ -2295,6 +2302,17 @@ modification times of the associated directory local variables file
2295updates this list. 2302updates this list.
2296@end defvar 2303@end defvar
2297 2304
2305@defvar dir-local-variables-alist
2306This buffer-local variable holds the alist of directory-local variable
2307settings. Each element of the alist is of the form @w{@code{(@var{var}
2308. @var{value})}}, where @var{var} is a symbol of the local variable and
2309@var{value} is its value (this is the same structure as that of
2310@code{file-local-variables-alist}, @pxref{File Local Variables}). When
2311Emacs visits a file, it collects all the directory-local variables into
2312this alist, and then the @code{hack-local-variables} function applies
2313them one by one (again, @pxref{File Local Variables}).
2314@end defvar
2315
2298@defvar hack-dir-local-get-variables-functions 2316@defvar hack-dir-local-get-variables-functions
2299This special hook holds the functions that gather the directory-local 2317This special hook holds the functions that gather the directory-local
2300variables to use for a given buffer. By default it contains just the 2318variables to use for a given buffer. By default it contains just the
diff --git a/lisp/files.el b/lisp/files.el
index cc1efdf836c..6ae4d764f63 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4205,10 +4205,12 @@ DIR-NAME is the name of the associated directory. Otherwise it is nil."
4205 4205
4206(defun hack-local-variables (&optional handle-mode inhibit-locals) 4206(defun hack-local-variables (&optional handle-mode inhibit-locals)
4207 "Parse and put into effect this buffer's local variables spec. 4207 "Parse and put into effect this buffer's local variables spec.
4208For buffers visiting files, also puts into effect directory-local 4208Also puts into effect directory-local variables.
4209variables. 4209For buffers not visiting files, apply the directory-local variables that
4210would be applicable to files in `default-directory'.
4210 4211
4211Uses `hack-local-variables-apply' to apply the variables. 4212Uses `hack-local-variables-apply' and `hack-dir-local-variables'
4213to apply the variables.
4212 4214
4213If `enable-local-variables' or `local-enable-local-variables' is 4215If `enable-local-variables' or `local-enable-local-variables' is
4214nil, or INHIBIT-LOCALS is non-nil, this function disregards all 4216nil, or INHIBIT-LOCALS is non-nil, this function disregards all