1999-05-09  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>

	* indent.c (current_column_1): Make it work correctly on multibyte
	characters even if there are any overlays or text properties.

	* indent.c (compute_motion): Make it work correctly on the overlay
	properties before-string or after-string containing multibyte
	characters.
	* xdisp.c (display_text_line): Ditto.

1997-07-14  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>

	* keyboard.c (make_lispy_event): Distinguish S-SPC from SPC.


--- mule-2.3@19.34/src/indent.c~	1996-07-15 09:09:46 +0000
+++ mule-2.3@19.34/src/indent.c	1999-05-09 14:28:35 +0000
@@ -518,11 +518,11 @@
 		  int bytes = char_bytes[(c = FETCH_CHAR (scan) - 0x20)];
 
 		  /* Check existence of trailing non ascii character.  */
-		  while (--bytes && scan < pos
+		  while (bytes-- && scan < pos
 			 && NONASCII_P (FETCH_CHAR (scan)))
 		    scan++;
 
-		  if (bytes)
+		  if (bytes != -1)
 		    /* Incomplete multibyte form.  */
 		    {
 		      scan = oldscan, width = 4;
@@ -1253,7 +1253,42 @@
 	       strings must contain single-column printing characters;
 	       if we want to relax that restriction, something will have
 	       to be changed here.  */
+#ifndef MULE
 	    hpos += overlay_strings (pos, win, (char **)0);
+#else /* MULE */
+/* OVERLAY の after-string / before-string 属性に multibyte 文字列が含
+   まれている場合の処理 ( 右から左に表示される場合や、改行文字などの制
+   御文字が含まれている場合について考慮していないので、そのような場合
+   には不具合が現れる可能性があるので注意すること。) */
+	    if (mc_flag)
+	      {
+		int ovlen;
+		char *ovstr;
+		ovlen = overlay_strings (pos, win, &ovstr);
+		while (ovlen > 0)
+		  {
+		    unsigned int c;
+		    int lc, len;
+		    c  = STRtoCHAR( (unsigned char *)ovstr, ovlen );
+		    lc = CHAR_LEADING_CHAR( c );
+		    if (lc == LCCMP)
+		      {
+			lc    = c & ( CHAR_F2_MASK | CHAR_F3_MASK );
+			len   = cmpchar_table[lc].len;
+			hpos += cmpchar_table[lc].width;
+		      }
+		    else
+		      {
+			len   = char_bytes[lc];
+			hpos += char_width[lc];
+		      }
+		    ovstr += len;
+		    ovlen -= len;
+		  }
+	      }
+	    else
+	      hpos += overlay_strings (pos, win, (char **)0);
+#endif /* MULE */
 	  did_motion = 0;
 
 	  if (pos >= to)
--- mule-2.3@19.34/src/keyboard.c~	1996-07-18 22:34:07 +0000
+++ mule-2.3@19.34/src/keyboard.c	2001-10-24 04:14:21 +0000
@@ -3722,6 +3722,10 @@
 	c |= (event->modifiers
 	      & (meta_modifier | alt_modifier
 		 | hyper_modifier | super_modifier));
+	/* Distinguish Shift-SPC from SPC.  */
+	if ((event->code & 0377) == 040
+	    && event->modifiers & shift_modifier)
+	  c |= shift_modifier;
 	button_down_time = 0;
 	XSETFASTINT (lispy_c, c);
 	return lispy_c;
--- mule-2.3@19.34/src/xdisp.c~	1996-08-21 13:30:49 +0000
+++ mule-2.3@19.34/src/xdisp.c	1999-05-09 15:38:00 +0000
@@ -2993,12 +2993,59 @@
 		  int ovlen;
 		  char *ovstr;
 		  ovlen = overlay_strings (pos, w, &ovstr);
+#ifndef MULE
 		  for (; ovlen; ovlen--, ovstr++)
 		    {
 		      if (p1 >= leftmargin && p1 < endp)
 			*p1 = MAKE_GLYPH (f, *ovstr, current_face);
 		      p1++;
 		    }
+#else /* MULE */
+/* OVERLAY の after-string / before-string 属性に multibyte 文字列が含
+   まれている場合の処理 ( 右から左に表示される場合や、改行文字などの制
+   御文字が含まれている場合について考慮していないので、そのような場合
+   には不具合が現れる可能性があるので注意すること。) */
+		  while (ovlen > 0)
+		    {
+		      unsigned int c;
+		      int col;
+		      if (mc_flag)
+			{
+			  int lc, len;
+			  c  = STRtoCHAR( (unsigned char *)ovstr, ovlen );
+			  lc = CHAR_LEADING_CHAR( c );
+			  if( lc == LCCMP )
+			    {
+			      lc  = c & ( CHAR_F2_MASK | CHAR_F3_MASK );
+			      len = cmpchar_table[lc].len;
+			      col = cmpchar_table[lc].width;
+			    }
+			  else
+			    {
+			      len = char_bytes[lc];
+			      col = char_width[lc];
+			    }
+			  ovstr += len;
+			  ovlen -= len;
+			}
+		      else
+			{
+			  c = *ovstr++;
+			  ovlen--;
+			  col = 1;
+			}
+		      if (p1 >= leftmargin && p1 < endp)
+			{
+			  *p1++ = MAKE_GLYPH (f, c, current_face);
+			  c |= GLYPH_CTL_COLUMN2;
+			  while( --col > 0 )
+			    {
+			      if (p1 >= leftmargin && p1 < endp) *p1 = MAKE_GLYPH (f, c, current_face);
+			      p1++;
+			    }
+			}
+		    }
+#endif /* MULE */
 		}
 
 	      /* Did we reach point?  Record the cursor location.  */
