(setenv): Call set-time-zone-rule when setting TZ.
[bpt/emacs.git] / src / editfns.c
index 13a851f..42fb68a 100644 (file)
@@ -235,17 +235,6 @@ DEFUN ("region-end", Fregion_end, Sregion_end, 0, 0, 0,
   return (region_limit (0));
 }
 
-#if 0 /* now in lisp code */
-DEFUN ("mark", Fmark, Smark, 0, 0, 0,
-  "Return this buffer's mark value as integer, or nil if no mark.\n\
-If you are using this in an editing command, you are most likely making\n\
-a mistake; see the documentation of `set-mark'.")
-  ()
-{
-  return Fmarker_position (current_buffer->mark);
-}
-#endif /* commented out code */
-
 DEFUN ("mark-marker", Fmark_marker, Smark_marker, 0, 0, 0,
   "Return this buffer's mark, as a marker object.\n\
 Watch out!  Moving this marker changes the mark position.\n\
@@ -255,41 +244,6 @@ If you set the marker not to point anywhere, the buffer will have no mark.")
   return current_buffer->mark;
 }
 
-#if 0 /* this is now in lisp code */
-DEFUN ("set-mark", Fset_mark, Sset_mark, 1, 1, 0,
-  "Set this buffer's mark to POS.  Don't use this function!\n\
-That is to say, don't use this function unless you want\n\
-the user to see that the mark has moved, and you want the previous\n\
-mark position to be lost.\n\
-\n\
-Normally, when a new mark is set, the old one should go on the stack.\n\
-This is why most applications should use push-mark, not set-mark.\n\
-\n\
-Novice programmers often try to use the mark for the wrong purposes.\n\
-The mark saves a location for the user's convenience.\n\
-Most editing commands should not alter the mark.\n\
-To remember a location for internal use in the Lisp program,\n\
-store it in a Lisp variable.  Example:\n\
-\n\
-   (let ((beg (point))) (forward-line 1) (delete-region beg (point))).")
-  (pos)
-     Lisp_Object pos;
-{
-  if (NILP (pos))
-    {
-      current_buffer->mark = Qnil;
-      return Qnil;
-    }
-  CHECK_NUMBER_COERCE_MARKER (pos, 0);
-
-  if (NILP (current_buffer->mark))
-    current_buffer->mark = Fmake_marker ();
-
-  Fset_marker (current_buffer->mark, pos, Qnil);
-  return pos;
-}
-#endif /* commented-out code */
-
 Lisp_Object
 save_excursion_save ()
 {
@@ -297,7 +251,7 @@ save_excursion_save ()
                          == current_buffer);
 
   return Fcons (Fpoint_marker (),
-               Fcons (Fcopy_marker (current_buffer->mark),
+               Fcons (Fcopy_marker (current_buffer->mark, Qnil),
                       Fcons (visible ? Qt : Qnil,
                              current_buffer->mark_active)));                  
 }
@@ -698,13 +652,14 @@ DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0,
 The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED)\n\
 or (HIGH . LOW), as from `current-time' and `file-attributes', or `nil'\n\
 to use the current time.  The list has the following nine members:\n\
-SEC is an integer between 0 and 59.  MINUTE is an integer between 0 and 59.\n\
+SEC is an integer between 0 and 60; SEC is 60 for a leap second, which\n\
+only some operating systems support.  MINUTE is an integer between 0 and 59.\n\
 HOUR is an integer between 0 and 23.  DAY is an integer between 1 and 31.\n\
 MONTH is an integer between 1 and 12.  YEAR is an integer indicating the\n\
 four-digit year.  DOW is the day of week, an integer between 0 and 6, where\n\
 0 is Sunday.  DST is t if daylight savings time is effect, otherwise nil.\n\
 ZONE is an integer indicating the number of seconds east of Greenwich.\n\
-(Note that Common Lisp has different meanings for DOW and ZONE.)")
+\(Note that Common Lisp has different meanings for DOW and ZONE.)")
   (specified_time)
      Lisp_Object specified_time;
 {
@@ -1378,6 +1333,13 @@ subst_char_in_region_unwind (arg)
   return current_buffer->undo_list = arg;
 }
 
+static Lisp_Object
+subst_char_in_region_unwind_1 (arg)
+     Lisp_Object arg;
+{
+  return current_buffer->filename = arg;
+}
+
 DEFUN ("subst-char-in-region", Fsubst_char_in_region,
   Ssubst_char_in_region, 4, 5, 0,
   "From START to END, replace FROMCHAR with TOCHAR each time it occurs.\n\
@@ -1400,12 +1362,17 @@ and don't mark the buffer as really changed.")
 
   /* If we don't want undo, turn off putting stuff on the list.
      That's faster than getting rid of things,
-     and it prevents even the entry for a first change.  */
+     and it prevents even the entry for a first change.
+     Also inhibit locking the file.  */
   if (!NILP (noundo))
     {
       record_unwind_protect (subst_char_in_region_unwind,
                             current_buffer->undo_list);
       current_buffer->undo_list = Qt;
+      /* Don't do file-locking.  */
+      record_unwind_protect (subst_char_in_region_unwind_1,
+                            current_buffer->filename);
+      current_buffer->filename = Qnil;
     }
 
   while (pos < stop)
