diff options
author | Dmitry Antipov <[email protected]> | 2013-03-07 08:42:59 +0400 |
---|---|---|
committer | Dmitry Antipov <[email protected]> | 2013-03-07 08:42:59 +0400 |
commit | c54aa1668ec5c2626b3f9a84513b00d90dcf24c1 (patch) | |
tree | 0277b558a7de2dece38c62056884d4bfdec8b2b3 /src/window.c | |
parent | 3de717bdb483f7c6e23cd7701ee4ebd77eccb8b9 (diff) |
Avoid character to byte conversions in motion subroutines.
* indent.h (compute_motion, vmotion): Add byte position argument.
* indent.c (compute_motion): Use it and avoid CHAR_TO_BYTE.
Add eassert.
(Fcompute_motion): Break long line. Adjust call to compute_motion.
Use list5 for return value.
(vmotion): Use byte position argument and avoid call to CHAR_TO_BYTE.
Adjust comments, style and calls to compute_motion.
(Fvertical_motion): Adjust call to vmotion.
* window.c (Fdelete_other_windows_internal): Record window start
byte position and adjust call to vmotion.
(window_scroll_line_based): Likewise with call to compute_motion.
Use SET_PT_BOTH.
(Frecenter): Adjust calls to vmotion.
Diffstat (limited to 'src/window.c')
-rw-r--r-- | src/window.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/window.c b/src/window.c index ed0c1283ab..7769613151 100644 --- a/src/window.c +++ b/src/window.c @@ -2743,7 +2743,7 @@ window-start value is reasonable when this function is called. */) struct window *w, *r, *s; struct frame *f; Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; - ptrdiff_t startpos IF_LINT (= 0); + ptrdiff_t startpos IF_LINT (= 0), startbyte IF_LINT (= 0); int top IF_LINT (= 0), new_top, resize_failed; w = decode_valid_window (window); @@ -2782,6 +2782,7 @@ window-start value is reasonable when this function is called. */) if (!NILP (w->buffer)) { startpos = marker_position (w->start); + startbyte = marker_byte_position (w->start); top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); /* Make sure WINDOW is the frame's selected window. */ @@ -2951,7 +2952,7 @@ window-start value is reasonable when this function is called. */) Fset_buffer (w->buffer); /* This computation used to temporarily move point, but that can have unwanted side effects due to text properties. */ - pos = *vmotion (startpos, -top, w); + pos = *vmotion (startpos, startbyte, -top, w); set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); w->window_end_valid = 0; @@ -4748,7 +4749,8 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) register Lisp_Object tem; int lose; Lisp_Object bolp; - ptrdiff_t startpos; + ptrdiff_t startpos = marker_position (w->start); + ptrdiff_t startbyte = marker_byte_position (w->start); Lisp_Object original_pos = Qnil; /* If scrolling screen-fulls, compute the number of lines to @@ -4756,8 +4758,6 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) if (whole) n *= max (1, ht - next_screen_context_lines); - startpos = marker_position (w->start); - if (!NILP (Vscroll_preserve_screen_position)) { if (window_scroll_preserve_vpos <= 0 @@ -4765,10 +4765,8 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) || NILP (Fget (KVAR (current_kboard, Vlast_command), Qscroll_command))) { struct position posit - = *compute_motion (startpos, 0, 0, 0, - PT, ht, 0, - -1, w->hscroll, - 0, w); + = *compute_motion (startpos, startbyte, 0, 0, 0, + PT, ht, 0, -1, w->hscroll, 0, w); window_scroll_preserve_vpos = posit.vpos; window_scroll_preserve_hpos = posit.hpos + w->hscroll; } @@ -4784,9 +4782,10 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) { Fvertical_motion (make_number (- (ht / 2)), window); startpos = PT; + startbyte = PT_BYTE; } - SET_PT (startpos); + SET_PT_BOTH (startpos, startbyte); lose = n < 0 && PT == BEGV; Fvertical_motion (make_number (n), window); pos = PT; @@ -5321,7 +5320,7 @@ and redisplay normally--don't erase and redraw the frame. */) iarg = max (iarg, this_scroll_margin); - pos = *vmotion (PT, -iarg, w); + pos = *vmotion (PT, PT_BYTE, -iarg, w); charpos = pos.bufpos; bytepos = pos.bytepos; } @@ -5340,7 +5339,7 @@ and redisplay normally--don't erase and redraw the frame. */) iarg = clip_to_bounds (this_scroll_margin, iarg, ht - this_scroll_margin - 1); - pos = *vmotion (PT, - iarg, w); + pos = *vmotion (PT, PT_BYTE, - iarg, w); charpos = pos.bufpos; bytepos = pos.bytepos; } |