diff options
| author | Richard M. Stallman | 1998-01-01 02:07:14 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-01 02:07:14 +0000 |
| commit | b73ea88edf86ce4878ad3f9d27c9dc9dcac0bb59 (patch) | |
| tree | 06b9f8f7dae34689479d97aa2dc3296f4d92648b /src | |
| parent | 6ae1f27ebf96696996056691839da02e70ab8ed9 (diff) | |
| download | emacs-b73ea88edf86ce4878ad3f9d27c9dc9dcac0bb59.tar.gz emacs-b73ea88edf86ce4878ad3f9d27c9dc9dcac0bb59.zip | |
(unshow_buffer): Set PT with TEMP_SET_PT_BOTH.
(Fset_window_buffer): Use set_marker_both.
(Fselect_window, Fscroll_other_window, save_window_save): Likewise.
(Fset_window_configuration): Pass p->mark itself to Fset_marker
and set_marker_restricted_both.
(temp_output_buffer_show): Use set_marker_restricted_both.
(window_scroll): Save and restore both kinds of pointers.
(Fdelete_other_windows): Rely on vmotion to give bytepos.
Use set_marker_both. Use byte positions.
(Frecenter): Likewise.
(Fmove_to_window_line): Use set_marker_both and Fgoto_char.
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/src/window.c b/src/window.c index 52ba9b6be7f..59ca18fb66f 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -711,13 +711,15 @@ unshow_buffer (w) | |||
| 711 | register struct window *w; | 711 | register struct window *w; |
| 712 | { | 712 | { |
| 713 | Lisp_Object buf; | 713 | Lisp_Object buf; |
| 714 | struct buffer *b; | ||
| 714 | 715 | ||
| 715 | buf = w->buffer; | 716 | buf = w->buffer; |
| 716 | if (XBUFFER (buf) != XMARKER (w->pointm)->buffer) | 717 | b = XBUFFER (buf); |
| 718 | if (b != XMARKER (w->pointm)->buffer) | ||
| 717 | abort (); | 719 | abort (); |
| 718 | 720 | ||
| 719 | if (w == XWINDOW (XBUFFER (buf)->last_selected_window)) | 721 | if (w == XWINDOW (b->last_selected_window)) |
| 720 | XBUFFER (buf)->last_selected_window = Qnil; | 722 | b->last_selected_window = Qnil; |
| 721 | 723 | ||
| 722 | #if 0 | 724 | #if 0 |
| 723 | if (w == XWINDOW (selected_window) | 725 | if (w == XWINDOW (selected_window) |
| @@ -732,16 +734,19 @@ unshow_buffer (w) | |||
| 732 | selected window, while last_window_start reflects another | 734 | selected window, while last_window_start reflects another |
| 733 | window which was recently showing the same buffer. | 735 | window which was recently showing the same buffer. |
| 734 | Some people might say that might be a good thing. Let's see. */ | 736 | Some people might say that might be a good thing. Let's see. */ |
| 735 | XBUFFER (buf)->last_window_start = marker_position (w->start); | 737 | b->last_window_start = marker_position (w->start); |
| 736 | 738 | ||
| 737 | /* Point in the selected window's buffer | 739 | /* Point in the selected window's buffer |
| 738 | is actually stored in that buffer, and the window's pointm isn't used. | 740 | is actually stored in that buffer, and the window's pointm isn't used. |
| 739 | So don't clobber point in that buffer. */ | 741 | So don't clobber point in that buffer. */ |
| 740 | if (! EQ (buf, XWINDOW (selected_window)->buffer)) | 742 | if (! EQ (buf, XWINDOW (selected_window)->buffer)) |
| 741 | BUF_PT (XBUFFER (buf)) | 743 | temp_set_point_both (b, |
| 742 | = clip_to_bounds (BUF_BEGV (XBUFFER (buf)), | 744 | clip_to_bounds (BUF_BEGV (b), |
| 743 | marker_position (w->pointm), | 745 | XMARKER (w->pointm)->charpos, |
| 744 | BUF_ZV (XBUFFER (buf))); | 746 | BUF_ZV (b)), |
| 747 | clip_to_bounds (BUF_BEGV_BYTE (b), | ||
| 748 | marker_byte_position (w->pointm), | ||
| 749 | BUF_ZV_BYTE (b))); | ||
| 745 | } | 750 | } |
| 746 | 751 | ||
| 747 | /* Put replacement into the window structure in place of old. */ | 752 | /* Put replacement into the window structure in place of old. */ |
| @@ -1595,9 +1600,9 @@ value is reasonable when this function is called.") | |||
| 1595 | have unwanted side effects due to text properties. */ | 1600 | have unwanted side effects due to text properties. */ |
| 1596 | pos = *vmotion (startpos, -top, w); | 1601 | pos = *vmotion (startpos, -top, w); |
| 1597 | 1602 | ||
| 1598 | Fset_marker (w->start, make_number (pos.bufpos), w->buffer); | 1603 | set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); |
| 1599 | w->start_at_line_beg = ((pos.bufpos == BEGV | 1604 | w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE |
| 1600 | || FETCH_BYTE (pos.bufpos - 1) == '\n') ? Qt | 1605 | || FETCH_BYTE (pos.bytepos - 1) == '\n') ? Qt |
| 1601 | : Qnil); | 1606 | : Qnil); |
| 1602 | /* We need to do this, so that the window-scroll-functions | 1607 | /* We need to do this, so that the window-scroll-functions |
| 1603 | get called. */ | 1608 | get called. */ |
| @@ -1900,9 +1905,8 @@ BUFFER can be a buffer or buffer name.") | |||
| 1900 | XSETFASTINT (w->window_end_pos, 0); | 1905 | XSETFASTINT (w->window_end_pos, 0); |
| 1901 | w->window_end_valid = Qnil; | 1906 | w->window_end_valid = Qnil; |
| 1902 | XSETFASTINT (w->hscroll, 0); | 1907 | XSETFASTINT (w->hscroll, 0); |
| 1903 | Fset_marker (w->pointm, | 1908 | set_marker_both (w->pointm, buffer, |
| 1904 | make_number (BUF_PT (XBUFFER (buffer))), | 1909 | BUF_PT (XBUFFER (buffer)), BUF_PT_BYTE (XBUFFER (buffer))); |
| 1905 | buffer); | ||
| 1906 | set_marker_restricted (w->start, | 1910 | set_marker_restricted (w->start, |
| 1907 | make_number (XBUFFER (buffer)->last_window_start), | 1911 | make_number (XBUFFER (buffer)->last_window_start), |
| 1908 | buffer); | 1912 | buffer); |
| @@ -1959,8 +1963,9 @@ before each command.") | |||
| 1959 | if (EQ (window, selected_window)) | 1963 | if (EQ (window, selected_window)) |
| 1960 | return window; | 1964 | return window; |
| 1961 | 1965 | ||
| 1962 | Fset_marker (ow->pointm, make_number (BUF_PT (XBUFFER (ow->buffer))), | 1966 | set_marker_both (ow->pointm, ow->buffer, |
| 1963 | ow->buffer); | 1967 | BUF_PT (XBUFFER (ow->buffer)), |
| 1968 | BUF_PT_BYTE (XBUFFER (ow->buffer))); | ||
| 1964 | 1969 | ||
| 1965 | selected_window = window; | 1970 | selected_window = window; |
| 1966 | if (XFRAME (WINDOW_FRAME (w)) != selected_frame) | 1971 | if (XFRAME (WINDOW_FRAME (w)) != selected_frame) |
| @@ -2302,8 +2307,8 @@ temp_output_buffer_show (buf) | |||
| 2302 | Vminibuf_scroll_window = window; | 2307 | Vminibuf_scroll_window = window; |
| 2303 | w = XWINDOW (window); | 2308 | w = XWINDOW (window); |
| 2304 | XSETFASTINT (w->hscroll, 0); | 2309 | XSETFASTINT (w->hscroll, 0); |
| 2305 | set_marker_restricted (w->start, make_number (1), buf); | 2310 | set_marker_restricted_both (w->start, buf, 1, 1); |
| 2306 | set_marker_restricted (w->pointm, make_number (1), buf); | 2311 | set_marker_restricted_both (w->pointm, buf, 1, 1); |
| 2307 | 2312 | ||
| 2308 | /* Run temp-buffer-show-hook, with the chosen window selected. */ | 2313 | /* Run temp-buffer-show-hook, with the chosen window selected. */ |
| 2309 | if (!NILP (Vrun_hooks)) | 2314 | if (!NILP (Vrun_hooks)) |
| @@ -2761,7 +2766,8 @@ window_scroll (window, n, whole, noerror) | |||
| 2761 | { | 2766 | { |
| 2762 | register struct window *w = XWINDOW (window); | 2767 | register struct window *w = XWINDOW (window); |
| 2763 | register int opoint = PT; | 2768 | register int opoint = PT; |
| 2764 | register int pos; | 2769 | register int opoint_byte = PT; |
| 2770 | register int pos, pos_byte; | ||
| 2765 | register int ht = window_internal_height (w); | 2771 | register int ht = window_internal_height (w); |
| 2766 | register Lisp_Object tem; | 2772 | register Lisp_Object tem; |
| 2767 | int lose; | 2773 | int lose; |
| @@ -2791,8 +2797,9 @@ window_scroll (window, n, whole, noerror) | |||
| 2791 | lose = n < 0 && PT == BEGV; | 2797 | lose = n < 0 && PT == BEGV; |
| 2792 | Fvertical_motion (make_number (n), window); | 2798 | Fvertical_motion (make_number (n), window); |
| 2793 | pos = PT; | 2799 | pos = PT; |
| 2800 | pos_byte = PT_BYTE; | ||
| 2794 | bolp = Fbolp (); | 2801 | bolp = Fbolp (); |
| 2795 | SET_PT (opoint); | 2802 | SET_PT_BOTH (opoint, opoint_byte); |
| 2796 | 2803 | ||
| 2797 | if (lose) | 2804 | if (lose) |
| 2798 | { | 2805 | { |
| @@ -2813,7 +2820,7 @@ window_scroll (window, n, whole, noerror) | |||
| 2813 | if (XINT (w->height) < 4 * scroll_margin) | 2820 | if (XINT (w->height) < 4 * scroll_margin) |
| 2814 | this_scroll_margin = XINT (w->height) / 4; | 2821 | this_scroll_margin = XINT (w->height) / 4; |
| 2815 | 2822 | ||
| 2816 | set_marker_restricted (w->start, make_number (pos), w->buffer); | 2823 | set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); |
| 2817 | w->start_at_line_beg = bolp; | 2824 | w->start_at_line_beg = bolp; |
| 2818 | w->update_mode_line = Qt; | 2825 | w->update_mode_line = Qt; |
| 2819 | XSETFASTINT (w->last_modified, 0); | 2826 | XSETFASTINT (w->last_modified, 0); |
| @@ -2824,7 +2831,7 @@ window_scroll (window, n, whole, noerror) | |||
| 2824 | 2831 | ||
| 2825 | if (whole && scroll_preserve_screen_position) | 2832 | if (whole && scroll_preserve_screen_position) |
| 2826 | { | 2833 | { |
| 2827 | SET_PT (pos); | 2834 | SET_PT_BOTH (pos, pos_byte); |
| 2828 | Fvertical_motion (make_number (original_vpos), window); | 2835 | Fvertical_motion (make_number (original_vpos), window); |
| 2829 | } | 2836 | } |
| 2830 | /* If we scrolled forward, put point enough lines down | 2837 | /* If we scrolled forward, put point enough lines down |
| @@ -2835,7 +2842,7 @@ window_scroll (window, n, whole, noerror) | |||
| 2835 | 2842 | ||
| 2836 | if (this_scroll_margin > 0) | 2843 | if (this_scroll_margin > 0) |
| 2837 | { | 2844 | { |
| 2838 | SET_PT (pos); | 2845 | SET_PT_BOTH (pos, pos_byte); |
| 2839 | Fvertical_motion (make_number (this_scroll_margin), window); | 2846 | Fvertical_motion (make_number (this_scroll_margin), window); |
| 2840 | top_margin = PT; | 2847 | top_margin = PT; |
| 2841 | } | 2848 | } |
| @@ -2843,10 +2850,10 @@ window_scroll (window, n, whole, noerror) | |||
| 2843 | top_margin = pos; | 2850 | top_margin = pos; |
| 2844 | 2851 | ||
| 2845 | if (top_margin <= opoint) | 2852 | if (top_margin <= opoint) |
| 2846 | SET_PT (opoint); | 2853 | SET_PT_BOTH (opoint, opoint_byte); |
| 2847 | else if (scroll_preserve_screen_position) | 2854 | else if (scroll_preserve_screen_position) |
| 2848 | { | 2855 | { |
| 2849 | SET_PT (pos); | 2856 | SET_PT_BOTH (pos, pos_byte); |
| 2850 | Fvertical_motion (make_number (original_vpos), window); | 2857 | Fvertical_motion (make_number (original_vpos), window); |
| 2851 | } | 2858 | } |
| 2852 | else | 2859 | else |
| @@ -2858,7 +2865,7 @@ window_scroll (window, n, whole, noerror) | |||
| 2858 | 2865 | ||
| 2859 | /* If we scrolled backward, put point near the end of the window | 2866 | /* If we scrolled backward, put point near the end of the window |
| 2860 | but not within the scroll margin. */ | 2867 | but not within the scroll margin. */ |
| 2861 | SET_PT (pos); | 2868 | SET_PT_BOTH (pos, pos_byte); |
| 2862 | tem = Fvertical_motion (make_number (ht - this_scroll_margin), window); | 2869 | tem = Fvertical_motion (make_number (ht - this_scroll_margin), window); |
| 2863 | if (XFASTINT (tem) == ht - this_scroll_margin) | 2870 | if (XFASTINT (tem) == ht - this_scroll_margin) |
| 2864 | bottom_margin = PT; | 2871 | bottom_margin = PT; |
| @@ -2866,12 +2873,12 @@ window_scroll (window, n, whole, noerror) | |||
| 2866 | bottom_margin = PT + 1; | 2873 | bottom_margin = PT + 1; |
| 2867 | 2874 | ||
| 2868 | if (bottom_margin > opoint) | 2875 | if (bottom_margin > opoint) |
| 2869 | SET_PT (opoint); | 2876 | SET_PT_BOTH (opoint, opoint_byte); |
| 2870 | else | 2877 | else |
| 2871 | { | 2878 | { |
| 2872 | if (scroll_preserve_screen_position) | 2879 | if (scroll_preserve_screen_position) |
| 2873 | { | 2880 | { |
| 2874 | SET_PT (pos); | 2881 | SET_PT_BOTH (pos, pos_byte); |
| 2875 | Fvertical_motion (make_number (original_vpos), window); | 2882 | Fvertical_motion (make_number (original_vpos), window); |
| 2876 | } | 2883 | } |
| 2877 | else | 2884 | else |
| @@ -3032,7 +3039,7 @@ showing that buffer, popping the buffer up if necessary.") | |||
| 3032 | window_scroll (window, XINT (arg), 0, 1); | 3039 | window_scroll (window, XINT (arg), 0, 1); |
| 3033 | } | 3040 | } |
| 3034 | 3041 | ||
| 3035 | Fset_marker (w->pointm, make_number (PT), Qnil); | 3042 | set_marker_both (w->pointm, Qnil, PT, PT_BYTE); |
| 3036 | unbind_to (count, Qnil); | 3043 | unbind_to (count, Qnil); |
| 3037 | 3044 | ||
| 3038 | return Qnil; | 3045 | return Qnil; |
| @@ -3108,9 +3115,9 @@ redraws with point in the center of the current window.") | |||
| 3108 | 3115 | ||
| 3109 | pos = *vmotion (PT, - XINT (arg), w); | 3116 | pos = *vmotion (PT, - XINT (arg), w); |
| 3110 | 3117 | ||
| 3111 | Fset_marker (w->start, make_number (pos.bufpos), w->buffer); | 3118 | set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); |
| 3112 | w->start_at_line_beg = ((pos.bufpos == BEGV | 3119 | w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE |
| 3113 | || FETCH_BYTE (pos.bufpos - 1) == '\n') | 3120 | || FETCH_BYTE (pos.bytepos - 1) == '\n') |
| 3114 | ? Qt : Qnil); | 3121 | ? Qt : Qnil); |
| 3115 | w->force_start = Qt; | 3122 | w->force_start = Qt; |
| 3116 | 3123 | ||
| @@ -3145,12 +3152,12 @@ negative means relative to bottom of window.") | |||
| 3145 | if (start < BEGV || start > ZV) | 3152 | if (start < BEGV || start > ZV) |
| 3146 | { | 3153 | { |
| 3147 | Fvertical_motion (make_number (- (height / 2)), window); | 3154 | Fvertical_motion (make_number (- (height / 2)), window); |
| 3148 | Fset_marker (w->start, make_number (PT), w->buffer); | 3155 | set_marker_both (w->start, w->buffer, PT, PT_BYTE); |
| 3149 | w->start_at_line_beg = Fbolp (); | 3156 | w->start_at_line_beg = Fbolp (); |
| 3150 | w->force_start = Qt; | 3157 | w->force_start = Qt; |
| 3151 | } | 3158 | } |
| 3152 | else | 3159 | else |
| 3153 | SET_PT (start); | 3160 | Fgoto_char (w->start); |
| 3154 | 3161 | ||
| 3155 | return Fvertical_motion (arg, window); | 3162 | return Fvertical_motion (arg, window); |
| 3156 | } | 3163 | } |
| @@ -3344,14 +3351,10 @@ by `current-window-configuration' (which see).") | |||
| 3344 | { | 3351 | { |
| 3345 | w->buffer = p->buffer; | 3352 | w->buffer = p->buffer; |
| 3346 | w->start_at_line_beg = p->start_at_line_beg; | 3353 | w->start_at_line_beg = p->start_at_line_beg; |
| 3347 | set_marker_restricted (w->start, | 3354 | set_marker_restricted (w->start, p->start, w->buffer); |
| 3348 | Fmarker_position (p->start), | 3355 | set_marker_restricted (w->pointm, p->pointm, w->buffer); |
| 3349 | w->buffer); | ||
| 3350 | set_marker_restricted (w->pointm, | ||
| 3351 | Fmarker_position (p->pointm), | ||
| 3352 | w->buffer); | ||
| 3353 | Fset_marker (XBUFFER (w->buffer)->mark, | 3356 | Fset_marker (XBUFFER (w->buffer)->mark, |
| 3354 | Fmarker_position (p->mark), w->buffer); | 3357 | p->mark, w->buffer); |
| 3355 | 3358 | ||
| 3356 | /* As documented in Fcurrent_window_configuration, don't | 3359 | /* As documented in Fcurrent_window_configuration, don't |
| 3357 | save the location of point in the buffer which was current | 3360 | save the location of point in the buffer which was current |
| @@ -3379,10 +3382,9 @@ by `current-window-configuration' (which see).") | |||
| 3379 | set_marker_restricted (w->start, make_number (0), | 3382 | set_marker_restricted (w->start, make_number (0), |
| 3380 | w->buffer); | 3383 | w->buffer); |
| 3381 | if (XMARKER (w->pointm)->buffer == 0) | 3384 | if (XMARKER (w->pointm)->buffer == 0) |
| 3382 | set_marker_restricted (w->pointm, | 3385 | set_marker_restricted_both (w->pointm, w->buffer, |
| 3383 | (make_number | 3386 | BUF_PT (XBUFFER (w->buffer)), |
| 3384 | (BUF_PT (XBUFFER (w->buffer)))), | 3387 | BUF_PT_BYTE (XBUFFER (w->buffer))); |
| 3385 | w->buffer); | ||
| 3386 | w->start_at_line_beg = Qt; | 3388 | w->start_at_line_beg = Qt; |
| 3387 | } | 3389 | } |
| 3388 | } | 3390 | } |
| @@ -3524,9 +3526,9 @@ save_window_save (window, vector, i) | |||
| 3524 | if (EQ (window, selected_window)) | 3526 | if (EQ (window, selected_window)) |
| 3525 | { | 3527 | { |
| 3526 | p->pointm = Fmake_marker (); | 3528 | p->pointm = Fmake_marker (); |
| 3527 | Fset_marker (p->pointm, | 3529 | set_marker_both (p->pointm, w->buffer, |
| 3528 | make_number (BUF_PT (XBUFFER (w->buffer))), | 3530 | BUF_PT (XBUFFER (w->buffer)), |
| 3529 | w->buffer); | 3531 | BUF_PT_BYTE (XBUFFER (w->buffer))); |
| 3530 | } | 3532 | } |
| 3531 | else | 3533 | else |
| 3532 | p->pointm = Fcopy_marker (w->pointm, Qnil); | 3534 | p->pointm = Fcopy_marker (w->pointm, Qnil); |