Add an optional parameter to kill-all-local-variables
* doc/lispref/variables.texi (Creating Buffer-Local): Document it (bug#30204). * src/buffer.c (Fkill_all_local_variables): Allow killing permanent local variables, too. * src/print.c (temp_output_buffer_setup): * src/minibuf.c (set_minibuffer_mode): Adjust callers.
This commit is contained in:
parent
ff31741b85
commit
c0f7396588
5 changed files with 21 additions and 12 deletions
|
@ -1695,12 +1695,14 @@ buffer-local variables interactively.
|
|||
@end deffn
|
||||
|
||||
@cindex local variables, killed by major mode
|
||||
@defun kill-all-local-variables
|
||||
@defun kill-all-local-variables &optional kill-permanent
|
||||
This function eliminates all the buffer-local variable bindings of the
|
||||
current buffer except for variables marked as permanent and local
|
||||
hook functions that have a non-@code{nil} @code{permanent-local-hook}
|
||||
property (@pxref{Setting Hooks}). As a result, the buffer will see
|
||||
the default values of most variables.
|
||||
current buffer. As a result, the buffer will see the default values
|
||||
of most variables. By default, for variables marked as permanent and
|
||||
local hook functions that have a non-@code{nil}
|
||||
@code{permanent-local-hook} property (@pxref{Setting Hooks}) won't be
|
||||
killed, but if the optional @var{kill-permanent} argument is
|
||||
non-@code{nil}, even these variables will be killed.
|
||||
|
||||
This function also resets certain other information pertaining to the
|
||||
buffer: it sets the local keymap to @code{nil}, the syntax table to the
|
||||
|
|
5
etc/NEWS
5
etc/NEWS
|
@ -125,6 +125,11 @@ with recent versions of Firefox.
|
|||
|
||||
* Lisp Changes in Emacs 29.1
|
||||
|
||||
+++
|
||||
** 'kill-all-local-variables' can now kill all local variables.
|
||||
If given the new optional KILL-PERMANENT argument, also kill permanent
|
||||
local variables.
|
||||
|
||||
+++
|
||||
** Third 'mapconcat' argument 'separator' is now optional.
|
||||
An explicit nil always meant the empty string, now it can be left out.
|
||||
|
|
12
src/buffer.c
12
src/buffer.c
|
@ -2805,7 +2805,7 @@ current buffer is cleared. */)
|
|||
}
|
||||
|
||||
DEFUN ("kill-all-local-variables", Fkill_all_local_variables,
|
||||
Skill_all_local_variables, 0, 0, 0,
|
||||
Skill_all_local_variables, 0, 1, 0,
|
||||
doc: /* Switch to Fundamental mode by killing current buffer's local variables.
|
||||
Most local variable bindings are eliminated so that the default values
|
||||
become effective once more. Also, the syntax table is set from
|
||||
|
@ -2816,18 +2816,20 @@ This function also forces redisplay of the mode line.
|
|||
Every function to select a new major mode starts by
|
||||
calling this function.
|
||||
|
||||
As a special exception, local variables whose names have
|
||||
a non-nil `permanent-local' property are not eliminated by this function.
|
||||
As a special exception, local variables whose names have a non-nil
|
||||
`permanent-local' property are not eliminated by this function. If
|
||||
the optional KILL-PERMANENT argument is non-nil, clear out these local
|
||||
variables, too.
|
||||
|
||||
The first thing this function does is run
|
||||
the normal hook `change-major-mode-hook'. */)
|
||||
(void)
|
||||
(Lisp_Object kill_permanent)
|
||||
{
|
||||
run_hook (Qchange_major_mode_hook);
|
||||
|
||||
/* Actually eliminate all local bindings of this buffer. */
|
||||
|
||||
reset_buffer_local_variables (current_buffer, 0);
|
||||
reset_buffer_local_variables (current_buffer, !NILP (kill_permanent));
|
||||
|
||||
/* Force mode-line redisplay. Useful here because all major mode
|
||||
commands call this function. */
|
||||
|
|
|
@ -1005,7 +1005,7 @@ set_minibuffer_mode (Lisp_Object buf, EMACS_INT depth)
|
|||
if (!NILP (Ffboundp (Qminibuffer_inactive_mode)))
|
||||
call0 (Qminibuffer_inactive_mode);
|
||||
else
|
||||
Fkill_all_local_variables ();
|
||||
Fkill_all_local_variables (Qnil);
|
||||
}
|
||||
buf = unbind_to (count, buf);
|
||||
}
|
||||
|
|
|
@ -564,7 +564,7 @@ temp_output_buffer_setup (const char *bufname)
|
|||
|
||||
Fset_buffer (Fget_buffer_create (build_string (bufname), Qnil));
|
||||
|
||||
Fkill_all_local_variables ();
|
||||
Fkill_all_local_variables (Qnil);
|
||||
delete_all_overlays (current_buffer);
|
||||
bset_directory (current_buffer, BVAR (old, directory));
|
||||
bset_read_only (current_buffer, Qnil);
|
||||
|
|
Loading…
Add table
Reference in a new issue