/* Lisp functions pertaining to editing.
- Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
return make_string_from_bytes (str, 1, len);
}
+DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0,
+ doc: /* Convert arg BYTE to a string containing that byte. */)
+ (byte)
+ Lisp_Object byte;
+{
+ unsigned char b;
+ CHECK_NUMBER (byte);
+ b = XINT (byte);
+ return make_string_from_bytes (&b, 1, 1);
+}
+
DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0,
doc: /* Convert arg STRING to a character, the first character of that string.
A multibyte character is handled correctly. */)
if (SCHARS (string))
{
if (STRING_MULTIBYTE (string))
- XSETFASTINT (val, STRING_CHAR (SDATA (string), SBYTES (string)));
+ XSETFASTINT (val, STRING_CHAR (SDATA (string)));
else
XSETFASTINT (val, SREF (string, 0));
}
of the mark at the end of the command. To prevent that, bind
`deactivate-mark' with `let'.
+If you only want to save the current buffer but not point nor mark,
+then just use `save-current-buffer', or even `with-current-buffer'.
+
usage: (save-excursion &rest BODY) */)
(args)
Lisp_Object args;
have the form (HIGH . LOW), but this is considered obsolete.
WARNING: Since the result is floating point, it may not be exact.
-Do not use this function if precise time stamps are required. */)
+If precise time stamps are required, use either `current-time',
+or (if you need time as a string) `format-time-string'. */)
(specified_time)
Lisp_Object specified_time;
{
}
DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0,
- doc: /* Return the current time, as a human-readable string.
+ doc: /* Return the current local time, as a human-readable string.
Programs can use this function to decode a time,
since the number of columns in each field is fixed
if the year is in the range 1000-9999.
{
if (MODIFF - 1 == SAVE_MODIFF)
SAVE_MODIFF++;
- if (MODIFF - 1 == current_buffer->auto_save_modified)
- current_buffer->auto_save_modified++;
+ if (MODIFF - 1 == BUF_AUTOSAVE_MODIFF (current_buffer))
+ BUF_AUTOSAVE_MODIFF (current_buffer)++;
}
/* The before-change-function may have moved the gap
memcpy (newbuf, buf, sizeof (int) * buf_used);
buf = newbuf;
}
- buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, 0, len);
+ buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len);
pos_byte += len;
}
if (XINT (AREF (elt, i)) != buf[i])
Lisp_Object val;
if (multibyte)
- oc = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len);
+ oc = STRING_CHAR_AND_LENGTH (p, len);
else
oc = *p, len = 1;
if (oc < size)
if (string_multibyte)
{
str = tt + string_char_to_byte (table, oc);
- nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH,
- str_len);
+ nc = STRING_CHAR_AND_LENGTH (str, str_len);
}
else
{
to be as large as is calculated here. Easy check for
the case PRECISION = 0. */
thissize = precision[n] ? CONVERTED_BYTE_SIZE (multibyte, args[n]) : 0;
+ /* The precision also constrains how much of the argument
+ string will finally appear (Bug#5710). */
actual_width = lisp_string_width (args[n], -1, NULL, NULL);
+ if (precision[n] != -1)
+ actual_width = min(actual_width,precision[n]);
}
/* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */
else if (INTEGERP (args[n]) && *format != 's')
len = make_number (SCHARS (args[n]));
new_len = make_number (info[n].end - info[n].start);
props = text_property_list (args[n], make_number (0), len, Qnil);
- extend_property_ranges (props, len, new_len);
- /* If successive arguments have properites, be sure that
+ props = extend_property_ranges (props, new_len);
+ /* If successive arguments have properties, be sure that
the value of `composition' property be the copy. */
if (n > 1 && info[n - 1].end)
make_composition_value_copy (props);
defsubr (&Sgoto_char);
defsubr (&Sstring_to_char);
defsubr (&Schar_to_string);
+ defsubr (&Sbyte_to_string);
defsubr (&Sbuffer_substring);
defsubr (&Sbuffer_substring_no_properties);
defsubr (&Sbuffer_string);