summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-07-11 15:42:26 +0000
committerGerd Moellmann <gerd@gnu.org>2001-07-11 15:42:26 +0000
commitd0e2444ef8c7d4d713a863e32350c88200913ae5 (patch)
tree524ddc8b7fcdd81df6a6dcb86d8f1cdd72f0e64b
parent5078c8abf35fd1166acd6e2251a65831cc87611d (diff)
downloademacs-d0e2444ef8c7d4d713a863e32350c88200913ae5.tar.gz
(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.
-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 @@
2001-07-11 Gerd Moellmann <gerd@gnu.org>
+ * fileio.c (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.
+
* fileio.c (unwind_read): New function.
(Finsert_file_contents): Record it as unwind-function for
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)
/* 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 @@ decide_coding_unwind (unwind_data)
+--------- 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));
+ int nbytes = XINT (inserted_bytes);
+ Lisp_Object args[3];
+ char *action;
- if (visit || Z == nbytes)
- current_buffer->enable_multibyte_characters = Qnil;
+ 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 @@ unwind_read (info)
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 @@ actually used.")
/* 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,