use guile conses
[bpt/emacs.git] / src / insdel.c
index ea5f630..10c53e9 100644 (file)
@@ -1,6 +1,6 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs.
-   Copyright (C) 1985-1986, 1993-1995, 1997-2014 Free Software
-   Foundation, Inc.
+
+Copyright (C) 1985-1986, 1993-1995, 1997-2014 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -701,7 +701,7 @@ count_combining_after (const unsigned char *string,
        (2) POS is the last of the current buffer.
        (3) A character at POS can't be a following byte of multibyte
            character.  */
-  if (length > 0 && ASCII_BYTE_P (string[length - 1])) /* case (1) */
+  if (length > 0 && ASCII_CHAR_P (string[length - 1])) /* case (1) */
     return 0;
   if (pos_byte == Z_BYTE)      /* case (2) */
     return 0;
@@ -1804,26 +1804,18 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
   else
     base_buffer = current_buffer;
 
-#ifdef CLASH_DETECTION
+  if (inhibit_modification_hooks)
+    return;
+
   if (!NILP (BVAR (base_buffer, file_truename))
       /* Make binding buffer-file-name to nil effective.  */
       && !NILP (BVAR (base_buffer, filename))
       && SAVE_MODIFF >= MODIFF)
     lock_file (BVAR (base_buffer, file_truename));
-#else
-  /* At least warn if this file has changed on disk since it was visited.  */
-  if (!NILP (BVAR (base_buffer, filename))
-      && SAVE_MODIFF >= MODIFF
-      && NILP (Fverify_visited_file_modtime (Fcurrent_buffer ()))
-      && !NILP (Ffile_exists_p (BVAR (base_buffer, filename))))
-    call1 (intern ("ask-user-about-supersession-threat"),
-          BVAR (base_buffer,filename));
-#endif /* not CLASH_DETECTION */
 
   /* If `select-active-regions' is non-nil, save the region text.  */
   /* FIXME: Move this to Elisp (via before-change-functions).  */
   if (!NILP (BVAR (current_buffer, mark_active))
-      && !inhibit_modification_hooks
       && XMARKER (BVAR (current_buffer, mark))->buffer
       && NILP (Vsaved_region_selection)
       && (EQ (Vselect_active_regions, Qonly)
@@ -1857,14 +1849,9 @@ invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
      need to consider the caches of their base buffer.  */
   if (buf->base_buffer)
     buf = buf->base_buffer;
-  if (buf->newline_cache)
-    invalidate_region_cache (buf,
-                             buf->newline_cache,
-                             start - BUF_BEG (buf), BUF_Z (buf) - end);
-  if (buf->width_run_cache)
-    invalidate_region_cache (buf,
-                             buf->width_run_cache,
-                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  /* The bidi_paragraph_cache must be invalidated first, because doing
+     so might need to use the newline_cache (via find_newline_no_quit,
+     see below).  */
   if (buf->bidi_paragraph_cache)
     {
       if (start != end
@@ -1888,13 +1875,20 @@ invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
                                               &start_byte);
              set_buffer_internal (old);
            }
-         if (line_beg > BUF_BEG (buf))
-           start = line_beg - 1;
+         start = line_beg - (line_beg > BUF_BEG (buf));
        }
       invalidate_region_cache (buf,
                               buf->bidi_paragraph_cache,
                               start - BUF_BEG (buf), BUF_Z (buf) - end);
     }
+  if (buf->newline_cache)
+    invalidate_region_cache (buf,
+                             buf->newline_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  if (buf->width_run_cache)
+    invalidate_region_cache (buf,
+                             buf->width_run_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
 }
 
 /* These macros work with an argument named `preserve_ptr'
@@ -1960,9 +1954,6 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
   ptrdiff_t count = SPECPDL_INDEX ();
   struct rvoe_arg rvoe_arg;
 
-  if (inhibit_modification_hooks)
-    return;
-
   start = make_number (start_int);
   end = make_number (end_int);
   preserve_marker = Qnil;
@@ -1973,7 +1964,7 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
   specbind (Qinhibit_modification_hooks, Qt);
 
   /* If buffer is unmodified, run a special hook for that case.  The
-   check for Vfirst_change_hook is just a minor optimization. */
+   check for Vfirst_change_hook is just a minor optimization.  */
   if (SAVE_MODIFF >= MODIFF
       && !NILP (Vfirst_change_hook))
     {
@@ -2012,10 +2003,6 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
                                   FETCH_START, FETCH_END, Qnil);
     }
 
-  if (! NILP (start_marker))
-    free_marker (start_marker);
-  if (! NILP (end_marker))
-    free_marker (end_marker);
   RESTORE_VALUE;
   UNGCPRO;