comparison src/process.c @ 17604:77b137e2d9a7

(read_process_output): Update opoint, old_begv and old_zv based on actual buffer change rather than size of string. old_begv and old_zv are now ints. (status_notify): Likewise for opoint.
author Richard M. Stallman <rms@gnu.org>
date Wed, 30 Apr 1997 18:34:17 +0000
parents 351006378b51
children dc9d056f204f
comparison
equal deleted inserted replaced
17603:892cc20c7d91 17604:77b137e2d9a7
2793 2793
2794 /* If no filter, write into buffer if it isn't dead. */ 2794 /* If no filter, write into buffer if it isn't dead. */
2795 if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) 2795 if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
2796 { 2796 {
2797 Lisp_Object old_read_only; 2797 Lisp_Object old_read_only;
2798 Lisp_Object old_begv, old_zv; 2798 int old_begv, old_zv;
2799 Lisp_Object odeactivate; 2799 Lisp_Object odeactivate;
2800 int before;
2800 2801
2801 odeactivate = Vdeactivate_mark; 2802 odeactivate = Vdeactivate_mark;
2802 2803
2803 Fset_buffer (p->buffer); 2804 Fset_buffer (p->buffer);
2804 opoint = PT; 2805 opoint = PT;
2805 old_read_only = current_buffer->read_only; 2806 old_read_only = current_buffer->read_only;
2806 XSETFASTINT (old_begv, BEGV); 2807 old_begv = BEGV;
2807 XSETFASTINT (old_zv, ZV); 2808 old_zv = ZV;
2808 2809
2809 current_buffer->read_only = Qnil; 2810 current_buffer->read_only = Qnil;
2810 2811
2811 /* Insert new output into buffer 2812 /* Insert new output into buffer
2812 at the current end-of-output marker, 2813 at the current end-of-output marker,
2813 thus preserving logical ordering of input and output. */ 2814 thus preserving logical ordering of input and output. */
2814 if (XMARKER (p->mark)->buffer) 2815 if (XMARKER (p->mark)->buffer)
2815 SET_PT (clip_to_bounds (BEGV, marker_position (p->mark), ZV)); 2816 SET_PT (clip_to_bounds (BEGV, marker_position (p->mark), ZV));
2816 else 2817 else
2817 SET_PT (ZV); 2818 SET_PT (ZV);
2819 before = PT;
2818 2820
2819 /* If the output marker is outside of the visible region, save 2821 /* If the output marker is outside of the visible region, save
2820 the restriction and widen. */ 2822 the restriction and widen. */
2821 if (! (BEGV <= PT && PT <= ZV)) 2823 if (! (BEGV <= PT && PT <= ZV))
2822 Fwiden (); 2824 Fwiden ();
2823
2824 /* Make sure opoint floats ahead of any new text, just as point
2825 would. */
2826 if (PT <= opoint)
2827 opoint += nchars;
2828
2829 /* Insert after old_begv, but before old_zv. */
2830 if (PT < XFASTINT (old_begv))
2831 XSETFASTINT (old_begv, XFASTINT (old_begv) + nchars);
2832 if (PT <= XFASTINT (old_zv))
2833 XSETFASTINT (old_zv, XFASTINT (old_zv) + nchars);
2834 2825
2835 /* Insert before markers in case we are inserting where 2826 /* Insert before markers in case we are inserting where
2836 the buffer's mark is, and the user's next command is Meta-y. */ 2827 the buffer's mark is, and the user's next command is Meta-y. */
2837 if (chars_in_decoding_buf) 2828 if (chars_in_decoding_buf)
2838 insert_from_string_before_markers (p->decoding_buf, 0, nchars, 0); 2829 insert_from_string_before_markers (p->decoding_buf, 0, nchars, 0);
2840 insert_before_markers (chars, nchars); 2831 insert_before_markers (chars, nchars);
2841 Fset_marker (p->mark, make_number (PT), p->buffer); 2832 Fset_marker (p->mark, make_number (PT), p->buffer);
2842 2833
2843 update_mode_lines++; 2834 update_mode_lines++;
2844 2835
2836 /* Make sure opoint and the old restrictions
2837 float ahead of any new text just as point would. */
2838 if (opoint >= before)
2839 opoint += PT - before;
2840 if (old_begv > before)
2841 old_begv += PT - before;
2842 if (old_zv >= before)
2843 old_zv += PT - before;
2844
2845 /* If the restriction isn't what it should be, set it. */ 2845 /* If the restriction isn't what it should be, set it. */
2846 if (XFASTINT (old_begv) != BEGV || XFASTINT (old_zv) != ZV) 2846 if (old_begv != BEGV || old_zv != ZV)
2847 Fnarrow_to_region (old_begv, old_zv); 2847 Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
2848 2848
2849 /* Handling the process output should not deactivate the mark. */ 2849 /* Handling the process output should not deactivate the mark. */
2850 Vdeactivate_mark = odeactivate; 2850 Vdeactivate_mark = odeactivate;
2851 2851
2852 current_buffer->read_only = old_read_only; 2852 current_buffer->read_only = old_read_only;
3950 else if (!EQ (symbol, Qrun) && !NILP (buffer)) 3950 else if (!EQ (symbol, Qrun) && !NILP (buffer))
3951 { 3951 {
3952 Lisp_Object ro, tem; 3952 Lisp_Object ro, tem;
3953 struct buffer *old = current_buffer; 3953 struct buffer *old = current_buffer;
3954 int opoint; 3954 int opoint;
3955 int before;
3955 3956
3956 ro = XBUFFER (buffer)->read_only; 3957 ro = XBUFFER (buffer)->read_only;
3957 3958
3958 /* Avoid error if buffer is deleted 3959 /* Avoid error if buffer is deleted
3959 (probably that's why the process is dead, too) */ 3960 (probably that's why the process is dead, too) */
3960 if (NILP (XBUFFER (buffer)->name)) 3961 if (NILP (XBUFFER (buffer)->name))
3961 continue; 3962 continue;
3962 Fset_buffer (buffer); 3963 Fset_buffer (buffer);
3964
3963 opoint = PT; 3965 opoint = PT;
3964 /* Insert new output into buffer 3966 /* Insert new output into buffer
3965 at the current end-of-output marker, 3967 at the current end-of-output marker,
3966 thus preserving logical ordering of input and output. */ 3968 thus preserving logical ordering of input and output. */
3967 if (XMARKER (p->mark)->buffer) 3969 if (XMARKER (p->mark)->buffer)
3968 SET_PT (marker_position (p->mark)); 3970 SET_PT (marker_position (p->mark));
3969 else 3971 else
3970 SET_PT (ZV); 3972 SET_PT (ZV);
3971 if (PT <= opoint) 3973
3972 opoint += XSTRING (msg)->size + XSTRING (p->name)->size + 10; 3974 before = PT;
3973 3975
3974 tem = current_buffer->read_only; 3976 tem = current_buffer->read_only;
3975 current_buffer->read_only = Qnil; 3977 current_buffer->read_only = Qnil;
3976 insert_string ("\nProcess "); 3978 insert_string ("\nProcess ");
3977 Finsert (1, &p->name); 3979 Finsert (1, &p->name);
3978 insert_string (" "); 3980 insert_string (" ");
3979 Finsert (1, &msg); 3981 Finsert (1, &msg);
3980 current_buffer->read_only = tem; 3982 current_buffer->read_only = tem;
3981 Fset_marker (p->mark, make_number (PT), p->buffer); 3983 Fset_marker (p->mark, make_number (PT), p->buffer);
3982 3984
3983 SET_PT (opoint); 3985 if (opoint >= before)
3986 SET_PT (opoint + (PT - before));
3987 else
3988 SET_PT (opoint);
3989
3984 set_buffer_internal (old); 3990 set_buffer_internal (old);
3985 } 3991 }
3986 } 3992 }
3987 } /* end for */ 3993 } /* end for */
3988 3994