diff options
author | Karoly Lorentey <karoly@lorentey.hu> | 2007-02-24 19:26:54 +0000 |
---|---|---|
committer | Karoly Lorentey <karoly@lorentey.hu> | 2007-02-24 19:26:54 +0000 |
commit | f65f7603312547e51230192daf34349b8ac569a0 (patch) | |
tree | cbc5877854d00bbdd5ecd4906d130ab8fbb44430 /src/process.c | |
parent | 9440b75fccbf763e3fb23a31a128d97eb4debdf5 (diff) | |
parent | 735895f1fa28f88c559e73910ea0ff0bda0f228c (diff) | |
download | emacs-f65f7603312547e51230192daf34349b8ac569a0.tar.gz emacs-f65f7603312547e51230192daf34349b8ac569a0.tar.bz2 emacs-f65f7603312547e51230192daf34349b8ac569a0.zip |
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-619
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-620
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-621
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-622
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-623
Remove RCS keywords
* emacs@sv.gnu.org/emacs--devo--0--patch-624
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-625
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-626
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-627
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-628
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-629
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-630
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-631
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-632
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-633
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-634
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-635
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-636
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-637
Remove RCS keywords
* emacs@sv.gnu.org/emacs--devo--0--patch-638
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-639
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-640
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-641
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-642
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-643
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-644
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-645
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-646
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-647
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-648
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-649
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-197
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-198
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-199
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-200
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-201
Update from CVS: lisp/nnweb.el (nnweb-google-parse-1): Update parser.
* emacs@sv.gnu.org/gnus--rel--5.10--patch-202
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-596
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 91 |
1 files changed, 79 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c index 38a5c8341cf..d11a300363d 100644 --- a/src/process.c +++ b/src/process.c @@ -5665,6 +5665,83 @@ send_process (proc, buf, len, object) UNGCPRO; } +static Lisp_Object +send_process_object_unwind (buf) + Lisp_Object buf; +{ + Lisp_Object tembuf; + + if (XBUFFER (buf) == current_buffer) + return Qnil; + tembuf = Fcurrent_buffer (); + Fset_buffer (buf); + Fkill_buffer (tembuf); + return Qnil; +} + +/* Send current contents of region between START and END to PROC. + If START is a string, send it instead. + This function can evaluate Lisp code and can garbage collect. */ + +static void +send_process_object (proc, start, end) + Lisp_Object proc, start, end; +{ + int count = SPECPDL_INDEX (); + Lisp_Object object = STRINGP (start) ? start : Fcurrent_buffer (); + struct buffer *given_buffer = current_buffer; + unsigned char *buf; + int len; + + record_unwind_protect (send_process_object_unwind, Fcurrent_buffer ()); + + if (STRINGP (object) ? STRING_MULTIBYTE (object) + : ! NILP (XBUFFER (object)->enable_multibyte_characters)) + { + struct Lisp_Process *p = XPROCESS (proc); + struct coding_system *coding = proc_encode_coding_system[XINT (p->outfd)]; + + if (! EQ (coding->symbol, p->encode_coding_system)) + /* The coding system for encoding was changed to raw-text + because we sent a unibyte text previously. Now we are + sending a multibyte text, thus we must encode it by the + original coding system specified for the current process. */ + setup_coding_system (p->encode_coding_system, coding); + if (! NILP (coding->pre_write_conversion)) + { + struct gcpro gcpro1, gcpro2; + + GCPRO2 (proc, object); + call2 (coding->pre_write_conversion, start, end); + UNGCPRO; + if (given_buffer != current_buffer) + { + start = make_number (BEGV), end = make_number (ZV); + object = Fcurrent_buffer (); + } + } + } + + if (BUFFERP (object)) + { + EMACS_INT start_byte; + + if (XINT (start) < GPT && XINT (end) > GPT) + move_gap (XINT (end)); + start_byte = CHAR_TO_BYTE (XINT (start)); + buf = BYTE_POS_ADDR (start_byte); + len = CHAR_TO_BYTE (XINT (end)) - start_byte; + } + else + { + buf = SDATA (object); + len = SBYTES (object); + } + send_process (proc, buf, len, object); + + unbind_to (count, Qnil); +} + DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, 3, 3, 0, doc: /* Send current contents of region as input to PROCESS. @@ -5678,19 +5755,10 @@ Output from processes can arrive in between bunches. */) Lisp_Object process, start, end; { Lisp_Object proc; - int start1, end1; proc = get_process (process); validate_region (&start, &end); - - if (XINT (start) < GPT && XINT (end) > GPT) - move_gap (XINT (start)); - - start1 = CHAR_TO_BYTE (XINT (start)); - end1 = CHAR_TO_BYTE (XINT (end)); - send_process (proc, BYTE_POS_ADDR (start1), end1 - start1, - Fcurrent_buffer ()); - + send_process_object (proc, start, end); return Qnil; } @@ -5708,8 +5776,7 @@ Output from processes can arrive in between bunches. */) Lisp_Object proc; CHECK_STRING (string); proc = get_process (process); - send_process (proc, SDATA (string), - SBYTES (string), string); + send_process_object (proc, string, Qnil); return Qnil; } |