changeset 39858:13bf107afa6d

(init_iterator): Be more strict with bytepos and charspos. (DOLIST, LOOP_PROPVAL): New macros. (invisible_p, invisible_ellipsis_p): Use them. (invisible_noellipsis_p): New function. (syms_of_xdisp): Use empty_string.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 12 Oct 2001 22:15:07 +0000
parents 6235c0f8e52c
children 36068b62b4c1
files src/xdisp.c
diffstat 1 files changed, 65 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Fri Oct 12 22:07:35 2001 +0000
+++ b/src/xdisp.c	Fri Oct 12 22:15:07 2001 +0000
@@ -710,8 +710,6 @@
 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *));
 static int trailing_whitespace_p P_ ((int));
 static int message_log_check_duplicate P_ ((int, int, int, int));
-int invisible_p P_ ((Lisp_Object, Lisp_Object));
-int invisible_ellipsis_p P_ ((Lisp_Object, Lisp_Object));
 static void push_it P_ ((struct it *));
 static void pop_it P_ ((struct it *));
 static void sync_frame_with_window_matrix_rows P_ ((struct window *));
@@ -1429,7 +1427,7 @@
    at character position CHARPOS.  CHARPOS < 0 means that no buffer
    position is specified which is useful when the iterator is assigned
    a position later.  BYTEPOS is the byte position corresponding to
-   CHARPOS.  BYTEPOS <= 0 means compute it from CHARPOS.
+   CHARPOS.  BYTEPOS < 0 means compute it from CHARPOS.
 
    If ROW is not null, calls to produce_glyphs with IT as parameter
    will produce glyphs in that row.
@@ -1535,7 +1533,7 @@
 
   /* Non-zero if we should highlight the region.  */
   highlight_region_p