@@ -1509,7 +1476,7 @@ This allows the buffer's full text to be seen and edited.")
 {
   BEGV = BEG;
   SET_BUF_ZV (current_buffer, Z);
-  clip_changed = 1;
+  current_buffer->clip_changed = 1;
   /* Changing the buffer bounds invalidates any recorded current column.  */
   invalidate_current_column ();
   return Qnil;
@@ -1545,7 +1512,7 @@ or markers) bounding the text that should remain visible.")
     SET_PT (XFASTINT (b));
   if (point > XFASTINT (e))
     SET_PT (XFASTINT (e));
-  clip_changed = 1;
+  current_buffer->clip_changed = 1;
   /* Changing the buffer bounds invalidates any recorded current column.  */
   invalidate_current_column ();
   return Qnil;
@@ -1587,7 +1554,7 @@ save_restriction_restore (data)
     }
   BUF_BEGV (buf) = BUF_BEG (buf) + newhead;
   SET_BUF_ZV (buf, BUF_Z (buf) - newtail);
-  clip_changed = 1;
+  current_buffer->clip_changed = 1;
 
   /* If point is outside the new visible range, move it inside. */
   SET_BUF_PT (buf,
@@ -1633,12 +1600,9 @@ static int message_length;
 
 DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
   "Print a one-line message at the bottom of the screen.\n\
-The first argument is a control string.\n\
-It may contain %s or %d or %c to print successive following arguments.\n\
-%s means print an argument as a string, %d means print as number in decimal,\n\
-%c means print a number as a single character.\n\
-The argument used by %s must be a string or a symbol;\n\
-the argument used by %d or %c must be a number.\n\
+The first argument is a format control string, and the rest are data\n\
+to be formatted under control of the string.  See `format' for details.\n\
+\n\
 If the first argument is nil, clear any existing message; let the\n\
 minibuffer contents show.")
   (nargs, args)
@@ -1758,9 +1722,13 @@ The other arguments are substituted into it to make the result, a string.\n\
 It may contain %-sequences meaning to substitute the next argument.\n\
 %s means print a string argument.  Actually, prints any object, with `princ'.\n\
 %d means print as number in decimal (%o octal, %x hex).\n\
+%e means print a number in exponential notation.\n\
+%f means print a number in decimal-point notation.\n\
+%g means print a number in exponential notation\n\
+  or decimal-point notation, whichever uses fewer characters.\n\
 %c means print a number as a single character.\n\
 %S means print any object as an s-expression (using prin1).\n\
-  The argument used for %d, %o, %x or %c must be a number.\n\
+  The argument used for %d, %o, %x, %e, %f, %g or %c must be a number.\n\
 Use %% to put a single % into the output.")
   (nargs, args)
      int nargs;
@@ -1787,10 +1755,9 @@ Use %% to put a single % into the output.")
 
        /* Process a numeric arg and skip it.  */
        minlen = atoi (format);
-       if (minlen > 0)
-         total += minlen;
-       else
-         total -= minlen;
+       if (minlen < 0)
+         minlen = - minlen;
+
        while ((*format >= '0' && *format <= '9')
               || *format == '-' || *format == ' ' || *format == '.')
          format++;
@@ -1798,7 +1765,7 @@ Use %% to put a single % into the output.")
        if (*format == '%')
          format++;
        else if (++n >= nargs)
-         error ("not enough arguments for format string");
+         error ("Not enough arguments for format string");
        else if (*format == 'S')
          {
            /* For `S', prin1 the argument and then treat like a string.  */
@@ -1818,6 +1785,10 @@ Use %% to put a single % into the output.")
            if (*format != 's' && *format != 'S')
              error ("format specifier doesn't match argument type");
            total += XSTRING (args[n])->size;
+           /* We have to put an arbitrary limit on minlen
+              since otherwise it could make alloca fail.  */
+           if (minlen < XSTRING (args[n])->size + 1000)
+             total += minlen;
          }
        /* Would get MPV otherwise, since Lisp_Int's `point' to low memory.  */
        else if (INTEGERP (args[n]) && *format != 's')
@@ -1831,6 +1802,10 @@ Use %% to put a single % into the output.")
              args[n] = Ffloat (args[n]);
 #endif
            total += 30;
+           /* We have to put an arbitrary limit on minlen
+              since otherwise it could make alloca fail.  */
+           if (minlen < 1000)
+             total += minlen;
          }
 #ifdef LISP_FLOAT_TYPE
        else if (FLOATP (args[n]) && *format != 's')
@@ -1838,6 +1813,10 @@ Use %% to put a single % into the output.")
            if (! (*format == 'e' || *format == 'f' || *format == 'g'))
              args[n] = Ftruncate (args[n]);
            total += 30;
+           /* We have to put an arbitrary limit on minlen
+              since otherwise it could make alloca fail.  */
+           if (minlen < 1000)
+             total += minlen;
          }
 #endif
        else
@@ -1882,6 +1861,9 @@ Use %% to put a single % into the output.")
          strings[i++] = XSTRING (args[n])->data;
       }
 
+    /* Make room in result for all the non-%-codes in the control string.  */
+    total += XSTRING (args[0])->size;
+
     /* Format it in bigger and bigger buf's until it all fits. */
     while (1)
       {