(display_prop_end, invisible_text_between_p): Use
[bpt/emacs.git] / src / xdisp.c
index 39fcb42..e5ffabb 100644 (file)
@@ -2243,7 +2243,7 @@ handle_display_prop (it)
 }
 
 
-/* Value is the position of the end of the `display' property stating
+/* Value is the position of the end of the `display' property starting
    at START_POS in OBJECT.  */
 
 static struct text_pos
@@ -2254,27 +2254,14 @@ display_prop_end (it, object, start_pos)
 {
   Lisp_Object end;
   struct text_pos end_pos;
-  
-  /* Characters having this form of property are not displayed, so
-     we have to find the end of the property.  */
-  end = Fnext_single_property_change (make_number (start_pos.charpos),
-                                     Qdisplay, object, Qnil);
-  if (NILP (end))
-    {
-      /* A nil value of `end' means there are no changes of the
-        property to the end of the buffer or string.  */
-      if (it->current.overlay_string_index >= 0)
-       end_pos.charpos = XSTRING (it->string)->size;
-      else
-       end_pos.charpos = it->end_charpos;
-    }
-  else
-    end_pos.charpos = XFASTINT (end);
 
-  if (STRINGP (it->string))
+  end = next_single_char_property_change (make_number (CHARPOS (start_pos)),
+                                         Qdisplay, object, Qnil);
+  CHARPOS (end_pos) = XFASTINT (end);
+  if (STRINGP (object))
     compute_string_pos (&end_pos, start_pos, it->string);
   else
-    end_pos.bytepos = CHAR_TO_BYTE (end_pos.charpos);
+    BYTEPOS (end_pos) = CHAR_TO_BYTE (XFASTINT (end));
 
   return end_pos;
 }
@@ -4430,10 +4417,9 @@ invisible_text_between_p (it, start_charpos, end_charpos)
     invisible_found_p = 1;
   else
     {
-      limit = Fnext_single_property_change (make_number (start_charpos),
-                                           Qinvisible,
-                                           Fcurrent_buffer (),
-                                           make_number (end_charpos));
+      limit = next_single_char_property_change (make_number (start_charpos),
+                                               Qinvisible, Qnil,
+                                               make_number (end_charpos));
       invisible_found_p = XFASTINT (limit) < end_charpos;
     }
 
@@ -4585,6 +4571,37 @@ move_it_by_lines (it, dvpos, need_y_p)
  ***********************************************************************/
 
 
+/* Add a message with format string FORMAT and arguments ARG1 and ARG2
+   to *Messages*.  */
+
+void
+add_to_log (format, arg1, arg2)
+     char *format;
+     Lisp_Object arg1, arg2;
+{
+  Lisp_Object args[3];
+  Lisp_Object msg, fmt;
+  char *buffer;
+  int len;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+
+  fmt = msg = Qnil;
+  GCPRO4 (fmt, msg, arg1, arg2);
+  
+  args[0] = fmt = build_string (format);
+  args[1] = arg1;
+  args[2] = arg2;
+  msg = Fformat (make_number (3), args);
+
+  len = STRING_BYTES (XSTRING (msg)) + 1;
+  buffer = (char *) alloca (len);
+  strcpy (buffer, XSTRING (msg)->data);
+  
+  message_dolog (buffer, len, 1, 0);
+  UNGCPRO;
+}
+
+
 /* Output a newline in the *Messages* buffer if "needs" one.  */
 
 void
@@ -5518,30 +5535,19 @@ resize_mini_window (w, exact_p)
 
       /* Let it grow only, until we display an empty message, in which
         case the window shrinks again.  */
-      if (height > XFASTINT (w->height)
-         || exact_p
-         || BEGV == ZV)
+      if (height > XFASTINT (w->height))
        {
-         Lisp_Object old_selected_window;
-         Lisp_Object fix_window;
          int old_height = XFASTINT (w->height);
-             
-         freeze_window_starts (f, height > XFASTINT (w->height));
-
-         /* If the mini-buffer is selected, try to not change
-            the height of Vminibuf_scroll_window.  Otherwise try
-            to not change the height of the selected window.  */
-         if (MINI_WINDOW_P (XWINDOW (selected_window)))
-           fix_window = Vminibuf_scroll_window;
-         else
-           fix_window = selected_window;
-         
-         old_selected_window = selected_window;
-         XSETWINDOW (selected_window, w);
-         XWINDOW (fix_window)->height_fixed_p = 1;
-         change_window_height (height - XFASTINT (w->height), 0);
-         XWINDOW (fix_window)->height_fixed_p = 0;
-         selected_window = old_selected_window;
+         freeze_window_starts (f, 1);
+         grow_mini_window (w, height - XFASTINT (w->height));
+         window_height_changed_p = XFASTINT (w->height) != old_height;
+       }
+      else if (height < XFASTINT (w->height)
+              && (exact_p || BEGV == ZV))
+       {
+         int old_height = XFASTINT (w->height);
+         freeze_window_starts (f, 0);
+         shrink_mini_window (w);
          window_height_changed_p = XFASTINT (w->height) != old_height;
        }
     }