changeset 4385:edffa4f0c5d9

(compute_motion): Compute correctly for invisible text. (vmotion): Take care of invisible newlines. (Fmove_to_column): After we split a tab, make sure to set last_known... consistently.
author Richard M. Stallman <rms@gnu.org>
date Sat, 31 Jul 1993 21:59:42 +0000
parents 98605d0ea3cf
children abd79e187610
files src/indent.c
diffstat 1 files changed, 53 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/indent.c	Sat Jul 31 21:58:45 1993 +0000
+++ b/src/indent.c	Sat Jul 31 21:59:42 1993 +0000
@@ -27,6 +27,7 @@
 #include "termchar.h"
 #include "termopts.h"
 #include "disptab.h"
+#include "intervals.h"
 
 /* Indentation can insert tabs if this is non-zero;
    otherwise always uses spaces */
@@ -352,6 +353,8 @@
       old_point = point;
       Findent_to (make_number (col), Qnil);
       SET_PT (old_point);
+      /* Set the last_known... vars consistently.  */
+      col = goal;
     }
 
   /* If line ends prematurely, add space to the end.  */
@@ -436,6 +439,11 @@
   int selective_rlen
     = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector
        ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0);
+#ifdef USE_TEXT_PROPERTIES
+  /* The next location where the `invisible' property changes */
+  int next_invisible = from;
+  Lisp_Object prop, position;
+#endif
 
   if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
   for (pos = from; pos < to; pos++)
@@ -448,6 +456,32 @@
       prev_vpos = vpos;
       prev_hpos = hpos;
 
+#ifdef USE_TEXT_PROPERTIES
+      /* if the `invisible' property is set, we can skip to
+	 the next property change */
+      while (pos == next_invisible && pos < to)
+      {
+	XFASTINT (position) = pos;
+	prop = Fget_text_property (position,
+				   Qinvisible,
+				   Fcurrent_buffer ());
+        {
+	  Lisp_Object end;
+
+	  end = Fnext_single_property_change (position,
+					      Qinvisible,
+					      Fcurrent_buffer ());
+	  if (INTEGERP (end))
+	    next_invisible = XINT (end);
+	  else
+	    next_invisible = to;
+	  if (! NILP (prop))
+	    pos = next_invisible;
+        }
+      }
+      if (pos >= to)
+	break;
+#endif
       c = FETCH_CHAR (pos);
       if (c >= 040 && c < 0177
 	  && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector))
@@ -610,9 +644,16 @@
       if (from > BEGV && FETCH_CHAR (from - 1) != '\n')
 	{
 	  prevline = find_next_newline (from, -1);
-	  while (selective > 0
-		 && prevline > BEGV
-		 && position_indentation (prevline) >= selective)
+	  while (prevline > BEGV
+		 && ((selective > 0
+		      && position_indentation (prevline) >= selective)
+#ifdef USE_TEXT_PROPERTIES
+		     /* watch out for newlines with `invisible' property */
+		     || ! NILP (Fget_text_property (XFASTINT (prevline),
+						    Qinvisible,
+						    Fcurrent_buffer ()))
+#endif
+		 ))
 	    prevline = find_next_newline (prevline - 1, -1);
 	  pos = *compute_motion (prevline, 0,
 				 lmargin + (prevline == 1 ? start_hpos : 0),
@@ -641,8 +682,15 @@
 	{
 	  prevline = find_next_newline (prevline - 1, -1);
 	  if (prevline == BEGV
-	      || selective <= 0
-	      || position_indentation (prevline) < selective)
+	      || ((selective <= 0
+		   || position_indentation (prevline) < selective)
+#ifdef USE_TEXT_PROPERTIES
+		  /* watch out for newlines with `invisible' property */
+		  && NILP (Fget_text_property (XFASTINT (prevline),
+					       Qinvisible,
+					       Fcurrent_buffer ()))
+#endif
+		  ))
 	    break;
 	}
       pos = *compute_motion (prevline, 0,