aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-12-21 01:20:26 +0000
committerRichard M. Stallman1997-12-21 01:20:26 +0000
commitbab29e15c4971e03f6ef00e35ac7ccb53bf92193 (patch)
tree8658d0047db9e8200a79acbe19330b4b9a836fef /src
parente0e4cb7afab544d0715a50efd4dcd697321afd26 (diff)
downloademacs-bab29e15c4971e03f6ef00e35ac7ccb53bf92193.tar.gz
emacs-bab29e15c4971e03f6ef00e35ac7ccb53bf92193.zip
(message_dolog): Update PT and ZV properly when at end of
buffer, when we convert between multibyte and single-byte. Properly initialize i. (message_dolog): Convert between single-byte and multibyte when inserting text into *Messages*.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 441ba92f869..cc65fff9ae9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -285,6 +285,8 @@ message_dolog (m, len, nlflag)
285 struct buffer *oldbuf; 285 struct buffer *oldbuf;
286 int oldpoint, oldbegv, oldzv; 286 int oldpoint, oldbegv, oldzv;
287 int old_windows_or_buffers_changed = windows_or_buffers_changed; 287 int old_windows_or_buffers_changed = windows_or_buffers_changed;
288 int point_at_end = 0;
289 int zv_at_end = 0;
288 290
289 oldbuf = current_buffer; 291 oldbuf = current_buffer;
290 Fset_buffer (Fget_buffer_create (build_string ("*Messages*"))); 292 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
@@ -295,12 +297,48 @@ message_dolog (m, len, nlflag)
295 BEGV = BEG; 297 BEGV = BEG;
296 ZV = Z; 298 ZV = Z;
297 if (oldpoint == Z) 299 if (oldpoint == Z)
298 oldpoint += len + nlflag; 300 point_at_end = 1;
299 if (oldzv == Z) 301 if (oldzv == Z)
300 oldzv += len + nlflag; 302 zv_at_end = 1;
301 TEMP_SET_PT (Z); 303 TEMP_SET_PT (Z);
302 if (len) 304
305 /* Insert the string--maybe converting multibyte to single byte
306 or vice versa, so that all the text fits the buffer. */
307 if (! NILP (oldbuf->enable_multibyte_characters)
308 && NILP (current_buffer->enable_multibyte_characters))
309 {
310 int c, i = 0, nbytes;
311 /* Convert a multibyte string to single-byte
312 for the *Message* buffer. */
313 while (i < len)
314 {
315 c = STRING_CHAR (m + i, len - i);
316 i += XFASTINT (Fchar_bytes (make_number (c)));
317 /* Truncate the character to its last byte--we can only hope
318 the user is happy with the character he gets,
319 since if it isn't right, there is no way to do it right. */
320 c &= 0xff;
321 insert_char (c);
322 }
323 }
324 else if (NILP (oldbuf->enable_multibyte_characters)
325 && ! NILP (current_buffer->enable_multibyte_characters))
326 {
327 int c, i = 0;
328 /* Convert a single-byte string to multibyte
329 for the *Message* buffer. */
330 while (i < len)
331 {
332 c = m[i++];
333 /* Convert non-ascii chars as if for self-insert. */
334 if (c >= 0200 && c <= 0377)
335 c += nonascii_insert_offset;
336 insert_char (c);
337 }
338 }
339 else if (len)
303 insert_1 (m, len, 1, 0); 340 insert_1 (m, len, 1, 0);
341
304 if (nlflag) 342 if (nlflag)
305 { 343 {
306 int this_bol, prev_bol, dup; 344 int this_bol, prev_bol, dup;
@@ -350,8 +388,14 @@ message_dolog (m, len, nlflag)
350 } 388 }
351 } 389 }
352 BEGV = oldbegv; 390 BEGV = oldbegv;
353 ZV = oldzv; 391 if (zv_at_end)
354 TEMP_SET_PT (oldpoint); 392 ZV = Z;
393 else
394 ZV = oldzv;
395 if (point_at_end)
396 TEMP_SET_PT (Z);
397 else
398 TEMP_SET_PT (oldpoint);
355 set_buffer_internal (oldbuf); 399 set_buffer_internal (oldbuf);
356 windows_or_buffers_changed = old_windows_or_buffers_changed; 400 windows_or_buffers_changed = old_windows_or_buffers_changed;
357 message_log_need_newline = !nlflag; 401 message_log_need_newline = !nlflag;