changeset 109208:0d144b53fe59

Merge from mainline.
author Katsumi Yamaoka <katsumi@flagship2>
date Sun, 30 May 2010 00:32:06 +0000
parents 4c39d84b5d9a (current diff) 87dad1e1c860 (diff)
children 19ee224844a2
files
diffstat 15 files changed, 325 insertions(+), 173 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Sat May 29 09:39:12 2010 +0000
+++ b/Makefile.in	Sun May 30 00:32:06 2010 +0000
@@ -279,6 +279,9 @@
 removenullpaths=sed -e 's/^://g' -e 's/:$$//g' -e 's/::/:/g'
 
 # Generate epaths.h from epaths.in.  This target is invoked by `configure'.
+# See comments in configure.in for why it is done this way, as opposed
+# to just letting configure generate epaths.h from epaths.in in a
+# similar way to how Makefile is made from Makefile.in.
 epaths-force: FRC
 	@(lisppath=`echo ${lisppath} | ${removenullpaths}` ;		\
 	  buildlisppath=`echo ${buildlisppath} | ${removenullpaths}` ;	\
--- a/configure	Sat May 29 09:39:12 2010 +0000
+++ b/configure	Sun May 30 00:32:06 2010 +0000
@@ -2724,7 +2724,7 @@
 ### the appropriate operating system and machine description files.
 
 ### You would hope that you could choose an m/*.h file pretty much
-### based on the machine portion of the configuration name, and an s-
+### based on the machine portion of the configuration name, and an s/*.h
 ### file based on the operating system portion.  However, it turns out
 ### that each m/*.h file is pretty manufacturer-specific - for
 ### example mips.h is MIPS
@@ -2736,10 +2736,6 @@
 ### /etc/MACHINES doesn't say anything about version numbers, be
 ### prepared to handle anything reasonably.  If version numbers
 ### matter, be sure /etc/MACHINES says something about it.
-###
-### Eric Raymond says we should accept strings like "sysvr4" to mean
-### "System V Release 4"; he writes, "The old convention encouraged
-### confusion between `system' and `release' levels'."
 
 machine='' opsys='' unported=no
 case "${canonical}" in
@@ -2748,14 +2744,14 @@
   *-*-freebsd* )
     opsys=freebsd
     case "${canonical}" in
-      alpha*-*-freebsd*)	machine=alpha ;;
-      arm*-*-freebsd*)          machine=arm ;;
-      ia64-*-freebsd*)		machine=ia64 ;;
-      sparc-*-freebsd*)         machine=sparc ;;
-      sparc64-*-freebsd*)	machine=sparc ;;
-      powerpc-*-freebsd*)	machine=macppc ;;
-      i[3456]86-*-freebsd*)	machine=intel386 ;;
-      amd64-*-freebsd*|x86_64-*-freebsd*) machine=amdx86-64 ;;
+      alpha*)           machine=alpha ;;
+      amd64-*|x86_64-*) machine=amdx86-64 ;;
+      arm*)             machine=arm ;;
+      ia64-*)           machine=ia64 ;;
+      i[3456]86-*)      machine=intel386 ;;
+      powerpc-*)        machine=macppc ;;
+      sparc-*)          machine=sparc ;;
+      sparc64-*)        machine=sparc ;;
     esac
   ;;
 
@@ -2763,13 +2759,13 @@
   *-*-kfreebsd*gnu* )
     opsys=gnu-kfreebsd
     case "${canonical}" in
-      alpha*-*-kfreebsd*)	machine=alpha ;;
-      ia64-*-kfreebsd*)		machine=ia64 ;;
-      sparc-*-kfreebsd*)	machine=sparc ;;
-      sparc64-*-kfreebsd*)	machine=sparc ;;
-      powerpc-*-kfreebsd*)	machine=macppc ;;
-      i[3456]86-*-kfreebsd*)	machine=intel386 ;;
-      amd64-*-kfreebsd*|x86_64-*-kfreebsd*) machine=amdx86-64 ;;
+      alpha*)           machine=alpha ;;
+      amd64-*|x86_64-*) machine=amdx86-64 ;;
+      ia64-*)           machine=ia64 ;;
+      i[3456]86-*)      machine=intel386 ;;
+      powerpc-*)        machine=macppc ;;
+      sparc-*)          machine=sparc ;;
+      sparc64-*)        machine=sparc ;;
     esac
   ;;
 
@@ -2777,18 +2773,17 @@
   *-*-netbsd* )
     opsys=netbsd
     case "${canonical}" in
