diff options
| author | Stefan Monnier | 2008-06-05 03:57:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-06-05 03:57:09 +0000 |
| commit | c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78 (patch) | |
| tree | 36b9cdbe3c2af0181b8e074c80a98e1119597f03 | |
| parent | 927abf37e2793fae653540cca8b4c324c65e448f (diff) | |
| download | emacs-c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78.tar.gz emacs-c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78.zip | |
* window.c (window_scroll_pixel_based_preserve_x)
(window_scroll_preserve_hpos, window_scroll_preserve_vpos): New vars.
(window_scroll_pixel_based, window_scroll_line_based):
Use them to preserve column positions.
(syms_of_window): Initialize them.
* indent.c (Fvertical_motion): Extend first arg to allow passing an
(HPOS . VPOS) pair.
* xdisp.c (move_it_in_display_line_to): Improve the type of its args.
(move_it_in_display_line): New wrapper.
* dispextern.h (move_it_in_display_line): Declare.
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | src/ChangeLog | 20 | ||||
| -rw-r--r-- | src/dispextern.h | 3 | ||||
| -rw-r--r-- | src/indent.c | 17 | ||||
| -rw-r--r-- | src/window.c | 57 | ||||
| -rw-r--r-- | src/xdisp.c | 20 |
6 files changed, 95 insertions, 23 deletions
| @@ -63,6 +63,7 @@ default toolkit, but you can use --with-x-toolkit=gtk if necessary. | |||
| 63 | 63 | ||
| 64 | * Changes in Emacs 23.1 | 64 | * Changes in Emacs 23.1 |
| 65 | 65 | ||
| 66 | ** scroll-preserve-screen-position also preserves the column position. | ||
| 66 | ** Completion. | 67 | ** Completion. |
| 67 | *** `completion-styles' can be customized to choose your favorite completion. | 68 | *** `completion-styles' can be customized to choose your favorite completion. |
| 68 | *** The default completion styles include a form of partial-completion. | 69 | *** The default completion styles include a form of partial-completion. |
diff --git a/src/ChangeLog b/src/ChangeLog index 48f80bf1583..9abd806ce63 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2008-06-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * xdisp.c (move_it_in_display_line_to): Improve the type of its args. | ||
| 4 | (move_it_in_display_line): New wrapper. | ||
| 5 | |||
| 6 | * window.c (window_scroll_pixel_based_preserve_x) | ||
| 7 | (window_scroll_preserve_hpos, window_scroll_preserve_vpos): New vars. | ||
| 8 | (window_scroll_pixel_based, window_scroll_line_based): | ||
| 9 | Use them to preserve column positions. | ||
| 10 | (syms_of_window): Initialize them. | ||
| 11 | |||
| 12 | * indent.c (Fvertical_motion): Extend first arg to allow passing an | ||
| 13 | (HPOS . VPOS) pair. | ||
| 14 | |||
| 15 | * dispextern.h (move_it_in_display_line): Declare. | ||
| 16 | |||
| 1 | 2008-06-05 Juanma Barranquero <lekktu@gmail.com> | 17 | 2008-06-05 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 18 | ||
| 3 | * window.c (Fwindow_parameter): Return VALUE, not (PARAMETER . VALUE). | 19 | * window.c (Fwindow_parameter): Return VALUE, not (PARAMETER . VALUE). |
| @@ -113,11 +129,11 @@ | |||
| 113 | (struct named_merge_point): Add `named_merge_point_kind' field. | 129 | (struct named_merge_point): Add `named_merge_point_kind' field. |
| 114 | (push_named_merge_point): Make cycle detection respect different | 130 | (push_named_merge_point): Make cycle detection respect different |
| 115 | named-merge-point kinds. | 131 | named-merge-point kinds. |
| 116 | (lface_from_face_name_no_resolve): Renamed from `lface_from_face_name'. | 132 | (lface_from_face_name_no_resolve): Rename from `lface_from_face_name'. |
| 117 | Remove face-name alias resolution. | 133 | Remove face-name alias resolution. |
| 118 | (lface_from_face_name): New definition using | 134 | (lface_from_face_name): New definition using |
| 119 | `lface_from_face_name_no_resolve'. | 135 | `lface_from_face_name_no_resolve'. |
| 120 | (get_lface_attributes_no_remap): Renamed from `get_lface_attributes'. | 136 | (get_lface_attributes_no_remap): Rename from `get_lface_attributes'. |
| 121 | Call lface_from_face_name_no_resolve instead of lface_from_face_name. | 137 | Call lface_from_face_name_no_resolve instead of lface_from_face_name. |
| 122 | (get_lface_attributes): New definition that layers face-remapping on | 138 | (get_lface_attributes): New definition that layers face-remapping on |
| 123 | top of get_lface_attributes_no_remap. New arg `named_merge_points'. | 139 | top of get_lface_attributes_no_remap. New arg `named_merge_points'. |
diff --git a/src/dispextern.h b/src/dispextern.h index 4a4c731748b..969f1c55021 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2685,6 +2685,9 @@ void move_it_vertically P_ ((struct it *, int)); | |||
| 2685 | void move_it_vertically_backward P_ ((struct it *, int)); | 2685 | void move_it_vertically_backward P_ ((struct it *, int)); |
| 2686 | void move_it_by_lines P_ ((struct it *, int, int)); | 2686 | void move_it_by_lines P_ ((struct it *, int, int)); |
| 2687 | void move_it_past_eol P_ ((struct it *)); | 2687 | void move_it_past_eol P_ ((struct it *)); |
| 2688 | void move_it_in_display_line (struct it *it, | ||
| 2689 | EMACS_INT to_charpos, int to_x, | ||
| 2690 | enum move_operation_enum op); | ||
| 2688 | int in_display_vector_p P_ ((struct it *)); | 2691 | int in_display_vector_p P_ ((struct it *)); |
| 2689 | int frame_mode_line_height P_ ((struct frame *)); | 2692 | int frame_mode_line_height P_ ((struct frame *)); |
| 2690 | void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *)); | 2693 | void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *)); |
diff --git a/src/indent.c b/src/indent.c index 9d69936d440..fdc042bc9e4 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1993,6 +1993,10 @@ The optional second argument WINDOW specifies the window to use for | |||
| 1993 | parameters such as width, horizontal scrolling, and so on. | 1993 | parameters such as width, horizontal scrolling, and so on. |
| 1994 | The default is to use the selected window's parameters. | 1994 | The default is to use the selected window's parameters. |
| 1995 | 1995 | ||
| 1996 | LINES can optionally take the form (COLS . LINES), in which case | ||
| 1997 | the motion will not stop at the start of a screen line but on | ||
| 1998 | its column COLS (if such exists on that line, that is). | ||
| 1999 | |||
| 1996 | `vertical-motion' always uses the current buffer, | 2000 | `vertical-motion' always uses the current buffer, |
| 1997 | regardless of which buffer is displayed in WINDOW. | 2001 | regardless of which buffer is displayed in WINDOW. |
| 1998 | This is consistent with other cursor motion functions | 2002 | This is consistent with other cursor motion functions |
| @@ -2006,6 +2010,14 @@ whether or not it is currently displayed in some window. */) | |||
| 2006 | struct window *w; | 2010 | struct window *w; |
| 2007 | Lisp_Object old_buffer; | 2011 | Lisp_Object old_buffer; |
| 2008 | struct gcpro gcpro1; | 2012 | struct gcpro gcpro1; |
| 2013 | int cols = 0; | ||
| 2014 | |||
| 2015 | /* Allow LINES to be of the form (HPOS . VPOS) aka (COLUMNS . LINES). */ | ||
| 2016 | if (CONSP (lines) && (NUMBERP (XCAR (lines)))) | ||
| 2017 | { | ||
| 2018 | cols = XINT (XCAR (lines)); | ||
| 2019 | lines = XCDR (lines); | ||
| 2020 | } | ||
| 2009 | 2021 | ||
| 2010 | CHECK_NUMBER (lines); | 2022 | CHECK_NUMBER (lines); |
| 2011 | if (! NILP (window)) | 2023 | if (! NILP (window)) |
| @@ -2094,6 +2106,11 @@ whether or not it is currently displayed in some window. */) | |||
| 2094 | if (XINT (lines) >= 0 || IT_CHARPOS (it) > 0) | 2106 | if (XINT (lines) >= 0 || IT_CHARPOS (it) > 0) |
| 2095 | move_it_by_lines (&it, XINT (lines), 0); | 2107 | move_it_by_lines (&it, XINT (lines), 0); |
| 2096 | 2108 | ||
| 2109 | if (cols) | ||
| 2110 | move_it_in_display_line (&it, ZV, | ||
| 2111 | cols * FRAME_COLUMN_WIDTH (XFRAME (w->frame)), | ||
| 2112 | MOVE_TO_X); | ||
| 2113 | |||
| 2097 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 2114 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 2098 | } | 2115 | } |
| 2099 | 2116 | ||
diff --git a/src/window.c b/src/window.c index 095e8412aa8..9385b307b9e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -224,8 +224,14 @@ int window_deletion_count; | |||
| 224 | 224 | ||
| 225 | /* Used by the function window_scroll_pixel_based */ | 225 | /* Used by the function window_scroll_pixel_based */ |
| 226 | 226 | ||
| 227 | static int window_scroll_pixel_based_preserve_x; | ||
| 227 | static int window_scroll_pixel_based_preserve_y; | 228 | static int window_scroll_pixel_based_preserve_y; |
| 228 | 229 | ||
| 230 | /* Same for window_scroll_line_based. */ | ||
| 231 | |||
| 232 | static int window_scroll_preserve_hpos; | ||
| 233 | static int window_scroll_preserve_vpos; | ||
| 234 | |||
| 229 | #if 0 /* This isn't used anywhere. */ | 235 | #if 0 /* This isn't used anywhere. */ |
| 230 | /* Nonzero means we can split a frame even if it is "unsplittable". */ | 236 | /* Nonzero means we can split a frame even if it is "unsplittable". */ |
| 231 | static int inhibit_frame_unsplittable; | 237 | static int inhibit_frame_unsplittable; |
| @@ -5216,10 +5222,12 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5216 | start_display (&it, w, start); | 5222 | start_display (&it, w, start); |
| 5217 | move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); | 5223 | move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); |
| 5218 | window_scroll_pixel_based_preserve_y = it.current_y; | 5224 | window_scroll_pixel_based_preserve_y = it.current_y; |
| 5225 | window_scroll_pixel_based_preserve_x = it.current_x; | ||
| 5219 | } | 5226 | } |
| 5220 | } | 5227 | } |
| 5221 | else | 5228 | else |
| 5222 | window_scroll_pixel_based_preserve_y = -1; | 5229 | window_scroll_pixel_based_preserve_y |
| 5230 | = window_scroll_pixel_based_preserve_x = -1; | ||
| 5223 | 5231 | ||
| 5224 | /* Move iterator it from start the specified distance forward or | 5232 | /* Move iterator it from start the specified distance forward or |
| 5225 | backward. The result is the new window start. */ | 5233 | backward. The result is the new window start. */ |
| @@ -5355,10 +5363,11 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5355 | { | 5363 | { |
| 5356 | /* If we have a header line, take account of it. | 5364 | /* If we have a header line, take account of it. |
| 5357 | This is necessary because we set it.current_y to 0, above. */ | 5365 | This is necessary because we set it.current_y to 0, above. */ |
| 5358 | move_it_to (&it, -1, -1, | 5366 | move_it_to (&it, -1, |
| 5367 | window_scroll_pixel_based_preserve_x, | ||
| 5359 | window_scroll_pixel_based_preserve_y | 5368 | window_scroll_pixel_based_preserve_y |
| 5360 | - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ), | 5369 | - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ), |
| 5361 | -1, MOVE_TO_Y); | 5370 | -1, MOVE_TO_Y | MOVE_TO_X); |
| 5362 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 5371 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 5363 | } | 5372 | } |
| 5364 | else | 5373 | else |
| @@ -5416,8 +5425,9 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5416 | /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT | 5425 | /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT |
| 5417 | here because we called start_display again and did not | 5426 | here because we called start_display again and did not |
| 5418 | alter it.current_y this time. */ | 5427 | alter it.current_y this time. */ |
| 5419 | move_it_to (&it, -1, -1, window_scroll_pixel_based_preserve_y, -1, | 5428 | move_it_to (&it, -1, window_scroll_pixel_based_preserve_x, |
| 5420 | MOVE_TO_Y); | 5429 | window_scroll_pixel_based_preserve_y, -1, |
| 5430 | MOVE_TO_Y | MOVE_TO_X); | ||
| 5421 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 5431 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 5422 | } | 5432 | } |
| 5423 | else | 5433 | else |
| @@ -5455,8 +5465,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5455 | int lose; | 5465 | int lose; |
| 5456 | Lisp_Object bolp; | 5466 | Lisp_Object bolp; |
| 5457 | int startpos; | 5467 | int startpos; |
| 5458 | struct position posit; | 5468 | Lisp_Object original_pos = Qnil; |
| 5459 | int original_vpos; | ||
| 5460 | 5469 | ||
| 5461 | /* If scrolling screen-fulls, compute the number of lines to | 5470 | /* If scrolling screen-fulls, compute the number of lines to |
| 5462 | scroll from the window's height. */ | 5471 | scroll from the window's height. */ |
| @@ -5465,11 +5474,24 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5465 | 5474 | ||
| 5466 | startpos = marker_position (w->start); | 5475 | startpos = marker_position (w->start); |
| 5467 | 5476 | ||
| 5468 | posit = *compute_motion (startpos, 0, 0, 0, | 5477 | if (!NILP (Vscroll_preserve_screen_position)) |
| 5469 | PT, ht, 0, | 5478 | { |
| 5470 | -1, XINT (w->hscroll), | 5479 | if (window_scroll_preserve_vpos <= 0 |
| 5471 | 0, w); | 5480 | || (!EQ (current_kboard->Vlast_command, Qscroll_up) |
| 5472 | original_vpos = posit.vpos; | 5481 | && !EQ (current_kboard->Vlast_command, Qscroll_down))) |
| 5482 | { | ||
| 5483 | struct position posit | ||
| 5484 | = *compute_motion (startpos, 0, 0, 0, | ||
| 5485 | PT, ht, 0, | ||
| 5486 | -1, XINT (w->hscroll), | ||
| 5487 | 0, w); | ||
| 5488 | window_scroll_preserve_vpos = posit.vpos; | ||
| 5489 | window_scroll_preserve_hpos = posit.hpos + XINT (w->hscroll); | ||
| 5490 | } | ||
| 5491 | |||
| 5492 | original_pos = Fcons (make_number (window_scroll_preserve_hpos), | ||
| 5493 | make_number (window_scroll_preserve_vpos)); | ||
| 5494 | } | ||
| 5473 | 5495 | ||
| 5474 | XSETFASTINT (tem, PT); | 5496 | XSETFASTINT (tem, PT); |
| 5475 | tem = Fpos_visible_in_window_p (tem, window, Qnil); | 5497 | tem = Fpos_visible_in_window_p (tem, window, Qnil); |
| @@ -5520,7 +5542,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5520 | && (whole || !EQ (Vscroll_preserve_screen_position, Qt))) | 5542 | && (whole || !EQ (Vscroll_preserve_screen_position, Qt))) |
| 5521 | { | 5543 | { |
| 5522 | SET_PT_BOTH (pos, pos_byte); | 5544 | SET_PT_BOTH (pos, pos_byte); |
| 5523 | Fvertical_motion (make_number (original_vpos), window); | 5545 | Fvertical_motion (original_pos, window); |
| 5524 | } | 5546 | } |
| 5525 | /* If we scrolled forward, put point enough lines down | 5547 | /* If we scrolled forward, put point enough lines down |
| 5526 | that it is outside the scroll margin. */ | 5548 | that it is outside the scroll margin. */ |
| @@ -5542,7 +5564,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5542 | else if (!NILP (Vscroll_preserve_screen_position)) | 5564 | else if (!NILP (Vscroll_preserve_screen_position)) |
| 5543 | { | 5565 | { |
| 5544 | SET_PT_BOTH (pos, pos_byte); | 5566 | SET_PT_BOTH (pos, pos_byte); |
| 5545 | Fvertical_motion (make_number (original_vpos), window); | 5567 | Fvertical_motion (original_pos, window); |
| 5546 | } | 5568 | } |
| 5547 | else | 5569 | else |
| 5548 | SET_PT (top_margin); | 5570 | SET_PT (top_margin); |
| @@ -5567,7 +5589,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5567 | if (!NILP (Vscroll_preserve_screen_position)) | 5589 | if (!NILP (Vscroll_preserve_screen_position)) |
| 5568 | { | 5590 | { |
| 5569 | SET_PT_BOTH (pos, pos_byte); | 5591 | SET_PT_BOTH (pos, pos_byte); |
| 5570 | Fvertical_motion (make_number (original_vpos), window); | 5592 | Fvertical_motion (original_pos, window); |
| 5571 | } | 5593 | } |
| 5572 | else | 5594 | else |
| 5573 | Fvertical_motion (make_number (-1), window); | 5595 | Fvertical_motion (make_number (-1), window); |
| @@ -7439,7 +7461,10 @@ syms_of_window () | |||
| 7439 | minibuf_selected_window = Qnil; | 7461 | minibuf_selected_window = Qnil; |
| 7440 | staticpro (&minibuf_selected_window); | 7462 | staticpro (&minibuf_selected_window); |
| 7441 | 7463 | ||
| 7464 | window_scroll_pixel_based_preserve_x = -1; | ||
| 7442 | window_scroll_pixel_based_preserve_y = -1; | 7465 | window_scroll_pixel_based_preserve_y = -1; |
| 7466 | window_scroll_preserve_hpos = -1; | ||
| 7467 | window_scroll_preserve_vpos = -1; | ||
| 7443 | 7468 | ||
| 7444 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | 7469 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, |
| 7445 | doc: /* Non-nil means call as function to display a help buffer. | 7470 | doc: /* Non-nil means call as function to display a help buffer. |
| @@ -7640,7 +7665,7 @@ windows horizontally. A value less than 2 is invalid. */); | |||
| 7640 | 7665 | ||
| 7641 | DEFVAR_LISP ("scroll-preserve-screen-position", | 7666 | DEFVAR_LISP ("scroll-preserve-screen-position", |
| 7642 | &Vscroll_preserve_screen_position, | 7667 | &Vscroll_preserve_screen_position, |
| 7643 | doc: /* *Controls if scroll commands move point to keep its screen line unchanged. | 7668 | doc: /* *Controls if scroll commands move point to keep its screen position unchanged. |
| 7644 | A value of nil means point does not keep its screen position except | 7669 | A value of nil means point does not keep its screen position except |
| 7645 | at the scroll margin or window boundary respectively. | 7670 | at the scroll margin or window boundary respectively. |
| 7646 | A value of t means point keeps its screen position if the scroll | 7671 | A value of t means point keeps its screen position if the scroll |
diff --git a/src/xdisp.c b/src/xdisp.c index 8d87123934b..56db272dcb0 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -939,8 +939,9 @@ static int init_from_display_pos P_ ((struct it *, struct window *, | |||
| 939 | struct display_pos *)); | 939 | struct display_pos *)); |
| 940 | static void reseat_to_string P_ ((struct it *, unsigned char *, | 940 | static void reseat_to_string P_ ((struct it *, unsigned char *, |
| 941 | Lisp_Object, int, int, int, int)); | 941 | Lisp_Object, int, int, int, int)); |
| 942 | static enum move_it_result move_it_in_display_line_to P_ ((struct it *, | 942 | static enum move_it_result |
| 943 | int, int, int)); | 943 | move_it_in_display_line_to (struct it *, EMACS_INT, int, |
| 944 | enum move_operation_enum); | ||
| 944 | void move_it_vertically_backward P_ ((struct it *, int)); | 945 | void move_it_vertically_backward P_ ((struct it *, int)); |
| 945 | static void init_to_row_start P_ ((struct it *, struct window *, | 946 | static void init_to_row_start P_ ((struct it *, struct window *, |
| 946 | struct glyph_row *)); | 947 | struct glyph_row *)); |
| @@ -6630,9 +6631,9 @@ next_element_from_composition (it) | |||
| 6630 | display is on. */ | 6631 | display is on. */ |
| 6631 | 6632 | ||
| 6632 | static enum move_it_result | 6633 | static enum move_it_result |
| 6633 | move_it_in_display_line_to (it, to_charpos, to_x, op) | 6634 | move_it_in_display_line_to (struct it *it, |
| 6634 | struct it *it; | 6635 | EMACS_INT to_charpos, int to_x, |
| 6635 | int to_charpos, to_x, op; | 6636 | enum move_operation_enum op) |
| 6636 | { | 6637 | { |
| 6637 | enum move_it_result result = MOVE_UNDEFINED; | 6638 | enum move_it_result result = MOVE_UNDEFINED; |
| 6638 | struct glyph_row *saved_glyph_row; | 6639 | struct glyph_row *saved_glyph_row; |
| @@ -6892,6 +6893,15 @@ move_it_in_display_line_to (it, to_charpos, to_x, op) | |||
| 6892 | return result; | 6893 | return result; |
| 6893 | } | 6894 | } |
| 6894 | 6895 | ||
| 6896 | /* For external use. */ | ||
| 6897 | void | ||
| 6898 | move_it_in_display_line (struct it *it, | ||
| 6899 | EMACS_INT to_charpos, int to_x, | ||
| 6900 | enum move_operation_enum op) | ||
| 6901 | { | ||
| 6902 | move_it_in_display_line_to (it, to_charpos, to_x, op); | ||
| 6903 | } | ||
| 6904 | |||
| 6895 | 6905 | ||
| 6896 | /* Move IT forward until it satisfies one or more of the criteria in | 6906 | /* Move IT forward until it satisfies one or more of the criteria in |
| 6897 | TO_CHARPOS, TO_X, TO_Y, and TO_VPOS. | 6907 | TO_CHARPOS, TO_X, TO_Y, and TO_VPOS. |