Executes BODY just like `progn'.\n\
The values of point, mark and the current buffer are restored\n\
even in case of abnormal exit (throw or error).\n\
-The state of activation of the mark is also restored.")
+The state of activation of the mark is also restored.\n\
+\n\
+This construct does not save `deactivate-mark', and therefore\n\
+functions that change the buffer will still cause deactivation\n\
+of the mark at the end of the command. To prevent that, bind\n\
+`deactivate-mark' with `let'.")
(args)
Lisp_Object args;
{
DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0,
"Return the byte position for character position POSITION.")
(position)
+ Lisp_Object position;
{
CHECK_NUMBER_COERCE_MARKER (position, 1);
return make_number (CHAR_TO_BYTE (XINT (position)));
register Lisp_Object val;
if (NILP (pos))
- return make_number (FETCH_CHAR (PT_BYTE));
-
- if (MARKERP (pos))
- pos_byte = marker_byte_position (pos);
+ pos_byte = PT_BYTE;
+ else if (MARKERP (pos))
+ {
+ pos_byte = marker_byte_position (pos);
+ if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
+ return Qnil;
+ }
else
{
CHECK_NUMBER_COERCE_MARKER (pos, 0);
+ if (pos < BEGV || pos >= ZV)
+ return Qnil;
pos_byte = CHAR_TO_BYTE (XINT (pos));
}
- if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
- return Qnil;
-
return make_number (FETCH_CHAR (pos_byte));
}
if (NILP (pos))
pos_byte = PT_BYTE;
else if (MARKERP (pos))
- pos_byte = marker_byte_position (pos);
+ {
+ pos_byte = marker_byte_position (pos);
+
+ if (pos_byte <= BEGV_BYTE || pos_byte > ZV_BYTE)
+ return Qnil;
+ }
else
{
CHECK_NUMBER_COERCE_MARKER (pos, 0);
+ if (pos <= BEGV || pos > ZV)
+ return Qnil;
+
pos_byte = CHAR_TO_BYTE (XINT (pos));
}
- if (pos_byte <= BEGV_BYTE || pos_byte > ZV_BYTE)
- return Qnil;
-
if (!NILP (current_buffer->enable_multibyte_characters))
{
DEC_POS (pos_byte);
if (NILP (noundo))
record_change (pos, 1);
for (i = 0; i < len; i++) *p++ = tostr[i];
- pos++;
- pos_byte += len;
}
INC_BOTH (pos, pos_byte);
}
message_text = (char *)xmalloc (80);
message_length = 80;
}
- if (XSTRING (val)->size > message_length)
+ if (XSTRING (val)->size_byte > message_length)
{
message_length = XSTRING (val)->size_byte;
message_text = (char *)xrealloc (message_text, message_length);
if (*format == 'e' || *format == 'f' || *format == 'g')
args[n] = Ffloat (args[n]);
#endif
- thissize = 30;
+ thissize = 30;
+ if (*format == 'c' && ! SINGLE_BYTE_CHAR_P (XINT (args[n])))
+ {
+ if (! multibyte)
+ {
+ multibyte = 1;
+ goto retry;
+ }
+ args[n] = Fchar_to_string (args[n]);
+ thissize = XSTRING (args[n])->size_byte;
+ }
}
#ifdef LISP_FLOAT_TYPE
else if (FLOATP (args[n]) && *format != 's')
/* Anything but a string, convert to a string using princ. */
register Lisp_Object tem;
tem = Fprin1_to_string (args[n], Qt);
- if (STRING_MULTIBYTE (tem))
+ if (STRING_MULTIBYTE (tem) & ! multibyte)
{
multibyte = 1;
goto retry;
if (STRINGP (args[n]))
{
- int padding, nbytes;
+ int padding, nbytes, width;
nbytes = copy_text (XSTRING (args[n])->data, p,
XSTRING (args[n])->size_byte,
STRING_MULTIBYTE (args[n]), multibyte);
+ width = strwidth (p, nbytes);
p += nbytes;
nchars += XSTRING (args[n])->size;
/* If spec requires it, pad on right with spaces. */
- padding = minlen - XSTRING (args[n])->size;
+ padding = minlen - width;
while (padding-- > 0)
{
*p++ = ' ';
args[2] = arg2;
args[3] = arg3;
args[4] = arg4;
- doprnt (buf, sizeof buf, string1, (char *)0, 5, args);
+ doprnt (buf, sizeof buf, string1, (char *)0, 5, (char **) args);
#else
doprnt (buf, sizeof buf, string1, (char *)0, 5, &string1 + 1);
#endif