If you only want to save the current buffer but not point,
then just use `save-current-buffer', or even `with-current-buffer'.
+Before Emacs 25.1, `save-excursion' used to save the mark state.
+To save the marker state as well as the point and buffer, use
+`save-mark-and-excursion'.
+
usage: (save-excursion &rest BODY) */)
(Lisp_Object args)
{
If BYTEPOS is out of range, the value is nil. */)
(Lisp_Object bytepos)
{
+ ptrdiff_t pos_byte;
+
CHECK_NUMBER (bytepos);
- if (XINT (bytepos) < BEG_BYTE || XINT (bytepos) > Z_BYTE)
+ pos_byte = XINT (bytepos);
+ if (pos_byte < BEG_BYTE || pos_byte > Z_BYTE)
return Qnil;
- return make_number (BYTE_TO_CHAR (XINT (bytepos)));
+ if (Z != Z_BYTE)
+ /* There are multibyte characters in the buffer.
+ The argument of BYTE_TO_CHAR must be a byte position at
+ a character boundary, so search for the start of the current
+ character. */
+ while (!CHAR_HEAD_P (FETCH_BYTE (pos_byte)))
+ pos_byte--;
+ return make_number (BYTE_TO_CHAR (pos_byte));
}
\f
DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 0, 0,
tzval[tzeqlen] = 0;
}
- if (new_tzvalbuf)
+ if (new_tzvalbuf
+#ifdef WINDOWSNT
+ /* MS-Windows implementation of 'putenv' copies the argument
+ string into a block it allocates, so modifying tzval string
+ does not change the environment. OTOH, the other threads run
+ by Emacs on MS-Windows never call 'xputenv' or 'putenv' or
+ 'unsetenv', so the original cause for the dicey in-place
+ modification technique doesn't exist there in the first
+ place. */
+ || 1
+#endif
+ )
{
/* Although this is not thread-safe, in practice this runs only
on startup when there is only one thread. */
doc: /* Insert before point a substring of the contents of BUFFER.
BUFFER may be a buffer or a buffer name.
Arguments START and END are character positions specifying the substring.
-They default to the values of (point-min) and (point-max) in BUFFER. */)
+They default to the values of (point-min) and (point-max) in BUFFER.
+
+Point and before-insertion markers move forward to end up after the
+inserted text.
+Any other markers at the point of insertion remain before the text.
+
+If the current buffer is multibyte and BUFFER is unibyte, or vice
+versa, strings are converted from unibyte to multibyte or vice versa
+using `string-make-multibyte' or `string-make-unibyte', which see. */)
(Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
{
register EMACS_INT b, e, temp;
nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf);
val = make_specified_string (buf, nchars, p - buf, multibyte);
- /* If we allocated BUF with malloc, free it too. */
- SAFE_FREE ();
-
/* If the format string has text properties, or any of the string
arguments has text properties, set up text properties of the
result string. */
UNGCPRO;
}
- return val;
-}
+ /* If we allocated BUF or INFO with malloc, free it too. */
+ SAFE_FREE ();
-Lisp_Object
-format2 (const char *string1, Lisp_Object arg0, Lisp_Object arg1)
-{
- AUTO_STRING (format, string1);
- return CALLN (Fformat, format, arg0, arg1);
+ return val;
}
\f
DEFUN ("char-equal", Fchar_equal, Schar_equal, 2, 2, 0,