(syms_of_buffer): Doc fixes for scroll-...-aggressively.
[bpt/emacs.git] / src / buffer.c
index 2207adc..49f8f34 100644 (file)
@@ -646,6 +646,8 @@ reset_buffer (b)
   b->enable_multibyte_characters = buffer_defaults.enable_multibyte_characters;
   b->cursor_type = buffer_defaults.cursor_type;
   b->extra_line_spacing = buffer_defaults.extra_line_spacing;
+
+  b->display_error_modiff = 0;
 }
 
 /* Reset buffer B's local variables info.
@@ -808,6 +810,58 @@ If BUFFER is not indirect, return nil.  */)
   return base_buffer;
 }
 
+DEFUN ("buffer-local-value", Fbuffer_local_value,
+       Sbuffer_local_value, 2, 2, 0, 
+       doc: /* Return the value of VARIABLE in BUFFER.
+If VARIABLE does not have a buffer-local binding in BUFFER, the value
+is the default binding of variable. */)
+     (symbol, buffer)
+     register Lisp_Object symbol;
+     register Lisp_Object buffer;
+{
+  register struct buffer *buf;
+  register Lisp_Object result;
+
+  CHECK_SYMBOL (symbol);
+  CHECK_BUFFER (buffer);
+  buf = XBUFFER (buffer);
+
+  /* Look in local_var_list */
+  result = Fassoc (symbol, buf->local_var_alist);
+  if (NILP (result)) 
+    {
+      int offset, idx;
+      int found = 0;
+
+      /* Look in special slots */
+      for (offset = PER_BUFFER_VAR_OFFSET (name);
+          offset < sizeof (struct buffer);
+          /* sizeof EMACS_INT == sizeof Lisp_Object */
+          offset += (sizeof (EMACS_INT)))
+       {
+         idx = PER_BUFFER_IDX (offset);
+         if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+             && SYMBOLP (PER_BUFFER_SYMBOL (offset)) 
+             && EQ (PER_BUFFER_SYMBOL (offset), symbol)) 
+           {
+             result = PER_BUFFER_VALUE (buf, offset);
+             found = 1;
+             break;
+           }
+       }
+
+      if (!found)
+       result = Fdefault_value (symbol);
+    }
+  else
+    result = XCDR (result);
+
+  if (EQ (result, Qunbound))
+    return Fsignal (Qvoid_variable, Fcons (symbol, Qnil));
+
+  return result;
+}
+
 DEFUN ("buffer-local-variables", Fbuffer_local_variables,
        Sbuffer_local_variables, 0, 1, 0,
        doc: /* Return an alist of variables that are buffer-local in BUFFER.
@@ -1240,8 +1294,7 @@ with SIGHUP.  */)
       }
 
     /* Then run the hooks.  */
-    if (!NILP (Vrun_hooks))
-      call1 (Vrun_hooks, Qkill_buffer_hook);
+    Frun_hooks (1, &Qkill_buffer_hook);
     unbind_to (count, Qnil);
   }
 
@@ -1315,10 +1368,12 @@ with SIGHUP.  */)
   frames_discard_buffer (buf);
   Vinhibit_quit = tem;
 
-  /* Delete any auto-save file, if we saved it in this session.  */
+  /* Delete any auto-save file, if we saved it in this session.
+     But not if the buffer is modified.  */
   if (STRINGP (b->auto_save_file_name)
       && b->auto_save_modified != 0
-      && BUF_SAVE_MODIFF (b) < b->auto_save_modified)
+      && BUF_SAVE_MODIFF (b) < b->auto_save_modified
+      && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
     {
       Lisp_Object tem;
       tem = Fsymbol_value (intern ("delete-auto-save-files"));
@@ -1846,12 +1901,14 @@ selected window if it is displayed there.  */)
       tem = Fwindow_buffer (selected_window);
       /* If we're burying the current buffer, unshow it.  */
       if (EQ (buffer, tem))
