aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-07-11 15:42:26 +0000
committerGerd Moellmann2001-07-11 15:42:26 +0000
commitd0e2444ef8c7d4d713a863e32350c88200913ae5 (patch)
tree524ddc8b7fcdd81df6a6dcb86d8f1cdd72f0e64b /src
parent5078c8abf35fd1166acd6e2251a65831cc87611d (diff)
downloademacs-d0e2444ef8c7d4d713a863e32350c88200913ae5.tar.gz
emacs-d0e2444ef8c7d4d713a863e32350c88200913ae5.zip
(unwind_read): Print a message when discarding inserted
text or switching the buffer to unibyte. Change parameter. (Finsert_file_contents): Don't pass VISIT to unwind_read.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/fileio.c34
2 files changed, 27 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4a2692f1b1d..d856d227807 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12001-07-11 Gerd Moellmann <gerd@gnu.org> 12001-07-11 Gerd Moellmann <gerd@gnu.org>
2 2
3 * fileio.c (unwind_read): Print a message when discarding inserted
4 text or switching the buffer to unibyte. Change parameter.
5 (Finsert_file_contents): Don't pass VISIT to unwind_read.
6
3 * fileio.c (unwind_read): New function. 7 * fileio.c (unwind_read): New function.
4 (Finsert_file_contents): Record it as unwind-function for 8 (Finsert_file_contents): Record it as unwind-function for
5 the case that reading is interrupted by C-g. 9 the case that reading is interrupted by C-g.
diff --git a/src/fileio.c b/src/fileio.c
index cf03f393328..0f05a465ab7 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3421,9 +3421,8 @@ decide_coding_unwind (unwind_data)
3421 3421
3422/* Unwind-function for reading from a file in insert-file-contents. 3422/* Unwind-function for reading from a file in insert-file-contents.
3423 3423
3424 INFO is a pair (INSERTED-BYTES . VISIT). INSERTED-BYTES is the 3424 INSERTED_BYTES is the number of bytes successfully inserted into
3425 number of bytes successfully inserted into current_buffer. VISIT 3425 current_buffer.
3426 is the same as the parameter VISIT Of insert-file-contents.
3427 3426
3428 When reading is interrupted by C-g, this leaves the newly read part 3427 When reading is interrupted by C-g, this leaves the newly read part
3429 of the current buffer undecoded. If this happens in a multibyte 3428 of the current buffer undecoded. If this happens in a multibyte
@@ -3438,16 +3437,22 @@ decide_coding_unwind (unwind_data)
3438 +--------- the gap ---------+ */ 3437 +--------- the gap ---------+ */
3439 3438
3440static Lisp_Object 3439static Lisp_Object
3441unwind_read (info) 3440unwind_read (inserted_bytes)
3442 Lisp_Object info; 3441 Lisp_Object inserted_bytes;
3443{ 3442{
3444 if (!NILP (current_buffer->enable_multibyte_characters)) 3443 if (!NILP (current_buffer->enable_multibyte_characters))
3445 { 3444 {
3446 int nbytes = XINT (XCAR (info)); 3445 int nbytes = XINT (inserted_bytes);
3447 int visit = !NILP (XCDR (info)); 3446 Lisp_Object args[3];
3447 char *action;
3448 3448
3449 if (visit || Z == nbytes) 3449 if (Z == nbytes)
3450 current_buffer->enable_multibyte_characters = Qnil; 3450 {
3451 /* Buffer was previously empty. Switch it to unibyte
3452 because newly inserted text is not decoded. */
3453 current_buffer->enable_multibyte_characters = Qnil;
3454 action = "buffer made unibyte";
3455 }
3451 else 3456 else
3452 { 3457 {
3453 ZV -= nbytes; 3458 ZV -= nbytes;
@@ -3458,7 +3463,15 @@ unwind_read (info)
3458 GPT = PT; 3463 GPT = PT;
3459 GPT_BYTE = PT_BYTE; 3464 GPT_BYTE = PT_BYTE;
3460 GAP_SIZE = nbytes + GAP_SIZE; 3465 GAP_SIZE = nbytes + GAP_SIZE;
3466
3467 action = "no text inserted";
3461 } 3468 }
3469
3470
3471 args[0] = build_string ("Quit while inserting text in buffer `%s': %s");
3472 args[1] = current_buffer->name;
3473 args[2] = build_string (action);
3474 Fmessage (3, args);
3462 } 3475 }
3463 3476
3464 return Qnil; 3477 return Qnil;
@@ -4187,8 +4200,7 @@ actually used.")
4187 /* Allow quitting out of the actual I/O. If a C-g interrupts 4200 /* Allow quitting out of the actual I/O. If a C-g interrupts
4188 this, make sure that no invalid characters remain 4201 this, make sure that no invalid characters remain
4189 in the undecoded part read. */ 4202 in the undecoded part read. */
4190 record_unwind_protect (unwind_read, 4203 record_unwind_protect (unwind_read, make_number (inserted));
4191 Fcons (make_number (inserted), visit));
4192 immediate_quit = 1; 4204 immediate_quit = 1;
4193 QUIT; 4205 QUIT;
4194 this = emacs_read (fd, BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1, 4206 this = emacs_read (fd, BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,