diff options
| author | Miles Bader | 2007-02-26 23:03:45 +0000 |
|---|---|---|
| committer | Miles Bader | 2007-02-26 23:03:45 +0000 |
| commit | a73d7753f965734247be482efa125da5235996da (patch) | |
| tree | 56af26fb1a12a2c93c146aac923947968c4c9d76 /src/process.c | |
| parent | 55a5664de23c07003d4d2584fc065619609500b6 (diff) | |
| parent | f6f3d0b9133d06b29523c7bc744130cddc5c8d6b (diff) | |
| download | emacs-a73d7753f965734247be482efa125da5235996da.tar.gz emacs-a73d7753f965734247be482efa125da5235996da.zip | |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 638-652)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 202)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-177
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 4611ce2c05c..27dc9f19e56 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -5641,6 +5641,83 @@ send_process (proc, buf, len, object) | |||
| 5641 | UNGCPRO; | 5641 | UNGCPRO; |
| 5642 | } | 5642 | } |
| 5643 | 5643 | ||
| 5644 | static Lisp_Object | ||
| 5645 | send_process_object_unwind (buf) | ||
| 5646 | Lisp_Object buf; | ||
| 5647 | { | ||
| 5648 | Lisp_Object tembuf; | ||
| 5649 | |||
| 5650 | if (XBUFFER (buf) == current_buffer) | ||
| 5651 | return Qnil; | ||
| 5652 | tembuf = Fcurrent_buffer (); | ||
| 5653 | Fset_buffer (buf); | ||
| 5654 | Fkill_buffer (tembuf); | ||
| 5655 | return Qnil; | ||
| 5656 | } | ||
| 5657 | |||
| 5658 | /* Send current contents of region between START and END to PROC. | ||
| 5659 | If START is a string, send it instead. | ||
| 5660 | This function can evaluate Lisp code and can garbage collect. */ | ||
| 5661 | |||
| 5662 | static void | ||
| 5663 | send_process_object (proc, start, end) | ||
| 5664 | Lisp_Object proc, start, end; | ||
| 5665 | { | ||
| 5666 | int count = SPECPDL_INDEX (); | ||
| 5667 | Lisp_Object object = STRINGP (start) ? start : Fcurrent_buffer (); | ||
| 5668 | struct buffer *given_buffer = current_buffer; | ||
| 5669 | unsigned char *buf; | ||
| 5670 | int len; | ||
| 5671 | |||
| 5672 | record_unwind_protect (send_process_object_unwind, Fcurrent_buffer ()); | ||
| 5673 | |||
| 5674 | if (STRINGP (object) ? STRING_MULTIBYTE (object) | ||
| 5675 | : ! NILP (XBUFFER (object)->enable_multibyte_characters)) | ||
| 5676 | { | ||
| 5677 | struct Lisp_Process *p = XPROCESS (proc); | ||
| 5678 | struct coding_system *coding = proc_encode_coding_system[XINT (p->outfd)]; | ||
| 5679 | |||
| 5680 | if (! EQ (coding->symbol, p->encode_coding_system)) | ||
| 5681 | /* The coding system for encoding was changed to raw-text | ||
| 5682 | because we sent a unibyte text previously. Now we are | ||
| 5683 | sending a multibyte text, thus we must encode it by the | ||
| 5684 | original coding system specified for the current process. */ | ||
| 5685 | setup_coding_system (p->encode_coding_system, coding); | ||
| 5686 | if (! NILP (coding->pre_write_conversion)) | ||
| 5687 | { | ||
| 5688 | struct gcpro gcpro1, gcpro2; | ||
| 5689 | |||
| 5690 | GCPRO2 (proc, object); | ||
| 5691 | call2 (coding->pre_write_conversion, start, end); | ||
| 5692 | UNGCPRO; | ||
| 5693 | if (given_buffer != current_buffer) | ||
| 5694 | { | ||
| 5695 | start = make_number (BEGV), end = make_number (ZV); | ||
| 5696 | object = Fcurrent_buffer (); | ||
| 5697 | } | ||
| 5698 | } | ||
| 5699 | } | ||
| 5700 | |||
| 5701 | if (BUFFERP (object)) | ||
| 5702 | { | ||
| 5703 | EMACS_INT start_byte; | ||
| 5704 | |||
| 5705 | if (XINT (start) < GPT && XINT (end) > GPT) | ||
| 5706 | move_gap (XINT (end)); | ||
| 5707 | start_byte = CHAR_TO_BYTE (XINT (start)); | ||
| 5708 | buf = BYTE_POS_ADDR (start_byte); | ||
| 5709 | len = CHAR_TO_BYTE (XINT (end)) - start_byte; | ||
| 5710 | } | ||
| 5711 | else | ||
| 5712 | { | ||
| 5713 | buf = SDATA (object); | ||
| 5714 | len = SBYTES (object); | ||
| 5715 | } | ||
| 5716 | send_process (proc, buf, len, object); | ||
| 5717 | |||
| 5718 | unbind_to (count, Qnil); | ||
| 5719 | } | ||
| 5720 | |||
| 5644 | DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, | 5721 | DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, |
| 5645 | 3, 3, 0, | 5722 | 3, 3, 0, |
| 5646 | doc: /* Send current contents of region as input to PROCESS. | 5723 | doc: /* Send current contents of region as input to PROCESS. |
| @@ -5654,19 +5731,10 @@ Output from processes can arrive in between bunches. */) | |||
| 5654 | Lisp_Object process, start, end; | 5731 | Lisp_Object process, start, end; |
| 5655 | { | 5732 | { |
| 5656 | Lisp_Object proc; | 5733 | Lisp_Object proc; |
| 5657 | int start1, end1; | ||
| 5658 | 5734 | ||
| 5659 | proc = get_process (process); | 5735 | proc = get_process (process); |
| 5660 | validate_region (&start, &end); | 5736 | validate_region (&start, &end); |
| 5661 | 5737 | send_process_object (proc, start, end); | |
| 5662 | if (XINT (start) < GPT && XINT (end) > GPT) | ||
| 5663 | move_gap (XINT (start)); | ||
| 5664 | |||
| 5665 | start1 = CHAR_TO_BYTE (XINT (start)); | ||
| 5666 | end1 = CHAR_TO_BYTE (XINT (end)); | ||
| 5667 | send_process (proc, BYTE_POS_ADDR (start1), end1 - start1, | ||
| 5668 | Fcurrent_buffer ()); | ||
| 5669 | |||
| 5670 | return Qnil; | 5738 | return Qnil; |
| 5671 | } | 5739 | } |
| 5672 | 5740 | ||
| @@ -5684,8 +5752,7 @@ Output from processes can arrive in between bunches. */) | |||
| 5684 | Lisp_Object proc; | 5752 | Lisp_Object proc; |
| 5685 | CHECK_STRING (string); | 5753 | CHECK_STRING (string); |
| 5686 | proc = get_process (process); | 5754 | proc = get_process (process); |
| 5687 | send_process (proc, SDATA (string), | 5755 | send_process_object (proc, string, Qnil); |
| 5688 | SBYTES (string), string); | ||
| 5689 | return Qnil; | 5756 | return Qnil; |
| 5690 | } | 5757 | } |
| 5691 | 5758 | ||