-      alpha*-*-netbsd*)	machine=alpha ;;
-      i[3456]86-*-netbsd*) machine=intel386 ;;
-      mips-*-netbsd*)	machine=mips ;;
-      mipsel-*-netbsd*)	machine=mips ;;
-      mipseb-*-netbsd*)	machine=mips ;;
-      powerpc-*-netbsd*) machine=macppc ;;
-      sparc*-*-netbsd*)	machine=sparc ;;
-      vax-*-netbsd*)	machine=vax ;;
-      arm-*-netbsd*)	machine=arm ;;
-      x86_64-*-netbsd*)	machine=amdx86-64 ;;
-      hppa-*-netbsd*)	machine=hp800 ;;
-      m68k-*-netbsd*)	machine=m68k ;;
+      alpha*)      machine=alpha ;;
+      x86_64-*)    machine=amdx86-64 ;;
+      arm-*)       machine=arm ;;
+      hppa-*)      machine=hp800 ;;
+      i[3456]86-*) machine=intel386 ;;
+      m68k-*)      machine=m68k ;;
+      powerpc-*)   machine=macppc ;;
+      mips-*)      machine=mips ;;
+      mipse[bl]-*) machine=mips ;;
+      sparc*-)     machine=sparc ;;
+      vax-*)       machine=vax ;;
     esac
   ;;
 
@@ -2796,14 +2791,14 @@
   *-*-openbsd* )
     opsys=openbsd
     case "${canonical}" in
-      alpha*-*-openbsd*)	machine=alpha ;;
-      arm-*-openbsd*)          machine=arm ;;
-      i386-*-openbsd*)         machine=intel386 ;;
-      powerpc-*-openbsd*)      machine=macppc ;;
-      sparc*-*-openbsd*)       machine=sparc ;;
-      vax-*-openbsd*)          machine=vax ;;
-      x86_64-*-openbsd*)       machine=amdx86-64 ;;
-      hppa-*-openbsd*)         machine=hp800 ;;
+      alpha*)    machine=alpha ;;
+      x86_64-*)  machine=amdx86-64 ;;
+      arm-*)     machine=arm ;;
+      hppa-*)    machine=hp800 ;;
+      i386-*)    machine=intel386 ;;
+      powerpc-*) machine=macppc ;;
+      sparc*)    machine=sparc ;;
+      vax-*)     machine=vax ;;
     esac
   ;;
 
@@ -2854,16 +2849,16 @@
   s390x-*-linux-gnu* )
     machine=ibms390x opsys=gnu-linux
   ;;
-  rs6000-ibm-aix4.2* | powerpc-ibm-aix4.2*  )
+  rs6000-ibm-aix4.[23]* )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix4.3* | powerpc-ibm-aix4.3*  )
+  powerpc-ibm-aix4.[23]*  )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix5* | powerpc-ibm-aix5*  )
+  rs6000-ibm-aix[56]* )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix6* | powerpc-ibm-aix6*  )
+  powerpc-ibm-aix[56]*  )
     machine=ibmrs6000 opsys=aix4-2
   ;;
 
@@ -2932,7 +2927,7 @@
     machine=ia64 opsys=gnu-linux
   ;;
 
-  ## Intel 386 machines where we don't care about the manufacturer
+  ## Intel 386 machines where we don't care about the manufacturer.
   i[3456]86-*-* )
     machine=intel386
     case "${canonical}" in
--- a/configure.in	Sat May 29 09:39:12 2010 +0000
+++ b/configure.in	Sun May 30 00:32:06 2010 +0000
@@ -32,6 +32,10 @@
 dnl --program-transform-name options
 AC_ARG_PROGRAM
 
+dnl It is important that variables on the RHS not be expanded here,
+dnl hence the single quotes.  This is per the GNU coding standards, see
+dnl (autoconf) Installation Directory Variables
+dnl See also epaths.h below.
 lispdir='${datadir}/emacs/${version}/lisp'
 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
 '${datadir}/emacs/site-lisp'
