aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorStefan Monnier2010-04-11 11:53:13 -0400
committerStefan Monnier2010-04-11 11:53:13 -0400
commit3a4fa2f208236104db1bab0c1c76e0bffd7955c1 (patch)
tree73d7d4a9b4d43ce9ff7c0f248be31b7e23acd80d /src/process.c
parent3acb4c9315578a26d878907a61da8487246ef470 (diff)
downloademacs-3a4fa2f208236104db1bab0c1c76e0bffd7955c1.tar.gz
emacs-3a4fa2f208236104db1bab0c1c76e0bffd7955c1.zip
(read_process_output): Move the save-current-buffer to
apply to both the filter and the non-filter branches.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/process.c b/src/process.c
index 3c539024b0a..69cd0d99c8a 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5314,6 +5314,8 @@ read_process_output (proc, channel)
5314 struct coding_system *coding = proc_decode_coding_system[channel]; 5314 struct coding_system *coding = proc_decode_coding_system[channel];
5315 int carryover = p->decoding_carryover; 5315 int carryover = p->decoding_carryover;
5316 int readmax = 4096; 5316 int readmax = 4096;
5317 int count = SPECPDL_INDEX ();
5318 Lisp_Object odeactivate;
5317 5319
5318 chars = (char *) alloca (carryover + readmax); 5320 chars = (char *) alloca (carryover + readmax);
5319 if (carryover) 5321 if (carryover)
@@ -5386,15 +5388,16 @@ read_process_output (proc, channel)
5386 /* Now set NBYTES how many bytes we must decode. */ 5388 /* Now set NBYTES how many bytes we must decode. */
5387 nbytes += carryover; 5389 nbytes += carryover;
5388 5390
5391 odeactivate = Vdeactivate_mark;
5392 /* There's no good reason to let process filters change the current
5393 buffer, and many callers of accept-process-output, sit-for, and
5394 friends don't expect current-buffer to be changed from under them. */
5395 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
5396
5389 /* Read and dispose of the process output. */ 5397 /* Read and dispose of the process output. */
5390 outstream = p->filter; 5398 outstream = p->filter;
5391 if (!NILP (outstream)) 5399 if (!NILP (outstream))
5392 { 5400 {
5393 /* We inhibit quit here instead of just catching it so that
5394 hitting ^G when a filter happens to be running won't screw
5395 it up. */
5396 int count = SPECPDL_INDEX ();
5397 Lisp_Object odeactivate;
5398 Lisp_Object obuffer, okeymap; 5401 Lisp_Object obuffer, okeymap;
5399 Lisp_Object text; 5402 Lisp_Object text;
5400 int outer_running_asynch_code = running_asynch_code; 5403 int outer_running_asynch_code = running_asynch_code;
@@ -5402,10 +5405,12 @@ read_process_output (proc, channel)
5402 5405
5403 /* No need to gcpro these, because all we do with them later 5406 /* No need to gcpro these, because all we do with them later
5404 is test them for EQness, and none of them should be a string. */ 5407 is test them for EQness, and none of them should be a string. */
5405 odeactivate = Vdeactivate_mark;
5406 XSETBUFFER (obuffer, current_buffer); 5408 XSETBUFFER (obuffer, current_buffer);
5407 okeymap = current_buffer->keymap; 5409 okeymap = current_buffer->keymap;
5408 5410
5411 /* We inhibit quit here instead of just catching it so that
5412 hitting ^G when a filter happens to be running won't screw
5413 it up. */
5409 specbind (Qinhibit_quit, Qt); 5414 specbind (Qinhibit_quit, Qt);
5410 specbind (Qlast_nonmenu_event, Qt); 5415 specbind (Qlast_nonmenu_event, Qt);
5411 5416
@@ -5474,9 +5479,6 @@ read_process_output (proc, channel)
5474 restore_search_regs (); 5479 restore_search_regs ();
5475 running_asynch_code = outer_running_asynch_code; 5480 running_asynch_code = outer_running_asynch_code;
5476 5481
5477 /* Handling the process output should not deactivate the mark. */
5478 Vdeactivate_mark = odeactivate;
5479
5480 /* Restore waiting_for_user_input_p as it was 5482 /* Restore waiting_for_user_input_p as it was
5481 when we were called, in case the filter clobbered it. */ 5483 when we were called, in case the filter clobbered it. */
5482 waiting_for_user_input_p = waiting; 5484 waiting_for_user_input_p = waiting;
@@ -5492,27 +5494,19 @@ read_process_output (proc, channel)
5492 cause trouble (for example it would make sit_for return). */ 5494 cause trouble (for example it would make sit_for return). */
5493 if (waiting_for_user_input_p == -1) 5495 if (waiting_for_user_input_p == -1)
5494 record_asynch_buffer_change (); 5496 record_asynch_buffer_change ();
5495
5496 unbind_to (count, Qnil);
5497 return nbytes;
5498 } 5497 }
5499 5498
5500 /* If no filter, write into buffer if it isn't dead. */ 5499 /* If no filter, write into buffer if it isn't dead. */
5501 if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) 5500 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
5502 { 5501 {
5503 Lisp_Object old_read_only; 5502 Lisp_Object old_read_only;
5504 int old_begv, old_zv; 5503 int old_begv, old_zv;
5505 int old_begv_byte, old_zv_byte; 5504 int old_begv_byte, old_zv_byte;
5506 Lisp_Object odeactivate;
5507 int before, before_byte; 5505 int before, before_byte;
5508 int opoint_byte; 5506 int opoint_byte;
5509 Lisp_Object text; 5507 Lisp_Object text;
5510 struct buffer *b; 5508 struct buffer *b;
5511 int count = SPECPDL_INDEX ();
5512
5513 odeactivate = Vdeactivate_mark;
5514 5509
5515 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
5516 Fset_buffer (p->buffer); 5510 Fset_buffer (p->buffer);
5517 opoint = PT; 5511 opoint = PT;
5518 opoint_byte = PT_BYTE; 5512 opoint_byte = PT_BYTE;
@@ -5610,13 +5604,14 @@ read_process_output (proc, channel)
5610 if (old_begv != BEGV || old_zv != ZV) 5604 if (old_begv != BEGV || old_zv != ZV)
5611 Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); 5605 Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
5612 5606
5613 /* Handling the process output should not deactivate the mark. */
5614 Vdeactivate_mark = odeactivate;
5615 5607
5616 current_buffer->read_only = old_read_only; 5608 current_buffer->read_only = old_read_only;
5617 SET_PT_BOTH (opoint, opoint_byte); 5609 SET_PT_BOTH (opoint, opoint_byte);
5618 unbind_to (count, Qnil);
5619 } 5610 }
5611 /* Handling the process output should not deactivate the mark. */
5612 Vdeactivate_mark = odeactivate;
5613
5614 unbind_to (count, Qnil);
5620 return nbytes; 5615 return nbytes;
5621} 5616}
5622 5617