From: Kenichi Handa Date: Fri, 23 Jan 2004 00:20:48 +0000 (+0000) Subject: (Fmd5): If OBJECT is a buffer different from the current X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85ae2d8485744ebf0564de3891461e8673fe8b9c;p=emacs.git (Fmd5): If OBJECT is a buffer different from the current one, set buffer to OBJECT temporarily. --- diff --git a/src/fns.c b/src/fns.c index abc1e276477..cfd32ed32d8 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5077,12 +5077,18 @@ guesswork fails. Normally, an error is signaled in such case.") } else { + struct buffer *prev = current_buffer; + + record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + CHECK_BUFFER (object, 0); bp = XBUFFER (object); - + if (bp != current_buffer) + set_buffer_internal (bp); + if (NILP (start)) - b = BUF_BEGV (bp); + b = BEGV; else { CHECK_NUMBER_COERCE_MARKER (start, 0); @@ -5090,7 +5096,7 @@ guesswork fails. Normally, an error is signaled in such case.") } if (NILP (end)) - e = BUF_ZV (bp); + e = ZV; else { CHECK_NUMBER_COERCE_MARKER (end, 1); @@ -5099,10 +5105,10 @@ guesswork fails. Normally, an error is signaled in such case.") if (b > e) temp = b, b = e, e = temp; - - if (!(BUF_BEGV (bp) <= b && e <= BUF_ZV (bp))) + + if (!(BEGV <= b && e <= ZV)) args_out_of_range (start, end); - + if (NILP (coding_system)) { /* Decide the coding-system to encode the data with. @@ -5167,6 +5173,11 @@ guesswork fails. Normally, an error is signaled in such case.") } object = make_buffer_string (b, e, 0); + if (prev != current_buffer) + set_buffer_internal (prev); + /* Discard the unwind protect for recovering the current + buffer. */ + specpdl_ptr--; if (STRING_MULTIBYTE (object)) object = code_convert_string1 (object, coding_system, Qnil, 1);