-       if (NILP (Fwindow_dedicated_p (selected_window)))
-         Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);
-       else if (NILP (XWINDOW (selected_window)->parent))
-         Ficonify_frame (Fwindow_frame (selected_window));
-       else
-         Fdelete_window (selected_window);
+       {
+         if (NILP (Fwindow_dedicated_p (selected_window)))
+           Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);
+         else if (NILP (XWINDOW (selected_window)->parent))
+           Ficonify_frame (Fwindow_frame (selected_window));
+         else
+           Fdelete_window (selected_window);
+       }
     }
   else
     {
@@ -2242,10 +2299,6 @@ the normal hook `change-major-mode-hook'.  */)
 
   reset_buffer_local_variables (current_buffer, 0);
 
-  /* Redisplay mode lines; we are changing major mode.  */
-
-  update_mode_lines++;
-
   /* Any which are supposed to be permanent,
      make local again, with the same values they had.  */
      
@@ -5104,21 +5157,22 @@ This is the same as (default-value 'indicate-empty-lines).  */);
   
   DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",
                     &buffer_defaults.scroll_up_aggressively,
-                    doc: /* Default value of `scroll-up-aggressively' for buffers that
-don't override it.  This is the same as (default-value
-'scroll-up-aggressively).  */);
+                    doc: /* Default value of `scroll-up-aggressively'.
+This value applies in buffers that don't have their own local values.
+This variable is an alias for (default-value 'scroll-up-aggressively).  */);
   
   DEFVAR_LISP_NOPRO ("default-scroll-down-aggressively",
                     &buffer_defaults.scroll_down_aggressively,
-                    doc: /* Default value of `scroll-down-aggressively' for buffers that
-don't override it.  This is the same as (default-value
-'scroll-down-aggressively).  */);
+                    doc: /* Default value of `scroll-down-aggressively'.
+This value applies in buffers that don't have their own local values.
+This variable is an alias for (default-value 'scroll-down-aggressively).  */);
   
   DEFVAR_PER_BUFFER ("header-line-format",
                     &current_buffer->header_line_format,
                     Qnil,
-                    doc: /* Analogous to `mode-line-format', but for the mode line that can be
-displayed at the top of a window.  */);
+                    doc: /* Analogous to `mode-line-format', but controls the header line.
+The header line appears, optionally, at the top of a window;
+the mode line appears at the bottom.  */);
   
   DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format,
                     Qnil,
@@ -5234,8 +5288,8 @@ This variable is never applied to a way of decoding a file while reading it.  */
                     doc: /* *Non-nil means lines in the buffer are displayed right to left.  */);
 
   DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil,
-                    doc: /* *Non-nil means do not display continuation lines;
-give each line of text one screen line.
+                    doc: /* *Non-nil means do not display continuation lines.
+Instead, give each line of text just one screen line.
 
 Note that this is overridden by the variable
 `truncate-partial-width-windows' if that variable is non-nil
@@ -5276,8 +5330,8 @@ and then abbreviated with `abbreviate-file-name'.  */);
   DEFVAR_PER_BUFFER ("buffer-auto-save-file-name",
                     &current_buffer->auto_save_file_name,
                     make_number (Lisp_String),
-                    doc: /* Name of file for auto-saving current buffer,
-or nil if buffer should not be auto-saved.  */);
+                    doc: /* Name of file for auto-saving current buffer.
+If it is nil, that means don't auto-save this buffer.  */);
 
   DEFVAR_PER_BUFFER ("buffer-read-only", &current_buffer->read_only, Qnil,
                     doc: /* Non-nil if this buffer is read-only.  */);
@@ -5293,11 +5347,12 @@ Backing up is done before the first time the file is saved.  */);
 
   DEFVAR_PER_BUFFER ("selective-display", &current_buffer->selective_display,
                     Qnil,
-                    doc: /* Non-nil enables selective display:
-Integer N as value means display only lines
- that start with less than n columns of space.
-A value of t means, after a ^M, all the rest of the line is invisible.
- Then ^M's in the file are written into files as newlines.  */);
+                    doc: /* Non-nil enables selective display.
+An Integer N as value means display only lines
+that start with less than n columns of space.
+A value of t means that the character ^M makes itself and
+all the rest of the line invisible; also, when saving the buffer
+in a file, save the ^M as a newline.  */);
 
 #ifndef old
   DEFVAR_PER_BUFFER ("selective-display-ellipses",
@@ -5371,16 +5426,16 @@ window-systems.  */);
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
                     &current_buffer->scroll_up_aggressively, Qnil,
                     doc: /* *If a number, scroll display up aggressively.
-If scrolling a window because point is above the window start, choose
+If scrolling a window because point is below the window end, choose
 a new window start so that point ends up that fraction of the window's
-height from the top of the window.  */);
+height from the bottom of the window.  */);
   
   DEFVAR_PER_BUFFER ("scroll-down-aggressively",
                     &current_buffer->scroll_down_aggressively, Qnil,
                     doc: /* *If a number, scroll display down aggressively.
-If scrolling a window because point is below the window end, choose
+If scrolling a window because point is above the window start, choose
 a new window start so that point ends up that fraction of the window's
-height from the bottom of the window.  */);
+height from the top of the window.  */);
   
 /*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,
     "Don't ask.");
@@ -5571,6 +5626,7 @@ The space is measured in pixels, and put below lines on window systems.  */);
 /*defsubr (&Sbuffer_number);*/
   defsubr (&Sbuffer_file_name);
   defsubr (&Sbuffer_base_buffer);
+  defsubr (&Sbuffer_local_value);
   defsubr (&Sbuffer_local_variables);
   defsubr (&Sbuffer_modified_p);
   defsubr (&Sset_buffer_modified_p);