@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
\f
* 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.
}
\f
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
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. */
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);
}
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);