]> code.delx.au - gnu-emacs/blobdiff - src/editfns.c
(Fset_window_margins): Allow only integers as args.
[gnu-emacs] / src / editfns.c
index f436ee15717016ff80b5df99b033b81f487c986d..0b71d10515596175e70e5835ba96781954687ff7 100644 (file)
@@ -1,5 +1,5 @@
 /* Lisp functions pertaining to editing.
-   Copyright (C) 1985,86,87,89,93,94,95,96,97,98, 1999, 2000, 2001, 2002
+   Copyright (C) 1985,86,87,89,93,94,95,96,97,98, 1999, 2000, 2001, 02, 2003
        Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -299,7 +299,7 @@ region_limit (beginningp)
   if (NILP (m))
     error ("The mark is not set now, so there is no region");
 
-  if ((PT < XFASTINT (m)) == beginningp)
+  if ((PT < XFASTINT (m)) == (beginningp != 0))
     m = make_number (PT);
   return m;
 }
@@ -338,15 +338,14 @@ overlays_around (pos, vec, len)
      Lisp_Object *vec;
      int len;
 {
-  Lisp_Object tail, overlay, start, end;
+  Lisp_Object overlay, start, end;
+  struct Lisp_Overlay *tail;
   int startpos, endpos;
   int idx = 0;
 
-  for (tail = current_buffer->overlays_before;
-       GC_CONSP (tail);
-       tail = XCDR (tail))
+  for (tail = current_buffer->overlays_before; tail; tail = tail->next)
     {
-      overlay = XCAR (tail);
+      XSETMISC (overlay, tail);
 
       end = OVERLAY_END (overlay);
       endpos = OVERLAY_POSITION (end);
@@ -363,11 +362,9 @@ overlays_around (pos, vec, len)
        }
     }
 
-  for (tail = current_buffer->overlays_after;
-       GC_CONSP (tail);
-       tail = XCDR (tail))
+  for (tail = current_buffer->overlays_after; tail; tail = tail->next)
     {
-      overlay = XCAR (tail);
+      XSETMISC (overlay, tail);
 
       start = OVERLAY_START (overlay);
       startpos = OVERLAY_POSITION (start);
@@ -399,19 +396,19 @@ get_pos_property (position, prop, object)
      Lisp_Object position, object;
      register Lisp_Object prop;
 {
-  struct window *w = 0;
-
   CHECK_NUMBER_COERCE_MARKER (position);
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
-
-  if (WINDOWP (object))
-    {
-      w = XWINDOW (object);
-      object = w->buffer;
-    }
-  if (BUFFERP (object))
+  else if (WINDOWP (object))
+    object = XWINDOW (object)->buffer;
+
+  if (!BUFFERP (object))
+    /* pos-property only makes sense in buffers right now, since strings
+       have no overlays and no notion of insertion for which stickiness
+       could be obeyed.  */
+    return Fget_text_property (position, prop, object);
+  else
     {
       int posn = XINT (position);
       int noverlays;
@@ -457,18 +454,18 @@ get_pos_property (position, prop, object)
            }
        }
 
+      { /* Now check the text-properties.  */
+       int stickiness = text_property_stickiness (prop, position, object);
+       if (stickiness > 0)
+         return Fget_text_property (position, prop, object);
+       else if (stickiness < 0
+                && XINT (position) > BUF_BEGV (XBUFFER (object)))
+         return Fget_text_property (make_number (XINT (position) - 1),
+                                    prop, object);
+       else
+         return Qnil;
+      }
     }
-
-  { /* Now check the text-properties.  */
-    int stickiness = text_property_stickiness (prop, position);
-    if (stickiness > 0)
-      return Fget_text_property (position, prop, Qnil);
-    else if (stickiness < 0 && XINT (position) > BEGV)
-      return Fget_text_property (make_number (XINT (position) - 1),
-                                prop, Qnil);
-    else
-      return Qnil;
-  }
 }
 
 /* Find the field surrounding POS in *BEG and *END.  If POS is nil,
@@ -868,7 +865,7 @@ save_excursion_restore (info)
   /* Point marker.  */
   tem = XCAR (info);
   Fgoto_char (tem);
-  unchain_marker (tem);
+  unchain_marker (XMARKER (tem));
 
   /* Mark marker.  */
   info = XCDR (info);
@@ -876,7 +873,7 @@ save_excursion_restore (info)
   omark = Fmarker_position (current_buffer->mark);
   Fset_marker (current_buffer->mark, tem, Fcurrent_buffer ());
   nmark = Fmarker_position (tem);
