]> code.delx.au - gnu-emacs/blobdiff - src/indent.c
(mail-extr-all-top-level-domains): More domains.
[gnu-emacs] / src / indent.c
index 6f2738b4165cc1e8ae6d4d16a03f0f4ffa6b6e05..b4592a2dddf8c9123a35515d22727ec8b970f212 100644 (file)
@@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA.  */
 #include "lisp.h"
 #include "buffer.h"
 #include "charset.h"
+#include "category.h"
 #include "indent.h"
 #include "frame.h"
 #include "window.h"
@@ -281,6 +282,7 @@ however, ^M is treated as end of line when `selective-display' is t.")
 
 /* Cancel any recorded value of the horizontal position.  */
 
+void
 invalidate_current_column ()
 {
   last_known_column_point = 0;
@@ -349,10 +351,12 @@ current_column ()
        col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
       else if (c >= 040 && c < 0177)
        col++;
-      else if (c == '\n')
-       break;
-      else if (c == '\r' && EQ (current_buffer->selective_display, Qt))
-       break;
+      else if (c == '\n'
+              || (c == '\r' && EQ (current_buffer->selective_display, Qt)))
+       {
+         ptr++;
+         break;
+       }
       else if (c == '\t')
        {
          if (tab_seen)
@@ -375,7 +379,7 @@ current_column ()
   if (ptr == BEGV_ADDR)
     current_column_bol_cache = BEGV;
   else
-    current_column_bol_cache = PTR_CHAR_POS ((ptr+1));
+    current_column_bol_cache = PTR_CHAR_POS (ptr);
   last_known_column = col;
   last_known_column_point = PT;
   last_known_column_modified = MODIFF;
@@ -678,6 +682,9 @@ position_indentation (pos)
        }
       switch (*p++)
        {
+       case 0240:
+         if (! NILP (current_buffer->enable_multibyte_characters))
+           return column;
        case ' ':
          column++;
          break;
@@ -685,7 +692,21 @@ position_indentation (pos)
          column += tab_width - column % tab_width;
          break;
        default:
-         return column;
+         if (ASCII_BYTE_P (p[-1])
+             || NILP (current_buffer->enable_multibyte_characters))
+           return column;
+         {
+           int pos = PTR_CHAR_POS (p - 1);
+           int c = FETCH_MULTIBYTE_CHAR (pos);
+           if (CHAR_HAS_CATEGORY (c, ' '))
+             {
+               column++;
+               INC_POS (pos);
+               p = POS_ADDR (pos);
+             }
+           else
+             return column;
+         }
        }
     }
 }
@@ -1152,7 +1173,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
       if (vpos > tovpos || vpos == tovpos && hpos >= tohpos)
        {
          if (contin_hpos && prev_hpos == 0
-             && (contin_hpos == width || wide_column))
+             && ((hpos > tohpos && contin_hpos == width) || wide_column))
            { /* Line breaks because we can't put the character at the
                 previous line any more.  It is not the multi-column
                 character continued in middle.  Go back to previous
@@ -1254,7 +1275,8 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
                }
            }
 
-         if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
+         if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))
+             && ! (multibyte && BASE_LEADING_CODE_P (c)))
            hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
          else if (c >= 040 && c < 0177)
            hpos++;