@@ -3750,6 +3754,14 @@
 test "${exec_prefix}" != NONE &&
   exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`]
 
+dnl You might wonder (I did) why epaths.h is generated by running make,
+dnl rather than just letting configure generate it from epaths.in.
+dnl One reason is that the various paths are not fully expanded (see above);
+dnl eg gamedir=${prefix}/var/games/emacs.
+dnl Secondly, the GNU Coding standards require that one should be able
+dnl to run `make prefix=/some/where/else' and override the values set
+dnl by configure.  This also explains the `move-if-change' test and
+dnl the use of force in the `epaths-force' rule in Makefile.in.
 AC_OUTPUT(Makefile lib-src/Makefile oldXMenu/Makefile \
 	doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
 	doc/lispref/Makefile src/Makefile \
--- a/doc/emacs/ChangeLog	Sat May 29 09:39:12 2010 +0000
+++ b/doc/emacs/ChangeLog	Sun May 30 00:32:06 2010 +0000
@@ -1,3 +1,8 @@
+2010-05-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* basic.texi (Moving Point): Update due to renaming of commands bound
+	to arrows.  Document bidi-aware behavior of C-<right> and C-<left>.
+
 2010-05-18  Eli Zaretskii  <eliz@gnu.org>
 
 	* display.texi (Fringes): Document reversal of fringe arrows for R2L
--- a/doc/emacs/basic.texi	Sat May 29 09:39:12 2010 +0000
+++ b/doc/emacs/basic.texi	Sun May 30 00:32:06 2010 +0000
@@ -146,8 +146,8 @@
 @findex move-end-of-line
 @findex forward-char
 @findex backward-char
-@findex right-arrow-command
-@findex left-arrow-command
+@findex right-char
+@findex left-char
 @findex next-line
 @findex previous-line
 @findex beginning-of-buffer
@@ -165,7 +165,7 @@
 @item C-f
 Move forward one character (@code{forward-char}).
 @item @key{right}
-Move one character to the right (@code{right-arrow-command}).  This
+Move one character to the right (@code{right-char}).  This
 moves one character forward in text that is read in the usual
 left-to-right direction, but one character @emph{backward} if the text
 is read right-to-left, as needed for right-to-left scripts such as
@@ -173,17 +173,23 @@
 @item C-b
 Move backward one character (@code{backward-char}).
 @item @key{left}
-Move one character to the left (@code{left-arrow-command}).  This
+Move one character to the left (@code{left-char}).  This
 moves one character backward in left-to-right text and one character
 forward in right-to-left text.
 @item M-f
 @itemx M-@key{right}
-@itemx C-@key{right}
 Move forward one word (@code{forward-word}).
+@item C-@key{right}
+Move one word to the right (@code{right-word}).  This moves one word
+forward in left-to-right text and one word backward in right-to-left
+text.
 @item M-b
 @itemx M-@key{left}
-@itemx C-@key{left}
 Move backward one word (@code{backward-word}).
+@item C-@key{left}
+Move one word to the left (@code{left-word}).  This moves one word
+backward in left-to-right text and one word forward in right-to-left
+text.
 @item C-n
 @itemx @key{down}
 Move down one screen line (@code{next-line}).  This command attempts
--- a/etc/NEWS	Sat May 29 09:39:12 2010 +0000
+++ b/etc/NEWS	Sun May 30 00:32:06 2010 +0000
@@ -43,6 +43,10 @@
 
 * Changes in Emacs 24.1
 
+** New emacsclient argument --parent-id ID can be used to open a
+client frame in parent X window ID, via XEmbed.  This works like the
+--parent-id argument to Emacs.
+
 ** Completion can cycle, depending on completion-cycle-threshold.
 
 ** auto-mode-case-fold is now enabled by default.
--- a/lib-src/ChangeLog	Sat May 29 09:39:12 2010 +0000
+++ b/lib-src/ChangeLog	Sun May 30 00:32:06 2010 +0000
@@ -1,3 +1,9 @@
+2010-05-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacsclient.c (longopts, decode_options, print_help_and_exit):
+	New arg `-parent-id'.
+	(main): Send parent-id to Emacs.
+
 2010-05-27  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (distclean): No more Makefile.c.
--- a/lib-src/emacsclient.c	Sat May 29 09:39:12 2010 +0000
+++ b/lib-src/emacsclient.c	Sun May 30 00:32:06 2010 +0000
@@ -138,6 +138,9 @@
 /* The display on which Emacs should work.  --display.  */
 char *display = NULL;
 
+/* The parent window ID, if we are opening a frame via XEmbed.  */
+char *parent_id = NULL;
+
 /* Nonzero means open a new Emacs frame on the current terminal. */
 int tty = 0;
 
@@ -173,6 +176,7 @@
 #ifndef WINDOWSNT
   { "display",	required_argument, NULL, 'd' },
 #endif
+  { "parent-id", required_argument, NULL, 'p' },
   { 0, 0, 0, 0 }
 };
 
@@ -583,6 +587,11 @@
           current_frame = 0;
           break;
 
+	case 'p':
+	  parent_id = optarg;
+          current_frame = 0;
+	  break;
+
 	case 'H':
 	  print_help_and_exit ();
 	  break;
@@ -656,7 +665,8 @@
 -e, --eval    		Evaluate the FILE arguments as ELisp expressions\n\
 -n, --no-wait		Don't wait for the server to return\n\
 -d DISPLAY, --display=DISPLAY\n\
-			Visit the file in the given display\n"
+			Visit the file in the given display\n\
+--parent-id=ID          Open in parent window ID, via XEmbed\n"
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
 "-s SOCKET, --socket-name=SOCKET\n\
 			Set filename of the UNIX socket for communication\n"
@@ -1620,6 +1630,13 @@
       send_to_emacs (emacs_socket, " ");
     }
 
+  if (parent_id)
+    {
+      send_to_emacs (emacs_socket, "-parent-id ");
+      quote_argument (emacs_socket, parent_id);
+      send_to_emacs (emacs_socket, " ");
+    }
+
   /* If using the current frame, send tty information to Emacs anyway.
      In daemon mode, Emacs may need to occupy this tty if no other
      frame is available.  */
--- a/lisp/ChangeLog	Sat May 29 09:39:12 2010 +0000
+++ b/lisp/ChangeLog	Sun May 30 00:32:06 2010 +0000
@@ -1,5 +1,33 @@
+2010-05-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* server.el (server-process-filter): Receive parent-id argument
+	from emacsclient.
+	(server-create-window-system-frame): New arg.  Pass parent-id as
+	frame parameter.
+
+2010-05-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* ansi-color.el: Delete unused escape sequences (Bug#6085).
+	(ansi-color-drop-regexp): New constant.
+	(ansi-color-apply, ansi-color-filter-region)
+	(ansi-color-apply-on-region): Delete unrecognized control
+	sequences.
+	(ansi-color-apply): Build string list before calling concat.
+
 2010-05-29  Eli Zaretskii  <eliz@gnu.org>
 
+	Bidi-sensitive word movement with arrow keys.
+	* subr.el (right-arrow-command, left-arrow-command): Move to
+	bindings.el.
+
+	* bindings.el (right-char, left-char): Move from subr.el and
+	rename from right-arrow-command and left-arrow-command.
+	(right-word, left-word): New functions.
+	(global-map) <right>: Bind to right-char.
+	(global-map) <left>: Bind to left-char.
+	(global-map) <C-right>: Bind to right-word.
+	(global-map) <C-left>: Bind to left-word.
+
 	* ls-lisp.el (ls-lisp-classify-file): New function.
 	(ls-lisp-insert-directory): Call it if switches include -F (bug#6294).
 	(ls-lisp-classify): Call ls-lisp-classify-file.
--- a/lisp/ansi-color.el	Sat May 29 09:39:12 2010 +0000
+++ b/lisp/ansi-color.el	Sun May 30 00:32:06 2010 +0000
@@ -142,6 +142,10 @@
 (defconst ansi-color-regexp "\033\\[\\([0-9;]*m\\)"
   "Regexp that matches SGR control sequences.")
 
+(defconst ansi-color-drop-regexp
+  "\033\\[\\([ABCDsuK]\\|2J\\|=[0-9]+[hI]\\|[0-9;]*[Hf]\\)"
+  "Regexp that matches ANSI control sequences to silently drop.")
+
 (defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]"
   "Regexp that matches SGR control sequence parameters.")
 
@@ -154,7 +158,7 @@
 If nil, do nothing.
 If the symbol `filter', then filter all SGR control sequences.
 If anything else (such as t), then translate SGR control sequences
-into text-properties.
+into text properties.
 
 In order for this to have any effect, `ansi-color-process-output' must
 be in `comint-output-filter-functions'.
@@ -188,12 +192,12 @@
 
 ;;;###autoload
 (defun ansi-color-process-output (ignored)
-  "Maybe translate SGR control sequences of comint output into text-properties.
+  "Maybe translate SGR control sequences of comint output into text properties.
 
 Depending on variable `ansi-color-for-comint-mode' the comint output is
 either not processed, SGR control sequences are filtered using
 `ansi-color-filter-region', or SGR control sequences are translated into
-text-properties using `ansi-color-apply-on-region'.
+text properties using `ansi-color-apply-on-region'.
 
 The comint output is assumed to lie between the marker
 `comint-last-output-start' and the process-mark.
@@ -217,15 +221,15 @@
 (defun ansi-color-unfontify-region (beg end &rest xemacs-stuff)
   "Replacement function for `font-lock-default-unfontify-region'.
 
-As text-properties are implemented using extents in XEmacs, this
+As text properties are implemented using extents in XEmacs, this
 function is probably not needed.  In Emacs, however, things are a bit
 different: When font-lock is active in a buffer, you cannot simply add
-face text-properties to the buffer.  Font-lock will remove the face
-text-property using `font-lock-unfontify-region-function'.  If you want
+face text properties to the buffer.  Font-lock will remove the face
+text property using `font-lock-unfontify-region-function'.  If you want
 to insert the strings returned by `ansi-color-apply' into such buffers,
 you must set `font-lock-unfontify-region-function' to
 `ansi-color-unfontify-region'.  This function will not remove all face
-text-properties unconditionally.  It will keep the face text-properties
+text properties unconditionally.  It will keep the face text properties
 if the property `ansi-color' is set.
 
 The region from BEG to END is unfontified.  XEMACS-STUFF is ignored.
@@ -262,7 +266,7 @@
 (make-variable-buffer-local 'ansi-color-context)
 
 (defun ansi-color-filter-apply (string)
-  "Filter out all SGR control sequences from STRING.
+  "Filter out all ANSI control sequences from STRING.
 
 Every call to this function will set and use the buffer-local variable
 `ansi-color-context' to save partial escape sequences.  This information
@@ -292,10 +296,11 @@
     result))
 
 (defun ansi-color-apply (string)
-  "Translates SGR control sequences into text-properties.
+  "Translates SGR control sequences into text properties.
+Delete all other control sequences without processing them.
 
 Applies SGR control sequences setting foreground and background colors
-to STRING using text-properties and returns the result.  The colors used
+to STRING using text properties and returns the result.  The colors used
 are given in `ansi-color-faces-vector' and `ansi-color-names-vector'.
 See function `ansi-color-apply-sequence' for details.
 
@@ -309,23 +314,27 @@
 You cannot insert the strings returned into buffers using font-lock.
 See `ansi-color-unfontify-region' for a way around this."
   (let ((face (car ansi-color-context))
-	(start 0) end escape-sequence result)
-    ;; if context was saved and is a string, prepend it
+	(start 0) end escape-sequence result
+	colorized-substring)
+    ;; If context was saved and is a string, prepend it.
     (if (cadr ansi-color-context)
         (setq string (concat (cadr ansi-color-context) string)
               ansi-color-context nil))
-    ;; find the next escape sequence
+    ;; Find the next escape sequence.
     (while (setq end (string-match ansi-color-regexp string start))
-      ;; store escape sequence
       (setq escape-sequence (match-string 1 string))
-      ;; colorize the old block from start to end using old face
+      ;; Colorize the old block from start to end using old face.
       (when face
 	(put-text-property start end 'ansi-color t string)
 	(put-text-property start end 'face face string))
-      (setq result (concat result (substring string start end))
+      (setq colorized-substring (substring string start end)
 	    start (match-end 0))
-      ;; create new face by applying all the parameters in the escape
-      ;; sequence
+      ;; Eliminate unrecognized ANSI sequences.
+      (while (string-match ansi-color-drop-regexp colorized-substring)
+	(setq colorized-substring
+	      (replace-match "" nil nil colorized-substring)))
+      (push colorized-substring result)
+      ;; Create new face, by applying escape sequence parameters.
       (setq face (ansi-color-apply-sequence escape-sequence face)))
     ;; if the rest of the string should have a face, put it there
     (when face
@@ -335,13 +344,13 @@
     (let (fragment)
       (if (string-match "\033" string start)
 	  (let ((pos (match-beginning 0)))
-	    (setq fragment (substring string pos)
-		  result (concat result (substring string start pos))))
-	(setq result (concat result (substring string start))))
+	    (setq fragment (substring string pos))
+	    (push (substring string start pos) result))
+	(push (substring string start) result))
       (if (or face fragment)
 	  (setq ansi-color-context (list face fragment))
 	(setq ansi-color-context nil)))
-    result))
+    (apply 'concat (nreverse result))))
 
 ;; Working with regions
 
@@ -354,7 +363,7 @@
 (make-variable-buffer-local 'ansi-color-context-region)
 
 (defun ansi-color-filter-region (begin end)
-  "Filter out all SGR control sequences from region BEGIN to END.
+  "Filter out all ANSI control sequences from region BEGIN to END.
 
 Every call to this function will set and use the buffer-local variable
 `ansi-color-context-region' to save position.  This information will be
@@ -365,23 +374,27 @@
 	(start (or (cadr ansi-color-context-region) begin)))
     (save-excursion
       (goto-char start)
-      ;; find the next escape sequence
-      (while (re-search-forward ansi-color-regexp end-marker t)
-	;; delete the escape sequence
+      ;; Delete unrecognized escape sequences.
+      (while (re-search-forward ansi-color-drop-regexp end-marker t)
         (replace-match ""))
-    ;; save context, add the remainder of the string to the result
-    (if (re-search-forward "\033" end-marker t)
-	(setq ansi-color-context-region (list nil (match-beginning 0)))
-      (setq ansi-color-context-region nil)))))
+      (goto-char start)
+      ;; Delete SGR escape sequences.
+      (while (re-search-forward ansi-color-regexp end-marker t)
+        (replace-match ""))
+      ;; save context, add the remainder of the string to the result
+      (if (re-search-forward "\033" end-marker t)
+	  (setq ansi-color-context-region (list nil (match-beginning 0)))
+	(setq ansi-color-context-region nil)))))
 
 (defun ansi-color-apply-on-region (begin end)
   "Translates SGR control sequences into overlays or extents.
+Delete all other control sequences without processing them.
 
-Applies SGR control sequences setting foreground and background colors
-to text in region between BEGIN and END using extents or overlays.
-Emacs will use overlays, XEmacs will use extents.  The colors used are
-given in `ansi-color-faces-vector' and `ansi-color-names-vector'.  See
-function `ansi-color-apply-sequence' for details.
+SGR control sequences are applied by setting foreground and
+background colors to the text between BEGIN and END using
+overlays.  The colors used are given in `ansi-color-faces-vector'
+and `ansi-color-names-vector'.  See `ansi-color-apply-sequence'
+for details.
 
 Every call to this function will set and use the buffer-local variable
 `ansi-color-context-region' to save position and current face.  This
@@ -394,11 +407,16 @@
 			  (copy-marker begin)))
 	(end-marker (copy-marker end))
 	escape-sequence)
+    ;; First, eliminate unrecognized ANSI control sequences.
     (save-excursion
       (goto-char start-marker)
-      ;; find the next escape sequence
+      (while (re-search-forward ansi-color-drop-regexp end-marker t)
+	(replace-match "")))
+    (save-excursion
+      (goto-char start-marker)
+      ;; Find the next SGR sequence.
       (while (re-search-forward ansi-color-regexp end-marker t)
-	;; colorize the old block from start to end using old face
+	;; Colorize the old block from start to end using old face.
 	(when face
 	  (ansi-color-set-extent-face
 	   (ansi-color-make-extent start-marker (match-beginning 0))
--- a/lisp/bindings.el	Sat May 29 09:39:12 2010 +0000
+++ b/lisp/bindings.el	Sun May 30 00:32:06 2010 +0000
@@ -678,6 +678,63 @@
 ;but they are not assigned to keys there.
 (put 'narrow-to-region 'disabled t)
 
+;; Moving with arrows in bidi-sensitive direction.
+(defun right-char (&optional n)
+  "Move point N characters to the right (to the left if N is negative).
+On reaching beginning or end of buffer, stop and signal error.
+
+Depending on the bidirectional context, this may move either forward
+or backward in the buffer.  This is in contrast with \\[forward-char]
+and \\[backward-char], which see."
+  (interactive "^p")
+  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+      (forward-char n)
+    (backward-char n)))
+
+(defun left-char ( &optional n)
+  "Move point N characters to the left (to the right if N is negative).
+On reaching beginning or end of buffer, stop and signal error.
+
+Depending on the bidirectional context, this may move either backward
+or forward in the buffer.  This is in contrast with \\[backward-char]
+and \\[forward-char], which see."
+  (interactive "^p")
+  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+      (backward-char n)
+    (forward-char n)))
+
+(defun right-word (&optional n)
+  "Move point N words to the right (to the left if N is negative).
+
+Depending on the bidirectional context, this may move either forward
+or backward in the buffer.  This is in contrast with \\[forward-word]
+and \\[backward-word], which see.
+
+Value is normally t.
+If an edge of the buffer or a field boundary is reached, point is left there
+there and the function returns nil.  Field boundaries are not noticed
+if `inhibit-field-text-motion' is non-nil."
+  (interactive "^p")
+  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+      (forward-word n)
+    (backward-word n)))
+
+(defun left-word (&optional n)
+  "Move point N words to the left (to the right if N is negative).
+
+Depending on the bidirectional context, this may move either backward
+or forward in the buffer.  This is in contrast with \\[backward-word]
+and \\[forward-word], which see.
+
+Value is normally t.
+If an edge of the buffer or a field boundary is reached, point is left there
+there and the function returns nil.  Field boundaries are not noticed
+if `inhibit-field-text-motion' is non-nil."
+  (interactive "^p")
+  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+      (backward-word n)
+    (forward-word n)))
+
 (defvar narrow-map (make-sparse-keymap)
   "Keymap for narrowing commands.")
 (define-key ctl-x-map "n" narrow-map)
@@ -828,9 +885,9 @@
 (define-key global-map [C-home]		'beginning-of-buffer)
 (define-key global-map [M-home]		'beginning-of-buffer-other-window)
 (define-key esc-map    [home]		'beginning-of-buffer-other-window)
-(define-key global-map [left]		'left-arrow-command)
+(define-key global-map [left]		'left-char)
 (define-key global-map [up]		'previous-line)
-(define-key global-map [right]		'right-arrow-command)
+(define-key global-map [right]		'right-char)
 (define-key global-map [down]		'next-line)
 (define-key global-map [prior]		'scroll-down-command)
 (define-key global-map [next]		'scroll-up-command)
@@ -1030,8 +1087,8 @@
 (global-set-key [M-left]   'backward-word)
 (define-key esc-map [left] 'backward-word)
 ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
-(global-set-key [C-right]  'forward-word)
-(global-set-key [C-left]   'backward-word)
+(global-set-key [C-right]  'right-word)
+(global-set-key [C-left]   'left-word)
 ;; This is not quite compatible, but at least is analogous
 (global-set-key [C-delete] 'kill-word)
 (global-set-key [C-backspace] 'backward-kill-word)
--- a/lisp/server.el	Sat May 29 09:39:12 2010 +0000
+++ b/lisp/server.el	Sun May 30 00:32:06 2010 +0000
@@ -711,7 +711,7 @@
                                      (number-to-string (emacs-pid)) "\n"))
     frame))
 
-(defun server-create-window-system-frame (display nowait proc)
+(defun server-create-window-system-frame (display nowait proc parent-id)
   (add-to-list 'frame-inherited-parameters 'client)
   (if (not (fboundp 'make-frame-on-display))
       (progn
@@ -727,12 +727,14 @@
     (let* ((params `((client . ,(if nowait 'nowait proc))
                      ;; This is a leftover, see above.
                      (environment . ,(process-get proc 'env))))
-           (frame (make-frame-on-display
-                   (or display
-                       (frame-parameter nil 'display)
-                       (getenv "DISPLAY")
-                       (error "Please specify display"))
-                   params)))
+	   (display (or display
+			(frame-parameter nil 'display)
+			(getenv "DISPLAY")
+			(error "Please specify display")))
+	   frame)
+      (if parent-id
+	  (push (cons 'parent-id (string-to-number parent-id)) params))
+      (setq frame (make-frame-on-display display params))
       (server-log (format "%s created" frame) proc)
       (select-frame frame)
       (process-put proc 'frame frame)
@@ -900,15 +902,16 @@
 		(coding-system (and (default-value 'enable-multibyte-characters)
 				    (or file-name-coding-system
 					default-file-name-coding-system)))
-		nowait ; t if emacsclient does not want to wait for us.
-		frame ; The frame that was opened for the client (if any).
-		display		     ; Open the frame on this display.
-		dontkill       ; t if the client should not be killed.
+		nowait     ; t if emacsclient does not want to wait for us.
+		frame      ; Frame opened for the client (if any).
+		display    ; Open frame on this display.
+		parent-id  ; Window ID for XEmbed
+		dontkill   ; t if client should not be killed.
 		commands
 		dir
 		use-current-frame
-		tty-name       ;nil, `window-system', or the tty name.
-		tty-type             ;string.
+		tty-name   ; nil, `window-system', or the tty name.
+		tty-type   ; string.
 		files
 		filepos
 		command-line-args-left
@@ -935,6 +938,12 @@
 		  (setq display (pop command-line-args-left))
                   (if (zerop (length display)) (setq display nil)))
 
+		 ;; -parent-id ID:
+		 ;; Open X frame within window ID, via XEmbed.
+		 ((and (equal "-parent-id" arg) command-line-args-left)
+		  (setq parent-id (pop command-line-args-left))
+                  (if (zerop (length parent-id)) (setq parent-id nil)))
+
 		 ;; -window-system:  Open a new X frame.
 		 ((equal "-window-system" arg)
                   (setq dontkill t)
@@ -1039,7 +1048,8 @@
 		    (setq tty-name nil tty-type nil)
 		    (if display (server-select-display display)))
 		   ((eq tty-name 'window-system)
-		    (server-create-window-system-frame display nowait proc))
+		    (server-create-window-system-frame display nowait proc
+						       parent-id))
 		   ;; When resuming on a tty, tty-name is nil.
 		   (tty-name
 		    (server-create-tty-frame tty-name tty-type proc))))
--- a/lisp/subr.el	Sat May 29 09:39:12 2010 +0000
+++ b/lisp/subr.el	Sun May 30 00:32:06 2010 +0000
@@ -3802,30 +3802,5 @@
 			  (prin1-to-string (make-hash-table)))))
   (provide 'hashtable-print-readable))
 
-;; Moving with arrows in bidi-sensitive direction.
-(defun right-arrow-command (&optional n)
-  "Move point N characters to the right (to the left if N is negative).
-On reaching beginning or end of buffer, stop and signal error.
-
-Depending on the bidirectional context, this may move either forward
-or backward in the buffer.  This is in contrast with \\[forward-char]
-and \\[backward-char], which see."
-  (interactive "^p")
-  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
-      (forward-char n)
-    (backward-char n)))
-
-(defun left-arrow-command ( &optional n)
-  "Move point N characters to the left (to the right if N is negative).
-On reaching beginning or end of buffer, stop and signal error.
-
-Depending on the bidirectional context, this may move either backward
-or forward in the buffer.  This is in contrast with \\[backward-char]
-and \\[forward-char], which see."
-  (interactive "^p")
-  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
-      (backward-char n)
-    (forward-char n)))
-
 ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc
 ;;; subr.el ends here
--- a/src/ChangeLog	Sat May 29 09:39:12 2010 +0000
+++ b/src/ChangeLog	Sun May 30 00:32:06 2010 +0000
@@ -1,3 +1,12 @@
+2010-05-29  Eli Zaretskii  <eliz@gnu.org>
+
+	Fix cursor motion in bidi-reordered continued lines.
+	* xdisp.c (try_cursor_movement): Backup to non-continuation line
+	only after finding point's row.  Fix the logic.  Rewrite the loop
+	over continuation lines in bidi-reordered buffers.  Return
+	CURSOR_MOVEMENT_MUST_SCROLL upon failure to find a suitable row,
+	rather than CURSOR_MOVEMENT_CANNOT_BE_USED.
+
 2010-05-28  Michael Albinus  <michael.albinus@gmx.de>
 
 	* fileio.c (Fdelete_file): Pass TRASH arg to handler call.
--- a/src/xdisp.c	Sat May 29 09:39:12 2010 +0000
+++ b/src/xdisp.c	Sun May 30 00:32:06 2010 +0000
@@ -13763,37 +13763,11 @@
 	    ++row;
 	  if (!row->enabled_p)
 	    rc = CURSOR_MOVEMENT_MUST_SCROLL;
-	  /* If rows are bidi-reordered, back up until we find a row
-	     that does not belong to a continuation line.  This is
-	     because we must consider all rows of a continued line as
-	     candidates for cursor positioning, since row start and
-	     end positions change non-linearly with vertical position
-	     in such rows.  */
-	  /* FIXME: Revisit this when glyph ``spilling'' in
-	     continuation lines' rows is implemented for
-	     bidi-reordered rows.  */
-	  if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering))
-	    {
-	      while (MATRIX_ROW_CONTINUATION_LINE_P (row))
-		{
-		  xassert (row->enabled_p);
-		  --row;
-		  /* If we hit the beginning of the displayed portion
-		     without finding the first row of a continued
-		     line, give up.  */
-		  if (row <= w->current_matrix->rows)
-		    {
-		      rc = CURSOR_MOVEMENT_MUST_SCROLL;
-		      break;
-		    }
-
-		}
-	    }
 	}
 
       if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED)
 	{
-	  int scroll_p = 0;
+	  int scroll_p = 0, must_scroll = 0;
 	  int last_y = window_text_bottom_y (w) - this_scroll_margin;
 
 	  if (PT > XFASTINT (w->last_point))
@@ -13886,10 +13860,41 @@
 	    {
 	      /* if PT is not in the glyph row, give up.  */
 	      rc = CURSOR_MOVEMENT_MUST_SCROLL;
+	      must_scroll = 1;
 	    }
 	  else if (rc != CURSOR_MOVEMENT_SUCCESS
-		   && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
-		   && make_cursor_line_fully_visible_p)
+		   && !NILP (XBUFFER (w->buffer)->bidi_display_reordering))
+	    {
+	      /* If rows are bidi-reordered and point moved, back up
+		 until we find a row that does not belong to a
+		 continuation line.  This is because we must consider
+		 all rows of a continued line as candidates for the
+		 new cursor positioning, since row start and end
+		 positions change non-linearly with vertical position
+		 in such rows.  */
+	      /* FIXME: Revisit this when glyph ``spilling'' in
+		 continuation lines' rows is implemented for
+		 bidi-reordered rows.  */
+	      while (MATRIX_ROW_CONTINUATION_LINE_P (row))
+		{
+		  xassert (row->enabled_p);
+		  --row;
+		  /* If we hit the beginning of the displayed portion
+		     without finding the first row of a continued
+		     line, give up.  */
+		  if (row <= w->current_matrix->rows)
+		    {
+		      rc = CURSOR_MOVEMENT_MUST_SCROLL;
+		      break;
+		    }
+
+		}
+	    }
+	  if (must_scroll)
+	    ;
+	  else if (rc != CURSOR_MOVEMENT_SUCCESS
+	      && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
+	      && make_cursor_line_fully_visible_p)
 	    {
 	      if (PT == MATRIX_ROW_END_CHARPOS (row)
 		  && !row->ends_at_zv_p
@@ -13915,7 +13920,8 @@
 	    }
 	  else if (scroll_p)
 	    rc = CURSOR_MOVEMENT_MUST_SCROLL;
-	  else if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering))
+	  else if (rc != CURSOR_MOVEMENT_SUCCESS
+		   && !NILP (XBUFFER (w->buffer)->bidi_display_reordering))
 	    {
 	      /* With bidi-reordered rows, there could be more than
 		 one candidate row whose start and end positions
@@ -13928,8 +13934,11 @@
 
 	      do
 		{
-		  rv |= set_cursor_from_row (w, row, w->current_matrix,
-					     0, 0, 0, 0);
+		  if (MATRIX_ROW_START_CHARPOS (row) <= PT
+		      && PT <= MATRIX_ROW_END_CHARPOS (row)
+		      && cursor_row_p (w, row))
+		    rv |= set_cursor_from_row (w, row, w->current_matrix,
+					       0, 0, 0, 0);
 		  /* As soon as we've found the first suitable row
 		     whose ends_at_zv_p flag is set, we are done.  */
 		  if (rv
@@ -13940,19 +13949,17 @@
 		    }
 		  ++row;
 		}
-	      while (MATRIX_ROW_BOTTOM_Y (row) < last_y
-		     && MATRIX_ROW_START_CHARPOS (row) <= PT
-		     && PT <= MATRIX_ROW_END_CHARPOS (row)
-		     && cursor_row_p (w, row));
+	      while ((MATRIX_ROW_CONTINUATION_LINE_P (row)
+		      && MATRIX_ROW_BOTTOM_Y (row) <= last_y)
+		     || (MATRIX_ROW_START_CHARPOS (row) == PT
+			 && MATRIX_ROW_BOTTOM_Y (row) < last_y));
 	      /* If we didn't find any candidate rows, or exited the
 		 loop before all the candidates were examined, signal
 		 to the caller that this method failed.  */
 	      if (rc != CURSOR_MOVEMENT_SUCCESS
-		  && (!rv
-		      || (MATRIX_ROW_START_CHARPOS (row) <= PT
-			  && PT <= MATRIX_ROW_END_CHARPOS (row))))
-		rc = CURSOR_MOVEMENT_CANNOT_BE_USED;
-	      else
+		  && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row)))
+		rc = CURSOR_MOVEMENT_MUST_SCROLL;
+	      else if (rv)
 		rc = CURSOR_MOVEMENT_SUCCESS;
 	    }
 	  else