Include keymap.h.
[bpt/emacs.git] / src / buffer.c
index a77600c..b5d1ab8 100644 (file)
@@ -49,6 +49,7 @@ extern int errno;
 #include "indent.h"
 #include "blockinput.h"
 #include "keyboard.h"
+#include "keymap.h"
 #include "frame.h"
 
 struct buffer *current_buffer;         /* the current buffer */
@@ -180,6 +181,7 @@ Lisp_Object Qinsert_behind_hooks;
 static void alloc_buffer_text P_ ((struct buffer *, size_t));
 static void free_buffer_text P_ ((struct buffer *b));
 static Lisp_Object copy_overlays P_ ((struct buffer *, Lisp_Object));
+static void modify_overlay P_ ((struct buffer *, int, int));
 
 
 /* For debugging; temporary.  See set_buffer_internal.  */
@@ -1682,7 +1684,7 @@ set_buffer_internal_1 (b)
 
   for (tail = b->local_var_alist; !NILP (tail); tail = XCDR (tail))
     {
-      valcontents = XSYMBOL (XCAR (XCAR (tail)))->value;
+      valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
       if ((BUFFER_LOCAL_VALUEP (valcontents)
           || SOME_BUFFER_LOCAL_VALUEP (valcontents))
          && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
@@ -1697,7 +1699,7 @@ set_buffer_internal_1 (b)
   if (old_buf)
     for (tail = old_buf->local_var_alist; !NILP (tail); tail = XCDR (tail))
       {
-       valcontents = XSYMBOL (XCAR (XCAR (tail)))->value;
+       valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
        if ((BUFFER_LOCAL_VALUEP (valcontents)
             || SOME_BUFFER_LOCAL_VALUEP (valcontents))
            && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
@@ -2259,26 +2261,26 @@ swap_out_buffer_local_variables (b)
       sym = XCAR (XCAR (alist));
 
       /* Need not do anything if some other buffer's binding is now encached.  */
-      tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer;
+      tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer;
       if (BUFFERP (tem) && XBUFFER (tem) == current_buffer)
        {
          /* Symbol is set up for this buffer's old local value.
             Set it up for the current buffer with the default value.  */
 
-         tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr;
+         tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->cdr;
          /* Store the symbol's current value into the alist entry
             it is currently set up for.  This is so that, if the
             local is marked permanent, and we make it local again
             later in Fkill_all_local_variables, we don't lose the value.  */
          XCDR (XCAR (tem))
-           = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue);
+           = do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue);
          /* Switch to the symbol's default-value alist entry.  */
          XCAR (tem) = tem;
          /* Mark it as current for buffer B.  */
-         XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer = buffer;
+         XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer;
          /* Store the current value into any forwarding in the symbol.  */
          store_symval_forwarding (sym,
-                                  XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue,
+                                  XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue,
                                   XCDR (tem), NULL);
        }
     }
@@ -3402,13 +3404,11 @@ modify_overlay (buf, start, end)
      struct buffer *buf;
      int start, end;
 {
-  if (start == end)
-    return;
-
   if (start > end)
     {
       int temp = start;
-      start = end; end = temp;
+      start = end;
+      end = temp;
     }
 
   BUF_COMPUTE_UNCHANGED (buf, start, end);
@@ -3547,19 +3547,25 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
     return Qnil;
 
   b = XBUFFER (buffer);
-
   specbind (Qinhibit_quit, Qt);
-
+  
   b->overlays_before = Fdelq (overlay, b->overlays_before);
-  b->overlays_after  = Fdelq (overlay, b->overlays_after);
-
+  b->overlays_after = Fdelq (overlay, b->overlays_after);
   modify_overlay (b,
                  marker_position (OVERLAY_START (overlay)),
                  marker_position (OVERLAY_END   (overlay)));
-
   Fset_marker (OVERLAY_START (overlay), Qnil, Qnil);
   Fset_marker (OVERLAY_END   (overlay), Qnil, Qnil);
 
+  /* When deleting an overlay with before or after strings, turn off
+     display optimizations for the affected buffer, on the basis that
+     these strings may contain newlines.  This is easier to do than to
+     check for that situation during redisplay.  */
+  if (!windows_or_buffers_changed
+      && (!NILP (Foverlay_get (overlay, Qbefore_string))
+         || !NILP (Foverlay_get (overlay, Qafter_string))))
+    b->prevent_redisplay_optimizations_p = 1;
+
   return unbind_to (count, Qnil);
 }
 \f
@@ -3833,8 +3839,8 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
     {
       if (changed)
        modify_overlay (XBUFFER (buffer),
-                         marker_position (OVERLAY_START (overlay)),
-                         marker_position (OVERLAY_END   (overlay)));
+                       marker_position (OVERLAY_START (overlay)),
+                       marker_position (OVERLAY_END   (overlay)));
       if (EQ (prop, Qevaporate) && ! NILP (value)
          && (OVERLAY_POSITION (OVERLAY_START (overlay))
              == OVERLAY_POSITION (OVERLAY_END (overlay))))
@@ -5238,7 +5244,8 @@ On other systems, this variable is normally always nil.");
   DEFVAR_PER_BUFFER ("default-directory", &current_buffer->directory,
                     make_number (Lisp_String),
     "Name of default directory of current buffer.  Should end with slash.\n\
-Each buffer has its own value of this variable.");
+Each buffer has its own value of this variable.  To change the\n\
+default directory, use function `cd'.");
 
   DEFVAR_PER_BUFFER ("auto-fill-function", &current_buffer->auto_fill_function,
                     Qnil,