changeset 108045:ad01848d2984

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 12 Apr 2010 01:03:06 +0000
parents c2a207021794 (current diff) bdf130eb4bf3 (diff)
children f61e8ca6c2fd
files
diffstat 47 files changed, 1392 insertions(+), 383 deletions(-) [+]
line wrap: on
line diff
--- a/.bzrignore	Wed Apr 07 21:55:20 2010 +0000
+++ b/.bzrignore	Mon Apr 12 01:03:06 2010 +0000
@@ -65,3 +65,4 @@
 configure.lineno
 conftest*
 confdefs.h
+core
--- a/admin/CPP-DEFINES	Wed Apr 07 21:55:20 2010 +0000
+++ b/admin/CPP-DEFINES	Mon Apr 12 01:03:06 2010 +0000
@@ -106,7 +106,6 @@
 CRT0_DUMMIES
 C_SWITCH_MACHINE
 C_SWITCH_SYSTEM
-C_SWITCH_SYSTEM_TEMACS
 C_SWITCH_X_SYSTEM
 DATA_SEG_BITS
 DATA_START
--- a/doc/emacs/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/doc/emacs/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,11 @@
+2010-04-11  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xresources.texi (Lucid Resources): Mention faceName for dialogs.
+
+2010-04-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
+
 2010-03-30  Eli Zaretskii  <eliz@gnu.org>
 
 	* mule.texi (Input Methods): Mention "C-x 8 RET" and add a
--- a/doc/emacs/xresources.texi	Wed Apr 07 21:55:20 2010 +0000
+++ b/doc/emacs/xresources.texi	Mon Apr 12 01:03:06 2010 +0000
@@ -399,8 +399,9 @@
 @end table
 
 @node Lucid Resources
-@appendixsec Lucid Menu X Resources
+@appendixsec Lucid Menu And Dialog X Resources
 @cindex Menu X Resources (Lucid widgets)
+@cindex Dialog X Resources (Lucid widgets)
 @cindex Lucid Widget X Resources
 
 @ifnottex
@@ -415,7 +416,7 @@
 @end example
 
 @noindent
-For example, to specify the font @samp{8x16} for the menu-bar items,
+For example, to specify the font @samp{Courier-12} for the menu-bar items,
 write this:
 @end ifnottex
 @iftex
@@ -423,11 +424,46 @@
 with the Lucid menu widgets, then the menu bar is a separate widget
 and has its own resources.  The resource specifications start with
 @samp{Emacs.pane.menubar}---for instance, to specify the font
-@samp{8x16} for the menu-bar items, write this:
+@samp{Courier-12} for the menu-bar items, write this:
 @end iftex
 
 @example
-Emacs.pane.menubar.font:  8x16
+Emacs.pane.menubar.faceName:  Courier-12
+@end example
+
+@noindent
+To specify a font, use fontconfig font names as values to the @code{faceName}
+resource.
+
+If Emacs is not built with the Xft library, Lucid menus and dialogs can only 
+display old style fonts.  If Emacs is built with Xft and you prefer the old 
+fonts, you have to specify @samp{none} to @code{faceName}:
+
+@example
+Emacs.pane.menubar.faceName:	none
+Emacs.pane.dialog.faceName:	none
+@end example
+
+@noindent
+To specify a non-Xft font, use @code{font}.  For example:
+
+@example
+Emacs.pane.menubar.font: lucidasanstypewriter-10
+@end example
+
+@noindent
+The Lucid menus can display multilingual text in your locale with old style
+fonts.  For more information about fontsets see the man page for
+@code{XCreateFontSet}.  To enable multilingual menu text you specify a
+@code{fontSet} resource instead of the font resource.  If both
+@code{font} and @code{fontSet} resources are specified, the
+@code{fontSet} resource is used.
+
+  Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
+for both the popup and menu bar menus, write this:
+
+@example
+Emacs*menu*fontSet:  -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
 @end example
 
 @noindent
@@ -443,22 +479,7 @@
 For dialog boxes, use @samp{dialog*}:
 
 @example
-Emacs.dialog*.font:	8x16
-@end example
-
-@noindent
-The Lucid menus can display multilingual text in your locale.  For
-more information about fontsets see the man page for
-@code{XCreateFontSet}.  To enable multilingual menu text you specify a
-@code{fontSet} resource instead of the font resource.  If both
-@code{font} and @code{fontSet} resources are specified, the
-@code{fontSet} resource is used.
-
-  Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
-for both the popup and menu bar menus, write this:
-
-@example
-Emacs*menu*fontSet:  -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
+Emacs.dialog*.faceName:	Sans-12
 @end example
 
 @noindent
@@ -473,6 +494,8 @@
   Here is a list of the specific resources for menu bars and pop-up menus:
 
 @table @code
+@item faceName
+Xft font for menu item text.
 @item font
 Font for menu item text.
 @item fontSet
--- a/doc/misc/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/doc/misc/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,14 @@
+2010-04-10  Michael Albinus  <michael.albinus@gmx.de>
+
+	Synchronize with Tramp repository.
+
+	* tramp.texi (Auto-save and Backup): Remove reference to Emacs 21.
+	(Frequently Asked Questions): Adapt supported (X)Emacs versions.  Adapt
+	supported MS Windows versions.  Remove obsolete URL.  Use the $()
+	syntax, texi2dvi reports errors with the backquotes.
+
+	* trampver.texi: Update release number.
+
 2010-04-01  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* gnus.texi (Finding the News): Add pointers to the Server buffer
Binary file doc/misc/tramp.texi has changed
--- a/doc/misc/trampver.texi	Wed Apr 07 21:55:20 2010 +0000
+++ b/doc/misc/trampver.texi	Mon Apr 12 01:03:06 2010 +0000
@@ -2,14 +2,14 @@
 @c texi/trampver.texi.  Generated from trampver.texi.in by configure.
 
 @c This is part of the Emacs manual.
-@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+@c   2010 Free Software Foundation, Inc.
 @c See file doclicense.texi for copying conditions.
 
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@set trampver 2.1.18-23.2
+@set trampver 2.1.19-pre
 
 @c Other flags from configuration
 @set instprefix /usr/local
--- a/etc/NEWS	Wed Apr 07 21:55:20 2010 +0000
+++ b/etc/NEWS	Mon Apr 12 01:03:06 2010 +0000
@@ -65,6 +65,9 @@
 ** GTK scroll-bars are now placed on the right by default.
 Use `set-scroll-bar-mode' to change this.
 
+** Lucid menus and dialogs can display antialiased fonts if Emacs is built
+with Xft.
+
 ** New scrolling commands `scroll-up-command' and `scroll-down-command'
 (bound to [next] and [prior]) does not signal errors at top/bottom
 of buffer at first key-press (instead moves to top/bottom of buffer).
@@ -105,6 +108,10 @@
 Author: NAME
 line will add "--author NAME" to the "bzr commit" command.
 
+**** For Git, adding an
+Author: NAME
+line will add "--author NAME" to the "git commit" command.
+
 **** For Hg, adding an
 Author: NAME
 line will add "--user NAME" to the "hg commit" command.
--- a/lib-src/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/lib-src/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,9 @@
+2010-04-11  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE): Define using
+	autoconf, not cpp.
+	(ALL_CFLAGS): Use them as make variables.
+
 2010-04-07  Christoph  <cschol2112@googlemail.com>  (tiny change)
 
 	* makefile.w32-in (OTHER_PLATFORM_SUPPORT): Use parenthesis
--- a/lib-src/Makefile.in	Wed Apr 07 21:55:20 2010 +0000
+++ b/lib-src/Makefile.in	Mon Apr 12 01:03:06 2010 +0000
@@ -34,6 +34,8 @@
 version=@version@
 configuration=@configuration@
 EXEEXT=@EXEEXT@
+C_SWITCH_SYSTEM=@c_switch_system@
+C_SWITCH_MACHINE=@c_switch_machine@
 
 # Program name transformation.
 TRANSFORM = @program_transform_name@
@@ -168,14 +170,6 @@
 #define LIBS_MACHINE
 #endif
 
-#ifndef C_SWITCH_SYSTEM
-#define C_SWITCH_SYSTEM
-#endif
-
-#ifndef C_SWITCH_MACHINE
-#define C_SWITCH_MACHINE
-#endif
-
 #undef MOVEMAIL_NEEDS_BLESSING
 #ifndef MAIL_USE_FLOCK
 #ifndef MAIL_USE_LOCKF
@@ -194,11 +188,11 @@
 /* Those files shared with other GNU utilities need HAVE_CONFIG_H
    defined before they know they can take advantage of the information
    in ../src/config.h.  */
-ALL_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
+ALL_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
-LINK_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
+LINK_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CFLAGS}
-CPP_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
+CPP_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS}
 
 .SUFFIXES: .m
