[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/coding.c
From: |
Kenichi Handa |
Subject: |
[Emacs-diffs] Changes to emacs/src/coding.c |
Date: |
Thu, 14 Jul 2005 03:57:22 -0400 |
Index: emacs/src/coding.c
diff -c emacs/src/coding.c:1.322 emacs/src/coding.c:1.323
*** emacs/src/coding.c:1.322 Tue Jul 12 13:16:18 2005
--- emacs/src/coding.c Thu Jul 14 07:57:21 2005
***************
*** 5353,5364 ****
}
\
} while (0)
static Lisp_Object
code_convert_region_unwind (arg)
Lisp_Object arg;
{
inhibit_pre_post_conversion = 0;
! Vlast_coding_system_used = arg;
return Qnil;
}
--- 5353,5369 ----
}
\
} while (0)
+ /* ARG is (CODING . BUFFER) where CODING is what to be set in
+ Vlast_coding_system_used and BUFFER if non-nil is a buffer to
+ kill. */
static Lisp_Object
code_convert_region_unwind (arg)
Lisp_Object arg;
{
inhibit_pre_post_conversion = 0;
! Vlast_coding_system_used = XCAR (arg);
! if (! NILP (XCDR (arg)))
! Fkill_buffer (XCDR (arg));
return Qnil;
}
***************
*** 5611,5617 ****
Lisp_Object new;
record_unwind_protect (code_convert_region_unwind,
! Vlast_coding_system_used);
/* We should not call any more pre-write/post-read-conversion
functions while this pre-write-conversion is running. */
inhibit_pre_post_conversion = 1;
--- 5616,5622 ----
Lisp_Object new;
record_unwind_protect (code_convert_region_unwind,
! Fcons (Vlast_coding_system_used, Qnil));
/* We should not call any more pre-write/post-read-conversion
functions while this pre-write-conversion is running. */
inhibit_pre_post_conversion = 1;
***************
*** 5979,5985 ****
TEMP_SET_PT_BOTH (from, from_byte);
prev_Z = Z;
record_unwind_protect (code_convert_region_unwind,
! Vlast_coding_system_used);
saved_coding_system = Vlast_coding_system_used;
Vlast_coding_system_used = coding->symbol;
/* We should not call any more pre-write/post-read-conversion
--- 5984,5990 ----
TEMP_SET_PT_BOTH (from, from_byte);
prev_Z = Z;
record_unwind_protect (code_convert_region_unwind,
! Fcons (Vlast_coding_system_used, Qnil));
saved_coding_system = Vlast_coding_system_used;
Vlast_coding_system_used = coding->symbol;
/* We should not call any more pre-write/post-read-conversion
***************
*** 6025,6041 ****
/* Set the current buffer to the working buffer prepared for
code-conversion. MULTIBYTE specifies the multibyteness of the
! buffer. */
! static struct buffer *
set_conversion_work_buffer (multibyte)
int multibyte;
{
! Lisp_Object buffer;
struct buffer *buf;
buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
buf = XBUFFER (buffer);
delete_all_overlays (buf);
buf->directory = current_buffer->directory;
buf->read_only = Qnil;
--- 6030,6060 ----
/* Set the current buffer to the working buffer prepared for
code-conversion. MULTIBYTE specifies the multibyteness of the
! buffer. Return the buffer we set if it must be killed after use.
! Otherwise return Qnil. */
! static Lisp_Object
set_conversion_work_buffer (multibyte)
int multibyte;
{
! Lisp_Object buffer, buffer_to_kill;
struct buffer *buf;
buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
buf = XBUFFER (buffer);
+ if (buf == current_buffer)
+ {
+ /* As we are already in the work buffer, we must generate a new
+ buffer for the work. */
+ Lisp_Object name;
+
+ name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
+ buffer = buffer_to_kill = Fget_buffer_create (name);
+ buf = XBUFFER (buffer);
+ }
+ else
+ buffer_to_kill = Qnil;
+
delete_all_overlays (buf);
buf->directory = current_buffer->directory;
buf->read_only = Qnil;
***************
*** 6048,6054 ****
Fwiden ();
del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0);
buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
! return buf;
}
Lisp_Object
--- 6067,6073 ----
Fwiden ();
del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0);
buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
! return buffer_to_kill;
}
Lisp_Object
***************
*** 6061,6070 ****
struct gcpro gcpro1, gcpro2;
int multibyte = STRING_MULTIBYTE (str);
Lisp_Object old_deactivate_mark;
record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
- record_unwind_protect (code_convert_region_unwind,
- Vlast_coding_system_used);
/* It is not crucial to specbind this. */
old_deactivate_mark = Vdeactivate_mark;
GCPRO2 (str, old_deactivate_mark);
--- 6080,6088 ----
struct gcpro gcpro1, gcpro2;
int multibyte = STRING_MULTIBYTE (str);
Lisp_Object old_deactivate_mark;
+ Lisp_Object buffer_to_kill;
record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
/* It is not crucial to specbind this. */
old_deactivate_mark = Vdeactivate_mark;
GCPRO2 (str, old_deactivate_mark);
***************
*** 6072,6078 ****
/* We must insert the contents of STR as is without
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
! set_conversion_work_buffer (multibyte);
insert_from_string (str, 0, 0,
SCHARS (str), SBYTES (str), 0);
--- 6090,6098 ----
/* We must insert the contents of STR as is without
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
! buffer_to_kill = set_conversion_work_buffer (multibyte);
! record_unwind_protect (code_convert_region_unwind,
! Fcons (Vlast_coding_system_used, buffer_to_kill));
insert_from_string (str, 0, 0,
SCHARS (str), SBYTES (str), 0);
***************
*** 6115,6120 ****
--- 6135,6141 ----
struct buffer *cur = current_buffer;
Lisp_Object old_deactivate_mark, old_last_coding_system_used;
Lisp_Object args[3];
+ Lisp_Object buffer_to_kill;
/* It is not crucial to specbind this. */
old_deactivate_mark = Vdeactivate_mark;
***************
*** 6124,6130 ****
/* We must insert the contents of STR as is without
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
! set_conversion_work_buffer (coding->src_multibyte);
insert_1_both (*str, nchars, nbytes, 0, 0, 0);
UNGCPRO;
inhibit_pre_post_conversion = 1;
--- 6145,6151 ----
/* We must insert the contents of STR as is without
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
! buffer_to_kill = set_conversion_work_buffer (coding->src_multibyte);
insert_1_both (*str, nchars, nbytes, 0, 0, 0);
UNGCPRO;
inhibit_pre_post_conversion = 1;
***************
*** 6148,6153 ****
--- 6169,6176 ----
coding->src_multibyte
= ! NILP (current_buffer->enable_multibyte_characters);
set_buffer_internal (cur);
+ if (! NILP (buffer_to_kill))
+ Fkill_buffer (buffer_to_kill);
}