-    = (!NILP (Vtransient_mark_mode) 
+    = (!NILP (Vtransient_mark_mode)
        && !NILP (current_buffer->mark_active)
        && XMARKER (current_buffer->mark)->buffer != 0);
 
@@ -1672,14 +1670,14 @@
 
   /* If a buffer position was specified, set the iterator there,
      getting overlays and face properties from that position.  */
-  if (charpos > 0)
+  if (charpos >= BUF_BEG (current_buffer))
     {
       it->end_charpos = ZV;
       it->face_id = -1;
       IT_CHARPOS (*it) = charpos;
       
       /* Compute byte position if not specified.  */
-      if (bytepos <= 0)
+      if (bytepos < charpos)
 	IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
       else
 	IT_BYTEPOS (*it) = bytepos;
@@ -7991,6 +7989,7 @@
 		      &text_area_width, &text_area_height);
 
 	  /* Scroll when cursor is inside this scroll margin.  */
+	  /* Shouldn't we export this `5' for customization ?  -stef  */
 	  hscroll_margin = 5 * CANON_X_UNIT (XFRAME (w->frame));
 	  
 	  if ((XFASTINT (w->hscroll)
@@ -14501,6 +14500,36 @@
 
 
 
+#define DOLIST(var, list, code)				\
+  {							\
+    register Lisp_Object tail;				\
+    for (tail = list; CONSP (tail); tail = XCDR (tail))	\
+      {							\
+	var = XCAR (tail);				\
+	code;						\
+      }							\
+  }
+
+/* Loop through the properties in PROPVAL and call CODE for each.
+   CODE can access the current element in `propelt'.  */
+
+#define LOOP_PROPVAL(var, propval, code)			\
+  {								\
+    var = (propval);						\
+    code;							\
+    								\
+    if (CONSP (propval))					\
+      {								\
+	register Lisp_Object tail;				\
+	for (tail = propval; CONSP (tail); tail = XCDR (tail))	\
+	  {							\
+	    var = XCAR (tail);					\
+	    code;						\
+	  }							\
+      }								\
+    return 0;							\
+  }
+
 /* This is like a combination of memq and assq.  Return 1 if PROPVAL
    appears as an element of LIST or as the car of an element of LIST.
    If PROPVAL is a list, compare each element against LIST in that
@@ -14512,37 +14541,13 @@
      register Lisp_Object propval;
      Lisp_Object list;
 {
-  register Lisp_Object tail, proptail;
-  
-  for (tail = list; CONSP (tail); tail = XCDR (tail))
-    {
-      register Lisp_Object tem;
-      tem = XCAR (tail);
-      if (EQ (propval, tem))
-	return 1;
-      if (CONSP (tem) && EQ (propval, XCAR (tem)))
-	return 1;
-    }
-  
-  if (CONSP (propval))
-    {
-      for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail))
-	{
-	  Lisp_Object propelt;
-	  propelt = XCAR (proptail);
-	  for (tail = list; CONSP (tail); tail = XCDR (tail))
-	    {
-	      register Lisp_Object tem;
-	      tem = XCAR (tail);
-	      if (EQ (propelt, tem))
-		return 1;
-	      if (CONSP (tem) && EQ (propelt, XCAR (tem)))
-		return 1;
-	    }
-	}
-    }
-  
-  return 0;
+  register Lisp_Object propelt, tem;
+  LOOP_PROPVAL (propelt, propval,
+		DOLIST (tem, list,
+			if (EQ (propelt, tem))
+			  return 1;
+			if (CONSP (tem) && EQ (propelt, XCAR (tem)))
+			  return 1;));
 }
 
 
@@ -14557,31 +14562,27 @@
      register Lisp_Object propval;
      Lisp_Object list;
 {
-  register Lisp_Object tail, proptail;
-  
-  for (tail = list; CONSP (tail); tail = XCDR (tail))
-    {
-      register Lisp_Object tem;
-      tem = XCAR (tail);
-      if (CONSP (tem) && EQ (propval, XCAR (tem)))
-	return ! NILP (XCDR (tem));
-    }
-  
-  if (CONSP (propval))
-    for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail))
-      {
-	Lisp_Object propelt;
-	propelt = XCAR (proptail);
-	for (tail = list; CONSP (tail); tail = XCDR (tail))
-	  {
-	    register Lisp_Object tem;
-	    tem = XCAR (tail);
-	    if (CONSP (tem) && EQ (propelt, XCAR (tem)))
-	      return ! NILP (XCDR (tem));
-	  }
-      }
-  
-  return 0;
+  register Lisp_Object propelt, tem;
+  LOOP_PROPVAL (propelt, propval,
+		DOLIST (tem, list,
+			if (CONSP (tem) && EQ (propelt, XCAR (tem)))
+			  return !NILP (XCDR (tem))));
+}
+
+/* As above but for "completely" invisible (no ellipsis).  */
+
+int
+invisible_noellipsis_p (propval, list)
+     register Lisp_Object propval;
+     Lisp_Object list;
+{
+  register Lisp_Object propelt, tem;
+  LOOP_PROPVAL (propelt, propval,
+		DOLIST (tem, list,
+			if (EQ (propelt, tem))
+			  return 1;
+			if (CONSP (tem) && EQ (propelt, XCAR (tem)))
+			  return NILP (XCDR (tem))));
 }
 
 
@@ -14801,7 +14802,7 @@
     = Vframe_title_format
     = Fcons (intern ("multiple-frames"),
 	     Fcons (build_string ("%b"),
-		    Fcons (Fcons (build_string (""),
+		    Fcons (Fcons (empty_string,
 				  Fcons (intern ("invocation-name"),
 					 Fcons (build_string ("@"),
 						Fcons (intern ("system-name"),
@@ -14856,8 +14857,7 @@
     "List of functions to call to fontify regions of text.\n\
 Each function is called with one argument POS.  Functions must\n\
 fontify a region starting at POS in the current buffer, and give\n\
-fontified regions the property `fontified'.\n\
-This variable automatically becomes buffer-local when set.");
+fontified regions the property `fontified'.");
   Vfontification_functions = Qnil;
   Fmake_variable_buffer_local (Qfontification_functions);