Mercurial > emacs
changeset 38367:bcff6c46ee05
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 11 Jul 2001 15:42:07 +0000 |
parents | cb65022a3abb |
children | 06544baec9ed |
files | src/fileio.c |
diffstat | 1 files changed, 24 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.c Wed Jul 11 12:07:27 2001 +0000 +++ b/src/fileio.c Wed Jul 11 15:42:07 2001 +0000 @@ -3421,9 +3421,8 @@ /* Unwind-function for reading from a file in insert-file-contents. - INFO is a pair (INSERTED-BYTES . VISIT). INSERTED-BYTES is the - number of bytes successfully inserted into current_buffer. VISIT - is the same as the parameter VISIT Of insert-file-contents. + INSERTED_BYTES is the number of bytes successfully inserted into + current_buffer. When reading is interrupted by C-g, this leaves the newly read part of the current buffer undecoded. If this happens in a multibyte @@ -3438,16 +3437,22 @@ +--------- the gap ---------+ */ static Lisp_Object -unwind_read (info) - Lisp_Object info; +unwind_read (inserted_bytes) + Lisp_Object inserted_bytes; { if (!NILP (current_buffer->enable_multibyte_characters)) { - int nbytes = XINT (XCAR (info)); - int visit = !NILP (XCDR (info)); - - if (visit || Z == nbytes) - current_buffer->enable_multibyte_characters = Qnil; + int nbytes = XINT (inserted_bytes); + Lisp_Object args[3]; + char *action; + + if (Z == nbytes) + { + /* Buffer was previously empty. Switch it to unibyte + because newly inserted text is not decoded. */ + current_buffer->enable_multibyte_characters = Qnil; + action = "buffer made unibyte"; + } else { ZV -= nbytes; @@ -3458,7 +3463,15 @@ GPT = PT; GPT_BYTE = PT_BYTE; GAP_SIZE = nbytes + GAP_SIZE; + + action = "no text inserted"; } + + + args[0] = build_string ("Quit while inserting text in buffer `%s': %s"); + args[1] = current_buffer->name; + args[2] = build_string (action); + Fmessage (3, args); } return Qnil; @@ -4187,8 +4200,7 @@ /* Allow quitting out of the actual I/O. If a C-g interrupts this, make sure that no invalid characters remain in the undecoded part read. */ - record_unwind_protect (unwind_read, - Fcons (make_number (inserted), visit)); + record_unwind_protect (unwind_read, make_number (inserted)); immediate_quit = 1; QUIT; this = emacs_read (fd, BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,