diff src/indent.c @ 95566:b3c0438c570b

* 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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 05 Jun 2008 03:57:09 +0000
parents 8971ddf55736
children 9687aec12c3f
line wrap: on
line diff
--- a/src/indent.c	Thu Jun 05 03:23:31 2008 +0000
+++ b/src/indent.c	Thu Jun 05 03:57:09 2008 +0000
@@ -1993,6 +1993,10 @@
 parameters such as width, horizontal scrolling, and so on.
 The default is to use the selected window's parameters.
 
+LINES can optionally take the form (COLS . LINES), in which case
+the motion will not stop at the start of a screen line but on
+its column COLS (if such exists on that line, that is).
+
 `vertical-motion' always uses the current buffer,
 regardless of which buffer is displayed in WINDOW.
 This is consistent with other cursor motion functions
@@ -2006,6 +2010,14 @@
   struct window *w;
   Lisp_Object old_buffer;
   struct gcpro gcpro1;
+  int cols = 0;
+
+  /* Allow LINES to be of the form (HPOS . VPOS) aka (COLUMNS . LINES).  */
+  if (CONSP (lines) && (NUMBERP (XCAR (lines))))
+    {
+      cols = XINT (XCAR (lines));
+      lines = XCDR (lines);
+    }
 
   CHECK_NUMBER (lines);
   if (! NILP (window))
@@ -2094,6 +2106,11 @@
       if (XINT (lines) >= 0 || IT_CHARPOS (it) > 0)
 	move_it_by_lines (&it, XINT (lines), 0);
 
+      if (cols)
+	move_it_in_display_line (&it, ZV,
+				 cols * FRAME_COLUMN_WIDTH (XFRAME (w->frame)),
+				 MOVE_TO_X);
+
       SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
     }