Finish making it fit Emacs conventions. Add autoloads.
[bpt/emacs.git] / src / buffer.c
index 1b0b5ee..d4c60f9 100644 (file)
@@ -364,14 +364,17 @@ The value is never nil.")
   BUF_OVERLAY_MODIFF (b) = 1;
   BUF_SAVE_MODIFF (b) = 1;
   BUF_INTERVALS (b) = 0;
+  BUF_UNCHANGED_MODIFIED (b) = 1;
+  BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
+  BUF_END_UNCHANGED (b) = 0;
+  BUF_BEG_UNCHANGED (b) = 0;
   *(BUF_GPT_ADDR (b)) = *(BUF_Z_ADDR (b)) = 0; /* Put an anchor '\0'.  */
 
   b->newline_cache = 0;
   b->width_run_cache = 0;
   b->width_table = Qnil;
-#if !NO_PROMPT_IN_BUFFER
   b->minibuffer_prompt_length = Qnil;
-#endif
+  b->prevent_redisplay_optimizations_p = 1;
 
   /* Put this on the chain of all buffers including killed ones.  */
   b->next = all_buffers;
@@ -450,9 +453,7 @@ NAME should be a string which is not the name of an existing buffer.")
   b->newline_cache = 0;
   b->width_run_cache = 0;
   b->width_table = Qnil;
-#if !NO_PROMPT_IN_BUFFER
   b->minibuffer_prompt_length = Qnil;
-#endif
 
   /* Put this on the chain of all buffers including killed ones.  */
   b->next = all_buffers;
@@ -525,7 +526,8 @@ reset_buffer (b)
   XSETFASTINT (b->save_length, 0);
   b->last_window_start = 1;
   /* It is more conservative to start out "changed" than "unchanged".  */
-  b->clip_changed = 1;
+  b->clip_changed = 0;
+  b->prevent_redisplay_optimizations_p = 1;
   b->backed_up = Qnil;
   b->auto_save_modified = 0;
   b->auto_save_failure_time = -1;
@@ -1221,9 +1223,7 @@ with SIGHUP.")
       b->width_run_cache = 0;
     }
   b->width_table = Qnil;
-#if !NO_PROMPT_IN_BUFFER
   b->minibuffer_prompt_length = Qnil;
-#endif
   UNBLOCK_INPUT;
   b->undo_list = Qnil;
 
@@ -1430,22 +1430,21 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
   return buf;
 }
 \f
-/* Set the current buffer to B.  */
+/* Set the current buffer to B.
+
+   We previously set windows_or_buffers_changed here to invalidate
+   global unchanged information in beg_unchanged and end_unchanged.
+   This is no longer necessary because we now compute unchanged
+   information on a buffer-basis.  Every action affecting other
+   windows than the selected one requires a select_window at some
+   time, and that increments windows_or_buffers_changed.  */
 
 void
 set_buffer_internal (b)
      register struct buffer *b;
 {
-  register struct buffer *old_buf;
-  register Lisp_Object tail, valcontents;
-  Lisp_Object tem;
-
-  if (current_buffer == b)
-    return;
-
-  /* Otherwise, force-mode-line-update doesn't work as expected.  */
-  windows_or_buffers_changed = 1;
-  set_buffer_internal_1 (b);
+  if (current_buffer != b)
+    set_buffer_internal_1 (b);
 }
 
 /* Set the current buffer to B, and do not set windows_or_buffers_changed.
@@ -1749,7 +1748,7 @@ advance_to_char_boundary (byte_pos)
   c = FETCH_BYTE (byte_pos);
   if (! CHAR_HEAD_P (c))
     {
-      /* We should advance BYTE_POS only when C is a constituen of a
+      /* We should advance BYTE_POS only when C is a constituent of a
          multibyte sequence.  */
       DEC_POS (byte_pos);
       INC_POS (byte_pos);
@@ -3095,28 +3094,11 @@ modify_overlay (buf, start, end)
      we must do other windows.  */
   if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
     windows_or_buffers_changed = 1;
-  /* If it's not current, we can't use beg_unchanged, end_unchanged for it.  */
-  else if (buf != current_buffer)
-    windows_or_buffers_changed = 1;
   /* If multiple windows show this buffer, we must do other windows.  */
   else if (buffer_shared > 1)
     windows_or_buffers_changed = 1;
   else
-    {
-      if (unchanged_modified == MODIFF
-         && overlay_unchanged_modified == OVERLAY_MODIFF)
-       {
-         beg_unchanged = start - BEG;
-         end_unchanged = Z - end;
-       }
-      else
-       {
-         if (Z - end < end_unchanged)
-           end_unchanged = Z - end;
-         if (start - BEG < beg_unchanged)
-           beg_unchanged = start - BEG;
-       }
-    }
+    BUF_COMPUTE_UNCHANGED (buf, start, end);
 
   ++BUF_OVERLAY_MODIFF (buf);
 }
@@ -3868,7 +3850,7 @@ init_buffer_once ()
 
   /* real setup is done in loaddefs.el */
   buffer_defaults.mode_line_format = build_string ("%-");
-  buffer_defaults.top_line_format = Qnil;
+  buffer_defaults.header_line_format = Qnil;
   buffer_defaults.abbrev_mode = Qnil;
   buffer_defaults.overwrite_mode = Qnil;
   buffer_defaults.case_fold_search = Qt;
@@ -3967,7 +3949,7 @@ init_buffer_once ()
   XSETFASTINT (buffer_local_flags.indicate_empty_lines, 0x400000);
   XSETFASTINT (buffer_local_flags.scroll_up_aggressively, 0x800000);
   XSETFASTINT (buffer_local_flags.scroll_down_aggressively, 0x1000000);
-  XSETFASTINT (buffer_local_flags.top_line_format, 0x2000000);
+  XSETFASTINT (buffer_local_flags.header_line_format, 0x2000000);
   
   Vbuffer_alist = Qnil;
   current_buffer = 0;
@@ -4115,10 +4097,10 @@ syms_of_buffer ()
     "Default value of `mode-line-format' for buffers that don't override it.\n\
 This is the same as (default-value 'mode-line-format).");
 
-  DEFVAR_LISP_NOPRO ("default-top-line-format",
-                    &buffer_defaults.top_line_format,
-    "Default value of `top-line-format' for buffers that don't override it.\n\
-This is the same as (default-value 'top-line-format).");
+  DEFVAR_LISP_NOPRO ("default-header-line-format",
+                    &buffer_defaults.header_line_format,
+    "Default value of `header-line-format' for buffers that don't override it.\n\
+This is the same as (default-value 'header-line-format).");
 
   DEFVAR_LISP_NOPRO ("default-abbrev-mode",
              &buffer_defaults.abbrev_mode,
@@ -4205,7 +4187,8 @@ don't override it.  This is the same as (default-value\n\
 don't override it.  This is the same as (default-value\n\
 'scroll-down-aggressively).");
   
-  DEFVAR_PER_BUFFER ("top-line-format", &current_buffer->top_line_format, 
+  DEFVAR_PER_BUFFER ("header-line-format",
+                    &current_buffer->header_line_format, 
                     Qnil,
    "Analogous to `mode-line-format', but for a mode line displayed\n\
 at the top of windows.");