--- a/lisp/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,7 +1,91 @@
+2010-04-10  Jari Aalto  <jari.aalto@cante.net>
+
+	* comint.el (comint-password-prompt-regexp): Use regexp-opt, and
+	recognize ssh-keygen prompt (Bug#2817).
+
+2010-04-10  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-do-copy-or-rename-file): Add progress reporter.
+
+2010-04-10  Michael Albinus  <michael.albinus@gmx.de>
+
+	Synchronize with Tramp repository.
+
+	* net/tramp.el (tramp-completion-function-alist)
+	(tramp-file-name-regexp, tramp-chunksize)
+	(tramp-local-coding-commands, tramp-remote-coding-commands): Fix
+	docstring.
+	(tramp-remote-process-environment): Use `format' instead of
+	`concat'.
+	(tramp-handle-directory-files-and-attributes)
+	(tramp-get-remote-path): Use `copy-tree'.
+	(tramp-handle-file-name-all-completions): Backward/ XEmacs
+	compatibility: Use `completion-ignore-case' if
+	`read-file-name-completion-ignore-case' does not exist.
+	(tramp-do-copy-or-rename-file-directly): Do not use
+	`tramp-handle-file-remote-p'.
+	(tramp-do-copy-or-rename-file-out-of-band): Use
+	`tramp-compat-delete-directory'.
+	(tramp-do-copy-or-rename-file-out-of-band)
+	(tramp-compute-multi-hops, tramp-maybe-open-connection): Use
+	`format-spec-make'.
+	(tramp-find-foreign-file-name-handler)
+	(tramp-advice-make-auto-save-file-name)
+	(tramp-set-auto-save-file-modes): Remove superfluous check for
+	`stringp'.  This is done inside `tramp-tramp-file-p'.
+	(tramp-debug-outline-regexp): New defconst.
+	(tramp-get-debug-buffer): Use it.
+	(tramp-check-for-regexp): Use (forward-line 1).
+	(tramp-set-auto-save-file-modes): Adapt version check.
+
+	* net/tramp-compat.el (tramp-advice-file-expand-wildcards): Wrap
+	call of `featurep' for 2nd argument.
+	(tramp-compat-make-temp-file): Simplify fallback implementation.
+	(tramp-compat-copy-tree): Remove function.
+	(tramp-compat-delete-directory): Provide implementation for older
+	Emacsen.
+
+	* net/tramp-fish.el (tramp-fish-handle-directory-files-and-attributes):
+	Do not use `tramp-fish-handle-file-attributes.
+
+	* net/trampver.el: Update release number.
+
+2010-04-10  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/compile.el (compilation-save-buffers-predicate):
+	Add missing :version tag.
+
+2010-04-09  Sam Steingold  <sds@gnu.org>
+
+	* progmodes/compile.el (compilation-save-buffers-predicate):
+	Remove the "autoload" cookie.
+
+	* progmodes/bug-reference.el (turn-on-bug-reference-mode)
+	(turn-on-bug-reference-prog-mode): Remove, `bug-reference-mode'
+	and `bug-reference-prog-mode' can be used in hooks directly.
+
+2010-04-09  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Add --author support to git commit.
+	* vc-git.el (vc-git-checkin): Pass extra-args to the commit command.
+	(vc-git-log-edit-mode): New minor mode.
+	(log-edit-mode, log-edit-extra-flags, log-edit-mode): New
+	declarations.
+
+2010-04-09  Eric Raymond  <esr@snark.thyrsus.com>
+
+	* vc-hooks.el, vc-git.el: Improve documentation comments.
+
+2010-04-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Fix some of the problems in defsubst* (bug#5728).
+	* emacs-lisp/cl-macs.el (defsubst*): Don't substitute non-trivial args.
+	(cl-defsubst-expand): Do the substitutions simultaneously (bug#5728).
+
 2010-04-07  Sam Steingold  <sds@gnu.org>
 
-	* progmodes/compile.el (compilation-save-buffers-predicate): New
-	custom variable.
+	* progmodes/compile.el (compilation-save-buffers-predicate):
+	New custom variable.
 	(compile, recompile): Pass it to `save-some-buffers'.
 
 2010-04-07  Jan Djärv  <jan.h.d@swipnet.se>
--- a/lisp/comint.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/comint.el	Mon Apr 12 01:03:06 2010 +0000
@@ -340,11 +340,17 @@
 ;; Some implementations of passwd use "Password (again)" as the 2nd prompt.
 ;; Something called "perforce" uses "Enter password:".
 (defcustom comint-password-prompt-regexp
-  "\\(\\(Enter \\|[Oo]ld \\|[Nn]ew \\|'s \\|login \\|\
-Kerberos \\|CVS \\|UNIX \\| SMB \\|LDAP \\|\\[sudo] \\|^\\)\
-\[Pp]assword\\( (again)\\)?\\|\
-pass phrase\\|\\(Enter \\|Repeat \\|Bad \\)?[Pp]assphrase\\)\
-\\(?:, try again\\)?\\(?: for [^:]+\\)?:\\s *\\'"
+  (concat
+   "^\\("
+   (regexp-opt
+    '("Enter" "Enter same" "Old" "old" "New" "new" "'s" "login"
+      "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad"))
+   " +\\)?"
+   (regexp-opt
+    '("password" "Password" "passphrase" "Passphrase"
+      "pass phrase" "Pass phrase"))
+   "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?\
+\\(?: for [^:]+\\)?:\\s *\\'")
   "Regexp matching prompts for passwords in the inferior process.
 This is used by `comint-watch-for-password-prompt'."
   :type 'regexp
--- a/lisp/dired.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/dired.el	Mon Apr 12 01:03:06 2010 +0000
@@ -3974,7 +3974,7 @@
 ;;;***
 
 ;;;### (autoloads (dired-do-relsymlink dired-jump) "dired-x" "dired-x.el"
-;;;;;;  "bb37ec379c0a523368794491b691fd8d")
+;;;;;;  "2f8d3d5a31b969b181e23c40d6bb16a0")
 ;;; Generated autoloads from dired-x.el
 
 (autoload 'dired-jump "dired-x" "\
--- a/lisp/emacs-lisp/cl-loaddefs.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/emacs-lisp/cl-loaddefs.el	Mon Apr 12 01:03:06 2010 +0000
@@ -282,7 +282,7 @@
 ;;;;;;  flet progv psetq do-all-symbols do-symbols dotimes dolist
 ;;;;;;  do* do loop return-from return block etypecase typecase ecase
 ;;;;;;  case load-time-value eval-when destructuring-bind function*
-;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "273ba25f4a116c61a464dbe55f1f8c63")
+;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "7fad7dd60f2f96ba90432f885015d61b")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'gensym "cl-macs" "\
--- a/lisp/emacs-lisp/cl-macs.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/emacs-lisp/cl-macs.el	Mon Apr 12 01:03:06 2010 +0000
@@ -128,6 +128,12 @@
   (and (eq (cl-const-expr-p x) t) (if (consp x) (nth 1 x) x)))
 
 (defun cl-expr-access-order (x v)
+  ;; This apparently tries to return nil iff the expression X evaluates
+  ;; the variables V in the same order as they appear in V (so as to
+  ;; be able to replace those vars with the expressions they're bound
+  ;; to).
+  ;; FIXME: This is very naive, it doesn't even check to see if those
+  ;; variables appear more than once.
   (if (cl-const-expr-p x) v
     (if (consp x)
 	(progn
@@ -2616,21 +2622,36 @@
 		    (cons '&cl-quote args))
 		  (list* 'cl-defsubst-expand (list 'quote argns)
 			 (list 'quote (list* 'block name body))
-			 (not (or unsafe (cl-expr-access-order pbody argns)))
+                         ;; We used to pass `simple' as
+                         ;; (not (or unsafe (cl-expr-access-order pbody argns)))
+                         ;; But this is much too simplistic since it
+                         ;; does not pay attention to the argvs (and
+                         ;; cl-expr-access-order itself is also too naive).
+			 nil
 			 (and (memq '&key args) 'cl-whole) unsafe argns)))
 	  (list* 'defun* name args body))))
 
 (defun cl-defsubst-expand (argns body simple whole unsafe &rest argvs)
   (if (and whole (not (cl-safe-expr-p (cons 'progn argvs)))) whole
     (if (cl-simple-exprs-p argvs) (setq simple t))
-    (let ((lets (delq nil
-		      (mapcar* (function
-				(lambda (argn argv)
-				  (if (or simple (cl-const-expr-p argv))
-				      (progn (setq body (subst argv argn body))
-					     (and unsafe (list argn argv)))
-				    (list argn argv))))
-			       argns argvs))))
+    (let* ((substs ())
+           (lets (delq nil
+                       (mapcar* (function
+                                 (lambda (argn argv)
+                                   (if (or simple (cl-const-expr-p argv))
+                                       (progn (push (cons argn argv) substs)
+                                              (and unsafe (list argn argv)))
+                                     (list argn argv))))
+                                argns argvs))))
+      ;; FIXME: `sublis/subst' will happily substitute the symbol
+      ;; `argn' in places where it's not used as a reference
+      ;; to a variable.
+      ;; FIXME: `sublis/subst' will happily copy `argv' to a different
+      ;; scope, leading to name capture.
+      (setq body (cond ((null substs) body)
+                       ((null (cdr substs))
+                        (subst (cdar substs) (caar substs) body))
+                       (t (sublis substs body))))
       (if lets (list 'let lets body) body))))
 
 
--- a/lisp/net/tramp-compat.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/net/tramp-compat.el	Mon Apr 12 01:03:06 2010 +0000
@@ -22,9 +22,9 @@
 
 ;;; Commentary:
 
-;; Tramp's main Emacs version for development is GNU Emacs 23.  This
-;; package provides compatibility functions for GNU Emacs 21, GNU
-;; Emacs 22 and XEmacs 21.4+.
+;; Tramp's main Emacs version for development is GNU Emacs 24.  This
+;; package provides compatibility functions for GNU Emacs 22, GNU
+;; Emacs 23 and XEmacs 21.4+.
 
 ;;; Code:
 
@@ -120,7 +120,7 @@
 	  (tramp-file-name-handler
 	   'file-remote-p file identification connected)))))
 
-  ;; `process-file' exists since Emacs 22.
+  ;; `process-file' does not exist in XEmacs.
   (unless (fboundp 'process-file)
     (defalias 'process-file
       (lambda (program &optional infile buffer display &rest args)
@@ -154,7 +154,9 @@
   ;; return the original filename if it can't expand anything.  Let's
   ;; just hope that this doesn't break anything else.
   ;; It is not needed anymore since GNU Emacs 23.2.
-  (unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards))
+  (unless (or (featurep 'xemacs)
+	      ;; `featurep' has only one argument in XEmacs.
+	      (funcall 'featurep 'files 'remote-wildcards))
     (defadvice file-expand-wildcards
       (around tramp-advice-file-expand-wildcards activate)
       (let ((name (ad-get-arg 0)))
@@ -211,10 +213,9 @@
 		       "`temp-directory' is defined -- using /tmp."))
       (file-name-as-directory "/tmp"))))
 
-;; `make-temp-file' exists in Emacs only.  The third parameter SUFFIX
-;; has been introduced with Emacs 22.  We try it, if it fails, we fall
-;; back to `make-temp-name', creating the temporary file immediately
-;; in order to avoid a security hole.
+;; `make-temp-file' exists in Emacs only.  On XEmacs, we use our own
+;; implementation with `make-temp-name', creating the temporary file
+;; immediately in order to avoid a security hole.
 (defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
   "Create a temporary file (compat function).
 Add the extension of FILENAME, if existing."
@@ -224,43 +225,34 @@
 		  (tramp-compat-temporary-file-directory)))
 	 (extension (file-name-extension filename t))
 	 result)
-    (condition-case nil
+    (if (fboundp 'make-temp-file)
 	(setq result
 	      (funcall
 	       (symbol-function 'make-temp-file) prefix dir-flag extension))
-      (error
-       ;; We use our own implementation, taken from files.el.
-       (while
-	   (condition-case ()
-	       (progn
-		 (setq result (concat (make-temp-name prefix) extension))
-		 (if dir-flag
-		     (make-directory result)
-		   (write-region
-		    "" nil result nil 'silent nil
-		    ;; 7th parameter is MUSTBENEW in Emacs, and
-		    ;; CODING-SYSTEM in XEmacs.  It is not a security
-		    ;; hole in XEmacs if we cannot use this parameter,
-		    ;; because XEmacs uses a user-specific
-		    ;; subdirectory with 0700 permissions.
-		    (when (not (featurep 'xemacs)) 'excl)))
-		 nil)
-	     (file-already-exists t))
-	 ;; The file was somehow created by someone else between
-	 ;; `make-temp-name' and `write-region', let's try again.
-	 nil)))
+      ;; We use our own implementation, taken from files.el.
+      (while
+	  (condition-case ()
+	      (progn
+		(setq result (concat (make-temp-name prefix) extension))
+		(if dir-flag
+		    (make-directory result)
+		  (write-region "" nil result nil 'silent))
+		nil)
+	    (file-already-exists t))
+	;; The file was somehow created by someone else between
+	;; `make-temp-name' and `write-region', let's try again.
+	nil))
     result))
 
-;; `most-positive-fixnum' arrived in Emacs 22.  Before, and in XEmacs,
-;; it is a fixed value.
+;; `most-positive-fixnum' does not exist in XEmacs.
 (defsubst tramp-compat-most-positive-fixnum ()
   "Return largest positive integer value (compat function)."
   (cond
    ((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum))
-   ;; Default value in XEmacs and Emacs 21.
+   ;; Default value in XEmacs.
    (t 134217727)))
 
-;; ID-FORMAT exists since Emacs 22.
+;; ID-FORMAT does not exists in XEmacs.
 (defun tramp-compat-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files (compat function)."
   (cond
@@ -292,8 +284,8 @@
       (funcall
        (symbol-function 'copy-directory) directory newname keep-time parents)
 
-    ;; If default-directory is a remote directory, make sure we find
-    ;; its copy-directory handler.
+    ;; If `default-directory' is a remote directory, make sure we find
+    ;; its `copy-directory' handler.
     (let ((handler (or (find-file-name-handler directory 'copy-directory)
 		       (find-file-name-handler newname 'copy-directory))))
       (if handler
@@ -325,32 +317,28 @@
 	(if keep-time
 	    (set-file-times newname (nth 5 (file-attributes directory))))))))
 
-;; `copy-tree' is a built-in function in XEmacs.  In Emacs 21, it is
-;; an autoloaded function in cl-extra.el.  Since Emacs 22, it is part
-;; of subr.el.  There are problems when autoloading, therefore we test
-;; for `subrp' and `symbol-file'.  Implementation is taken from Emacs 23.
-(defun tramp-compat-copy-tree (tree)
-  "Make a copy of TREE (compat function)."
-  (if (or (subrp 'copy-tree) (symbol-file 'copy-tree))
-      (funcall (symbol-function 'copy-tree) tree)
-    (let (result)
-      (while (consp tree)
-	(let ((newcar (car tree)))
-	  (if (consp (car tree))
-	      (setq newcar (tramp-compat-copy-tree (car tree))))
-	  (push newcar result))
-	(setq tree (cdr tree)))
-      (nconc (nreverse result) tree))))
-
 ;; RECURSIVE has been introduced with Emacs 23.2.
 (defun tramp-compat-delete-directory (directory &optional recursive)
   "Like `delete-directory' for Tramp files (compat function)."
-  (if recursive
-      (funcall (symbol-function 'delete-directory) directory recursive)
-    (delete-directory directory)))
+  (if (null recursive)
+      (delete-directory directory)
+    (condition-case nil
+	(funcall (symbol-function 'delete-directory) directory recursive)
+      ;; This Emacs version does not support the RECURSIVE flag.  We
+      ;; use the implementation from Emacs 23.2.
+      (error
+       (setq directory (directory-file-name (expand-file-name directory)))
+       (if (not (file-symlink-p directory))
+	   (mapc (lambda (file)
+		   (if (eq t (car (file-attributes file)))
+		       (tramp-compat-delete-directory file recursive)
+		     (delete-file file)))
+		 (directory-files
+		  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
+       (delete-directory directory)))))
 
-;; `number-sequence' has been introduced in Emacs 22.  Implementation
-;; is taken from Emacs 23.
+;; `number-sequence' does not exist in XEmacs.  Implementation is
+;; taken from Emacs 23.
 (defun tramp-compat-number-sequence (from &optional to inc)
   "Return a sequence of numbers from FROM to TO as a list (compat function)."
   (if (or (subrp 'number-sequence) (symbol-file 'number-sequence))
--- a/lisp/net/tramp-fish.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/net/tramp-fish.el	Mon Apr 12 01:03:06 2010 +0000
@@ -341,10 +341,10 @@
   "Like `directory-files-and-attributes' for Tramp files."
   (mapcar
    (lambda (x)
-     ;; We cannot call `file-attributes' for backward compatibility reasons.
-     ;; Its optional parameter ID-FORMAT is introduced with Emacs 22.
-     (cons x (tramp-fish-handle-file-attributes
-	(if full x (expand-file-name x directory)) id-format)))
+     (cons x
+	   (tramp-compat-file-attributes
+	    (if full x (expand-file-name x directory))
+	    id-format)))
    (directory-files directory full match nosort)))
 
 (defun tramp-fish-handle-expand-file-name (name &optional dir)
@@ -1030,15 +1030,15 @@
 	 ;; last line
 	 ((looking-at "^$")
 	  (return)))
-	;; delete line
+	;; Delete line.
 	(forward-line)
 	(delete-region (point-min) (point))))
 
-    ;; delete trailing empty line
+    ;; Delete trailing empty line.
     (forward-line)
     (delete-region (point-min) (point))
 
-    ;; Return entry in file-attributes format
+    ;; Return entry in `file-attributes' format.
     (list localname link -1 uid gid '(0 0) mtime '(0 0) size mode nil)))
 
 (defun tramp-fish-retrieve-data (vec)
--- a/lisp/net/tramp.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/net/tramp.el	Mon Apr 12 01:03:06 2010 +0000
@@ -36,7 +36,7 @@
 ;; Notes:
 ;; -----
 ;;
-;; This package only works for Emacs 21.1 and higher, and for XEmacs 21.4
+;; This package only works for Emacs 22.1 and higher, and for XEmacs 21.4
 ;; and higher.  For XEmacs 21, you need the package `fsf-compat' for
 ;; the `with-timeout' macro.
 ;;
@@ -79,7 +79,7 @@
 	    (when (featurep 'tramp-compat)
 	      (unload-feature 'tramp-compat 'force))))
 
-(require 'format-spec)                  ; from Gnus 5.8, also in tar ball
+(require 'format-spec)
 ;; As long as password.el is not part of (X)Emacs, it shouldn't
 ;; be mandatory
 (if (featurep 'xemacs)
@@ -871,9 +871,9 @@
 
 (defvar tramp-completion-function-alist nil
   "*Alist of methods for remote files.
-This is a list of entries of the form (NAME PAIR1 PAIR2 ...).
+This is a list of entries of the form \(NAME PAIR1 PAIR2 ...\).
 Each NAME stands for a remote access method.  Each PAIR is of the form
-\(FUNCTION FILE).  FUNCTION is responsible to extract user names and host
+\(FUNCTION FILE\).  FUNCTION is responsible to extract user names and host
 names from FILE for completion.  The following predefined FUNCTIONs exists:
 
  * `tramp-parse-rhosts'      for \"~/.rhosts\" like files,
@@ -1025,7 +1025,7 @@
 
 (defcustom tramp-remote-process-environment
   `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C"
-    ,(concat "TERM=" tramp-terminal-type)
+    ,(format "TERM=%s" tramp-terminal-type)
     "EMACS=t" ;; Deprecated.
     ,(format "INSIDE_EMACS=%s,tramp:%s" emacs-version tramp-version)
     "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH="
@@ -1429,14 +1429,14 @@
 	(t (error "Wrong `tramp-syntax' defined")))
   "*Regular expression matching file names handled by Tramp.
 This regexp should match Tramp file names but no other file names.
-\(When tramp.el is loaded, this regular expression is prepended to
+When tramp.el is loaded, this regular expression is prepended to
 `file-name-handler-alist', and that is searched sequentially.  Thus,
 if the Tramp entry appears rather early in the `file-name-handler-alist'
 and is a bit too general, then some files might be considered Tramp
 files which are not really Tramp files.
 
 Please note that the entry in `file-name-handler-alist' is made when
-this file (tramp.el) is loaded.  This means that this variable must be set
+this file \(tramp.el\) is loaded.  This means that this variable must be set
 before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
 updated after changing this variable.
 
@@ -1566,18 +1566,18 @@
 
 In the Emacs normally running Tramp, evaluate the above code
 \(replace \"xxx\" and \"yyy\" by the remote user and host name,
-respectively).  You can do this, for example, by pasting it into
+respectively\).  You can do this, for example, by pasting it into
 the `*scratch*' buffer and then hitting C-j with the cursor after the
 last closing parenthesis.  Note that it works only if you have configured
-\"ssh\" to run without password query, see ssh-agent(1).
+\"ssh\" to run without password query, see ssh-agent\(1\).
 
 You will see the number of bytes sent successfully to the remote host.
 If that number exceeds 1000, you can stop the execution by hitting
 C-g, because your Emacs is likely clean.
 
 When it is necessary to set `tramp-chunksize', you might consider to
-use an out-of-the-band method (like \"scp\") instead of an internal one
-\(like \"ssh\"), because setting `tramp-chunksize' to non-nil decreases
+use an out-of-the-band method \(like \"scp\"\) instead of an internal one
+\(like \"ssh\"\), because setting `tramp-chunksize' to non-nil decreases
 performance.
 
 If your Emacs is buggy, the code stops and gives you an indication
@@ -3166,7 +3166,7 @@
   (when (file-directory-p directory)
     (setq directory (expand-file-name directory))
     (let* ((temp
-	    (tramp-compat-copy-tree
+	    (copy-tree
 	     (with-parsed-tramp-file-name directory nil
 	       (with-file-property
 		   v localname
@@ -3297,7 +3297,12 @@
                           (tramp-shell-quote-argument localname)
                           (tramp-shell-quote-argument filename)
                           (if (symbol-value
-			       'read-file-name-completion-ignore-case)
+			       ;; `read-file-name-completion-ignore-case'
+			       ;; is introduced with Emacs 22.1.
+			       (if (boundp
+				    'read-file-name-completion-ignore-case)
+				   'read-file-name-completion-ignore-case
+				 'completion-ignore-case))
 			      1 0)))
 
               (format (concat
@@ -3382,7 +3387,6 @@
             "file-name-all-completions"
             result))))))))
 
-;; The following isn't needed for Emacs 20 but for 19.34?
 (defun tramp-handle-file-name-completion
   (filename directory &optional predicate)
   "Like `file-name-completion' for Tramp files."
@@ -3520,7 +3524,8 @@
   (unless (memq op '(copy rename))
     (error "Unknown operation `%s', must be `copy' or `rename'" op))
   (let ((t1 (tramp-tramp-file-p filename))
-	(t2 (tramp-tramp-file-p newname)))
+	(t2 (tramp-tramp-file-p newname))
+	pr tm)
 
     (when (and (not ok-if-already-exists) (file-exists-p newname))
       (with-parsed-tramp-file-name (if t1 filename newname) nil
@@ -3530,7 +3535,16 @@
     (with-parsed-tramp-file-name (if t1 filename newname) nil
       (tramp-message v 0 "Transferring %s to %s..." filename newname))
 
-    (prog1
+    ;; We start a pulsing progress reporter.  Introduced in Emacs 24.1.
+    (when (> (nth 7 (file-attributes filename)) tramp-copy-size-limit)
+      (condition-case nil
+	  (setq pr (funcall
+		    'make-progress-reporter
+		    (format "Transferring %s to %s..." filename newname))
+		tm (run-at-time 0 0.1 'progress-reporter-update pr))
+	(error nil)))
+
+    (unwind-protect
 	(cond
 	 ;; Both are Tramp files.
 	 ((and t1 t2)
@@ -3600,6 +3614,8 @@
 	  (tramp-flush-file-property v (file-name-directory localname))
 	  (tramp-flush-file-property v localname)))
 
+      ;; Stop progress reporter.
+      (if tm (cancel-timer tm))
       (with-parsed-tramp-file-name (if t1 filename newname) nil
 	(tramp-message v 0 "Transferring %s to %s...done" filename newname)))))
 
@@ -3650,9 +3666,13 @@
 			    "Unknown operation `%s', must be `copy' or `rename'"
 			    op))))
 	     (localname1
-	      (if t1 (tramp-handle-file-remote-p filename 'localname) filename))
+	      (if t1
+		  (tramp-file-name-handler 'file-remote-p filename 'localname)
+		filename))
 	     (localname2
-	      (if t2 (tramp-handle-file-remote-p newname 'localname) newname))
+	      (if t2
+		  (tramp-file-name-handler 'file-remote-p newname 'localname)
+		newname))
 	     (prefix (file-remote-p (if t1 filename newname)))
              cmd-result)
 
@@ -3814,7 +3834,7 @@
 	      ;; Save exit.
 	      (condition-case nil
 		  (if dir-flag
-		      (delete-directory
+		      (tramp-compat-delete-directory
 		       (expand-file-name ".." tmpfile) 'recursive)
 		    (delete-file tmpfile))
 		(error))))
@@ -3841,10 +3861,11 @@
 	      port (or (and port (number-to-string port)) ""))
 
 	;; Compose copy command.
-	(setq spec `((?h . ,host) (?u . ,user) (?p . ,port)
-		     (?t . ,(tramp-get-connection-property
-			     (tramp-get-connection-process v) "temp-file" ""))
-		     (?k . ,(if keep-date " " "")))
+	(setq spec (format-spec-make
+		    ?h host ?u user ?p port
+		    ?t (tramp-get-connection-property
+			(tramp-get-connection-process v) "temp-file" "")
+		    ?k (if keep-date " " ""))
 	      copy-program (tramp-get-method-parameter
 			    method 'tramp-copy-program)
 	      copy-keep-date (tramp-get-method-parameter
@@ -3934,7 +3955,7 @@
       (unless (eq op 'copy)
 	(if (file-regular-p filename)
 	    (delete-file filename)
-	  (delete-directory filename 'recursive))))))
+	  (tramp-compat-delete-directory filename 'recursive))))))
 
 (defun tramp-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
@@ -4863,9 +4884,9 @@
   "Like `find-backup-file-name' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     ;; We set both variables. It doesn't matter whether it is
-    ;; Emacs or XEmacs
+    ;; Emacs or XEmacs.
     (let ((backup-directory-alist
-	   ;; Emacs case
+	   ;; Emacs case.
 	   (when (boundp 'backup-directory-alist)
 	     (if (symbol-value 'tramp-backup-directory-alist)
 		 (mapcar
@@ -4881,7 +4902,7 @@
 	       (symbol-value 'backup-directory-alist))))
 
 	  (bkup-backup-directory-info
-	   ;; XEmacs case
+	   ;; XEmacs case.
 	   (when (boundp 'bkup-backup-directory-info)
 	     (if (symbol-value 'tramp-bkup-backup-directory-info)
 		 (mapcar
@@ -5295,7 +5316,7 @@
   "Return file name related to OPERATION file primitive.
 ARGS are the arguments OPERATION has been called with."
   (cond
-   ; FILE resp DIRECTORY
+   ;; FILE resp DIRECTORY.
    ((member operation
 	    (list 'access-file 'byte-compiler-base-file-name 'delete-directory
 		  'delete-file 'diff-latest-backup-file 'directory-file-name
@@ -5313,9 +5334,9 @@
 		  'load 'make-directory 'make-directory-internal
 		  'set-file-modes 'substitute-in-file-name
 		  'unhandled-file-name-directory 'vc-registered
-		  ; Emacs 22 only
+		  ;; Emacs 22+ only.
 		  'set-file-times
-		  ; XEmacs only
+		  ;; XEmacs only.
 		  'abbreviate-file-name 'create-file-buffer
 		  'dired-file-modtime 'dired-make-compressed-filename
 		  'dired-recursive-delete-directory 'dired-set-file-modtime
@@ -5325,14 +5346,14 @@
     (if (file-name-absolute-p (nth 0 args))
 	(nth 0 args)
       (expand-file-name (nth 0 args))))
-   ; FILE DIRECTORY resp FILE1 FILE2
+   ;; FILE DIRECTORY resp FILE1 FILE2.
    ((member operation
 	    (list 'add-name-to-file 'copy-file 'expand-file-name
 		  'file-name-all-completions 'file-name-completion
 		  'file-newer-than-file-p 'make-symbolic-link 'rename-file
-		  ; Emacs 23 only
+		  ;; Emacs 23+ only.
 		  'copy-directory
-		  ; XEmacs only
+		  ;; XEmacs only.
 		  'dired-make-relative-symlink
 		  'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail))
     (save-match-data
@@ -5340,39 +5361,39 @@
        ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
        ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
        (t (buffer-file-name (current-buffer))))))
-   ; START END FILE
+   ;; START END FILE.
    ((eq operation 'write-region)
     (nth 2 args))
-   ; BUF
+   ;; BUFFER.
    ((member operation
 	    (list 'set-visited-file-modtime 'verify-visited-file-modtime
-                  ; since Emacs 22 only
+                  ;; Emacs 22+ only.
 		  'make-auto-save-file-name
-	          ; XEmacs only
+	          ;; XEmacs only.
 		  'backup-buffer))
     (buffer-file-name
      (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer))))
-   ; COMMAND
+   ;; COMMAND.
    ((member operation
-	    (list ; not in Emacs 23
+	    (list ;; not in Emacs 23+.
 	          'dired-call-process
-                  ; Emacs only
+                  ;; Emacs only.
 		  'shell-command
-                  ; since Emacs 22 only
+                  ;; Emacs 22+ only.
                   'process-file
-                  ; since Emacs 23 only
+                  ;; Emacs 23+ only.
                   'start-file-process
-	          ; XEmacs only
+	          ;; XEmacs only.
 		  'dired-print-file 'dired-shell-call-process
-		  ; nowhere yet
+		  ;; nowhere yet.
 		  'executable-find 'start-process 'call-process))
     default-directory)
-   ; unknown file primitive
+   ;; Unknown file primitive.
    (t (error "unknown file I/O primitive: %s" operation))))
 
 (defun tramp-find-foreign-file-name-handler (filename)
   "Return foreign file name handler if exists."
-  (when (and (stringp filename) (tramp-tramp-file-p filename))
+  (when (tramp-tramp-file-p filename)
     (let ((v (tramp-dissect-file-name filename t))
 	  (handler tramp-foreign-file-name-handler-alist)
 	  elt res)
@@ -6257,22 +6278,24 @@
 	(format "*debug tramp/%s %s@%s*" method user host)
       (format "*debug tramp/%s %s*" method host))))
 
+(defconst tramp-debug-outline-regexp
+  "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #")
+
 (defun tramp-get-debug-buffer (vec)
   "Get the debug buffer for VEC."
   (with-current-buffer
       (get-buffer-create (tramp-debug-buffer-name vec))
     (when (bobp)
       (setq buffer-undo-list t)
-      ;; Activate outline-mode.  This runs `text-mode-hook' and
+      ;; Activate `outline-mode'.  This runs `text-mode-hook' and
       ;; `outline-mode-hook'.  We must prevent that local processes
-      ;; die.  Yes: I've seen `flyspell-mode', which starts "ispell"
-      ;; ...
-      (let ((default-directory (tramp-compat-temporary-file-directory)))
+      ;; die.  Yes: I've seen `flyspell-mode', which starts "ispell".
+      ;; Furthermore, `outline-regexp' must have the correct value
+      ;; already, because it is used by `font-lock-compile-keywords'.
+      (let ((default-directory (tramp-compat-temporary-file-directory))
+	    (outline-regexp tramp-debug-outline-regexp))
 	(outline-mode))
-      (set (make-local-variable 'outline-regexp)
-	   "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #")
-;      (set (make-local-variable 'outline-regexp)
-;	   "[a-z.-]+:[0-9]+: [a-z0-9-]+ (\\([0-9]+\\)) #")
+      (set (make-local-variable 'outline-regexp) tramp-debug-outline-regexp)
       (set (make-local-variable 'outline-level) 'tramp-outline-level))
     (current-buffer)))
 
@@ -6307,7 +6330,7 @@
 	    (setq result (concat "\\" progname))))
       (unless result
 	(when ignore-tilde
-	  ;; Remove all ~/foo directories from dirlist.  In Emacs 20,
+	  ;; Remove all ~/foo directories from dirlist.  In XEmacs,
 	  ;; `remove' is in CL, and we want to avoid CL dependencies.
 	  (let (newdl d)
 	    (while dirlist
@@ -6624,7 +6647,7 @@
 	  ;; Discard echo from remote output.
 	  (tramp-set-connection-property proc "check-remote-echo" nil)
 	  (tramp-message proc 5 "echo-mark found")
-	  (forward-line)
+	  (forward-line 1)
 	  (delete-region begin (point))
 	  (goto-char (point-min)))))
 
@@ -6895,7 +6918,7 @@
   "List of local coding commands for inline transfer.
 Each item is a list that looks like this:
 
-\(FORMAT ENCODING DECODING)
+\(FORMAT ENCODING DECODING\)
 
 FORMAT is  symbol describing the encoding/decoding format.  It can be
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
@@ -6928,7 +6951,7 @@
   "List of remote coding commands for inline transfer.
 Each item is a list that looks like this:
 
-\(FORMAT ENCODING DECODING)
+\(FORMAT ENCODING DECODING\)
 
 FORMAT is  symbol describing the encoding/decoding format.  It can be
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
@@ -7089,8 +7112,9 @@
 	  (setq proxy
 		(format-spec
 		 proxy
-		 `((?u . ,(or (tramp-file-name-user (car target-alist)) ""))
-		   (?h . ,(or (tramp-file-name-host (car target-alist)) "")))))
+		 (format-spec-make
+		  ?u (or (tramp-file-name-user (car target-alist)) "")
+		  ?h (or (tramp-file-name-host (car target-alist)) ""))))
 	  (with-parsed-tramp-file-name proxy l
 	    ;; Add the hop.
 	    (add-to-list 'target-alist l)
@@ -7308,8 +7332,7 @@
 	       l-host (or l-host "")
 	       l-user (or l-user "")
 	       l-port (or l-port "")
-	       spec `((?h . ,l-host) (?u . ,l-user) (?p . ,l-port)
-		      (?t . ,tmpfile))
+	       spec (format-spec-make ?h l-host ?u l-user ?p l-port ?t tmpfile)
 	       command
 	       (concat
 		;; We do not want to see the trailing local prompt in
@@ -7981,7 +8004,7 @@
 	  (tramp-get-connection-process vec)
 	vec)
       "remote-path"
-    (let* ((remote-path (tramp-compat-copy-tree tramp-remote-path))
+    (let* ((remote-path (copy-tree tramp-remote-path))
 	   (elt1 (memq 'tramp-default-remote-path remote-path))
 	   (elt2 (memq 'tramp-own-remote-path remote-path))
 	   (default-remote-path
@@ -8280,7 +8303,7 @@
   (defadvice make-auto-save-file-name
     (around tramp-advice-make-auto-save-file-name () activate)
     "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files."
-    (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
+    (if (tramp-tramp-file-p (buffer-file-name))
 	;; We cannot call `tramp-handle-make-auto-save-file-name'
 	;; directly, because this would bypass the locking mechanism.
 	(setq ad-return-value
@@ -8294,14 +8317,13 @@
       'around 'tramp-advice-make-auto-save-file-name)
      (ad-activate 'make-auto-save-file-name))))
 
-;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have
-;; permission 0666 minus umask. This is a security threat.
+;; In XEmacs < 21.5, autosaved remote files have permission 0666 minus
+;; umask. This is a security threat.
 
 (defun tramp-set-auto-save-file-modes ()
   "Set permissions of autosaved remote files to the original permissions."
   (let ((bfn (buffer-file-name)))
-    (when (and (stringp bfn)
-	       (tramp-tramp-file-p bfn)
+    (when (and (tramp-tramp-file-p bfn)
 	       (buffer-modified-p)
 	       (stringp buffer-auto-save-file-name)
 	       (not (equal bfn buffer-auto-save-file-name)))
@@ -8313,10 +8335,9 @@
       (set-file-modes buffer-auto-save-file-name
 		      (or (file-modes bfn) (tramp-octal-to-decimal "0600"))))))
 
-(unless (or (> emacs-major-version 21)
-	    (and (featurep 'xemacs)
-		 (= emacs-major-version 21)
-		 (> emacs-minor-version 4)))
+(unless (and (featurep 'xemacs)
+	     (= emacs-major-version 21)
+	     (> emacs-minor-version 4))
   (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
   (add-hook 'tramp-unload-hook
 	    (lambda ()
@@ -8560,7 +8581,6 @@
 ;; * Remove unneeded parameters from methods.
 ;; * Make it work for different encodings, and for different file name
 ;;   encodings, too.  (Daniel Pittman)
-;; * Progress reports while copying files.  (Michael Kifer)
 ;; * Don't search for perl5 and perl.  Instead, only search for perl and
 ;;   then look if it's the right version (with `perl -v').
 ;; * When editing a remote CVS controlled file as a different user, VC
@@ -8625,7 +8645,7 @@
 ;;   expects only English messages?  (Juri Linkov)
 ;; * Make shadowfile.el grok Tramp filenames.  (Bug#4526, Bug#4846)
 ;; * Do not handle files with drive letter as remote.  (Bug#5447)
-;; * Load Tramp subpackages only when needed.  (Bug#1529, Bug#5448)
+;; * Load Tramp subpackages only when needed.  (Bug#1529, Bug#5448, Bug#5705)
 ;; * Try telnet+curl as new method.  It might be useful for busybox,
 ;;   without built-in uuencode/uudecode.
 ;; * Let `shell-dynamic-complete-*' and `comint-dynamic-complete' work
--- a/lisp/net/trampver.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/net/trampver.el	Mon Apr 12 01:03:06 2010 +0000
@@ -1,8 +1,8 @@
 ;;; trampver.el --- Transparent Remote Access, Multiple Protocol
 ;;; lisp/trampver.el.  Generated from trampver.el.in by configure.
 
-;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008,
-;;   2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
 ;; Keywords: comm, processes
@@ -24,19 +24,20 @@
 
 ;;; Code:
 
-;; In the Tramp CVS repository, the version numer and the bug report address
-;; are auto-frobbed from configure.ac, so you should edit that file and run
-;; "autoconf && ./configure" to change them.  (X)Emacs version check is defined
-;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there.
+;; In the Tramp CVS repository, the version number and the bug report
+;; address are auto-frobbed from configure.ac, so you should edit that
+;; file and run "autoconf && ./configure" to change them.  (X)Emacs
+;; version check is defined in macro AC_EMACS_INFO of aclocal.m4;
+;; should be changed only there.
 
-(defconst tramp-version "2.1.18-23.2"
+(defconst tramp-version "2.1.19-pre"
   "This version of Tramp.")
 
 (defconst tramp-bug-report-address "tramp-devel@gnu.org"
   "Email address to send bug reports to.")
 
 ;; Check for (X)Emacs version.
-(let ((x (if (or (< emacs-major-version 21)	(and (featurep 'xemacs)	     (= emacs-major-version 21)	     (< emacs-minor-version 4)))    (format "Tramp 2.1.18-pre is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version))))    "ok")))
+(let ((x (if (or (>= emacs-major-version 22)	(and (featurep 'xemacs)	     (= emacs-major-version 21)	     (>= emacs-minor-version 4)))    "ok"    (format "Tramp 2.1.19-pre is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version)))))))
   (unless (string-match "\\`ok\\'" x) (error "%s" x)))
 
 (provide 'trampver)
--- a/lisp/progmodes/bug-reference.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/progmodes/bug-reference.el	Mon Apr 12 01:03:06 2010 +0000
@@ -131,12 +131,6 @@
       (bug-reference-unfontify (point-min) (point-max)))))
 
 ;;;###autoload
-(defun turn-on-bug-reference-mode ()
-  "Unconditionally turn bug reference mode on."
-  (unless bug-reference-mode
-    (bug-reference-mode)))
-
-;;;###autoload
 (define-minor-mode bug-reference-prog-mode
   "Like `bug-reference-mode', but only buttonize in comments and strings."
   nil
@@ -149,11 +143,5 @@
       (widen)
       (bug-reference-unfontify (point-min) (point-max)))))
 
-;;;###autoload
-(defun turn-on-bug-reference-prog-mode ()
-  "Unconditionally turn bug reference prog mode on."
-  (unless bug-reference-prog-mode
-    (bug-reference-prog-mode)))
-
 ;; arch-tag: b138abce-e5c3-475e-bd58-7afba40387ea
 ;;; bug-reference.el ends here
--- a/lisp/progmodes/compile.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/progmodes/compile.el	Mon Apr 12 01:03:06 2010 +0000
@@ -583,7 +583,6 @@
   :type 'boolean
   :group 'compilation)
 
-;;;###autoload
 (defcustom compilation-save-buffers-predicate nil
   "The second argument (PRED) passed to `save-some-buffers' before compiling.
 E.g., one can set this to
@@ -596,7 +595,8 @@
           (const :tag "Default (save all file-visiting buffers)" nil)
           (const :tag "Save all buffers" t)
           function)
-  :group 'compilation)
+  :group 'compilation
+  :version "24.1")
 
 ;;;###autoload
 (defcustom compilation-search-path '(nil)
--- a/lisp/vc-arch.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/vc-arch.el	Mon Apr 12 01:03:06 2010 +0000
@@ -254,8 +254,7 @@
 	       (buffer-substring (point-min) (1- (point-max)))))))))
 
 (defun vc-arch-workfile-unchanged-p (file)
-  "Check if FILE is unchanged by diffing against the master version.
-Return non-nil if FILE is unchanged."
+  "Stub: arch workfiles are always considered to be in a changed state,"
   nil)
 
 (defun vc-arch-state (file)
--- a/lisp/vc-git.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/vc-git.el	Mon Apr 12 01:03:06 2010 +0000
@@ -171,7 +171,14 @@
 
 (defun vc-git-state (file)
   "Git-specific version of `vc-state'."
-  ;; FIXME: This can't set 'ignored yet
+  ;; FIXME: This can't set 'ignored or 'conflict yet
+  ;; The 'ignored state could be detected with `git ls-files -i -o
+  ;; --exclude-standard` It also can't set 'needs-update or
+  ;; 'needs-merge. The rough equivalent would be that upstream branch
+  ;; for current branch is in fast-forward state i.e. current branch
+  ;; is direct ancestor of corresponding upstream branch, and the file
+  ;; was modified upstream.  But we can't check that without a network
+  ;; operation.
   (if (not (vc-git-registered file))
       'unregistered
     (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
@@ -541,10 +548,10 @@
   (vc-git-command nil 0 file "rm" "-f" "--cached" "--"))
 
 
-(defun vc-git-checkin (files rev comment  &optional extra-args-ignored)
+(defun vc-git-checkin (files rev comment  &optional extra-args)
   (let ((coding-system-for-write git-commits-coding-system))
-    (vc-git-command nil 0 files "commit"
-		    "-m" comment "--only" "--")))
+    (apply 'vc-git-command nil 0 files
+	   (nconc (list "commit" "-m" comment) extra-args (list "--only" "--")))))
 
 (defun vc-git-find-revision (file rev buffer)
   (let* (process-file-side-effects
@@ -783,6 +790,21 @@
                    (progn (forward-line 1) (1- (point)))))))))
     (or (vc-git-symbolic-commit next-rev) next-rev)))
 
+(declare-function log-edit-mode "log-edit" ())
+(defvar log-edit-extra-flags)
+(defvar log-edit-before-checkin-process)
+
+(define-derived-mode vc-git-log-edit-mode log-edit-mode "Git-log-edit"
+  "Mode for editing Git commit logs.
+If a line like:
+Author: NAME
+is present in the log, it is removed, and
+--author=NAME
+is passed to the git commit command."
+  (set (make-local-variable 'log-edit-extra-flags) nil)
+  (set (make-local-variable 'log-edit-before-checkin-process)
+       '(("^Author:[ \t]+\\(.*\\)[ \t]*$" . (list "--author" (match-string 1))))))
+
 (defun vc-git-delete-file (file)
   (vc-git-command nil 0 file "rm" "-f" "--"))
 
--- a/lisp/vc-hooks.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/vc-hooks.el	Mon Apr 12 01:03:06 2010 +0000
@@ -396,7 +396,7 @@
 
 
 (defun vc-backend-subdirectory-name (file)
-  "Return where the master and lock FILEs for the current directory are kept."
+  "Return where the repository for the current directory is kept."
   (symbol-name (vc-backend file)))
 
 (defun vc-name (file)
@@ -460,17 +460,20 @@
   'edited            The working file has been edited by the user.  If
                      locking is used for the file, this state means that
                      the current version is locked by the calling user.
+                     This status should *not* be reported for files 
+                     which have a changed mtime but the same content 
+                     as the repo copy.
 
   USER               The current version of the working file is locked by
                      some other USER (a string).
 
-  'needs-update       The file has not been edited by the user, but there is
+  'needs-update      The file has not been edited by the user, but there is
                      a more recent version on the current branch stored
-                     in the master file.
+                     in the repository.
 
   'needs-merge       The file has been edited by the user, and there is also
                      a more recent version on the current branch stored in
-                     the master file.  This state can only occur if locking
+                     the repository.  This state can only occur if locking
                      is not used for the file.
 
   'unlocked-changes  The working version of the file is not locked,
@@ -549,7 +552,7 @@
 	unchanged))))
 
 (defun vc-default-workfile-unchanged-p (backend file)
-  "Check if FILE is unchanged by diffing against the master version.
+  "Check if FILE is unchanged by diffing against the repository version.
 Return non-nil if FILE is unchanged."
   (zerop (condition-case err
              ;; If the implementation supports it, let the output
--- a/lisp/vc.el	Wed Apr 07 21:55:20 2010 +0000
+++ b/lisp/vc.el	Mon Apr 12 01:03:06 2010 +0000
@@ -63,11 +63,18 @@
 ;; although you might prefer to use C-c C-a (i.e. `log-edit-insert-changelog')
 ;; from the commit buffer instead or to set `log-edit-setup-invert'.
 ;;
-;; The vc code maintains some internal state in order to reduce expensive
-;; version-control operations to a minimum.  Some names are only computed
-;; once.  If you perform version control operations with the backend while
-;; vc's back is turned, or move/rename master files while vc is running,
-;; vc may get seriously confused.  Don't do these things!
+;; When using SCCS, RCS, CVS: be careful not to do repo surgery, or
+;; operations like registrations and deletions and renames, outside VC
+;; while VC is running. The support for these systems was designed
+;; when disks were much slower, and the code maintains a lot of
+;; internal state in order to reduce expensive operations to a
+;; minimum. Thus, if you mess with the repo while VC's back is turned,
+;; VC may get seriously confused.
+;;
+;; When using Subversion or a later system, anything you do outside VC
+;; *through the VCS tools* should safely interlock with VC
+;; operations. Under these VC does little state caching, because local
+;; operations are assumed to be fast.  The dividing line is
 ;;
 ;; ADDING SUPPORT FOR OTHER BACKENDS
 ;;
@@ -196,7 +203,7 @@
 ;;
 ;;   Return non-nil if FILE is unchanged from the working revision.
 ;;   This function should do a brief comparison of FILE's contents
-;;   with those of the repository master of the working revision.  If
+;;   with those of the repository copy of the working revision.  If
 ;;   the backend does not have such a brief-comparison feature, the
 ;;   default implementation of this function can be used, which
 ;;   delegates to a full vc-BACKEND-diff.  (Note that vc-BACKEND-diff
@@ -784,7 +791,7 @@
 (defcustom vc-checkout-carefully (= (user-uid) 0)
   "Non-nil means be extra-careful in checkout.
 Verify that the file really is not locked
-and that its contents match what the master file says."
+and that its contents match what the repository version says."
   :type 'boolean
   :group 'vc)
 (make-obsolete-variable 'vc-checkout-carefully
@@ -1518,7 +1525,7 @@
                   (not (string= (vc-working-revision file) "0")))
               (push file filtered)
             ;; This file is added but not yet committed;
-            ;; there is no master file to diff against.
+            ;; there is no repository version to diff against.
             (if (or rev1 rev2)
                 (error "No revisions of %s exist" file)
               ;; We regard this as "changed".
@@ -2318,7 +2325,7 @@
 		(if unmodified-file
 		    (copy-file unmodified-file file
 			       'ok-if-already-exists 'keep-date)
-		  (when (y-or-n-p "Get base revision from master? ")
+		  (when (y-or-n-p "Get base revision from repository? ")
 		    (vc-revert-file file))))
 	      (vc-call-backend new-backend 'receive-file file rev))
 	  (when modified-file
@@ -2405,7 +2412,7 @@
 
 ;;;###autoload
 (defun vc-rename-file (old new)
-  "Rename file OLD to NEW, and rename its master file likewise."
+  "Rename file OLD to NEW in both work area and repository."
   (interactive "fVC rename file: \nFRename to: ")
   ;; in CL I would have said (setq new (merge-pathnames new old))
   (let ((old-base (file-name-nondirectory old)))
--- a/lwlib/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,59 @@
+2010-04-11  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE)
+	(C_SWITCH_X_SITE): Define using autoconf.
+
+2010-04-11  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* lwlib-Xaw.c (widget_xft_data): New for Xft data.
+	(fill_xft_data, openFont, get_text_width_and_height)
+	(draw_text, set_text, find_xft_data, command_press)
+	(command_reset): New functions.
+	(xaw_update_one_widget): Call set_text for dialog and buttons
+	if HAVE_XFT.  Also set internalHeight for buttons.
+	(xaw_destroy_instance): Free all Xft related data.
+	(button_actions, buttonTrans): New structures.
+	(make_dialog): Call XtAppAddActions for button_actions.
+	Find xft font to use and call fill_xft_data for widgets.
+	(xaw_create_dialog): Pass instance parameter to make_dialog.
+
+	* lwlib-int.h (_widget_instance): Add Xft data if HAVE_XFT.
+	Override translations for buttons.  If depth is 16 or more, tell
+	Xaw3d to not be nice to colormap.
+	Remove separator widget, use XtNhorizDistance on first right button
+	instead.
+
+2010-04-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xlwmenu.c (xlwmenu_default_font): Make static.
+	(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
+	(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
+	(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
+	HAVE_XFT.
+	(size_menu): Set max_rest_width in window_state structure.
+	(display_menu_item): If HAVE_XFT and xft_draw is set, use
+	XftDrawRect and XftDrawStringUtf8 to draw text.
+	(make_windows_if_needed): Set max_rest_width and xft_draw
+	in windows[i].
+	(openXftFont): New.
+	(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
+	is not set, load font fixed and save it in xlwmenu_default_font.
+	(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
+	(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
+	(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
+	windows[0].xft_draw if xft_font is set.
+	(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
+	(facename_changed): New.
+	(XlwMenuSetValues): Call facename_changed. If face name did change,
+	close old fonts and destroy xft_draw:s.  Then create new ones.
+
+	* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
+	XtCDefaultFace): New.
+
+	* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
+	(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
+	xft_font.
+
 2010-03-10  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Branch for 23.2.
--- a/lwlib/Makefile.in	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/Makefile.in	Mon Apr 12 01:03:06 2010 +0000
@@ -26,6 +26,8 @@
 srcdir=@srcdir@
 VPATH=@srcdir@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
+C_SWITCH_SYSTEM=@c_switch_system@
+C_SWITCH_MACHINE=@c_switch_machine@
 
 CC=@CC@
 CFLAGS=@CFLAGS@
--- a/lwlib/lwlib-Xaw.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/lwlib-Xaw.c	Mon Apr 12 01:03:06 2010 +0000
@@ -54,6 +54,22 @@
 
 #include <X11/Xatom.h>
 
+#ifdef HAVE_XFT
+#include <X11/Xft/Xft.h>
+
+struct widget_xft_data
+{
+  Widget widget;
+  XftFont *xft_font;
+  XftDraw *xft_draw;
+  XftColor xft_fg, xft_bg;
+  int p_width, p_height;
+  Pixmap p;
+};
+
+
+#endif
+
 static void xaw_generic_callback (/*Widget, XtPointer, XtPointer*/);
 
 
@@ -130,6 +146,207 @@
 }
 #endif
 
+#ifdef HAVE_XFT
+static void
+fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
+{
+  data->widget = widget;
+  data->xft_font = font;
+  Pixel bg, fg;
+  XColor colors[2];
+  int screen = XScreenNumberOfScreen (XtScreen (widget));
+
+  XtVaGetValues (widget,
+                 XtNbackground, &bg,
+                 XtNforeground, &fg,
+                 NULL);
+
+  colors[0].pixel = data->xft_fg.pixel = fg;
+  colors[1].pixel = data->xft_bg.pixel = bg;
+  XQueryColors (XtDisplay (widget),
+                DefaultColormapOfScreen (XtScreen (widget)),
+                colors, 2);
+
+  data->xft_fg.color.alpha = 0xFFFF;
+  data->xft_fg.color.red = colors[0].red;
+  data->xft_fg.color.green = colors[0].green;
+  data->xft_fg.color.blue = colors[0].blue;
+  data->xft_bg.color.alpha = 0xFFFF;
+  data->xft_bg.color.red = colors[1].red;
+  data->xft_bg.color.green = colors[1].green;
+  data->xft_bg.color.blue = colors[1].blue;
+
+  data->p = None;
+  data->xft_draw = 0;
+  data->p_width = data->p_height = 0;
+}
+
+static XftFont*
+openFont (Widget widget, char *name)
+{
+  char *fname = name;
+  int screen = XScreenNumberOfScreen (XtScreen (widget));
+  int len = strlen (fname), i = len-1;
+  XftFont *fn;
+
+  /* Try to convert Gtk-syntax (Sans 9) to Xft syntax Sans-9.  */
+  while (i > 0 && isdigit (fname[i]))
+    --i;
+  if (fname[i] == ' ')
+    {
+      fname = xstrdup (name);
+      fname[i] = '-';
+    }
+
+  fn = XftFontOpenName (XtDisplay (widget), screen, fname);
+  if (fname != name) free (fname);
+
+  return fn;
+}
+
+static int
+get_text_width_and_height (Widget widget, char *text,
+                           XftFont *xft_font,
+                           int *height)
+{
+  int w = 0, h = 0;
+  char *bp = text;
+  
+  while (bp && *bp != '\0')
+    {
+      XGlyphInfo gi;
+      char *cp = strchr (bp, '\n');
+      XftTextExtentsUtf8 (XtDisplay (widget), xft_font,
+                          (FcChar8 *) bp,
+                          cp ? cp - bp : strlen (bp),
+                          &gi);
+      bp = cp ? cp + 1 : NULL;
+      h += xft_font->height;
+      if (w < gi.width) w = gi.width;
+    }
+
+  *height = h;
+  return w;
+}
+
+static void
+draw_text (struct widget_xft_data *data, char *lbl, int inverse)
+{
+  Screen *sc = XtScreen (data->widget);
+  int screen = XScreenNumberOfScreen (sc);
+  int y = data->xft_font->ascent;
+  int x = inverse ? 0 : 2;
+  char *bp = lbl;
+
+  data->xft_draw = XftDrawCreate (XtDisplay (data->widget),
+                                  data->p,
+                                  DefaultVisual (XtDisplay (data->widget),
+                                                 screen),
+                                  DefaultColormapOfScreen (sc));
+  XftDrawRect (data->xft_draw,
+               inverse ? &data->xft_fg : &data->xft_bg,
+               0, 0, data->p_width, data->p_height);
+
+  if (!inverse) y += 2;
+  while (bp && *bp != '\0')
+    {
+      char *cp = strchr (bp, '\n');
+      XftDrawStringUtf8 (data->xft_draw,
+                         inverse ? &data->xft_bg : &data->xft_fg,
+                         data->xft_font, x, y, bp, cp ? cp - bp : strlen (bp));
+      bp = cp ? cp + 1 : NULL;
+      /* 1.2 gives reasonable line spacing.  */
+      y += data->xft_font->height * 1.2;
+    }
+
+}
+
+
+static void
+set_text (struct widget_xft_data *data, Widget toplevel, char *lbl, int margin)
+{
+  int screen = XScreenNumberOfScreen (XtScreen (data->widget));
+  int width, height;
+
+  width = get_text_width_and_height (data->widget, lbl, data->xft_font,
+                                     &height);
+  data->p_width = width + margin;
+  data->p_height = height + margin;
+
+  data->p = XCreatePixmap (XtDisplay (data->widget),
+                           XtWindow (toplevel),
+                           data->p_width,
+                           data->p_height,
+                           DefaultDepthOfScreen (XtScreen (data->widget)));
+  draw_text (data, lbl, 0);
+  XtVaSetValues (data->widget, XtNbitmap, data->p, NULL);
+}
+
+static struct widget_xft_data *
+find_xft_data (Widget widget)
+{
+  widget_instance *inst = NULL;
+  Widget parent = XtParent (widget);
+  struct widget_xft_data *data = NULL;
+  int nr;
+  while (parent && !inst) 
+    {
+      inst = lw_get_widget_instance (parent);
+      parent = XtParent (parent);
+    }
+  if (!inst || !inst->xft_data || !inst->xft_data[0].xft_font) return;
+
+  for (nr = 0; data == NULL && nr < inst->nr_xft_data; ++nr) 
+    {
+      if (inst->xft_data[nr].widget == widget) 
+        data = &inst->xft_data[nr];
+    }
+
+  return data;
+}
+
+static void
+command_press (Widget widget,
+               XEvent* event,
+               String *params,
+               Cardinal *num_params)
+{
+  struct widget_xft_data *data = find_xft_data (widget);
+  if (data) 
+    {
+      char *lbl;
+      /* Since this isn't used for rectangle buttons, use it to for armed.  */
+      XtVaSetValues (widget, XtNcornerRoundPercent, 1, NULL);
+
+      XtVaGetValues (widget, XtNlabel, &lbl, NULL);
+      draw_text (data, lbl, 1);
+    }
+}
+
+static void
+command_reset (Widget widget,
+                 XEvent* event,
+                 String *params,
+                 Cardinal *num_params)
+{
+  struct widget_xft_data *data = find_xft_data (widget);
+  if (data) 
+    {
+      Dimension cr;
+      XtVaGetValues (widget, XtNcornerRoundPercent, &cr, NULL);
+      if (cr == 1) 
+        {
+          char *lbl;
+          XtVaSetValues (widget, XtNcornerRoundPercent, 0, NULL);
+          XtVaGetValues (widget, XtNlabel, &lbl, NULL);
+          draw_text (data, lbl, 0);
+        }
+    }
+}
+
+
+#endif
+
 void
 #ifdef PROTOTYPES
 xaw_update_one_widget (widget_instance *instance, Widget widget,
@@ -150,15 +367,21 @@
 #endif
   if (XtIsSubclass (widget, dialogWidgetClass))
     {
-      Arg al[1];
-      int ac = 0;
-      XtSetArg (al[ac], XtNlabel, val->contents->value); ac++;
-      XtSetValues (widget,  al, ac);
+
+#ifdef HAVE_XFT
+      if (instance->xft_data && instance->xft_data[0].xft_font)
+        {
+          set_text (&instance->xft_data[0], instance->parent,
+                    val->contents->value, 10);
+        }
+#endif
+      XtVaSetValues (widget, XtNlabel, val->contents->value, NULL);
     }
   else if (XtIsSubclass (widget, commandWidgetClass))
     {
       Dimension bw = 0;
-      Arg al[3];
+      Arg al[10];
+      int ac = 0;
 
       XtVaGetValues (widget, XtNborderWidth, &bw, NULL);
       if (bw == 0)
@@ -174,10 +397,30 @@
 	}
 
       XtSetSensitive (widget, val->enabled);
-      XtSetArg (al[0], XtNlabel, val->value);
+      XtSetArg (al[ac], XtNlabel, val->value);ac++;
       /* Force centered button text.  Se above. */
-      XtSetArg (al[1], XtNjustify, XtJustifyCenter);
-      XtSetValues (widget, al, 2);
+      XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
+#ifdef HAVE_XFT
+      if (instance->xft_data && instance->xft_data[0].xft_font)
+        {
+          int th;
+          int nr;
+          for (nr = 0; nr < instance->nr_xft_data; ++nr)
+            if (instance->xft_data[nr].widget == widget)
+              break;
+          if (nr < instance->nr_xft_data)
+            {
+              set_text (&instance->xft_data[nr], instance->parent,
+                        val->value, 6);
+
+              /* Must set internalHeight to twice the highlight thickness,
+                 or else it gets overwritten by our pixmap.  Probably a bug.  */
+              XtVaGetValues (widget, XtNhighlightThickness, &th, NULL);
+              XtSetArg (al[ac], XtNinternalHeight, 2*th);ac++;
+            }
+        }
+#endif
+      XtSetValues (widget, al, ac);
       XtRemoveAllCallbacks (widget, XtNcallback);
       XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
     }
@@ -198,6 +441,28 @@
 xaw_destroy_instance (instance)
      widget_instance *instance;
 {
+#ifdef HAVE_XFT
+  if (instance->xft_data) 
+    {
+      int i;
+      for (i = 0; i < instance->nr_xft_data; ++i) 
+        {
+          if (instance->xft_data[i].xft_draw)
+            XftDrawDestroy (instance->xft_data[i].xft_draw);
+          if (instance->xft_data[i].p != None) 
+            {
+              XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None,
+                             NULL);
+              XFreePixmap (XtDisplay (instance->widget),
+                           instance->xft_data[i].p);
+            }
+        }
+      if (instance->xft_data[0].xft_font)
+        XftFontClose (XtDisplay (instance->widget),
+                      instance->xft_data[0].xft_font);
+      free (instance->xft_data);
+    }
+#endif
   if (XtIsSubclass (instance->widget, dialogWidgetClass))
     /* Need to destroy the Shell too. */
     XtDestroyWidget (XtParent (instance->widget));
@@ -298,8 +563,21 @@
 };
 static Boolean actions_initted = False;
 
+#ifdef HAVE_XFT
+static XtActionsRec button_actions[] = 
+  {
+    { "my_reset", command_reset },
+    { "my_press", command_press },
+  };
+char buttonTrans[] =
+  "<Leave>: reset() my_reset()\n"
+  "<Btn1Down>: set() my_press()\n"
+  "<Btn1Up>:  my_reset() notify() unset()\n";
+#endif
+
 static Widget
-make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot, radio_box, list, left_buttons, right_buttons)
+make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot,
+             radio_box, list, left_buttons, right_buttons, instance)
      char* name;
      Widget parent;
      Boolean pop_up_p;
@@ -310,6 +588,7 @@
      Boolean list;
      int left_buttons;
      int right_buttons;
+     widget_instance *instance;
 {
   Arg av [20];
   int ac = 0;
@@ -319,6 +598,10 @@
   Widget dialog;
   Widget button;
   XtTranslations override;
+#ifdef HAVE_XFT
+  XftFont *xft_font = 0;
+  XtTranslations button_override;
+#endif
 
   if (! pop_up_p) abort (); /* not implemented */
   if (text_input_slot) abort (); /* not implemented */
@@ -330,6 +613,10 @@
       XtAppContext app = XtWidgetToApplicationContext (parent);
       XtAppAddActions (app, xaw_actions,
 		       sizeof (xaw_actions) / sizeof (xaw_actions[0]));
+#ifdef HAVE_XFT
+      XtAppAddActions (app, button_actions,
+		       sizeof (button_actions) / sizeof (button_actions[0]));
+#endif
       actions_initted = True;
     }
 
@@ -351,6 +638,49 @@
   override = XtParseTranslationTable (dialogOverride);
   XtOverrideTranslations (dialog, override);
 
+#ifdef HAVE_XFT
+  {
+    int num;
+    Widget *ch = NULL;
+    Widget w = 0;
+    XtVaGetValues (dialog,
+                   XtNnumChildren, &num,
+                   XtNchildren, &ch, NULL);
+    for (i = 0; i < num; ++i) 
+      {
+        if (!XtIsSubclass (ch[i], commandWidgetClass)
+            && XtIsSubclass (ch[i], labelWidgetClass))
+          {
+            w = ch[i];
+            break;
+          }
+      }
+    instance->xft_data = 0;
+    instance->nr_xft_data = 0;
+    if (w) 
+      {
+        XtResource rec[] = 
+          { { "faceName", "FaceName", XtRString, sizeof(String), 0, XtRString,
+              (XtPointer)"Sans-14" }};
+        char *faceName;
+        XtVaGetSubresources (dialog, &faceName, "Dialog", "dialog",
+                             rec, 1, 0, NULL);
+        if (strcmp ("none", faceName) != 0)
+          xft_font = openFont (dialog, faceName);
+        if (xft_font) 
+          {
+            instance->nr_xft_data = left_buttons + right_buttons + 1;
+            instance->xft_data = calloc (instance->nr_xft_data,
+                                         sizeof(*instance->xft_data));
+
+            fill_xft_data (&instance->xft_data[0], w, xft_font);
+          }
+      }
+
+    button_override = XtParseTranslationTable (buttonTrans);
+  }
+#endif
+
   bc = 0;
   button = 0;
   for (i = 0; i < left_buttons; i++)
@@ -362,51 +692,56 @@
       XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
       XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
       XtSetArg (av [ac], XtNresizable, True); ac++;
+#ifdef HAVE_XAW3D
+      if (DefaultDepthOfScreen (XtScreen (dialog)) >= 16)
+        {
+          /* Turn of dithered shadow if we can.  Looks bad */
+          XtSetArg (av [ac], "beNiceToColormap", False); ac++;
+        }
+#endif
       sprintf (button_name, "button%d", ++bc);
       button = XtCreateManagedWidget (button_name, commandWidgetClass,
 				      dialog, av, ac);
+#ifdef HAVE_XFT
+      if (xft_font)
+        {
+          fill_xft_data (&instance->xft_data[bc], button, xft_font);
+          XtOverrideTranslations (button, button_override);
+        }
+#endif
     }
-  if (right_buttons)
-    {
-      /* Create a separator
 
-	 I want the separator to take up the slack between the buttons on
-	 the right and the buttons on the left (that is I want the buttons
-	 after the separator to be packed against the right edge of the
-	 window) but I can't seem to make it do it.
-       */
-      ac = 0;
-      XtSetArg (av [ac], XtNfromHoriz, button); ac++;
-/*  XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */
-      XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
-      XtSetArg (av [ac], XtNright, XtChainRight); ac++;
-      XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
-      XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
-      XtSetArg (av [ac], XtNlabel, ""); ac++;
-      XtSetArg (av [ac], XtNwidth, 30); ac++;	/* #### aaack!! */
-      XtSetArg (av [ac], XtNborderWidth, 0); ac++;
-      XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++;
-      XtSetArg (av [ac], XtNresizable, False); ac++;
-      XtSetArg (av [ac], XtNsensitive, False); ac++;
-      button = XtCreateManagedWidget ("separator",
-				      /* labelWidgetClass, */
-				      /* This has to be Command to fake out
-					 the Dialog widget... */
-				      commandWidgetClass,
-				      dialog, av, ac);
-    }
   for (i = 0; i < right_buttons; i++)
     {
       ac = 0;
       XtSetArg (av [ac], XtNfromHoriz, button); ac++;
+      if (i == 0) 
+        {
+          /* Separator to the other buttons. */
+          XtSetArg (av [ac], XtNhorizDistance, 30); ac++;
+        }
       XtSetArg (av [ac], XtNleft, XtChainRight); ac++;
       XtSetArg (av [ac], XtNright, XtChainRight); ac++;
       XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
       XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
       XtSetArg (av [ac], XtNresizable, True); ac++;
+#ifdef HAVE_XAW3D
+      if (DefaultDepthOfScreen (XtScreen (dialog)) >= 16)
+        {
+          /* Turn of dithered shadow if we can.  Looks bad */
+          XtSetArg (av [ac], "beNiceToColormap", False); ac++;
+        }
+#endif
       sprintf (button_name, "button%d", ++bc);
       button = XtCreateManagedWidget (button_name, commandWidgetClass,
 				      dialog, av, ac);
+#ifdef HAVE_XFT
+      if (xft_font)
+        {
+          fill_xft_data (&instance->xft_data[bc], button, xft_font);
+          XtOverrideTranslations (button, button_override);
+        }
+#endif
     }
 
   return dialog;
@@ -472,8 +807,7 @@
 
   widget = make_dialog (name, parent, pop_up_p,
 			shell_name, icon_name, text_input_slot, radio_box,
-			list, left_buttons, right_buttons);
-
+			list, left_buttons, right_buttons, instance);
   return widget;
 }
 
--- a/lwlib/lwlib-int.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/lwlib-int.h	Mon Apr 12 01:03:06 2010 +0000
@@ -28,11 +28,17 @@
 
 extern char *safe_strdup __P ((const char *));
 
+struct widget_xft_data;
+
 typedef struct _widget_instance
 {
   Widget		widget;
   Widget		parent;
   Boolean		pop_up_p;
+#ifdef HAVE_XFT
+  struct widget_xft_data *xft_data;
+  int                   nr_xft_data;
+#endif
   struct _widget_info*		info;
   struct _widget_instance*	next;
 } widget_instance;
--- a/lwlib/xlwmenu.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/xlwmenu.c	Mon Apr 12 01:03:06 2010 +0000
@@ -30,6 +30,7 @@
 #include "lisp.h"
 
 #include <stdio.h>
+#include <ctype.h>
 
 #include <sys/types.h>
 #if (defined __sun) && !(defined SUNOS41)
@@ -69,7 +70,7 @@
 static int pointer_grabbed;
 static XEvent menu_post_event;
 
-XFontStruct *xlwmenu_default_font;
+static XFontStruct *xlwmenu_default_font;
 
 static char
 xlwMenuTranslations [] =
@@ -128,6 +129,13 @@
   {XtNfontSet,  XtCFontSet, XtRFontSet, sizeof(XFontSet),
      offset(menu.fontSet), XtRFontSet, NULL},
 #endif
+#ifdef HAVE_XFT
+#define DEFAULT_FACENAME "Sans-10"
+  {XtNfaceName,  XtCFaceName, XtRString, sizeof(String),
+   offset(menu.faceName), XtRString, DEFAULT_FACENAME},
+  {XtNdefaultFace,  XtCDefaultFace, XtRInt, sizeof(int),
+   offset(menu.default_face), XtRImmediate, (XtPointer)1},
+#endif
   {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
      offset(menu.font), XtRString, "XtDefaultFont"},
   {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
@@ -352,10 +360,20 @@
 {
   XCharStruct xcs;
   int drop;
+#ifdef HAVE_XFT
+  if (mw->menu.xft_font)
+    {
+      XGlyphInfo gi;
+      XftTextExtentsUtf8 (XtDisplay (mw), mw->menu.xft_font,
+                          (FcChar8 *) s,
+                          strlen (s), &gi);
+      return gi.width;
+    }
+#endif
 #ifdef HAVE_X_I18N
-  XRectangle ink, logical;
   if (mw->menu.fontSet)
     {
+      XRectangle ink, logical;
       XmbTextExtents (mw->menu.fontSet, s, strlen (s), &ink, &logical);
       return logical.width;
     }
@@ -366,6 +384,20 @@
 
 }
 
+#ifdef HAVE_XFT
+#define MENU_FONT_HEIGHT(mw)                                    \
+  ((mw)->menu.xft_font != NULL                                  \
+   ? (mw)->menu.xft_font->height                                \
+   : ((mw)->menu.fontSet != NULL                                \
+      ? (mw)->menu.font_extents->max_logical_extent.height      \
+      : (mw)->menu.font->ascent + (mw)->menu.font->descent))
+#define MENU_FONT_ASCENT(mw)                                    \
+  ((mw)->menu.xft_font != NULL                                  \
+    ? (mw)->menu.xft_font->ascent                               \
+    : ((mw)->menu.fontSet != NULL                               \
+       ? - (mw)->menu.font_extents->max_logical_extent.y        \
+       : (mw)->menu.font->ascent))
+#else
 #ifdef HAVE_X_I18N
 #define MENU_FONT_HEIGHT(mw) \
   ((mw)->menu.fontSet != NULL \
@@ -380,6 +412,7 @@
   ((mw)->menu.font->ascent + (mw)->menu.font->descent)
 #define MENU_FONT_ASCENT(mw) ((mw)->menu.font->ascent)
 #endif
+#endif
 
 static int
 arrow_width (mw)
@@ -559,6 +592,7 @@
 
   ws->width += 2 * mw->menu.shadow_thickness;
   ws->height += 2 * mw->menu.shadow_thickness;
+  ws->max_rest_width = max_rest_width;
 
   if (horizontal_p)
     {
@@ -987,6 +1021,9 @@
   int width;
   enum menu_separator separator;
   int separator_p = lw_separator_p (val->name, &separator, 0);
+#ifdef HAVE_XFT
+  XftColor *xftfg;
+#endif
 
   /* compute the sizes of the item */
   size_menu_item (mw, val, horizontal_p, &label_width, &rest_width,
@@ -1024,6 +1061,9 @@
       else
 	text_gc = mw->menu.disabled_gc;
       deco_gc = mw->menu.foreground_gc;
+#ifdef HAVE_XFT
+      xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
+#endif
 
       if (separator_p)
 	{
@@ -1048,6 +1088,21 @@
 	    x_offset += ws->button_width;
 
 
+#ifdef HAVE_XFT
+          if (ws->xft_draw)
+            {
+              int draw_y = y + v_spacing + shadow;
+              XftDrawRect (ws->xft_draw, &mw->menu.xft_bg,
+                           x_offset, draw_y,
+                           ws->width, font_height);
+              XftDrawStringUtf8 (ws->xft_draw, xftfg,
+                                 mw->menu.xft_font,
+                                 x_offset, draw_y + font_ascent,
+                                 (unsigned char *) display_string,
+                                 strlen (display_string));
+            }
+          else
+#endif
 #ifdef HAVE_X_I18N
           if (mw->menu.fontSet)
             XmbDrawString (XtDisplay (mw), ws->window, mw->menu.fontSet,
@@ -1082,6 +1137,21 @@
 		}
 	      else if (val->key)
 		{
+#ifdef HAVE_XFT
+                  if (ws->xft_draw)
+                    {
+                      XGlyphInfo gi;
+                      int draw_x = ws->width - ws->max_rest_width
+                        + mw->menu.arrow_spacing;
+                      int draw_y = y + v_spacing + shadow + font_ascent;
+                      XftDrawStringUtf8 (ws->xft_draw, xftfg,
+                                         mw->menu.xft_font,
+                                         draw_x, draw_y,
+                                         (unsigned char *) val->key,
+                                         strlen (val->key));
+                    }
+                  else
+#endif
 #ifdef HAVE_X_I18N
                   if (mw->menu.fontSet)
                     XmbDrawString (XtDisplay (mw), ws->window,
@@ -1242,6 +1312,9 @@
   int mask;
   Window root = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
   window_state* windows;
+#ifdef HAVE_XFT
+  int screen = XScreenNumberOfScreen (mw->core.screen);
+#endif
 
   if (mw->menu.windows_length >= n)
     return;
@@ -1280,10 +1353,21 @@
      windows [i].y = 0;
      windows [i].width = 1;
      windows [i].height = 1;
+     windows [i].max_rest_width = 0;
      windows [i].window =
        XCreateWindow (XtDisplay (mw), root, 0, 0, 1, 1,
 		      0, 0, CopyFromParent, CopyFromParent, mask, &xswa);
-  }
+#ifdef HAVE_XFT
+     if (mw->menu.xft_font)
+       mw->menu.windows [i].xft_draw
+         = XftDrawCreate (XtDisplay (mw),
+                          windows [i].window,
+                          DefaultVisual (XtDisplay (mw), screen),
+                          mw->core.colormap);
+     else
+       mw->menu.windows [i].xft_draw = 0;
+#endif
+   }
 }
 
 /* Value is non-zero if WINDOW is part of menu bar widget W.  */
@@ -1758,6 +1842,44 @@
   XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
 }
 
+#ifdef HAVE_XFT
+static int
+openXftFont (mw)
+     XlwMenuWidget mw;
+{
+  char *fname = mw->menu.faceName;
+
+  mw->menu.xft_font = 0;
+  mw->menu.default_face = fname && strcmp (fname, DEFAULT_FACENAME) == 0;
+
+  if (fname && strcmp (fname, "none") != 0)
+    {
+      int screen = XScreenNumberOfScreen (mw->core.screen);
+      int len = strlen (fname), i = len-1;
+      /* Try to convert Gtk-syntax (Sans 9) to Xft syntax Sans-9.  */
+      while (i > 0 && isdigit (fname[i]))
+        --i;
+      if (fname[i] == ' ')
+        {
+          fname = xstrdup (mw->menu.faceName);
+          fname[i] = '-';
+        }
+
+      mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
+      if (!mw->menu.xft_font) 
+        {
+          fprintf (stderr, "Can't find font '%s'\n", fname);
+          mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen,
+                                               DEFAULT_FACENAME);
+        }
+    }
+
+  if (fname != mw->menu.faceName) free (fname);
+
+  return mw->menu.xft_font != 0;
+}
+#endif
+
 static void
 XlwMenuInitialize (request, mw, args, num_args)
      Widget request;
@@ -1779,7 +1901,7 @@
   mw->menu.contents = tem;
 #endif
 
-/*  mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
+  /*  mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
   mw->menu.cursor = mw->menu.cursor_shape;
 
   mw->menu.gray_pixmap
@@ -1787,11 +1909,24 @@
 				   gray_bitmap_width, gray_bitmap_height,
 				   (unsigned long)1, (unsigned long)0, 1);
 
-  /* I don't understand why this ends up 0 sometimes,
-     but it does.  This kludge works around it.
-     Can anyone find a real fix?   -- rms.  */
-  if (mw->menu.font == 0)
-    mw->menu.font = xlwmenu_default_font;
+#ifdef HAVE_XFT
+  if (openXftFont (mw))
+    ;
+  else
+#endif
+  
+  if (!mw->menu.font)
+    {
+      if (!xlwmenu_default_font)
+        xlwmenu_default_font = XLoadQueryFont (display, "fixed");
+      mw->menu.font = xlwmenu_default_font;
+      if (!mw->menu.font) 
+        {
+          fprintf (stderr, "Menu font fixed not found, can't continue.\n");
+          abort ();
+        }
+    }
+
 #ifdef HAVE_X_I18N
   if (mw->menu.fontSet)
     mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet);
@@ -1818,6 +1953,10 @@
   mw->menu.windows [0].y = 0;
   mw->menu.windows [0].width = 0;
   mw->menu.windows [0].height = 0;
+  mw->menu.windows [0].max_rest_width = 0;
+#ifdef HAVE_XFT
+  mw->menu.windows [0].xft_draw = 0;
+#endif
   size_menu (mw, 0);
 
   mw->core.width = mw->menu.windows [0].width;
@@ -1827,6 +1966,7 @@
 static void
 XlwMenuClassInitialize ()
 {
+  xlwmenu_default_font = 0;
 }
 
 static void
@@ -1861,6 +2001,38 @@
   mw->menu.windows [0].y = w->core.y;
   mw->menu.windows [0].width = w->core.width;
   mw->menu.windows [0].height = w->core.height;
+
+#ifdef HAVE_XFT
+  if (mw->menu.xft_font)
+    {
+      XColor colors[3];
+      int screen = XScreenNumberOfScreen (mw->core.screen);
+      mw->menu.windows [0].xft_draw
+        = XftDrawCreate (XtDisplay (w),
+                         mw->menu.windows [0].window,
+                         DefaultVisual (XtDisplay (w), screen),
+                         mw->core.colormap);
+      colors[0].pixel = mw->menu.xft_fg.pixel = mw->menu.foreground;
+      colors[1].pixel = mw->menu.xft_bg.pixel = mw->core.background_pixel;
+      colors[2].pixel = mw->menu.xft_disabled_fg.pixel
+        = mw->menu.disabled_foreground;
+      XQueryColors (XtDisplay (mw), mw->core.colormap, colors, 3);
+      mw->menu.xft_fg.color.alpha = 0xFFFF;
+      mw->menu.xft_fg.color.red = colors[0].red;
+      mw->menu.xft_fg.color.green = colors[0].green;
+      mw->menu.xft_fg.color.blue = colors[0].blue;
+      mw->menu.xft_bg.color.alpha = 0xFFFF;
+      mw->menu.xft_bg.color.red = colors[1].red;
+      mw->menu.xft_bg.color.green = colors[1].green;
+      mw->menu.xft_bg.color.blue = colors[1].blue;
+      mw->menu.xft_disabled_fg.color.alpha = 0xFFFF;
+      mw->menu.xft_disabled_fg.color.red = colors[2].red;
+      mw->menu.xft_disabled_fg.color.green = colors[2].green;
+      mw->menu.xft_disabled_fg.color.blue = colors[2].blue;
+    }
+  else
+    mw->menu.windows [0].xft_draw = 0;
+#endif
 }
 
 /* Only the toplevel menubar/popup is a widget so it's the only one that
@@ -1942,13 +2114,37 @@
      client exits.  Nice, eh?
    */
 
+#ifdef HAVE_XFT
+  if (mw->menu.windows [0].xft_draw)
+    XftDrawDestroy (mw->menu.windows [0].xft_draw);
+  if (mw->menu.xft_font)
+    XftFontClose (XtDisplay (mw), mw->menu.xft_font);
+#endif
+
   /* start from 1 because the one in slot 0 is w->core.window */
   for (i = 1; i < mw->menu.windows_length; i++)
-    XDestroyWindow (XtDisplay (mw), mw->menu.windows [i].window);
+    {
+      XDestroyWindow (XtDisplay (mw), mw->menu.windows [i].window);
+#ifdef HAVE_XFT
+      if (mw->menu.windows [i].xft_draw)
+        XftDrawDestroy (mw->menu.windows [i].xft_draw);
+#endif
+    }
+
   if (mw->menu.windows)
     XtFree ((char *) mw->menu.windows);
 }
 
+static int
+facename_changed (XlwMenuWidget newmw,
+                  XlwMenuWidget oldmw)
+{
+  /* This will fore a new XftFont even if the same sting is set.
+     This is good, as rendering parameters may have changed and
+     we just want to do a redisplay.  */
+  return newmw->menu.faceName != oldmw->menu.faceName;
+}
+
 static Boolean
 XlwMenuSetValues (current, request, new)
      Widget current;
@@ -1972,6 +2168,9 @@
 
   if (newmw->core.background_pixel != oldmw->core.background_pixel
       || newmw->menu.foreground != oldmw->menu.foreground
+#ifdef HAVE_XFT
+      || facename_changed (newmw, oldmw)
+#endif
 #ifdef HAVE_X_I18N
       || newmw->menu.fontSet != oldmw->menu.fontSet
       || (newmw->menu.fontSet == NULL && newmw->menu.font != oldmw->menu.font)
@@ -2004,6 +2203,29 @@
 	  }
     }
 
+#ifdef HAVE_XFT
+  if (facename_changed (newmw, oldmw))
+    {
+      int i;
+      int screen = XScreenNumberOfScreen (newmw->core.screen);
+      if (newmw->menu.xft_font)
+        XftFontClose (XtDisplay (newmw), newmw->menu.xft_font);
+      openXftFont (newmw);
+      for (i = 0; i < newmw->menu.windows_length; i++)
+        {
+          if (newmw->menu.windows [i].xft_draw)
+            XftDrawDestroy (newmw->menu.windows [i].xft_draw);
+          newmw->menu.windows [i].xft_draw = 0;
+        }
+      if (newmw->menu.xft_font)
+      for (i = 0; i < newmw->menu.windows_length; i++)
+          newmw->menu.windows [i].xft_draw
+            = XftDrawCreate (XtDisplay (newmw),
+                             newmw->menu.windows [i].window,
+                             DefaultVisual (XtDisplay (newmw), screen),
+                             newmw->core.colormap);
+    }
+#endif
 #ifdef HAVE_X_I18N
   if (newmw->menu.fontSet != oldmw->menu.fontSet && newmw->menu.fontSet != NULL)
     {
--- a/lwlib/xlwmenu.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/xlwmenu.h	Mon Apr 12 01:03:06 2010 +0000
@@ -58,6 +58,10 @@
 #define XtCResizeToPreferred "ResizeToPreferred"
 #define XtNallowResize "allowResize"
 #define XtCAllowResize "AllowResize"
+#define XtNfaceName "faceName"
+#define XtCFaceName "FaceName"
+#define XtNdefaultFace "defaultFace"
+#define XtCDefaultFace "DefaultFace"
 
 /* Motif-compatible resource names */
 #define XmNshadowThickness	"shadowThickness"
--- a/lwlib/xlwmenuP.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/lwlib/xlwmenuP.h	Mon Apr 12 01:03:06 2010 +0000
@@ -25,6 +25,9 @@
 
 #include "xlwmenu.h"
 #include <X11/CoreP.h>
+#ifdef HAVE_XFT
+#include <X11/Xft/Xft.h>
+#endif
 
 /* Elements in the stack arrays. */
 typedef struct _window_state
@@ -35,9 +38,13 @@
   Dimension	width;
   Dimension	height;
   Dimension	label_width;
+  int           max_rest_width;
 
   /* Width of toggle buttons or radio buttons.  */
   Dimension     button_width;
+#ifdef HAVE_XFT
+  XftDraw*      xft_draw;
+#endif
 } window_state;
 
 
@@ -49,6 +56,12 @@
   XFontSet	fontSet;
   XFontSetExtents *font_extents;
 #endif
+#ifdef HAVE_XFT
+  String        faceName;
+  int           default_face;
+  XftFont*      xft_font;
+  XftColor      xft_fg, xft_bg, xft_disabled_fg;
+#endif
   XFontStruct*	font;
   Pixel		foreground;
   Pixel		disabled_foreground;
--- a/oldXMenu/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/oldXMenu/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,8 @@
+2010-04-11  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE)
+	(C_SWITCH_X_SITE): Define using autoconf.
+
 2010-03-10  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Branch for 23.2.
--- a/oldXMenu/Makefile.in	Wed Apr 07 21:55:20 2010 +0000
+++ b/oldXMenu/Makefile.in	Mon Apr 12 01:03:06 2010 +0000
@@ -46,6 +46,8 @@
 srcdir=@srcdir@
 VPATH=@srcdir@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
+C_SWITCH_SYSTEM=@c_switch_system@
+C_SWITCH_MACHINE=@c_switch_machine@
 
 EXTRA=insque.o
 CC=@CC@
--- a/src/ChangeLog	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/ChangeLog	Mon Apr 12 01:03:06 2010 +0000
@@ -1,3 +1,95 @@
+2010-04-11  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Remove C_SWITCH_SYSTEM_TEMACS.
+	* s/darwin.h (C_SWITCH_SYSTEM_TEMACS): Remove.
+	(malloc, realloc, free): Use emacs, not temacs for conditional
+	definition.
+
+	* Makefile.in (C_SWITCH_SYSTEM_TEMACS): Remove.
+	(ALL_CFLAGS): Do not use C_SWITCH_SYSTEM_TEMACS.
+
+	Use autoconf, not cpp for some variables.
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE)
+	(C_SWITCH_X_SITE): Define using autoconf, not cpp.
+	(ALL_CFLAGS): Use them as make variables.
+	(really-lwlib, really-oldXMenu): Do not pass them.
+
+2010-04-11  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xmenu.c (apply_systemfont_to_dialog): New.
+	(create_and_show_dialog): Call apply_systemfont_to_dialog if HAVE_XFT.
+
+2010-04-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* process.c (exec_sentinel): Preserve current-buffer.
+
+	* process.c (read_process_output): Move the save-current-buffer to
+	apply to both the filter and the non-filter branches.
+
+2010-04-10  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* s/msdos.h (UNEXEC): New definition.
+
+2010-04-10  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* dispextern.h (TRY_WINDOW_CHECK_MARGINS)
+	(TRY_WINDOW_IGNORE_FONTS_CHANGE): New defines.
+
+	* xdisp.c (try_window): Change arg from CHECK_MARGINS to FLAGS.
+	Don't abort with fonts change if TRY_WINDOW_IGNORE_FONTS_CHANGE is
+	set in FLAGS.  Callers with non-zero CHECK_MARGINS changed to use
+	TRY_WINDOW_CHECK_MARGINS.
+
+	* xfns.c (Fx_show_tip): Undo last change.  Call try_window with
+	TRY_WINDOW_IGNORE_FONTS_CHANGE (Bug#2423).  Subtract last glyph's
+	width only when it is for padding.
+
+2010-04-09  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xfns.c (Fx_show_tip): Call try_window in a loop until
+	fonts_changed_p is zero (Bug#2423).
+
+2010-04-08  Eli Zaretskii  <eliz@gnu.org>
+
+	* xdisp.c (set_cursor_from_row): Don't dereference glyphs beyond
+	the end of TEXT_AREA.  (Bug#5856)
+
+2010-04-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsettings.c (XSETTINGS_FONT_NAME): Move XSETTINGS_FONT_NAME out of
+	HAVE_GCONF.
+
+2010-04-08  Eli Zaretskii  <eliz@gnu.org>
+
+	* bidi.c (bidi_resolve_weak): Use prev.type_after_w1, instead of
+	prev.orig_type, for resolving type of NSM.  (Bug#5858)
+
+2010-04-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
+	(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
+	in current_font.
+	(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
+	(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
+	functions.
+	(syms_of_xsettings): Initialize current_font. defsubr
+	Sfont_get_system_normal_font.
+
+	* xsettings.h (Ffont_get_system_normal_font,
+	xsettings_get_system_normal_font): Declare.
+
+	* xfns.c (extern xlwmenu_default_font): Remove.
+	(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
+	to xlwmenu.c.
+
+	* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
+	menu items in UTF-8.
+
+	* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
+	(apply_systemfont_to_menu): New function.
+	(set_frame_menubar, create_and_show_popup_menu): Call
+	apply_systemfont_to_menu.
+
 2010-04-07  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* frame.h (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT): Don't use
--- a/src/Makefile.in	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/Makefile.in	Mon Apr 12 01:03:06 2010 +0000
@@ -75,11 +75,14 @@
 LIBXPM=@LIBXPM@
 XFT_LIBS=@XFT_LIBS@
 
+C_SWITCH_SYSTEM=@c_switch_system@
+C_SWITCH_MACHINE=@c_switch_machine@
+
+C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
+
 # ========================== start of cpp stuff =======================
 /* From here on, comments must be done in C syntax.  */
 
-C_SWITCH_SYSTEM=
-
 /* just to be sure the sh is used */
 SHELL=/bin/sh
 
@@ -163,12 +166,6 @@
 #define LD_SWITCH_SYSTEM_TEMACS
 #endif
 
-/* Some s/SYSTEM.h files define this to request special switches
-   for compiling temacs.  */
-#ifndef C_SWITCH_SYSTEM_TEMACS
-#define C_SWITCH_SYSTEM_TEMACS
-#endif
-
 /* Some m/MACHINE.h files define this to request special switches in ld.  */
 #ifndef LD_SWITCH_MACHINE
 #define LD_SWITCH_MACHINE
@@ -180,16 +177,6 @@
 #define LD_SWITCH_MACHINE_TEMACS
 #endif
 
-/* Some m/MACHINE.h files define this to request special switches in cc.  */
-#ifndef C_SWITCH_MACHINE
-#define C_SWITCH_MACHINE
-#endif
-
-/* Some s/SYSTEM.h files define this to request special switches in cc.  */
-#ifndef C_SWITCH_SYSTEM
-#define C_SWITCH_SYSTEM
-#endif
-
 /* These macros are for switches specifically related to X Windows.  */
 #ifndef C_SWITCH_X_MACHINE
 #define C_SWITCH_X_MACHINE
@@ -199,10 +186,6 @@
 #define C_SWITCH_X_SYSTEM
 #endif
 
-#ifndef C_SWITCH_X_SITE
-#define C_SWITCH_X_SITE
-#endif
-
 #ifndef LD_SWITCH_X_SITE
 #define LD_SWITCH_X_SITE
 #endif
@@ -269,7 +252,7 @@
 
 /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
    since it may have -I options that should override those two.  */
-ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS}
+ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS}
 ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@
 
 .SUFFIXES: .m
@@ -924,9 +907,6 @@
 
 /* Encode the values of these two macros in Make variables,
    so we can use $(...) to substitute their values within "...".  */
-C_SWITCH_MACHINE_1 = C_SWITCH_MACHINE
-C_SWITCH_SYSTEM_1 = C_SWITCH_SYSTEM
-C_SWITCH_X_SITE_1 = C_SWITCH_X_SITE
 C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE
 C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM
 
@@ -936,11 +916,8 @@
 really-lwlib:
 	cd ${lwlibdir}; ${MAKE} ${MFLAGS} \
     CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \
-    "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \
     "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \
-    "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \
-    "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \
-    "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)"
+    "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)"
 	@true  /* make -t should not create really-lwlib.  */
 .PHONY: really-lwlib
 #else /* not USE_X_TOOLKIT */
@@ -949,11 +926,8 @@
 really-oldXMenu:
 	cd ${oldXMenudir}; ${MAKE} ${MFLAGS} \
     CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \
-    "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \
     "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \
-    "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \
-    "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \
-    "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)"
+    "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)"
 	@true  /* make -t should not create really-oldXMenu.  */
 .PHONY: really-oldXMenu
 #endif /* not USE_X_TOOLKIT */
--- a/src/bidi.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/bidi.c	Mon Apr 12 01:03:06 2010 +0000
@@ -1347,12 +1347,14 @@
       if (type == WEAK_NSM)	/* W1 */
 	{
 	  /* Note that we don't need to consider the case where the
-	     prev character has its type overridden by an RLO or LRO:
-	     such characters are outside the current level run, and
-	     thus not relevant to this NSM.  Thus, NSM gets the
-	     orig_type of the previous character.  */
+	     prev character has its type overridden by an RLO or LRO,
+	     because then either the type of this NSM would have been
+	     also overridden, or the previous character is outside the
+	     current level run, and thus not relevant to this NSM.
+	     This is why NSM gets the type_after_w1 of the previous
+	     character.  */
 	  if (bidi_it->prev.type != UNKNOWN_BT)
-	    type = bidi_it->prev.orig_type;
+	    type = bidi_it->prev.type_after_w1;
 	  else if (bidi_it->sor == R2L)
 	    type = STRONG_R;
 	  else if (bidi_it->sor == L2R)
--- a/src/dispextern.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/dispextern.h	Mon Apr 12 01:03:06 2010 +0000
@@ -2974,6 +2974,10 @@
 				       XRectangle *));
 #endif
 
+/* Flags passed to try_window.  */
+#define TRY_WINDOW_CHECK_MARGINS	(1 << 0)
+#define TRY_WINDOW_IGNORE_FONTS_CHANGE	(1 << 1)
+
 /* Defined in fringe.c */
 
 int lookup_fringe_bitmap (Lisp_Object);
--- a/src/menu.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/menu.c	Mon Apr 12 01:03:06 2010 +0000
@@ -697,6 +697,12 @@
 
 	      ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
 	    }
+#elif defined (USE_LUCID) && defined (HAVE_XFT)
+	  if (STRINGP (pane_name))
+            {
+              pane_name = ENCODE_UTF_8 (pane_name);
+	      ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
+            }
 #elif !defined (HAVE_MULTILINGUAL_MENU)
 	  if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
 	    {
@@ -770,6 +776,18 @@
 	      descrip = ENCODE_SYSTEM (descrip);
 	      ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
 	    }
+#elif USE_LUCID
+	  if (STRINGP (item_name))
+	    {
+              item_name = ENCODE_UTF_8 (item_name);
+	      ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
+	    }
+
+	  if (STRINGP (descrip))
+	    {
+	      descrip = ENCODE_UTF_8 (descrip);
+	      ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
+	    }
 #elif !defined (HAVE_MULTILINGUAL_MENU)
           if (STRING_MULTIBYTE (item_name))
 	    {
--- a/src/process.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/process.c	Mon Apr 12 01:03:06 2010 +0000
@@ -5314,6 +5314,8 @@
   struct coding_system *coding = proc_decode_coding_system[channel];
   int carryover = p->decoding_carryover;
   int readmax = 4096;
+  int count = SPECPDL_INDEX ();
+  Lisp_Object odeactivate;
 
   chars = (char *) alloca (carryover + readmax);
   if (carryover)
@@ -5386,15 +5388,16 @@
   /* Now set NBYTES how many bytes we must decode.  */
   nbytes += carryover;
 
+  odeactivate = Vdeactivate_mark;
+  /* There's no good reason to let process filters change the current
+     buffer, and many callers of accept-process-output, sit-for, and
+     friends don't expect current-buffer to be changed from under them.  */
+  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
   /* Read and dispose of the process output.  */
   outstream = p->filter;
   if (!NILP (outstream))
     {
-      /* We inhibit quit here instead of just catching it so that
-	 hitting ^G when a filter happens to be running won't screw
-	 it up.  */
-      int count = SPECPDL_INDEX ();
-      Lisp_Object odeactivate;
       Lisp_Object obuffer, okeymap;
       Lisp_Object text;
       int outer_running_asynch_code = running_asynch_code;
@@ -5402,10 +5405,12 @@
 
       /* No need to gcpro these, because all we do with them later
 	 is test them for EQness, and none of them should be a string.  */
-      odeactivate = Vdeactivate_mark;
       XSETBUFFER (obuffer, current_buffer);
       okeymap = current_buffer->keymap;
 
+      /* We inhibit quit here instead of just catching it so that
+	 hitting ^G when a filter happens to be running won't screw
+	 it up.  */
       specbind (Qinhibit_quit, Qt);
       specbind (Qlast_nonmenu_event, Qt);
 
@@ -5474,9 +5479,6 @@
       restore_search_regs ();
       running_asynch_code = outer_running_asynch_code;
 
-      /* Handling the process output should not deactivate the mark.  */
-      Vdeactivate_mark = odeactivate;
-
       /* Restore waiting_for_user_input_p as it was
 	 when we were called, in case the filter clobbered it.  */
       waiting_for_user_input_p = waiting;
@@ -5492,27 +5494,19 @@
 	   cause trouble (for example it would make sit_for return).  */
 	if (waiting_for_user_input_p == -1)
 	  record_asynch_buffer_change ();
-
-      unbind_to (count, Qnil);
-      return nbytes;
     }
 
   /* If no filter, write into buffer if it isn't dead.  */
-  if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
+  else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
     {
       Lisp_Object old_read_only;
       int old_begv, old_zv;
       int old_begv_byte, old_zv_byte;
-      Lisp_Object odeactivate;
       int before, before_byte;
       int opoint_byte;
       Lisp_Object text;
       struct buffer *b;
-      int count = SPECPDL_INDEX ();
-
-      odeactivate = Vdeactivate_mark;
-
-      record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
       Fset_buffer (p->buffer);
       opoint = PT;
       opoint_byte = PT_BYTE;
@@ -5610,13 +5604,14 @@
       if (old_begv != BEGV || old_zv != ZV)
 	Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
 
-      /* Handling the process output should not deactivate the mark.  */
-      Vdeactivate_mark = odeactivate;
 
       current_buffer->read_only = old_read_only;
       SET_PT_BOTH (opoint, opoint_byte);
-      unbind_to (count, Qnil);
     }
+  /* Handling the process output should not deactivate the mark.  */
+  Vdeactivate_mark = odeactivate;
+
+  unbind_to (count, Qnil);
   return nbytes;
 }
 
@@ -6845,6 +6840,11 @@
   XSETBUFFER (obuffer, current_buffer);
   okeymap = current_buffer->keymap;
 
+  /* There's no good reason to let sentinels change the current
+     buffer, and many callers of accept-process-output, sit-for, and
+     friends don't expect current-buffer to be changed from under them.  */
+  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
   sentinel = p->sentinel;
   if (NILP (sentinel))
     return;
--- a/src/s/darwin.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/s/darwin.h	Mon Apr 12 01:03:06 2010 +0000
@@ -165,9 +165,7 @@
    each); under Cocoa 31 commands are required.  */
 #define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA
 
-#define C_SWITCH_SYSTEM_TEMACS -Dtemacs
-
-#ifdef temacs
+#ifdef emacs
 #define malloc unexec_malloc
 #define realloc unexec_realloc
 #define free unexec_free
--- a/src/s/msdos.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/s/msdos.h	Mon Apr 12 01:03:06 2010 +0000
@@ -172,5 +172,7 @@
 
 #define NO_REMAP
 
+#define UNEXEC unexec.o
+
 /* arch-tag: d184f860-815d-4ff4-8187-d05c0f3c37d0
    (do not change this comment) */
--- a/src/xdisp.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/xdisp.c	Mon Apr 12 01:03:06 2010 +0000
@@ -12553,6 +12553,9 @@
   EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta;
   EMACS_INT pos_after = MATRIX_ROW_END_CHARPOS (row) + delta;
   struct glyph *glyph_before = glyph - 1, *glyph_after = end;
+  /* A glyph beyond the edge of TEXT_AREA which we should never
+     touch.  */
+  struct glyph *glyphs_end = end;
   /* Non-zero means we've found a match for cursor position, but that
      glyph has the avoid_cursor_p flag set.  */
   int match_with_avoid_cursor = 0;
@@ -12594,7 +12597,7 @@
 
 	  /* If the glyph row is reversed, we need to process it from back
 	     to front, so swap the edge pointers.  */
-	  end = glyph - 1;
+	  glyphs_end = end = glyph - 1;
 	  glyph += row->used[TEXT_AREA] - 1;
 	  /* Reverse the known positions in the row.  */
 	  last_pos = pos_after = MATRIX_ROW_START_CHARPOS (row) + delta;
@@ -12772,7 +12775,8 @@
   /* Step 2: If we didn't find an exact match for point, we need to
      look for a proper place to put the cursor among glyphs between
      GLYPH_BEFORE and GLYPH_AFTER.  */
-  if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old)
+  if (!((row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)
+	&& BUFFERP (glyph->object) && glyph->charpos == pt_old)
       && bpos_covered < pt_old)
     {
       if (row->ends_in_ellipsis_p && pos_after == last_pos)
@@ -12938,9 +12942,15 @@
       struct glyph *g1 =
 	MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos;
 
+      /* Don't consider glyphs that are outside TEXT_AREA.  */
+      if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end))
+	return 0;
       /* Keep the candidate whose buffer position is the closest to
 	 point.  */
-      if (BUFFERP (g1->object)
+      if (/* previous candidate is a glyph in TEXT_AREA of that row */
+	  w->cursor.hpos >= 0
+	  && w->cursor.hpos < MATRIX_ROW_USED(matrix, w->cursor.vpos)
+	  && BUFFERP (g1->object)
 	  && (g1->charpos == pt_old /* an exact match always wins */
 	      || (BUFFERP (glyph->object)
 		  && eabs (g1->charpos - pt_old)
@@ -14193,7 +14203,7 @@
 	       = try_window_reusing_current_matrix (w)))
 	{
 	  IF_DEBUG (debug_method_add (w, "1"));
-	  if (try_window (window, startp, 1) < 0)
+	  if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0)
 	    /* -1 means we need to scroll.
 	       0 means we need new matrices, but fonts_changed_p
 	       is set in that case, so we will detect it below.  */
@@ -14544,13 +14554,15 @@
    Value is 1 if successful.  It is zero if fonts were loaded during
    redisplay which makes re-adjusting glyph matrices necessary, and -1
    if point would appear in the scroll margins.
-   (We check that only if CHECK_MARGINS is nonzero.  */
+   (We check the former only if TRY_WINDOW_IGNORE_FONTS_CHANGE is
+   unset in FLAGS, and the latter only if TRY_WINDOW_CHECK_MARGINS is
+   set in FLAGS.)  */
 
 int
-try_window (window, pos, check_margins)
+try_window (window, pos, flags)
      Lisp_Object window;
      struct text_pos pos;
-     int check_margins;
+     int flags;
 {
   struct window *w = XWINDOW (window);
   struct it it;
@@ -14572,12 +14584,12 @@
     {
       if (display_line (&it))
 	last_text_row = it.glyph_row - 1;
-      if (fonts_changed_p)
+      if (fonts_changed_p && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE))
 	return 0;
     }
 
   /* Don't let the cursor end in the scroll margins.  */
-  if (check_margins
+  if ((flags & TRY_WINDOW_CHECK_MARGINS)
       && !MINI_WINDOW_P (w))
     {
       int this_scroll_margin;
--- a/src/xfns.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/xfns.c	Mon Apr 12 01:03:06 2010 +0000
@@ -110,11 +110,6 @@
 
 extern LWLIB_ID widget_id_tick;
 
-#ifdef USE_LUCID
-/* This is part of a kludge--see lwlib/xlwmenu.c.  */
-extern XFontStruct *xlwmenu_default_font;
-#endif
-
 extern void free_frame_menubar ();
 extern double atof ();
 
@@ -3379,14 +3374,6 @@
       error ("Invalid frame font");
     }
 
-#ifdef USE_LUCID
-  /* Prevent lwlib/xlwmenu.c from crashing because of a bug
-     whereby it fails to get any font.  */
-  BLOCK_INPUT;
-  xlwmenu_default_font = XLoadQueryFont (FRAME_X_DISPLAY (f), "fixed");
-  UNBLOCK_INPUT;
-#endif
-
   /* Frame contents get displaced if an embedded X window has a border.  */
   if (! FRAME_X_EMBEDDED_P (f))
     x_default_parameter (f, parms, Qborder_width, make_number (2),
@@ -5241,7 +5228,7 @@
   clear_glyph_matrix (w->desired_matrix);
   clear_glyph_matrix (w->current_matrix);
   SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
-  try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+  try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
 
   /* Compute width and height of the tooltip.  */
   width = height = 0;
@@ -5258,15 +5245,15 @@
       /* Let the row go over the full width of the frame.  */
       row->full_width_p = 1;
 
+      row_width = row->pixel_width;
       /* There's a glyph at the end of rows that is used to place
 	 the cursor there.  Don't include the width of this glyph.  */
       if (row->used[TEXT_AREA])
 	{
 	  last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
-	  row_width = row->pixel_width - last->pixel_width;
+	  if (INTEGERP (last->object))
+	    row_width -= last->pixel_width;
 	}
-      else
-	row_width = row->pixel_width;
 
       height += row->height;
       width = max (width, row_width);
--- a/src/xmenu.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/xmenu.c	Mon Apr 12 01:03:06 2010 +0000
@@ -81,6 +81,8 @@
 #include <X11/StringDefs.h>
 #include <X11/Shell.h>
 #ifdef USE_LUCID
+#include "xsettings.h"
+#include "../lwlib/xlwmenu.h"
 #ifdef HAVE_XAW3D
 #include <X11/Xaw3d/Paned.h>
 #else /* !HAVE_XAW3D */
@@ -950,6 +952,49 @@
   return 1;
 }
 
+#ifdef USE_LUCID
+static void
+apply_systemfont_to_dialog (w)
+     Widget w;
+{
+  const char *fn = xsettings_get_system_normal_font ();
+  if (fn) 
+    {
+      XrmDatabase db = XtDatabase (XtDisplay (w));
+      if (db)
+        XrmPutStringResource (&db, "*dialog.faceName", fn);
+    }
+}
+
+static void
+apply_systemfont_to_menu (w)
+     Widget w;
+{
+  const char *fn = xsettings_get_system_normal_font ();
+  int defflt;
+
+  if (!fn) return;
+
+  if (XtIsShell (w)) /* popup menu */
+    {
+      Widget *childs = NULL;
+      int num = 0;
+
+      XtVaGetValues (w, XtNnumChildren, &num, NULL);
+      if (num != 1) return; /* Should only be one. */
+
+      childs[0] = 0;
+      XtVaGetValues (w, XtNchildren, &childs, NULL);
+      if (childs && *childs) w = *childs;
+    }
+
+  /* Only use system font if the default is used for the menu.  */
+  XtVaGetValues (w, XtNdefaultFace, &defflt, NULL);
+  if (defflt)
+    XtVaSetValues (w, XtNfaceName, fn, NULL);
+}
+#endif
+
 /* Set the contents of the menubar widgets of frame F.
    The argument FIRST_TIME is currently ignored;
    it is set the first time this is called, from initialize_frame_menubar.  */
@@ -1262,6 +1307,7 @@
 
       /* Make menu pop down on C-g.  */
       XtOverrideTranslations (menubar_widget, override);
+      apply_systemfont_to_menu (menubar_widget);
     }
 
   {
@@ -1608,6 +1654,8 @@
                            popup_deactivate_callback,
                            menu_highlight_callback);
 
+  apply_systemfont_to_menu (menu);
+
   dummy.type = ButtonPress;
   dummy.serial = 0;
   dummy.send_event = 0;
@@ -2012,11 +2060,13 @@
     abort();
 
   dialog_id = widget_id_tick++;
+#ifdef HAVE_XFT
+  apply_systemfont_to_dialog (f->output_data.x->widget);
+#endif
   lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
                     f->output_data.x->widget, 1, 0,
                     dialog_selection_callback, 0, 0);
   lw_modify_all_widgets (dialog_id, first_wv->contents, True);
-
   /* Display the dialog box.  */
   lw_pop_up_all_widgets (dialog_id);
   popup_activated_flag = 1;
--- a/src/xsettings.c	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/xsettings.c	Mon Apr 12 01:03:06 2010 +0000
@@ -39,6 +39,7 @@
 #endif
 
 static char *current_mono_font;
+static char *current_font;
 static struct x_display_info *first_dpyinfo;
 static Lisp_Object Qfont_name, Qfont_render;
 static int use_system_font;
@@ -63,9 +64,12 @@
   kbd_buffer_store_event (&event);
 }
 
+#define XSETTINGS_FONT_NAME  "Gtk/FontName"
+
 #ifdef HAVE_GCONF
 
-#define SYSTEM_MONO_FONT       "/desktop/gnome/interface/monospace_font_name"
+#define SYSTEM_MONO_FONT     "/desktop/gnome/interface/monospace_font_name"
+#define SYSTEM_FONT          "/desktop/gnome/interface/font_name"
 
 /* Callback called when something changed in GConf that we care about,
    that is SYSTEM_MONO_FONT.  */
@@ -235,7 +239,7 @@
 
   memset (settings, 0, sizeof (*settings));
 
-  while (bytes_parsed+4 < bytes && settings_seen < 6
+  while (bytes_parsed+4 < bytes && settings_seen < 7
          && i < n_settings)
     {
       int type = prop[bytes_parsed++];
@@ -243,7 +247,7 @@
       CARD32 vlen, ival = 0;
       char name[128]; /* The names we are looking for are not this long.  */
       char sval[128]; /* The values we are looking for are not this long.  */
-      int is_xft;
+      int want_this;
       int to_cpy;
 
       sval[0] = '\0';
@@ -264,13 +268,14 @@
       bytes_parsed += 4; /* Skip serial for this value */
       if (bytes_parsed > bytes) return BadLength;
 
-      is_xft = nlen > 6 && strncmp (name, "Xft/", 4) == 0;
+      want_this = (nlen > 6 && strncmp (name, "Xft/", 4) == 0)
+        || (strcmp (XSETTINGS_FONT_NAME, name) == 0);
 
       switch (type) 
         {
         case 0: /* Integer */
           if (bytes_parsed+4 > bytes) return BadLength;
-          if (is_xft)
+          if (want_this)
             {
               memcpy (&ival, prop+bytes_parsed, 4);
               if (my_bo != that_bo) ival = SWAP32 (ival);
@@ -283,7 +288,7 @@
           memcpy (&vlen, prop+bytes_parsed, 4);
           bytes_parsed += 4;
           if (my_bo != that_bo) vlen = SWAP32 (vlen);
-          if (is_xft)
+          if (want_this)
             {
               to_cpy = vlen > 127 ? 127 : vlen;
               memcpy (sval, prop+bytes_parsed, to_cpy);
@@ -303,7 +308,7 @@
           return BadValue;
         }
 
-      if (is_xft) 
+      if (want_this) 
         {
           ++settings_seen;
           if (strcmp (name, "Xft/Antialias") == 0)
@@ -361,6 +366,11 @@
               else
                 settings->seen &= ~SEEN_LCDFILTER;
             }
+          else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
+            {
+              free (current_font);
+              current_font = xstrdup (sval);
+            }
         }
     }
 
@@ -571,6 +581,12 @@
       current_mono_font = xstrdup (s);
       g_free (s);
     }
+  s = gconf_client_get_string (gconf_client, SYSTEM_FONT, NULL);
+  if (s)
+    {
+      current_font = xstrdup (s);
+      g_free (s);
+    }
   gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
   gconf_client_add_dir (gconf_client,
                         SYSTEM_MONO_FONT,
@@ -635,6 +651,23 @@
   return current_mono_font;
 }
 
+const char *
+xsettings_get_system_normal_font ()
+{
+  return current_font;
+}
+
+DEFUN ("font-get-system-normal-font", Ffont_get_system_normal_font,
+       Sfont_get_system_normal_font,
+       0, 0, 0,
+       doc: /* Get the system default font. */)
+  ()
+{
+  return current_font && use_system_font
+    ? make_string (current_font, strlen (current_font))
+    : Qnil;
+}
+
 DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font,
        0, 0, 0,
        doc: /* Get the system default monospaced font. */)
@@ -649,6 +682,7 @@
 syms_of_xsettings ()
 {
   current_mono_font = NULL;
+  current_font = NULL;
   first_dpyinfo = NULL;
 #ifdef HAVE_GCONF
   gconf_client = NULL;
@@ -659,6 +693,7 @@
   Qfont_render = intern_c_string ("font-render");
   staticpro (&Qfont_render);
   defsubr (&Sfont_get_system_font);
+  defsubr (&Sfont_get_system_normal_font);
 
   DEFVAR_BOOL ("font-use-system-font", &use_system_font,
     doc: /* *Non-nil means to use the system defined font.  */);
--- a/src/xsettings.h	Wed Apr 07 21:55:20 2010 +0000
+++ b/src/xsettings.h	Mon Apr 12 01:03:06 2010 +0000
@@ -21,10 +21,13 @@
 #define XSETTINGS_H
 
 EXFUN (Ffont_get_system_font, 0);
+EXFUN (Ffont_get_system_normal_font, 0);
+
 extern void xsettings_initialize P_ ((struct x_display_info *dpyinfo));
 extern void xft_settings_event P_ ((struct x_display_info *dpyinfo,
                                     XEvent *));
 extern const char *xsettings_get_system_font P_ ((void));
+extern const char *xsettings_get_system_normal_font P_ ((void));
 
 
 #endif /* XSETTINGS_H */