Merge from origin/emacs-30

2029104605 Correct some outdated docs for hack-local-variables
This commit is contained in:
Sean Whitton 2025-03-12 10:09:45 +08:00
commit 22db8a2c2a
2 changed files with 30 additions and 10 deletions

View file

@ -2015,14 +2015,21 @@ function does not look for the @samp{mode:} local variable in the
@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking
@code{enable-local-variables} into account (@pxref{Auto Major Mode}).
This function works by walking the alist stored in
@code{file-local-variables-alist} and applying each local variable in
turn. It calls @code{before-hack-local-variables-hook} and
This function also puts into effect directory-local variables as
specified in @file{.dir-locals.el}. If the buffer is not visiting any
file, then the directory-local variables that apply are those which
would be applicable to files in the @code{default-directory}
(@pxref{Directory Local Variables}).
This function works by walking the alists stored in
@code{file-local-variables-alist} and @code{dir-local-variables-alist}
and applying each local variable in turn. It calls
@code{before-hack-local-variables-hook} and
@code{hack-local-variables-hook} before and after applying the
variables, respectively. It only calls the before-hook if the alist
is non-@code{nil}; it always calls the other hook. This
function ignores a @samp{mode} element if it specifies the same major
mode as the buffer already has.
variables, respectively. It only calls the before-hook if
@code{file-local-variables-alist} is non-@code{nil}; it always calls the
other hook. This function ignores a @samp{mode} element if it specifies
the same major mode as the buffer already has.
If the optional argument @var{handle-mode} is @code{t}, then all this
function does is return a symbol specifying the major mode, if the
@ -2295,6 +2302,17 @@ modification times of the associated directory local variables file
updates this list.
@end defvar
@defvar dir-local-variables-alist
This buffer-local variable holds the alist of directory-local variable
settings. Each element of the alist is of the form @w{@code{(@var{var}
. @var{value})}}, where @var{var} is a symbol of the local variable and
@var{value} is its value (this is the same structure as that of
@code{file-local-variables-alist}, @pxref{File Local Variables}). When
Emacs visits a file, it collects all the directory-local variables into
this alist, and then the @code{hack-local-variables} function applies
them one by one (again, @pxref{File Local Variables}).
@end defvar
@defvar hack-dir-local-get-variables-functions
This special hook holds the functions that gather the directory-local
variables to use for a given buffer. By default it contains just the

View file

@ -4205,10 +4205,12 @@ DIR-NAME is the name of the associated directory. Otherwise it is nil."
(defun hack-local-variables (&optional handle-mode inhibit-locals)
"Parse and put into effect this buffer's local variables spec.
For buffers visiting files, also puts into effect directory-local
variables.
Also puts into effect directory-local variables.
For buffers not visiting files, apply the directory-local variables that
would be applicable to files in `default-directory'.
Uses `hack-local-variables-apply' to apply the variables.
Uses `hack-local-variables-apply' and `hack-dir-local-variables'
to apply the variables.
If `enable-local-variables' or `local-enable-local-variables' is
nil, or INHIBIT-LOCALS is non-nil, this function disregards all