summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 321bc88ed2c..f8a7a4f5109 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -912,6 +912,10 @@ does not run the hooks `kill-buffer-hook',
Fset (intern ("buffer-save-without-query"), Qnil);
Fset (intern ("buffer-file-number"), Qnil);
Fset (intern ("buffer-stale-function"), Qnil);
+ /* Cloned buffers need extra setup, to do things such as deep
+ variable copies for list variables that might be mangled due
+ to destructive operations in the indirect buffer. */
+ run_hook (Qclone_indirect_buffer_hook);
set_buffer_internal_1 (old_b);
}
@@ -1155,11 +1159,9 @@ is first appended to NAME, to speed up finding a non-existent buffer. */)
else
{
char number[sizeof "-999999"];
-
- /* Use XFIXNUM instead of XFIXNAT to work around GCC bug 80776. */
- int i = XFIXNUM (Frandom (make_fixnum (1000000)));
- eassume (0 <= i && i < 1000000);
-
+ EMACS_INT r = get_random ();
+ eassume (0 <= r);
+ int i = r % 1000000;
AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d", i));
genbase = concat2 (name, lnumber);
if (NILP (Fget_buffer (genbase)))
@@ -1247,7 +1249,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
{ /* Look in local_var_alist. */
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
XSETSYMBOL (variable, sym); /* Update In case of aliasing. */
- result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil);
+ result = assq_no_quit (variable, BVAR (buf, local_var_alist));
if (!NILP (result))
{
if (blv->fwd.fwdptr)
@@ -1552,7 +1554,7 @@ This does not change the name of the visited file (if any). */)
/* Catch redisplay's attention. Unless we do this, the mode lines for
any windows displaying current_buffer will stay unchanged. */
- update_mode_lines = 11;
+ bset_update_mode_line (current_buffer);
XSETBUFFER (buf, current_buffer);
Fsetcar (Frassq (buf, Vbuffer_alist), newname);
@@ -1562,6 +1564,9 @@ This does not change the name of the visited file (if any). */)
run_buffer_list_update_hook (current_buffer);
+ call2 (intern ("uniquify--rename-buffer-advice"),
+ BVAR (current_buffer, name), unique);
+
/* Refetch since that last call may have done GC. */
return BVAR (current_buffer, name);
}
@@ -1767,7 +1772,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
/* Run hooks with the buffer to be killed as the current buffer. */
{
- ptrdiff_t count = SPECPDL_INDEX ();
+ specpdl_ref count = SPECPDL_INDEX ();
bool modified;
record_unwind_protect_excursion ();
@@ -2090,7 +2095,6 @@ Use this function before selecting the buffer, since it may need to inspect
the current buffer's major mode. */)
(Lisp_Object buffer)
{
- ptrdiff_t count;
Lisp_Object function;
CHECK_BUFFER (buffer);
@@ -2113,7 +2117,7 @@ the current buffer's major mode. */)
`hack-local-variables' get run. */
return Qnil;
- count = SPECPDL_INDEX ();
+ specpdl_ref count = SPECPDL_INDEX ();
/* To select a nonfundamental mode,
select the buffer temporarily and then call the mode function. */
@@ -2805,7 +2809,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 +2820,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. */
@@ -4026,7 +4032,7 @@ buffer. */)
{
struct buffer *b, *ob = 0;
Lisp_Object obuffer;
- ptrdiff_t count = SPECPDL_INDEX ();
+ specpdl_ref count = SPECPDL_INDEX ();
ptrdiff_t n_beg, n_end;
ptrdiff_t o_beg UNINIT, o_end UNINIT;
@@ -4147,7 +4153,7 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
{
Lisp_Object buffer;
struct buffer *b;
- ptrdiff_t count = SPECPDL_INDEX ();
+ specpdl_ref count = SPECPDL_INDEX ();
CHECK_OVERLAY (overlay);
@@ -5564,6 +5570,8 @@ syms_of_buffer (void)
Fput (Qprotected_field, Qerror_message,
build_pure_c_string ("Attempt to modify a protected field"));
+ DEFSYM (Qclone_indirect_buffer_hook, "clone-indirect-buffer-hook");
+
DEFVAR_PER_BUFFER ("tab-line-format",
&BVAR (current_buffer, tab_line_format),
Qnil,
@@ -6387,6 +6395,13 @@ If `delete-auto-save-files' is nil, any autosave deletion is inhibited. */);
This is the default. If nil, auto-save file deletion is inhibited. */);
delete_auto_save_files = 1;
+ DEFVAR_LISP ("clone-indirect-buffer-hook", Vclone_indirect_buffer_hook,
+ doc: /* Normal hook to run in the new buffer at the end of `make-indirect-buffer'.
+
+Since `clone-indirect-buffer' calls `make-indirect-buffer', this hook
+will run for `clone-indirect-buffer' calls as well. */);
+ Vclone_indirect_buffer_hook = Qnil;
+
defsubr (&Sbuffer_live_p);
defsubr (&Sbuffer_list);
defsubr (&Sget_buffer);