]> code.delx.au - gnu-emacs/blobdiff - src/editfns.c
merge from trunk
[gnu-emacs] / src / editfns.c
index 6357a28e8ead16bc1aec8eda6adea6f84d4e2666..bbaeaea5240f8bca9787fe48d6ffb8594614ac33 100644 (file)
@@ -373,7 +373,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   else if (WINDOWP (object))
-    object = XWINDOW (object)->buffer;
+    object = XWINDOW (object)->contents;
 
   if (!BUFFERP (object))
     /* pos-property only makes sense in buffers right now, since strings
@@ -838,22 +838,21 @@ This function does not move point.  */)
 Lisp_Object
 save_excursion_save (void)
 {
-  return make_save_value
-    (SAVE_TYPE_OBJ_OBJ_OBJ_OBJ,
-     Fpoint_marker (),
+  return make_save_obj_obj_obj_obj
+    (Fpoint_marker (),
      /* Do not copy the mark if it points to nowhere.  */
      (XMARKER (BVAR (current_buffer, mark))->buffer
       ? Fcopy_marker (BVAR (current_buffer, mark), Qnil)
       : Qnil),
      /* Selected window if current buffer is shown in it, nil otherwise.  */
-     ((XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
+     (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ())
       ? selected_window : Qnil),
      BVAR (current_buffer, mark_active));
 }
 
 /* Restore saved buffer before leaving `save-excursion' special form.  */
 
-Lisp_Object
+void
 save_excursion_restore (Lisp_Object info)
 {
   Lisp_Object tem, tem1, omark, nmark;
@@ -915,7 +914,7 @@ save_excursion_restore (Lisp_Object info)
   tem = XSAVE_OBJECT (info, 2);
   if (WINDOWP (tem)
       && !EQ (tem, selected_window)
-      && (tem1 = XWINDOW (tem)->buffer,
+      && (tem1 = XWINDOW (tem)->contents,
          (/* Window is live...  */
           BUFFERP (tem1)
           /* ...and it shows the current buffer.  */
@@ -927,7 +926,6 @@ save_excursion_restore (Lisp_Object info)
  out:
 
   free_misc (info);
-  return Qnil;
 }
 
 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0,
@@ -1946,7 +1944,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)  */)
          EMACS_INT zone_hr = abszone / (60*60);
          int zone_min = (abszone/60) % 60;
          int zone_sec = abszone % 60;
-         sprintf (tzbuf, tzbuf_format, "-" + (XINT (zone) < 0),
+         sprintf (tzbuf, tzbuf_format, &"-"[XINT (zone) < 0],
                   zone_hr, zone_min, zone_sec);
          tzstring = tzbuf;
        }
@@ -2332,6 +2330,10 @@ to multibyte for insertion (see `unibyte-char-to-multibyte').
 If the current buffer is unibyte, multibyte strings are converted
 to unibyte for insertion.
 
+If an overlay begins at the insertion point, the inserted text falls
+outside the overlay; if a nonempty overlay ends at the insertion
+point, the inserted text falls inside that overlay.
+
 usage: (insert-before-markers &rest ARGS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
@@ -2809,18 +2811,16 @@ determines whether case is significant or ignored.  */)
   return make_number (0);
 }
 \f
-static Lisp_Object
+static void
 subst_char_in_region_unwind (Lisp_Object arg)
 {
   bset_undo_list (current_buffer, arg);
-  return arg;
 }
 
-static Lisp_Object
+static void
 subst_char_in_region_unwind_1 (Lisp_Object arg)
 {
   bset_filename (current_buffer, arg);
-  return arg;
 }
 
 DEFUN ("subst-char-in-region", Fsubst_char_in_region,
@@ -2932,7 +2932,7 @@ Both characters must have the same length of multi-byte form.  */)
          else if (!changed)
            {
              changed = -1;
-             modify_region_1 (pos, XINT (end), false);
+             modify_text (pos, XINT (end));
 
              if (! NILP (noundo))
                {
@@ -3108,7 +3108,7 @@ It returns the number of characters changed.  */)
   pos = XINT (start);
   pos_byte = CHAR_TO_BYTE (pos);
   end_pos = XINT (end);
-  modify_region_1 (pos, end_pos, false);
+  modify_text (pos, end_pos);
 
   cnt = 0;
   for (; pos < end_pos; )
@@ -3331,7 +3331,7 @@ save_restriction_save (void)
     }
 }
 
-Lisp_Object
+void
 save_restriction_restore (Lisp_Object data)
 {
   struct buffer *cur = NULL;
@@ -3398,8 +3398,6 @@ save_restriction_restore (Lisp_Object data)
 
   if (cur)
     set_buffer_internal (cur);
-
-  return Qnil;
 }
 
 DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0,
@@ -3492,7 +3490,7 @@ usage: (message-box FORMAT-STRING &rest ARGS)  */)
       {
        Lisp_Object pane, menu;
        struct gcpro gcpro1;
-       pane = Fcons (Fcons (build_string ("OK"), Qt), Qnil);
+       pane = list1 (Fcons (build_string ("OK"), Qt));
        GCPRO1 (pane);
        menu = Fcons (val, pane);
        Fx_popup_dialog (Qt, menu, Qt);
@@ -3627,7 +3625,7 @@ usage: (format STRING &rest OBJECTS)  */)
   ptrdiff_t bufsize = sizeof initial_buffer;
   ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
   char *p;
-  Lisp_Object buf_save_value IF_LINT (= {0});
+  ptrdiff_t buf_save_value_index IF_LINT (= 0);
   char *format, *end, *format_start;
   ptrdiff_t formatlen, nchars;
   /* True if the format is multibyte.  */
@@ -3958,7 +3956,7 @@ usage: (format STRING &rest OBJECTS)  */)
                   trailing "d").  */
                pMlen = sizeof pMd - 2
              };
-             verify (0 < USEFUL_PRECISION_MAX);
+             verify (USEFUL_PRECISION_MAX > 0);
 
              int prec;
              ptrdiff_t padding, sprintf_bytes;
@@ -4236,14 +4234,14 @@ usage: (format STRING &rest OBJECTS)  */)
          {
            buf = xmalloc (bufsize);
            sa_must_free = 1;
-           buf_save_value = make_save_pointer (buf);
-           record_unwind_protect (safe_alloca_unwind, buf_save_value);
+           buf_save_value_index = SPECPDL_INDEX ();
+           record_unwind_protect_ptr (xfree, buf);
            memcpy (buf, initial_buffer, used);
          }
        else
          {
            buf = xrealloc (buf, bufsize);
-           set_save_pointer (buf_save_value, 0, buf);
+           set_unwind_protect_ptr (buf_save_value_index, xfree, buf);
          }
 
        p = buf + used;
@@ -4621,7 +4619,7 @@ Transposing beyond buffer boundaries is an error.  */)
 
   if (end1 == start2)          /* adjacent regions */
     {
-      modify_region_1 (start1, end2, false);
+      modify_text (start1, end2);
       record_change (start1, len1 + len2);
 
       tmp_interval1 = copy_intervals (cur_intv, start1, len1);
@@ -4680,8 +4678,8 @@ Transposing beyond buffer boundaries is an error.  */)
         {
          USE_SAFE_ALLOCA;
 
-          modify_region_1 (start1, end1, false);
-          modify_region_1 (start2, end2, false);
+          modify_text (start1, end1);
+          modify_text (start2, end2);
           record_change (start1, len1);
           record_change (start2, len2);
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
@@ -4714,7 +4712,7 @@ Transposing beyond buffer boundaries is an error.  */)
         {
          USE_SAFE_ALLOCA;
 
-          modify_region_1 (start1, end2, false);
+          modify_text (start1, end2);
           record_change (start1, (end2 - start1));
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
@@ -4747,7 +4745,7 @@ Transposing beyond buffer boundaries is an error.  */)
          USE_SAFE_ALLOCA;
 
           record_change (start1, (end2 - start1));
-          modify_region_1 (start1, end2, false);
+          modify_text (start1, end2);
 
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);