-  unchain_marker (tem);
+  unchain_marker (XMARKER (tem));
 
   /* visible */
   info = XCDR (info);
@@ -1668,6 +1665,9 @@ for example, a DAY of 0 means the day preceding the given month.
 Year numbers less than 100 are treated just like other year numbers.
 If you want them to stand for years in this century, you must do that yourself.
 
+Years before 1970 are not guaranteed to work.  On some systems,
+year values as low as 1901 do work.
+
 usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)  */)
      (nargs, args)
      int nargs;
@@ -3255,8 +3255,12 @@ usage: (format STRING &rest OBJECTS)  */)
   /* We may have to change "%S" to "%s". */
   args[0] = Fcopy_sequence (args[0]);
 
+  /* GC should never happen here, so abort if it does.  */
+  abort_on_gc++;
+
   /* If we start out planning a unibyte result,
-     and later find it has to be multibyte, we jump back to retry.  */
+     then discover it has to be multibyte, we jump back to retry.
+     That can only happen from the first large while loop below.  */
  retry:
 
   format = SDATA (args[0]);
@@ -3456,6 +3460,8 @@ usage: (format STRING &rest OBJECTS)  */)
        total += thissize + 4;
       }
 
+  abort_on_gc--;
+
   /* Now we can no longer jump to retry.
      TOTAL and LONGEST_FORMAT are known for certain.  */
 
@@ -3474,6 +3480,8 @@ usage: (format STRING &rest OBJECTS)  */)
 
   /* Scan the format and store result in BUF.  */
   format = SDATA (args[0]);
+  format_start = format;
+  end = format + SBYTES (args[0]);
   maybe_combine_byte = 0;
   while (format != end)
     {
@@ -3674,7 +3682,8 @@ usage: (format STRING &rest OBJECTS)  */)
             and ARGN is the number of the next arg we will come to.  */
          for (list = props; CONSP (list); list = XCDR (list))
            {
-             Lisp_Object item, pos;
+             Lisp_Object item;
+             int pos;
 
              item = XCAR (list);
 
@@ -3753,7 +3762,6 @@ format2 (string1, arg0, arg1)
      Lisp_Object arg0, arg1;
 {
   Lisp_Object args[3];
-  int numargs;
   args[0] = build_string (string1);
   args[1] = arg0;
   args[2] = arg1;
@@ -3806,7 +3814,7 @@ transpose_markers (start1, end1, start2, end2,
      register int start1_byte, end1_byte, start2_byte, end2_byte;
 {
   register int amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos;
-  register Lisp_Object marker;
+  register struct Lisp_Marker *marker;
 
   /* Update point as if it were a marker.  */
   if (PT < start1)
@@ -3841,10 +3849,9 @@ transpose_markers (start1, end1, start2, end2,
   amt1_byte = (end2_byte - start2_byte) + (start2_byte - end1_byte);
   amt2_byte = (end1_byte - start1_byte) + (start2_byte - end1_byte);
 
-  for (marker = BUF_MARKERS (current_buffer); !NILP (marker);
-       marker = XMARKER (marker)->chain)
+  for (marker = BUF_MARKERS (current_buffer); marker; marker = marker->next)
     {
-      mpos = marker_byte_position (marker);
+      mpos = marker->bytepos;
       if (mpos >= start1_byte && mpos < end2_byte)
        {
          if (mpos < end1_byte)
@@ -3853,9 +3860,9 @@ transpose_markers (start1, end1, start2, end2,
            mpos += diff_byte;
          else
            mpos -= amt2_byte;
-         XMARKER (marker)->bytepos = mpos;
+         marker->bytepos = mpos;
        }
-      mpos = XMARKER (marker)->charpos;
+      mpos = marker->charpos;
       if (mpos >= start1 && mpos < end2)
        {
          if (mpos < end1)
@@ -3865,7 +3872,7 @@ transpose_markers (start1, end1, start2, end2,
          else
            mpos -= amt2;
        }
-      XMARKER (marker)->charpos = mpos;
+      marker->charpos = mpos;
     }
 }
 
@@ -4300,3 +4307,6 @@ functions if all the text being accessed has this property.  */);
   defsubr (&Ssave_restriction);
   defsubr (&Stranspose_regions);
 }
+
+/* arch-tag: fc3827d8-6f60-4067-b11e-c3218031b018
+   (do not change this comment) */