]> code.delx.au - gnu-emacs/blobdiff - src/indent.c
(Ffont_spec): Docstring modified.
[gnu-emacs] / src / indent.c
index 7bef4949908d0b5cd0b57c8d40b6a8b8c355a13e..8c6c52358ff564bbb01d5316c6ff3e72de95f7e0 100644 (file)
@@ -1,6 +1,6 @@
 /* Indentation functions.
    Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1998, 2000, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -533,6 +533,8 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
   register struct Lisp_Char_Table *dp = buffer_display_table ();
   int multibyte = !NILP (current_buffer->enable_multibyte_characters);
   struct composition_it cmp_it;
+  Lisp_Object window;
+  struct window *w;
 
   /* Start the scan at the beginning of this line with column number 0.  */
   register EMACS_INT col = 0, prev_col = 0;
@@ -549,6 +551,9 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
   next_boundary = scan;
   }
 
+  window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
+  w = ! NILP (window) ? XWINDOW (window) : NULL;
+
   if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
   bzero (&cmp_it, sizeof cmp_it);
   cmp_it.id = -1;
@@ -597,7 +602,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
       if (cmp_it.id >= 0
          || (scan == cmp_it.stop_pos
              && composition_reseat_it (&cmp_it, scan, scan_byte, end,
-                                       XWINDOW (selected_window), NULL, Qnil)))
+                                       w, NULL, Qnil)))
        composition_update_it (&cmp_it, scan, scan_byte, Qnil);
       if (cmp_it.id >= 0)
        {
@@ -2058,7 +2063,7 @@ whether or not it is currently displayed in some window.  */)
     }
   else
     {
-      int it_start, oselective, first_x, it_overshoot_expected;
+      int it_start, first_x, it_overshoot_expected;
 
       SET_TEXT_POS (pt, PT, PT_BYTE);
       start_display (&it, w, pt);
@@ -2070,7 +2075,7 @@ whether or not it is currently displayed in some window.  */)
        {
          if (it.cmp_it.id >= 0)
            it_overshoot_expected = 1;
-         if (it.method == GET_FROM_STRING)
+         else if (it.method == GET_FROM_STRING)
            {
              const char *s = SDATA (it.string);
              const char *e = s + SBYTES (it.string);
@@ -2088,11 +2093,15 @@ whether or not it is currently displayed in some window.  */)
         really at some x > 0.  */
       reseat_at_previous_visible_line_start (&it);
       it.current_x = it.hpos = 0;
-      /* Temporarily disable selective display so we don't move too far */
-      oselective = it.selective;
-      it.selective = 0;
-      move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
-      it.selective = oselective;
+      if (IT_CHARPOS (it) != PT)
+       {
+         int oselective = it.selective;
+         /* Temporarily disable selective display so we don't move
+            too far */
+         it.selective = 0;
+         move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+         it.selective = oselective;
+       }
 
       if (XINT (lines) <= 0)
        {
@@ -2104,7 +2113,7 @@ whether or not it is currently displayed in some window.  */)
        }
       else
        {
-         if (IT_CHARPOS (it) > PT)
+         if (IT_CHARPOS (it) > it_start)
            {
              /* IT may move too far if truncate-lines is on and PT
                 lies beyond the right margin.  In that case,
@@ -2128,15 +2137,21 @@ whether or not it is currently displayed in some window.  */)
                 which might span multiple screen lines (e.g., if it's
                 on a multi-line display string).  We want to start
                 from the last line that it occupies.  */
-             it.vpos = 0;
-             if (PT < ZV)
+             if (it_start < ZV)
                {
-                 while (IT_CHARPOS (it) <= PT)
-                   move_it_by_lines (&it, 1, 0);
-                 move_it_by_lines (&it, XINT (lines) - 1, 0);
+                 while (IT_CHARPOS (it) <= it_start)
+                   {
+                     it.vpos = 0;
+                     move_it_by_lines (&it, 1, 0);
+                   }
+                 if (XINT (lines) > 1)
+                   move_it_by_lines (&it, XINT (lines) - 1, 0);
                }
              else
-               move_it_by_lines (&it, XINT (lines), 0);
+               {
+                 it.vpos = 0;
+                 move_it_by_lines (&it, XINT (lines), 0);
+               }
            }
        }