]> code.delx.au - gnu-emacs/commitdiff
Merge from emacs--devo--0
authorMiles Bader <miles@gnu.org>
Wed, 29 Aug 2007 05:03:40 +0000 (05:03 +0000)
committerMiles Bader <miles@gnu.org>
Wed, 29 Aug 2007 05:03:40 +0000 (05:03 +0000)
Patches applied:

 * emacs--devo--0  (patch 857-865)

   - Update from CVS
   - Merge from emacs--rel--22
   - Update from CVS: lisp/emacs-lisp/avl-tree.el: New file.
   - Remove RCS keywords

 * emacs--rel--22  (patch 97-100)

   - Update from CVS
   - Merge from gnus--rel--5.10

 * gnus--rel--5.10  (patch 246-247)

   - Update from CVS

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-252

28 files changed:
1  2 
configure
configure.in
etc/PROBLEMS
lisp/emacs-lisp/byte-opt.el
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/cl-loaddefs.el
lisp/eshell/esh-opt.el
lisp/format.el
lisp/gnus/mml.el
lisp/info.el
lisp/loadup.el
lisp/mail/rmail.el
lisp/play/gamegrid.el
lisp/progmodes/perl-mode.el
lisp/simple.el
lisp/startup.el
lisp/term/mac-win.el
lisp/term/x-win.el
make-dist
src/ChangeLog
src/Makefile.in
src/config.in
src/dispextern.h
src/fileio.c
src/keyboard.c
src/lread.c
src/macterm.c
src/xdisp.c

diff --combined configure
index 622af8f87b8290bef6f151b955e3d62945ad977a,24f3a5cc6778517e37edeb439d7e546a42f38ba9..c8382e4bf2c52b307a5ad0a61193213e685818e9
+++ b/configure
@@@ -412,10 -412,10 +412,10 @@@ els
  fi
  
  test \$exitcode = 0") || {
 -  echo Please tell bug-autoconf@gnu.org about your system,
 -  echo including any error possibly output before this message.
 -  echo This can help us improve future autoconf versions.
 -  echo Configuration will now proceed without shell functions.
 +  echo No shell found that supports shell functions.
 +  echo Please tell autoconf@gnu.org about your system,
 +  echo including any error possibly output before this
 +  echo message
  }
  
  
@@@ -679,6 -679,6 +679,7 @@@ INSTALL_DAT
  RANLIB
  INSTALL_INFO
  GZIP_PROG
++MAKEINFO
  LIBSOUND
  PKG_CONFIG
  ALSA_CFLAGS
@@@ -687,17 -687,12 +688,19 @@@ CFLAGS_SOUN
  SET_MAKE
  XMKMF
  HAVE_XSERVER
+ RSVG_CFLAGS
+ RSVG_LIBS
  GTK_CFLAGS
  GTK_LIBS
  XFT_CFLAGS
  XFT_LIBS
 +FREETYPE_CFLAGS
 +FREETYPE_LIBS
 +FONTCONFIG_CFLAGS
 +FONTCONFIG_LIBS
 +HAVE_LIBOTF
 +LIBOTF_CFLAGS
 +LIBOTF_LIBS
  ALLOCA
  liblockfile
  LIBOBJS
@@@ -1323,7 -1318,6 +1326,7 @@@ Optional Features
    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
    --enable-carbon-app[=DIR]  [DIR=/Application]
                            specify install directory for Emacs.app on Mac OS X
 +  --enable-font-backend   compile code of font-backend support
    --enable-asserts        compile code with asserts enabled
    --enable-maintainer-mode enable make rules and dependencies not useful
                            (and sometimes confusing) to the casual installer
@@@ -1348,11 -1342,10 +1351,12 @@@ Optional Packages
    --with-tiff             use -ltiff for displaying TIFF images
    --with-gif              use -lgif (or -lungif) for displaying GIF images
    --with-png              use -lpng for displaying PNG images
 +  --with-freetype         use -lfreetype for local fonts support
 +  --with-xft              use -lXft for anti aliased fonts
    --with-gpm              use -lgpm for mouse support on a GNU/Linux console
+   --with-rsvg             use -lrsvg-2 for displaying SVG images
    --with-gtk              use GTK (same as --with-x-toolkit=gtk)
-   --with-pkg-config-prog  Path to pkg-config to use for finding GTK
+   --with-pkg-config-prog  Path to pkg-config to use for finding GTK and librsvg
    --without-toolkit-scroll-bars
                            don't use Motif or Xaw3d scroll bars
    --without-xim           don't use X11 XIM
@@@ -1953,24 -1946,18 +1957,30 @@@ if test "${with_png+set}" = set; the
  fi
  
  
 +# Check whether --with-freetype was given.
 +if test "${with_freetype+set}" = set; then
 +  withval=$with_freetype;
 +fi
 +
 +
 +# Check whether --with-xft was given.
 +if test "${with_xft+set}" = set; then
 +  withval=$with_xft;
 +fi
 +
 +
  # Check whether --with-gpm was given.
  if test "${with_gpm+set}" = set; then
    withval=$with_gpm;
  fi
  
  
+ # Check whether --with-rsvg was given.
+ if test "${with_rsvg+set}" = set; then
+   withval=$with_rsvg;
+ fi
  # Check whether --with-gtk was given.
  if test "${with_gtk+set}" = set; then
    withval=$with_gtk;
@@@ -2006,14 -1993,6 +2016,14 @@@ if test "${enable_carbon_app+set}" = se
  fi
  
  
 +# Check whether --enable-font-backend was given.
 +if test "${enable_font_backend+set}" = set; then
 +  enableval=$enable_font_backend; USE_FONT_BACKEND=$enableval
 +else
 +  USE_FONT_BACKEND=no
 +fi
 +
 +
  # Check whether --enable-asserts was given.
  if test "${enable_asserts+set}" = set; then
    enableval=$enable_asserts; USE_XASSERTS=$enableval
  
  
  
++## Need makeinfo >= 4.6 (?) to build the manuals.
++# Extract the first word of "makeinfo", so it can be a program name with args.
++set dummy makeinfo; ac_word=$2
++{ echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
++if test "${ac_cv_path_MAKEINFO+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  case $MAKEINFO in
++  [\\/]* | ?:[\\/]*)
++  ac_cv_path_MAKEINFO="$MAKEINFO" # Let the user override the test with a path.
++  ;;
++  *)
++  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++  for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_path_MAKEINFO="$as_dir/$ac_word$ac_exec_ext"
++    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++done
++IFS=$as_save_IFS
++
++  test -z "$ac_cv_path_MAKEINFO" && ac_cv_path_MAKEINFO="no"
++  ;;
++esac
++fi
++MAKEINFO=$ac_cv_path_MAKEINFO
++if test -n "$MAKEINFO"; then
++  { echo "$as_me:$LINENO: result: $MAKEINFO" >&5
++echo "${ECHO_T}$MAKEINFO" >&6; }
++else
++  { echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6; }
++fi
++
++
++if test "$MAKEINFO" != "no" && \
++  test x"`$MAKEINFO --version 2> /dev/null | $EGREP 'texinfo[^0-9]*([5-9]|4\.[6-9])'`" = x; then
++   MAKEINFO=no
++fi
++
++if test "$MAKEINFO" = "no"; then
++  { { echo "$as_me:$LINENO: error: makeinfo >= 4.6 is required " >&5
++echo "$as_me: error: makeinfo >= 4.6 is required " >&2;}
++   { (exit 1); exit 1; }; }
++fi
++
++
++
  if test x$GCC = xyes && test "x$GCC_LINK_TEST_OPTIONS" != x
  then
    ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
@@@ -11098,6 -11077,130 +11163,130 @@@ echo "${ECHO_T}before 5" >&6; 
    fi
  fi
  
+ ### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
+ HAVE_RSVG=no
+ if test "${HAVE_X11}" = "yes" || test "${HAVE_CARBON}" = "yes"; then
+   if test "${with_rsvg}" != "no"; then
+         if test "X${with_pkg_config_prog}" != X; then
+       PKG_CONFIG="${with_pkg_config_prog}"
+     fi
+     RSVG_REQUIRED=2.0.0
+     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
+   succeeded=no
+   if test -z "$PKG_CONFIG"; then
+     # Extract the first word of "pkg-config", so it can be a program name with args.
+ set dummy pkg-config; ac_word=$2
+ { echo "$as_me:$LINENO: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+ if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   case $PKG_CONFIG in
+   [\\/]* | ?:[\\/]*)
+   ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+   ;;
+   *)
+   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+ for as_dir in $PATH
+ do
+   IFS=$as_save_IFS
+   test -z "$as_dir" && as_dir=.
+   for ac_exec_ext in '' $ac_executable_extensions; do
+   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+     ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+     break 2
+   fi
+ done
+ done
+ IFS=$as_save_IFS
+   test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+   ;;
+ esac
+ fi
+ PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+ if test -n "$PKG_CONFIG"; then
+   { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+ echo "${ECHO_T}$PKG_CONFIG" >&6; }
+ else
+   { echo "$as_me:$LINENO: result: no" >&5
+ echo "${ECHO_T}no" >&6; }
+ fi
+   fi
+   if test "$PKG_CONFIG" = "no" ; then
+      :
+   else
+      PKG_CONFIG_MIN_VERSION=0.9.0
+      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+         { echo "$as_me:$LINENO: checking for $RSVG_MODULE" >&5
+ echo $ECHO_N "checking for $RSVG_MODULE... $ECHO_C" >&6; }
+         if $PKG_CONFIG --exists "$RSVG_MODULE" 2>&5; then
+             { echo "$as_me:$LINENO: result: yes" >&5
+ echo "${ECHO_T}yes" >&6; }
+             succeeded=yes
+             { echo "$as_me:$LINENO: checking RSVG_CFLAGS" >&5
+ echo $ECHO_N "checking RSVG_CFLAGS... $ECHO_C" >&6; }
+             RSVG_CFLAGS=`$PKG_CONFIG --cflags "$RSVG_MODULE"|sed -e 's,///*,/,g'`
+             { echo "$as_me:$LINENO: result: $RSVG_CFLAGS" >&5
+ echo "${ECHO_T}$RSVG_CFLAGS" >&6; }
+             { echo "$as_me:$LINENO: checking RSVG_LIBS" >&5
+ echo $ECHO_N "checking RSVG_LIBS... $ECHO_C" >&6; }
+             RSVG_LIBS=`$PKG_CONFIG --libs "$RSVG_MODULE"|sed -e 's,///*,/,g'`
+             { echo "$as_me:$LINENO: result: $RSVG_LIBS" >&5
+ echo "${ECHO_T}$RSVG_LIBS" >&6; }
+         else
+             { echo "$as_me:$LINENO: result: no" >&5
+ echo "${ECHO_T}no" >&6; }
+             RSVG_CFLAGS=""
+             RSVG_LIBS=""
+             ## If we have a custom action on failure, don't print errors, but
+             ## do set a variable so people can do so.
+             RSVG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$RSVG_MODULE"`
+         fi
+      else
+         echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+         echo "*** See http://www.freedesktop.org/software/pkgconfig"
+      fi
+   fi
+   if test $succeeded = yes; then
+      :
+   else
+      :
+   fi
+     if test ".${RSVG_CFLAGS}" != "."; then
+       HAVE_RSVG=yes
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_RSVG 1
+ _ACEOF
+       CFLAGS="$CFLAGS $RSVG_CFLAGS"
+       LIBS="$RSVG_LIBS $LIBS"
+     fi
+   fi
+ fi
  HAVE_GTK=no
  if test "${with_gtk}" = "yes" && test "$USE_X_TOOLKIT" = "gtk"; then
    USE_X_TOOLKIT=none
    fi
  fi
  
 -### Link with -lXft if available to work around a bug.
 -HAVE_XFT=maybe
 -if test "${HAVE_GTK}" = "yes"; then
 -    if test "X${with_pkg_config_prog}" != X; then
 -    PKG_CONFIG="${with_pkg_config_prog}"
 -  fi
 -
 -
 -  succeeded=no
 -
 -  if test -z "$PKG_CONFIG"; then
 -    # Extract the first word of "pkg-config", so it can be a program name with args.
 -set dummy pkg-config; ac_word=$2
 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5
 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 -else
 -  case $PKG_CONFIG in
 -  [\\/]* | ?:[\\/]*)
 -  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
 -  ;;
 -  *)
 -  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 -for as_dir in $PATH
 -do
 -  IFS=$as_save_IFS
 -  test -z "$as_dir" && as_dir=.
 -  for ac_exec_ext in '' $ac_executable_extensions; do
 -  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 -    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
 -    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
 -    break 2
 -  fi
 -done
 -done
 -IFS=$as_save_IFS
 -
 -  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
 -  ;;
 -esac
 -fi
 -PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 -if test -n "$PKG_CONFIG"; then
 -  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
 -echo "${ECHO_T}$PKG_CONFIG" >&6; }
 -else
 -  { echo "$as_me:$LINENO: result: no" >&5
 -echo "${ECHO_T}no" >&6; }
 -fi
 -
 -
 -  fi
 -
 -  if test "$PKG_CONFIG" = "no" ; then
 -     HAVE_XFT=no
 -  else
 -     PKG_CONFIG_MIN_VERSION=0.9.0
 -     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
 -        { echo "$as_me:$LINENO: checking for xft >= 0.13.0" >&5
 -echo $ECHO_N "checking for xft >= 0.13.0... $ECHO_C" >&6; }
 -
 -        if $PKG_CONFIG --exists "xft >= 0.13.0" 2>&5; then
 -            { echo "$as_me:$LINENO: result: yes" >&5
 -echo "${ECHO_T}yes" >&6; }
 -            succeeded=yes
 -
 -            { echo "$as_me:$LINENO: checking XFT_CFLAGS" >&5
 -echo $ECHO_N "checking XFT_CFLAGS... $ECHO_C" >&6; }
 -            XFT_CFLAGS=`$PKG_CONFIG --cflags "xft >= 0.13.0"|sed -e 's,///*,/,g'`
 -            { echo "$as_me:$LINENO: result: $XFT_CFLAGS" >&5
 -echo "${ECHO_T}$XFT_CFLAGS" >&6; }
 -
 -            { echo "$as_me:$LINENO: checking XFT_LIBS" >&5
 -echo $ECHO_N "checking XFT_LIBS... $ECHO_C" >&6; }
 -            XFT_LIBS=`$PKG_CONFIG --libs "xft >= 0.13.0"|sed -e 's,///*,/,g'`
 -            { echo "$as_me:$LINENO: result: $XFT_LIBS" >&5
 -echo "${ECHO_T}$XFT_LIBS" >&6; }
 -        else
 -            { echo "$as_me:$LINENO: result: no" >&5
 -echo "${ECHO_T}no" >&6; }
 -            XFT_CFLAGS=""
 -            XFT_LIBS=""
 -            ## If we have a custom action on failure, don't print errors, but
 -            ## do set a variable so people can do so.
 -            XFT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xft >= 0.13.0"`
 -
 -        fi
 -
 -
 -
 -     else
 -        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
 -        echo "*** See http://www.freedesktop.org/software/pkgconfig"
 -     fi
 -  fi
 -
 -  if test $succeeded = yes; then
 -     :
 +HAVE_XAW3D=no
 +if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
 +  if test x"${HAVE_X11R5}" != xyes; then
 +    USE_X_TOOLKIT=none
    else
 -     HAVE_XFT=no
 -  fi
 -
 -  if test "$HAVE_XFT" != no; then
 -    OLD_CFLAGS="$CPPFLAGS"
 -    OLD_CPPFLAGS="$CFLAGS"
 -    OLD_LIBS="$LIBS"
 -    CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
 -    CFLAGS="$CFLAGS $XFT_CFLAGS"
 -    LIBS="$XFT_LIBS $LIBS"
 -    if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 -  { echo "$as_me:$LINENO: checking for X11/Xft/Xft.h" >&5
 -echo $ECHO_N "checking for X11/Xft/Xft.h... $ECHO_C" >&6; }
 -if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 +    { echo "$as_me:$LINENO: checking for xaw3d" >&5
 +echo $ECHO_N "checking for xaw3d... $ECHO_C" >&6; }
 +    if test "${emacs_cv_xaw3d+set}" = set; then
    echo $ECHO_N "(cached) $ECHO_C" >&6
 -fi
 -{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xft_Xft_h" >&5
 -echo "${ECHO_T}$ac_cv_header_X11_Xft_Xft_h" >&6; }
  else
 -  # Is the header compilable?
 -{ echo "$as_me:$LINENO: checking X11/Xft/Xft.h usability" >&5
 -echo $ECHO_N "checking X11/Xft/Xft.h usability... $ECHO_C" >&6; }
 -cat >conftest.$ac_ext <<_ACEOF
 +  cat >conftest.$ac_ext <<_ACEOF
  /* confdefs.h.  */
  _ACEOF
  cat confdefs.h >>conftest.$ac_ext
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
 -$ac_includes_default
 -#include <X11/Xft/Xft.h>
 +
 +#include <X11/Intrinsic.h>
 +#include <X11/Xaw3d/Simple.h>
 +int
 +main ()
 +{
 +
 +  ;
 +  return 0;
 +}
  _ACEOF
 -rm -f conftest.$ac_objext
 -if { (ac_try="$ac_compile"
 +rm -f conftest.$ac_objext conftest$ac_exeext
 +if { (ac_try="$ac_link"
  case "(($ac_try" in
    *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    *) ac_try_echo=$ac_try;;
  esac
  eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_compile") 2>conftest.er1
 +  (eval "$ac_link") 2>conftest.er1
    ac_status=$?
    grep -v '^ *+' conftest.er1 >conftest.err
    rm -f conftest.er1
    (exit $ac_status); } && {
         test -z "$ac_c_werror_flag" ||
         test ! -s conftest.err
 -       } && test -s conftest.$ac_objext; then
 -  ac_header_compiler=yes
 +       } && test -s conftest$ac_exeext &&
 +       $as_test_x conftest$ac_exeext; then
 +  emacs_cv_xaw3d=yes
  else
    echo "$as_me: failed program was:" >&5
  sed 's/^/| /' conftest.$ac_ext >&5
  
 -      ac_header_compiler=no
 +      emacs_cv_xaw3d=no
  fi
  
 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
 -echo "${ECHO_T}$ac_header_compiler" >&6; }
 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 +      conftest$ac_exeext conftest.$ac_ext
 +fi
  
 -# Is the header present?
 -{ echo "$as_me:$LINENO: checking X11/Xft/Xft.h presence" >&5
 -echo $ECHO_N "checking X11/Xft/Xft.h presence... $ECHO_C" >&6; }
 -cat >conftest.$ac_ext <<_ACEOF
 +    if test $emacs_cv_xaw3d = yes; then
 +      { echo "$as_me:$LINENO: result: yes; using Lucid toolkit" >&5
 +echo "${ECHO_T}yes; using Lucid toolkit" >&6; }
 +      USE_X_TOOLKIT=LUCID
 +      HAVE_XAW3D=yes
 +
 +cat >>confdefs.h <<\_ACEOF
 +#define HAVE_XAW3D 1
 +_ACEOF
 +
 +    else
 +      { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +      { echo "$as_me:$LINENO: checking for libXaw" >&5
 +echo $ECHO_N "checking for libXaw... $ECHO_C" >&6; }
 +      if test "${emacs_cv_xaw+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  cat >conftest.$ac_ext <<_ACEOF
  /* confdefs.h.  */
  _ACEOF
  cat confdefs.h >>conftest.$ac_ext
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
 -#include <X11/Xft/Xft.h>
 +
 +#include <X11/Intrinsic.h>
 +#include <X11/Xaw/Simple.h>
 +int
 +main ()
 +{
 +
 +  ;
 +  return 0;
 +}
  _ACEOF
 -if { (ac_try="$ac_cpp conftest.$ac_ext"
 +rm -f conftest.$ac_objext conftest$ac_exeext
 +if { (ac_try="$ac_link"
  case "(($ac_try" in
    *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    *) ac_try_echo=$ac_try;;
  esac
  eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
 +  (eval "$ac_link") 2>conftest.er1
    ac_status=$?
    grep -v '^ *+' conftest.er1 >conftest.err
    rm -f conftest.er1
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } >/dev/null && {
 -       test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
         test ! -s conftest.err
 -       }; then
 -  ac_header_preproc=yes
 +       } && test -s conftest$ac_exeext &&
 +       $as_test_x conftest$ac_exeext; then
 +  emacs_cv_xaw=yes
  else
    echo "$as_me: failed program was:" >&5
  sed 's/^/| /' conftest.$ac_ext >&5
  
 -  ac_header_preproc=no
 +      emacs_cv_xaw=no
  fi
  
 -rm -f conftest.err conftest.$ac_ext
 -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
 -echo "${ECHO_T}$ac_header_preproc" >&6; }
 -
 -# So?  What about this header?
 -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
 -  yes:no: )
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: accepted by the compiler, rejected by the preprocessor!" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: proceeding with the compiler's result" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: proceeding with the compiler's result" >&2;}
 -    ac_header_preproc=yes
 -    ;;
 -  no:yes:* )
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: present but cannot be compiled" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: present but cannot be compiled" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h:     check for missing prerequisite headers?" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h:     check for missing prerequisite headers?" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: see the Autoconf documentation" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: see the Autoconf documentation" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h:     section \"Present But Cannot Be Compiled\"" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h:     section \"Present But Cannot Be Compiled\"" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: proceeding with the preprocessor's result" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: proceeding with the preprocessor's result" >&2;}
 -    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: in the future, the compiler will take precedence" >&5
 -echo "$as_me: WARNING: X11/Xft/Xft.h: in the future, the compiler will take precedence" >&2;}
 -
 -    ;;
 -esac
 -{ echo "$as_me:$LINENO: checking for X11/Xft/Xft.h" >&5
 -echo $ECHO_N "checking for X11/Xft/Xft.h... $ECHO_C" >&6; }
 -if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 -else
 -  ac_cv_header_X11_Xft_Xft_h=$ac_header_preproc
 -fi
 -{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xft_Xft_h" >&5
 -echo "${ECHO_T}$ac_cv_header_X11_Xft_Xft_h" >&6; }
 -
 -fi
 -if test $ac_cv_header_X11_Xft_Xft_h = yes; then
 -  { echo "$as_me:$LINENO: checking for XftFontOpen in -lXft" >&5
 -echo $ECHO_N "checking for XftFontOpen in -lXft... $ECHO_C" >&6; }
 -if test "${ac_cv_lib_Xft_XftFontOpen+set}" = set; then
 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 -else
 -  ac_check_lib_save_LIBS=$LIBS
 -LIBS="-lXft $XFT_LIBS $LIBS"
 -cat >conftest.$ac_ext <<_ACEOF
 -/* confdefs.h.  */
 -_ACEOF
 -cat confdefs.h >>conftest.$ac_ext
 -cat >>conftest.$ac_ext <<_ACEOF
 -/* end confdefs.h.  */
 -
 -/* Override any GCC internal prototype to avoid an error.
 -   Use char because int might match the return type of a GCC
 -   builtin and then its argument prototype would still apply.  */
 -#ifdef __cplusplus
 -extern "C"
 -#endif
 -char XftFontOpen ();
 -int
 -main ()
 -{
 -return XftFontOpen ();
 -  ;
 -  return 0;
 -}
 -_ACEOF
 -rm -f conftest.$ac_objext conftest$ac_exeext
 -if { (ac_try="$ac_link"
 -case "(($ac_try" in
 -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 -  *) ac_try_echo=$ac_try;;
 -esac
 -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_link") 2>conftest.er1
 -  ac_status=$?
 -  grep -v '^ *+' conftest.er1 >conftest.err
 -  rm -f conftest.er1
 -  cat conftest.err >&5
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } && {
 -       test -z "$ac_c_werror_flag" ||
 -       test ! -s conftest.err
 -       } && test -s conftest$ac_exeext &&
 -       $as_test_x conftest$ac_exeext; then
 -  ac_cv_lib_Xft_XftFontOpen=yes
 -else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
 -
 -      ac_cv_lib_Xft_XftFontOpen=no
 -fi
 -
 -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 -      conftest$ac_exeext conftest.$ac_ext
 -LIBS=$ac_check_lib_save_LIBS
 -fi
 -{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xft_XftFontOpen" >&5
 -echo "${ECHO_T}$ac_cv_lib_Xft_XftFontOpen" >&6; }
 -if test $ac_cv_lib_Xft_XftFontOpen = yes; then
 -  HAVE_XFT=yes
 -fi
 -
 -fi
 -
 -
 -
 -    if test "${HAVE_XFT}" = "yes"; then
 -
 -cat >>confdefs.h <<\_ACEOF
 -#define HAVE_XFT 1
 -_ACEOF
 -
 -
 -      C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
 -    else
 -      CFLAGS="$OLD_CPPFLAGS"
 -      CFLAGS="$OLD_CFLAGS"
 -      LIBS="$OLD_LIBS"
 -    fi
 -  fi
 -fi
 -
 -HAVE_XAW3D=no
 -if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
 -  if test x"${HAVE_X11R5}" != xyes; then
 -    USE_X_TOOLKIT=none
 -  else
 -    { echo "$as_me:$LINENO: checking for xaw3d" >&5
 -echo $ECHO_N "checking for xaw3d... $ECHO_C" >&6; }
 -    if test "${emacs_cv_xaw3d+set}" = set; then
 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 -else
 -  cat >conftest.$ac_ext <<_ACEOF
 -/* confdefs.h.  */
 -_ACEOF
 -cat confdefs.h >>conftest.$ac_ext
 -cat >>conftest.$ac_ext <<_ACEOF
 -/* end confdefs.h.  */
 -
 -#include <X11/Intrinsic.h>
 -#include <X11/Xaw3d/Simple.h>
 -int
 -main ()
 -{
 -
 -  ;
 -  return 0;
 -}
 -_ACEOF
 -rm -f conftest.$ac_objext conftest$ac_exeext
 -if { (ac_try="$ac_link"
 -case "(($ac_try" in
 -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 -  *) ac_try_echo=$ac_try;;
 -esac
 -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_link") 2>conftest.er1
 -  ac_status=$?
 -  grep -v '^ *+' conftest.er1 >conftest.err
 -  rm -f conftest.er1
 -  cat conftest.err >&5
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } && {
 -       test -z "$ac_c_werror_flag" ||
 -       test ! -s conftest.err
 -       } && test -s conftest$ac_exeext &&
 -       $as_test_x conftest$ac_exeext; then
 -  emacs_cv_xaw3d=yes
 -else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
 -
 -      emacs_cv_xaw3d=no
 -fi
 -
 -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 -      conftest$ac_exeext conftest.$ac_ext
 -fi
 -
 -    if test $emacs_cv_xaw3d = yes; then
 -      { echo "$as_me:$LINENO: result: yes; using Lucid toolkit" >&5
 -echo "${ECHO_T}yes; using Lucid toolkit" >&6; }
 -      USE_X_TOOLKIT=LUCID
 -      HAVE_XAW3D=yes
 -
 -cat >>confdefs.h <<\_ACEOF
 -#define HAVE_XAW3D 1
 -_ACEOF
 -
 -    else
 -      { echo "$as_me:$LINENO: result: no" >&5
 -echo "${ECHO_T}no" >&6; }
 -      { echo "$as_me:$LINENO: checking for libXaw" >&5
 -echo $ECHO_N "checking for libXaw... $ECHO_C" >&6; }
 -      if test "${emacs_cv_xaw+set}" = set; then
 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 -else
 -  cat >conftest.$ac_ext <<_ACEOF
 -/* confdefs.h.  */
 -_ACEOF
 -cat confdefs.h >>conftest.$ac_ext
 -cat >>conftest.$ac_ext <<_ACEOF
 -/* end confdefs.h.  */
 -
 -#include <X11/Intrinsic.h>
 -#include <X11/Xaw/Simple.h>
 -int
 -main ()
 -{
 -
 -  ;
 -  return 0;
 -}
 -_ACEOF
 -rm -f conftest.$ac_objext conftest$ac_exeext
 -if { (ac_try="$ac_link"
 -case "(($ac_try" in
 -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 -  *) ac_try_echo=$ac_try;;
 -esac
 -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_link") 2>conftest.er1
 -  ac_status=$?
 -  grep -v '^ *+' conftest.er1 >conftest.err
 -  rm -f conftest.er1
 -  cat conftest.err >&5
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } && {
 -       test -z "$ac_c_werror_flag" ||
 -       test ! -s conftest.err
 -       } && test -s conftest$ac_exeext &&
 -       $as_test_x conftest$ac_exeext; then
 -  emacs_cv_xaw=yes
 -else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
 -
 -      emacs_cv_xaw=no
 -fi
 -
 -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 -      conftest$ac_exeext conftest.$ac_ext
 -fi
 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 +      conftest$ac_exeext conftest.$ac_ext
 +fi
  
        if test $emacs_cv_xaw = yes; then
          { echo "$as_me:$LINENO: result: yes; using Lucid toolkit" >&5
@@@ -12404,809 -12828,78 +12593,809 @@@ case "(($ac_try" i
    *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    *) ac_try_echo=$ac_try;;
  esac
 -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_compile") 2>conftest.er1
 -  ac_status=$?
 -  grep -v '^ *+' conftest.er1 >conftest.err
 -  rm -f conftest.er1
 -  cat conftest.err >&5
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } && {
 -       test -z "$ac_c_werror_flag" ||
 -       test ! -s conftest.err
 -       } && test -s conftest.$ac_objext; then
 -  emacs_cv_lesstif=yes
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  emacs_cv_lesstif=yes
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      emacs_cv_lesstif=no
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +fi
 +{ echo "$as_me:$LINENO: result: $emacs_cv_lesstif" >&5
 +echo "${ECHO_T}$emacs_cv_lesstif" >&6; }
 +    if test $emacs_cv_lesstif = yes; then
 +      # Make sure this -I option remains in CPPFLAGS after it is set
 +      # back to REAL_CPPFLAGS.
 +      # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
 +      # have those other -I options anyway.  Ultimately, having this
 +      # directory ultimately in CPPFLAGS will be enough.
 +      REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
 +      LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
 +    else
 +      CFLAGS=$OLD_CFLAGS
 +      CPPFLAGS=$OLD_CPPFLAGS
 +    fi
 +  fi
 +fi
 +
 +
 +
 +USE_TOOLKIT_SCROLL_BARS=no
 +if test "${with_toolkit_scroll_bars}" != "no"; then
 +  if test "${USE_X_TOOLKIT}" != "none"; then
 +    if test "${USE_X_TOOLKIT}" = "MOTIF"; then
 +      cat >>confdefs.h <<\_ACEOF
 +#define USE_TOOLKIT_SCROLL_BARS 1
 +_ACEOF
 +
 +      HAVE_XAW3D=no
 +      USE_TOOLKIT_SCROLL_BARS=yes
 +    elif test "${HAVE_XAW3D}" = "yes"; then
 +      cat >>confdefs.h <<\_ACEOF
 +#define USE_TOOLKIT_SCROLL_BARS 1
 +_ACEOF
 +
 +      USE_TOOLKIT_SCROLL_BARS=yes
 +    fi
 +  elif test "${HAVE_GTK}" = "yes"; then
 +    cat >>confdefs.h <<\_ACEOF
 +#define USE_TOOLKIT_SCROLL_BARS 1
 +_ACEOF
 +
 +    USE_TOOLKIT_SCROLL_BARS=yes
 +  elif test "${HAVE_CARBON}" = "yes"; then
 +    cat >>confdefs.h <<\_ACEOF
 +#define USE_TOOLKIT_SCROLL_BARS 1
 +_ACEOF
 +
 +    USE_TOOLKIT_SCROLL_BARS=yes
 +  fi
 +fi
 +
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +
 +        #include <X11/Xlib.h>
 +        #include <X11/Xresource.h>
 +int
 +main ()
 +{
 +XIMProc  callback;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  HAVE_XIM=yes
 +
 +cat >>confdefs.h <<\_ACEOF
 +#define HAVE_XIM 1
 +_ACEOF
 +
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      HAVE_XIM=no
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +
 +
 +if test "${with_xim}" != "no"; then
 +
 +cat >>confdefs.h <<\_ACEOF
 +#define USE_XIM 1
 +_ACEOF
 +
 +fi
 +
 +
 +if test "${HAVE_XIM}" != "no"; then
 +  late_CFLAGS=$CFLAGS
 +  if test "$GCC" = yes; then
 +    CFLAGS="$CFLAGS --pedantic-errors"
 +  fi
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +
 +#include <X11/Xlib.h>
 +#include <X11/Xresource.h>
 +int
 +main ()
 +{
 +Display *display;
 +XrmDatabase db;
 +char *res_name;
 +char *res_class;
 +XIMProc  callback;
 +XPointer *client_data;
 +#ifndef __GNUC__
 +/* If we're not using GCC, it's probably not XFree86, and this is
 +   probably right, but we can't use something like --pedantic-errors.  */
 +extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
 +                                           char*, XIMProc, XPointer*);
 +#endif
 +(void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
 +   client_data);
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  emacs_cv_arg6_star=yes
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +
 +  if test "$emacs_cv_arg6_star" = yes; then
 +    cat >>confdefs.h <<\_ACEOF
 +#define XRegisterIMInstantiateCallback_arg6 XPointer*
 +_ACEOF
 +
 +  else
 +    cat >>confdefs.h <<\_ACEOF
 +#define XRegisterIMInstantiateCallback_arg6 XPointer
 +_ACEOF
 +
 +  fi
 +  CFLAGS=$late_CFLAGS
 +fi
 +
 +### For font-backend
 +if test "${USE_FONT_BACKEND}" = "yes"; then
 +
 +
 +cat >>confdefs.h <<\_ACEOF
 +#define USE_FONT_BACKEND 1
 +_ACEOF
 +
 +
 +### Use -lXft if available, unless `--with-freetype=no' nor `--with-xft=no'.
 +HAVE_XFT=maybe
 +if test "${HAVE_X11}" = "yes"; then
 +  if test "x${with_freetype}" = "xno"; then
 +    with_xft="no";
 +  fi
 +  if test "x${with_xft}" != "xno"; then
 +
 +        if test "X${with_pkg_config_prog}" != X; then
 +      PKG_CONFIG="${with_pkg_config_prog}"
 +    fi
 +
 +
 +  succeeded=no
 +
 +  if test -z "$PKG_CONFIG"; then
 +    # Extract the first word of "pkg-config", so it can be a program name with args.
 +set dummy pkg-config; ac_word=$2
 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5
 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  case $PKG_CONFIG in
 +  [\\/]* | ?:[\\/]*)
 +  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
 +  ;;
 +  *)
 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 +for as_dir in $PATH
 +do
 +  IFS=$as_save_IFS
 +  test -z "$as_dir" && as_dir=.
 +  for ac_exec_ext in '' $ac_executable_extensions; do
 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 +    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
 +    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
 +    break 2
 +  fi
 +done
 +done
 +IFS=$as_save_IFS
 +
 +  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
 +  ;;
 +esac
 +fi
 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 +if test -n "$PKG_CONFIG"; then
 +  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
 +echo "${ECHO_T}$PKG_CONFIG" >&6; }
 +else
 +  { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +fi
 +
 +
 +  fi
 +
 +  if test "$PKG_CONFIG" = "no" ; then
 +     HAVE_XFT=no
 +  else
 +     PKG_CONFIG_MIN_VERSION=0.9.0
 +     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
 +        { echo "$as_me:$LINENO: checking for xft >= 0.13.0" >&5
 +echo $ECHO_N "checking for xft >= 0.13.0... $ECHO_C" >&6; }
 +
 +        if $PKG_CONFIG --exists "xft >= 0.13.0" 2>&5; then
 +            { echo "$as_me:$LINENO: result: yes" >&5
 +echo "${ECHO_T}yes" >&6; }
 +            succeeded=yes
 +
 +            { echo "$as_me:$LINENO: checking XFT_CFLAGS" >&5
 +echo $ECHO_N "checking XFT_CFLAGS... $ECHO_C" >&6; }
 +            XFT_CFLAGS=`$PKG_CONFIG --cflags "xft >= 0.13.0"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $XFT_CFLAGS" >&5
 +echo "${ECHO_T}$XFT_CFLAGS" >&6; }
 +
 +            { echo "$as_me:$LINENO: checking XFT_LIBS" >&5
 +echo $ECHO_N "checking XFT_LIBS... $ECHO_C" >&6; }
 +            XFT_LIBS=`$PKG_CONFIG --libs "xft >= 0.13.0"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $XFT_LIBS" >&5
 +echo "${ECHO_T}$XFT_LIBS" >&6; }
 +        else
 +            { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +            XFT_CFLAGS=""
 +            XFT_LIBS=""
 +            ## If we have a custom action on failure, don't print errors, but
 +            ## do set a variable so people can do so.
 +            XFT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xft >= 0.13.0"`
 +
 +        fi
 +
 +
 +
 +     else
 +        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
 +        echo "*** See http://www.freedesktop.org/software/pkgconfig"
 +     fi
 +  fi
 +
 +  if test $succeeded = yes; then
 +     :
 +  else
 +     HAVE_XFT=no
 +  fi
 +
 +    if test "$HAVE_XFT" != no; then
 +      OLD_CPPFLAGS="$CPPFLAGS"
 +      OLD_CFLAGS="$CFLAGS"
 +      OLD_LIBS="$LIBS"
 +      CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
 +      CFLAGS="$CFLAGS $XFT_CFLAGS"
 +      LIBS="$XFT_LIBS $LIBS"
 +      if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 +  { echo "$as_me:$LINENO: checking for X11/Xft/Xft.h" >&5
 +echo $ECHO_N "checking for X11/Xft/Xft.h... $ECHO_C" >&6; }
 +if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +fi
 +{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xft_Xft_h" >&5
 +echo "${ECHO_T}$ac_cv_header_X11_Xft_Xft_h" >&6; }
 +else
 +  # Is the header compilable?
 +{ echo "$as_me:$LINENO: checking X11/Xft/Xft.h usability" >&5
 +echo $ECHO_N "checking X11/Xft/Xft.h usability... $ECHO_C" >&6; }
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +$ac_includes_default
 +#include <X11/Xft/Xft.h>
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  ac_header_compiler=yes
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      ac_header_compiler=no
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
 +echo "${ECHO_T}$ac_header_compiler" >&6; }
 +
 +# Is the header present?
 +{ echo "$as_me:$LINENO: checking X11/Xft/Xft.h presence" >&5
 +echo $ECHO_N "checking X11/Xft/Xft.h presence... $ECHO_C" >&6; }
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <X11/Xft/Xft.h>
 +_ACEOF
 +if { (ac_try="$ac_cpp conftest.$ac_ext"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } >/dev/null && {
 +       test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       }; then
 +  ac_header_preproc=yes
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +  ac_header_preproc=no
 +fi
 +
 +rm -f conftest.err conftest.$ac_ext
 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
 +echo "${ECHO_T}$ac_header_preproc" >&6; }
 +
 +# So?  What about this header?
 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
 +  yes:no: )
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: accepted by the compiler, rejected by the preprocessor!" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: proceeding with the compiler's result" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: proceeding with the compiler's result" >&2;}
 +    ac_header_preproc=yes
 +    ;;
 +  no:yes:* )
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: present but cannot be compiled" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: present but cannot be compiled" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h:     check for missing prerequisite headers?" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h:     check for missing prerequisite headers?" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: see the Autoconf documentation" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: see the Autoconf documentation" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h:     section \"Present But Cannot Be Compiled\"" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h:     section \"Present But Cannot Be Compiled\"" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: proceeding with the preprocessor's result" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: proceeding with the preprocessor's result" >&2;}
 +    { echo "$as_me:$LINENO: WARNING: X11/Xft/Xft.h: in the future, the compiler will take precedence" >&5
 +echo "$as_me: WARNING: X11/Xft/Xft.h: in the future, the compiler will take precedence" >&2;}
 +
 +    ;;
 +esac
 +{ echo "$as_me:$LINENO: checking for X11/Xft/Xft.h" >&5
 +echo $ECHO_N "checking for X11/Xft/Xft.h... $ECHO_C" >&6; }
 +if test "${ac_cv_header_X11_Xft_Xft_h+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  ac_cv_header_X11_Xft_Xft_h=$ac_header_preproc
 +fi
 +{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xft_Xft_h" >&5
 +echo "${ECHO_T}$ac_cv_header_X11_Xft_Xft_h" >&6; }
 +
 +fi
 +if test $ac_cv_header_X11_Xft_Xft_h = yes; then
 +  { echo "$as_me:$LINENO: checking for XftFontOpen in -lXft" >&5
 +echo $ECHO_N "checking for XftFontOpen in -lXft... $ECHO_C" >&6; }
 +if test "${ac_cv_lib_Xft_XftFontOpen+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  ac_check_lib_save_LIBS=$LIBS
 +LIBS="-lXft $XFT_LIBS $LIBS"
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +
 +/* Override any GCC internal prototype to avoid an error.
 +   Use char because int might match the return type of a GCC
 +   builtin and then its argument prototype would still apply.  */
 +#ifdef __cplusplus
 +extern "C"
 +#endif
 +char XftFontOpen ();
 +int
 +main ()
 +{
 +return XftFontOpen ();
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext conftest$ac_exeext
 +if { (ac_try="$ac_link"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 +  (eval "$ac_link") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest$ac_exeext &&
 +       $as_test_x conftest$ac_exeext; then
 +  ac_cv_lib_Xft_XftFontOpen=yes
 +else
 +  echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      ac_cv_lib_Xft_XftFontOpen=no
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 +      conftest$ac_exeext conftest.$ac_ext
 +LIBS=$ac_check_lib_save_LIBS
 +fi
 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xft_XftFontOpen" >&5
 +echo "${ECHO_T}$ac_cv_lib_Xft_XftFontOpen" >&6; }
 +if test $ac_cv_lib_Xft_XftFontOpen = yes; then
 +  HAVE_XFT=yes
 +fi
 +
 +fi
 +
 +
 +
 +      if test "${HAVE_XFT}" = "yes"; then
 +
 +cat >>confdefs.h <<\_ACEOF
 +#define HAVE_XFT 1
 +_ACEOF
 +
 +
 +        C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
 +      else
 +        CFLAGS="$OLD_CPPFLAGS"
 +        CFLAGS="$OLD_CFLAGS"
 +        LIBS="$OLD_LIBS"
 +      fi
 +    fi
 +  fi
 +fi
 +
 +HAVE_FREETYPE=no
 +### Use -lfreetype if available, unless `--with-freetype=no'.
 +if test "${HAVE_XFT}" = "yes"; then
 +      HAVE_FREETYPE=yes
 +elif test "x${with_freetype}" != "xno"; then
 +    if test "X${with_pkg_config_prog}" != X; then
 +    PKG_CONFIG="${with_pkg_config_prog}"
 +  fi
 +
 +
 +  succeeded=no
 +
 +  if test -z "$PKG_CONFIG"; then
 +    # Extract the first word of "pkg-config", so it can be a program name with args.
 +set dummy pkg-config; ac_word=$2
 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5
 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  case $PKG_CONFIG in
 +  [\\/]* | ?:[\\/]*)
 +  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
 +  ;;
 +  *)
 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 +for as_dir in $PATH
 +do
 +  IFS=$as_save_IFS
 +  test -z "$as_dir" && as_dir=.
 +  for ac_exec_ext in '' $ac_executable_extensions; do
 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 +    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
 +    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
 +    break 2
 +  fi
 +done
 +done
 +IFS=$as_save_IFS
 +
 +  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
 +  ;;
 +esac
 +fi
 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 +if test -n "$PKG_CONFIG"; then
 +  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
 +echo "${ECHO_T}$PKG_CONFIG" >&6; }
 +else
 +  { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +fi
 +
 +
 +  fi
 +
 +  if test "$PKG_CONFIG" = "no" ; then
 +     HAVE_FREETYPE=no
 +  else
 +     PKG_CONFIG_MIN_VERSION=0.9.0
 +     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
 +        { echo "$as_me:$LINENO: checking for freetype2" >&5
 +echo $ECHO_N "checking for freetype2... $ECHO_C" >&6; }
 +
 +        if $PKG_CONFIG --exists "freetype2" 2>&5; then
 +            { echo "$as_me:$LINENO: result: yes" >&5
 +echo "${ECHO_T}yes" >&6; }
 +            succeeded=yes
 +
 +            { echo "$as_me:$LINENO: checking FREETYPE_CFLAGS" >&5
 +echo $ECHO_N "checking FREETYPE_CFLAGS... $ECHO_C" >&6; }
 +            FREETYPE_CFLAGS=`$PKG_CONFIG --cflags "freetype2"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $FREETYPE_CFLAGS" >&5
 +echo "${ECHO_T}$FREETYPE_CFLAGS" >&6; }
 +
 +            { echo "$as_me:$LINENO: checking FREETYPE_LIBS" >&5
 +echo $ECHO_N "checking FREETYPE_LIBS... $ECHO_C" >&6; }
 +            FREETYPE_LIBS=`$PKG_CONFIG --libs "freetype2"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $FREETYPE_LIBS" >&5
 +echo "${ECHO_T}$FREETYPE_LIBS" >&6; }
 +        else
 +            { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +            FREETYPE_CFLAGS=""
 +            FREETYPE_LIBS=""
 +            ## If we have a custom action on failure, don't print errors, but
 +            ## do set a variable so people can do so.
 +            FREETYPE_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "freetype2"`
 +
 +        fi
 +
 +
 +
 +     else
 +        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
 +        echo "*** See http://www.freedesktop.org/software/pkgconfig"
 +     fi
 +  fi
 +
 +  if test $succeeded = yes; then
 +     HAVE_FREETYPE=yes
 +  else
 +     HAVE_FREETYPE=no
 +  fi
 +
 +  if test "${HAVE_FREETYPE}" = "yes"; then
 +
 +  succeeded=no
 +
 +  if test -z "$PKG_CONFIG"; then
 +    # Extract the first word of "pkg-config", so it can be a program name with args.
 +set dummy pkg-config; ac_word=$2
 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5
 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  case $PKG_CONFIG in
 +  [\\/]* | ?:[\\/]*)
 +  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
 +  ;;
 +  *)
 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 +for as_dir in $PATH
 +do
 +  IFS=$as_save_IFS
 +  test -z "$as_dir" && as_dir=.
 +  for ac_exec_ext in '' $ac_executable_extensions; do
 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 +    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
 +    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
 +    break 2
 +  fi
 +done
 +done
 +IFS=$as_save_IFS
 +
 +  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
 +  ;;
 +esac
 +fi
 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 +if test -n "$PKG_CONFIG"; then
 +  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
 +echo "${ECHO_T}$PKG_CONFIG" >&6; }
  else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
 -
 -      emacs_cv_lesstif=no
 +  { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
  fi
  
 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 -fi
 -{ echo "$as_me:$LINENO: result: $emacs_cv_lesstif" >&5
 -echo "${ECHO_T}$emacs_cv_lesstif" >&6; }
 -    if test $emacs_cv_lesstif = yes; then
 -      # Make sure this -I option remains in CPPFLAGS after it is set
 -      # back to REAL_CPPFLAGS.
 -      # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
 -      # have those other -I options anyway.  Ultimately, having this
 -      # directory ultimately in CPPFLAGS will be enough.
 -      REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
 -      LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
 -    else
 -      CFLAGS=$OLD_CFLAGS
 -      CPPFLAGS=$OLD_CPPFLAGS
 -    fi
 +
    fi
 -fi
  
 +  if test "$PKG_CONFIG" = "no" ; then
 +     HAVE_FC=no
 +  else
 +     PKG_CONFIG_MIN_VERSION=0.9.0
 +     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
 +        { echo "$as_me:$LINENO: checking for fontconfig" >&5
 +echo $ECHO_N "checking for fontconfig... $ECHO_C" >&6; }
  
 +        if $PKG_CONFIG --exists "fontconfig" 2>&5; then
 +            { echo "$as_me:$LINENO: result: yes" >&5
 +echo "${ECHO_T}yes" >&6; }
 +            succeeded=yes
  
 -USE_TOOLKIT_SCROLL_BARS=no
 -if test "${with_toolkit_scroll_bars}" != "no"; then
 -  if test "${USE_X_TOOLKIT}" != "none"; then
 -    if test "${USE_X_TOOLKIT}" = "MOTIF"; then
 -      cat >>confdefs.h <<\_ACEOF
 -#define USE_TOOLKIT_SCROLL_BARS 1
 -_ACEOF
 +            { echo "$as_me:$LINENO: checking FONTCONFIG_CFLAGS" >&5
 +echo $ECHO_N "checking FONTCONFIG_CFLAGS... $ECHO_C" >&6; }
 +            FONTCONFIG_CFLAGS=`$PKG_CONFIG --cflags "fontconfig"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $FONTCONFIG_CFLAGS" >&5
 +echo "${ECHO_T}$FONTCONFIG_CFLAGS" >&6; }
 +
 +            { echo "$as_me:$LINENO: checking FONTCONFIG_LIBS" >&5
 +echo $ECHO_N "checking FONTCONFIG_LIBS... $ECHO_C" >&6; }
 +            FONTCONFIG_LIBS=`$PKG_CONFIG --libs "fontconfig"|sed -e 's,///*,/,g'`
 +            { echo "$as_me:$LINENO: result: $FONTCONFIG_LIBS" >&5
 +echo "${ECHO_T}$FONTCONFIG_LIBS" >&6; }
 +        else
 +            { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
 +            FONTCONFIG_CFLAGS=""
 +            FONTCONFIG_LIBS=""
 +            ## If we have a custom action on failure, don't print errors, but
 +            ## do set a variable so people can do so.
 +            FONTCONFIG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "fontconfig"`
  
 -      HAVE_XAW3D=no
 -      USE_TOOLKIT_SCROLL_BARS=yes
 -    elif test "${HAVE_XAW3D}" = "yes"; then
 -      cat >>confdefs.h <<\_ACEOF
 -#define USE_TOOLKIT_SCROLL_BARS 1
 -_ACEOF
 +        fi
  
 -      USE_TOOLKIT_SCROLL_BARS=yes
 +
 +
 +     else
 +        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
 +        echo "*** See http://www.freedesktop.org/software/pkgconfig"
 +     fi
 +  fi
 +
 +  if test $succeeded = yes; then
 +     HAVE_FC=yes
 +  else
 +     HAVE_FC=no
 +  fi
 +
 +    if test "${HAVE_FC}" = "no"; then
 +            HAVE_FREETYPE=no
      fi
 -  elif test "${HAVE_GTK}" = "yes"; then
 -    cat >>confdefs.h <<\_ACEOF
 -#define USE_TOOLKIT_SCROLL_BARS 1
 -_ACEOF
 +  fi
 +fi
 +if test "${HAVE_FREETYPE}" = "yes"; then
  
 -    USE_TOOLKIT_SCROLL_BARS=yes
 -  elif test "${HAVE_CARBON}" = "yes"; then
 -    cat >>confdefs.h <<\_ACEOF
 -#define USE_TOOLKIT_SCROLL_BARS 1
 +cat >>confdefs.h <<\_ACEOF
 +#define HAVE_FREETYPE 1
  _ACEOF
  
 -    USE_TOOLKIT_SCROLL_BARS=yes
 +  # Extract the first word of "libotf-config", so it can be a program name with args.
 +set dummy libotf-config; ac_word=$2
 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5
 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 +if test "${ac_cv_prog_HAVE_LIBOTF+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  if test -n "$HAVE_LIBOTF"; then
 +  ac_cv_prog_HAVE_LIBOTF="$HAVE_LIBOTF" # Let the user override the test.
 +else
 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 +for as_dir in $PATH
 +do
 +  IFS=$as_save_IFS
 +  test -z "$as_dir" && as_dir=.
 +  for ac_exec_ext in '' $ac_executable_extensions; do
 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 +    ac_cv_prog_HAVE_LIBOTF="yes"
 +    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
 +    break 2
    fi
 +done
 +done
 +IFS=$as_save_IFS
 +
 +  test -z "$ac_cv_prog_HAVE_LIBOTF" && ac_cv_prog_HAVE_LIBOTF="no"
 +fi
 +fi
 +HAVE_LIBOTF=$ac_cv_prog_HAVE_LIBOTF
 +if test -n "$HAVE_LIBOTF"; then
 +  { echo "$as_me:$LINENO: result: $HAVE_LIBOTF" >&5
 +echo "${ECHO_T}$HAVE_LIBOTF" >&6; }
 +else
 +  { echo "$as_me:$LINENO: result: no" >&5
 +echo "${ECHO_T}no" >&6; }
  fi
  
 +
 +  if test "${HAVE_LIBOTF}" = "yes"; then
 +
 +{ echo "$as_me:$LINENO: checking for OTF_get_features in -lotf" >&5
 +echo $ECHO_N "checking for OTF_get_features in -lotf... $ECHO_C" >&6; }
 +if test "${ac_cv_lib_otf_OTF_get_features+set}" = set; then
 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 +else
 +  ac_check_lib_save_LIBS=$LIBS
 +LIBS="-lotf  $LIBS"
  cat >conftest.$ac_ext <<_ACEOF
  /* confdefs.h.  */
  _ACEOF
@@@ -13214,29 -12907,24 +13403,29 @@@ cat confdefs.h >>conftest.$ac_ex
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
  
 -        #include <X11/Xlib.h>
 -        #include <X11/Xresource.h>
 +/* Override any GCC internal prototype to avoid an error.
 +   Use char because int might match the return type of a GCC
 +   builtin and then its argument prototype would still apply.  */
 +#ifdef __cplusplus
 +extern "C"
 +#endif
 +char OTF_get_features ();
  int
  main ()
  {
 -XIMProc  callback;
 +return OTF_get_features ();
    ;
    return 0;
  }
  _ACEOF
 -rm -f conftest.$ac_objext
 -if { (ac_try="$ac_compile"
 +rm -f conftest.$ac_objext conftest$ac_exeext
 +if { (ac_try="$ac_link"
  case "(($ac_try" in
    *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    *) ac_try_echo=$ac_try;;
  esac
  eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_compile") 2>conftest.er1
 +  (eval "$ac_link") 2>conftest.er1
    ac_status=$?
    grep -v '^ *+' conftest.er1 >conftest.err
    rm -f conftest.er1
    (exit $ac_status); } && {
         test -z "$ac_c_werror_flag" ||
         test ! -s conftest.err
 -       } && test -s conftest.$ac_objext; then
 -  HAVE_XIM=yes
 -
 -cat >>confdefs.h <<\_ACEOF
 -#define HAVE_XIM 1
 -_ACEOF
 -
 +       } && test -s conftest$ac_exeext &&
 +       $as_test_x conftest$ac_exeext; then
 +  ac_cv_lib_otf_OTF_get_features=yes
  else
    echo "$as_me: failed program was:" >&5
  sed 's/^/| /' conftest.$ac_ext >&5
  
 -      HAVE_XIM=no
 +      ac_cv_lib_otf_OTF_get_features=no
  fi
  
 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 +      conftest$ac_exeext conftest.$ac_ext
 +LIBS=$ac_check_lib_save_LIBS
 +fi
 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_otf_OTF_get_features" >&5
 +echo "${ECHO_T}$ac_cv_lib_otf_OTF_get_features" >&6; }
 +if test $ac_cv_lib_otf_OTF_get_features = yes; then
 +  cat >>confdefs.h <<_ACEOF
 +#define HAVE_LIBOTF 1
 +_ACEOF
  
 +  LIBS="-lotf $LIBS"
  
 -if test "${with_xim}" != "no"; then
 +else
 +  HAVE_LIBOTF=no
 +fi
 +
 +    if test "${HAVE_LIBOTF}" = "yes"; then
  
  cat >>confdefs.h <<\_ACEOF
 -#define USE_XIM 1
 +#define HAVE_LIBOTF 1
  _ACEOF
  
 -fi
 -
 -
 -if test "${HAVE_XIM}" != "no"; then
 -  late_CFLAGS=$CFLAGS
 -  if test "$GCC" = yes; then
 -    CFLAGS="$CFLAGS --pedantic-errors"
 +      LIBOTF_CFLAGS=`libotf-config --cflags`
 +      LIBOTF_LIBS=`libotf-config --libs`
 +    fi
    fi
 -  cat >conftest.$ac_ext <<_ACEOF
 -/* confdefs.h.  */
 -_ACEOF
 -cat confdefs.h >>conftest.$ac_ext
 -cat >>conftest.$ac_ext <<_ACEOF
 -/* end confdefs.h.  */
 +fi
  
 -#include <X11/Xlib.h>
 -#include <X11/Xresource.h>
 -int
 -main ()
 -{
 -Display *display;
 -XrmDatabase db;
 -char *res_name;
 -char *res_class;
 -XIMProc  callback;
 -XPointer *client_data;
 -#ifndef __GNUC__
 -/* If we're not using GCC, it's probably not XFree86, and this is
 -   probably right, but we can't use something like --pedantic-errors.  */
 -extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
 -                                           char*, XIMProc, XPointer*);
 -#endif
 -(void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
 -   client_data);
 -  ;
 -  return 0;
 -}
 -_ACEOF
 -rm -f conftest.$ac_objext
 -if { (ac_try="$ac_compile"
 -case "(($ac_try" in
 -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 -  *) ac_try_echo=$ac_try;;
 -esac
 -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 -  (eval "$ac_compile") 2>conftest.er1
 -  ac_status=$?
 -  grep -v '^ *+' conftest.er1 >conftest.err
 -  rm -f conftest.er1
 -  cat conftest.err >&5
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); } && {
 -       test -z "$ac_c_werror_flag" ||
 -       test ! -s conftest.err
 -       } && test -s conftest.$ac_objext; then
 -  emacs_cv_arg6_star=yes
 -else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
  
  
 -fi
  
 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  
 -  if test "$emacs_cv_arg6_star" = yes; then
 -    cat >>confdefs.h <<\_ACEOF
 -#define XRegisterIMInstantiateCallback_arg6 XPointer*
 -_ACEOF
  
 -  else
 -    cat >>confdefs.h <<\_ACEOF
 -#define XRegisterIMInstantiateCallback_arg6 XPointer
 -_ACEOF
  
 -  fi
 -  CFLAGS=$late_CFLAGS
  fi
  
  ### Use -lXpm if available, unless `--with-xpm=no'.
@@@ -14510,13 -14253,13 +14699,13 @@@ if test "${HAVE_X11}" = "yes"; the
      MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
  
    if test "X${MISSING}" != X; then
--    { { echo "$as_me:$LINENO: error: The following required libraries was not found:
++    { { echo "$as_me:$LINENO: error: The following required libraries were not found:
      $MISSING
  Maybe some development libraries/packages are missing?
  If you don't want to link with them give
      $WITH_NO
  as options to configure" >&5
--echo "$as_me: error: The following required libraries was not found:
++echo "$as_me: error: The following required libraries were not found:
      $MISSING
  Maybe some development libraries/packages are missing?
  If you don't want to link with them give
  cat confdefs.h >>conftest.$ac_ext
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
 -#include <sys/types.h> /* for off_t */
 -     #include <stdio.h>
 +#include <stdio.h>
  int
  main ()
  {
 -int (*fp) (FILE *, off_t, int) = fseeko;
 -     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
 +return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
    ;
    return 0;
  }
@@@ -18747,11 -18492,13 +18936,11 @@@ cat confdefs.h >>conftest.$ac_ex
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
  #define _LARGEFILE_SOURCE 1
 -#include <sys/types.h> /* for off_t */
 -     #include <stdio.h>
 +#include <stdio.h>
  int
  main ()
  {
 -int (*fp) (FILE *, off_t, int) = fseeko;
 -     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
 +return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
    ;
    return 0;
  }
@@@ -23904,6 -23651,7 +24093,7 @@@ echo "  Does Emacs use -ljpeg
  echo "  Does Emacs use -ltiff?                                  ${HAVE_TIFF}"
  echo "  Does Emacs use a gif library?                           ${HAVE_GIF} $ac_gif_lib_name"
  echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
+ echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
  echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
  echo "  Does Emacs use X toolkit scroll bars?                   ${USE_TOOLKIT_SCROLL_BARS}"
  echo
@@@ -24657,6 -24405,6 +24847,7 @@@ INSTALL_DATA!$INSTALL_DATA$ac_deli
  RANLIB!$RANLIB$ac_delim
  INSTALL_INFO!$INSTALL_INFO$ac_delim
  GZIP_PROG!$GZIP_PROG$ac_delim
++MAKEINFO!$MAKEINFO$ac_delim
  LIBSOUND!$LIBSOUND$ac_delim
  PKG_CONFIG!$PKG_CONFIG$ac_delim
  ALSA_CFLAGS!$ALSA_CFLAGS$ac_delim
@@@ -24665,17 -24413,12 +24856,19 @@@ CFLAGS_SOUND!$CFLAGS_SOUND$ac_deli
  SET_MAKE!$SET_MAKE$ac_delim
  XMKMF!$XMKMF$ac_delim
  HAVE_XSERVER!$HAVE_XSERVER$ac_delim
+ RSVG_CFLAGS!$RSVG_CFLAGS$ac_delim
+ RSVG_LIBS!$RSVG_LIBS$ac_delim
  GTK_CFLAGS!$GTK_CFLAGS$ac_delim
  GTK_LIBS!$GTK_LIBS$ac_delim
  XFT_CFLAGS!$XFT_CFLAGS$ac_delim
  XFT_LIBS!$XFT_LIBS$ac_delim
 +FREETYPE_CFLAGS!$FREETYPE_CFLAGS$ac_delim
 +FREETYPE_LIBS!$FREETYPE_LIBS$ac_delim
 +FONTCONFIG_CFLAGS!$FONTCONFIG_CFLAGS$ac_delim
 +FONTCONFIG_LIBS!$FONTCONFIG_LIBS$ac_delim
 +HAVE_LIBOTF!$HAVE_LIBOTF$ac_delim
 +LIBOTF_CFLAGS!$LIBOTF_CFLAGS$ac_delim
 +LIBOTF_LIBS!$LIBOTF_LIBS$ac_delim
  ALLOCA!$ALLOCA$ac_delim
  liblockfile!$liblockfile$ac_delim
  LIBOBJS!$LIBOBJS$ac_delim
@@@ -24688,9 -24431,14 +24881,6 @@@ version!$version$ac_deli
  configuration!$configuration$ac_delim
  canonical!$canonical$ac_delim
  srcdir!$srcdir$ac_delim
--lispdir!$lispdir$ac_delim
--locallisppath!$locallisppath$ac_delim
--lisppath!$lisppath$ac_delim
 -x_default_search_path!$x_default_search_path$ac_delim
 -etcdir!$etcdir$ac_delim
 -archlibdir!$archlibdir$ac_delim
 -bitmapdir!$bitmapdir$ac_delim
 -gamedir!$gamedir$ac_delim
  _ACEOF
  
    if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
  ac_delim='%!_!# '
  for ac_last_try in false false false false false :; do
    cat >conf$$subs.sed <<_ACEOF
++lispdir!$lispdir$ac_delim
++locallisppath!$locallisppath$ac_delim
++lisppath!$lisppath$ac_delim
 +x_default_search_path!$x_default_search_path$ac_delim
 +etcdir!$etcdir$ac_delim
 +archlibdir!$archlibdir$ac_delim
 +bitmapdir!$bitmapdir$ac_delim
 +gamedir!$gamedir$ac_delim
  gameuser!$gameuser$ac_delim
  c_switch_system!$c_switch_system$ac_delim
  c_switch_machine!$c_switch_machine$ac_delim
@@@ -24750,7 -24493,7 +24943,7 @@@ carbon_appdir!$carbon_appdir$ac_deli
  LTLIBOBJS!$LTLIBOBJS$ac_delim
  _ACEOF
  
-   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 16; then
 -  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 11; then
++  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 19; then
      break
    elif $ac_last_try; then
      { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@@ -25209,9 -24952,6 +25402,9 @@@ echo creating src/Makefil
    sed -e '1,/start of cpp stuff/d'\
        -e 's,/\*\*/#\(.*\)$,/* \1 */,' \
        < Makefile.c > junk.c
 +  if test -f ${srcdir}/admin/unidata/UnicodeData.txt; then
 +    CPPFLAGS="$CPPFLAGS -DHAVE_UNIDATA"
 +  fi
    $CPP $undefs -I. -I$srcdir/src $CPPFLAGS junk.c | \
        sed -e 's/^ /   /' -e '/^#/d' -e '/^[   \f]*$/d' > junk2.c
    cat junk1.c junk2.c > Makefile.new
diff --combined configure.in
index 88a2216cde18ad52b2320572925c1510465b2661,b4f8b07d7a6a670f5f2108fb53d172f2013089fe..690e0348746170a1cd9c8594ff9e2546c7fd50aa
@@@ -108,16 -108,14 +108,18 @@@ AC_ARG_WITH(gif
  [  --with-gif              use -lgif (or -lungif) for displaying GIF images])
  AC_ARG_WITH(png,
  [  --with-png              use -lpng for displaying PNG images])
 +AC_ARG_WITH(freetype,
 +[  --with-freetype         use -lfreetype for local fonts support])
 +AC_ARG_WITH(xft,
 +[  --with-xft              use -lXft for anti aliased fonts])
  AC_ARG_WITH(gpm,
  [  --with-gpm              use -lgpm for mouse support on a GNU/Linux console])
+ AC_ARG_WITH(rsvg,
+ [  --with-rsvg             use -lrsvg-2 for displaying SVG images])
  AC_ARG_WITH(gtk,
  [  --with-gtk              use GTK (same as --with-x-toolkit=gtk)])
  AC_ARG_WITH(pkg-config-prog,
- [  --with-pkg-config-prog  Path to pkg-config to use for finding GTK])
+ [  --with-pkg-config-prog  Path to pkg-config to use for finding GTK and librsvg])
  AC_ARG_WITH(toolkit-scroll-bars,
  [  --without-toolkit-scroll-bars
                            don't use Motif or Xaw3d scroll bars])
@@@ -130,11 -128,6 +132,11 @@@ AC_ARG_ENABLE(carbon-app
                            specify install directory for Emacs.app on Mac OS X]],
  [ carbon_appdir_x=${enableval}])
  
 +AC_ARG_ENABLE(font-backend,
 +[  --enable-font-backend   compile code of font-backend support],
 +      USE_FONT_BACKEND=$enableval,
 +      USE_FONT_BACKEND=no)
 +
  AC_ARG_ENABLE(asserts,
  [  --enable-asserts        compile code with asserts enabled],
        USE_XASSERTS=$enableval,
@@@ -1350,6 -1343,21 +1352,21 @@@ AC_PATH_PROG(INSTALL_INFO, install-info
  dnl Don't use GZIP, which is used by gzip for additional parameters.
  AC_PATH_PROG(GZIP_PROG, gzip)
  
+ ## Need makeinfo >= 4.6 (?) to build the manuals.
+ AC_PATH_PROG(MAKEINFO, makeinfo, no)
+ dnl By this stage, configure has already checked for egrep and set EGREP, 
+ dnl or exited with an error if no egrep was found.
+ if test "$MAKEINFO" != "no" && \
+   test x"`$MAKEINFO --version 2> /dev/null | $EGREP 'texinfo[[^0-9]]*([[5-9]]|4\.[[6-9]])'`" = x; then
+    MAKEINFO=no    
+ fi
+ if test "$MAKEINFO" = "no"; then
+   AC_MSG_ERROR( [makeinfo >= 4.6 is required] )
+ fi
  dnl Add our options to ac_link now, after it is set up.
  
  if test x$GCC = xyes && test "x$GCC_LINK_TEST_OPTIONS" != x
@@@ -2131,6 -2139,32 +2148,32 @@@ fail
    fi
  fi
  
+ ### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
+ HAVE_RSVG=no
+ if test "${HAVE_X11}" = "yes" || test "${HAVE_CARBON}" = "yes"; then
+   if test "${with_rsvg}" != "no"; then
+     dnl Check if `--with-pkg-config-prog' has been given.
+     if test "X${with_pkg_config_prog}" != X; then
+       PKG_CONFIG="${with_pkg_config_prog}"
+     fi
+     RSVG_REQUIRED=2.0.0
+     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
+     PKG_CHECK_MODULES(RSVG, $RSVG_MODULE, :, :)
+     AC_SUBST(RSVG_CFLAGS)
+     AC_SUBST(RSVG_LIBS)
+     if test ".${RSVG_CFLAGS}" != "."; then
+       HAVE_RSVG=yes
+       AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
+       CFLAGS="$CFLAGS $RSVG_CFLAGS"
+       LIBS="$RSVG_LIBS $LIBS"
+     fi
+   fi
+ fi
  HAVE_GTK=no
  if test "${with_gtk}" = "yes" && test "$USE_X_TOOLKIT" = "gtk"; then
    USE_X_TOOLKIT=none
@@@ -2227,6 -2261,37 +2270,6 @@@ if test "${HAVE_GTK}" = "yes"; the
    fi
  fi
  
 -### Link with -lXft if available to work around a bug.
 -HAVE_XFT=maybe
 -if test "${HAVE_GTK}" = "yes"; then
 -  dnl Check if --with-pkg-config-prog has been given.
 -  if test "X${with_pkg_config_prog}" != X; then
 -    PKG_CONFIG="${with_pkg_config_prog}"
 -  fi
 -
 -  PKG_CHECK_MODULES(XFT, xft >= 0.13.0, , HAVE_XFT=no)
 -  if test "$HAVE_XFT" != no; then
 -    OLD_CFLAGS="$CPPFLAGS"
 -    OLD_CPPFLAGS="$CFLAGS"
 -    OLD_LIBS="$LIBS"
 -    CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
 -    CFLAGS="$CFLAGS $XFT_CFLAGS"
 -    LIBS="$XFT_LIBS $LIBS"
 -    AC_CHECK_HEADER(X11/Xft/Xft.h,
 -      AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS))
 -
 -    if test "${HAVE_XFT}" = "yes"; then
 -      AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
 -      AC_SUBST(XFT_LIBS)
 -      C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
 -    else
 -      CFLAGS="$OLD_CPPFLAGS"
 -      CFLAGS="$OLD_CFLAGS"
 -      LIBS="$OLD_LIBS"
 -    fi
 -  fi
 -fi
 -
  dnl Do not put whitespace before the #include statements below.
  dnl Older compilers (eg sunos4 cc) choke on it.
  HAVE_XAW3D=no
@@@ -2432,93 -2497,6 +2475,93 @@@ either XPointer or XPointer*.])dn
    CFLAGS=$late_CFLAGS
  fi
  
 +### For font-backend
 +if test "${USE_FONT_BACKEND}" = "yes"; then
 +
 +AC_DEFINE(USE_FONT_BACKEND, 1,
 +          [Define to 1 if we should use font-backend.])
 +
 +### Use -lXft if available, unless `--with-freetype=no' nor `--with-xft=no'.
 +HAVE_XFT=maybe
 +if test "${HAVE_X11}" = "yes"; then
 +  if test "x${with_freetype}" = "xno"; then
 +    with_xft="no";
 +  fi
 +  if test "x${with_xft}" != "xno"; then
 +
 +    dnl Check if --with-pkg-config-prog has been given.
 +    if test "X${with_pkg_config_prog}" != X; then
 +      PKG_CONFIG="${with_pkg_config_prog}"
 +    fi
 +
 +    PKG_CHECK_MODULES(XFT, xft >= 0.13.0, , HAVE_XFT=no)
 +    if test "$HAVE_XFT" != no; then
 +      OLD_CPPFLAGS="$CPPFLAGS"
 +      OLD_CFLAGS="$CFLAGS"
 +      OLD_LIBS="$LIBS"
 +      CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
 +      CFLAGS="$CFLAGS $XFT_CFLAGS"
 +      LIBS="$XFT_LIBS $LIBS"
 +      AC_CHECK_HEADER(X11/Xft/Xft.h,
 +        AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS))
 +
 +      if test "${HAVE_XFT}" = "yes"; then
 +        AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
 +      AC_SUBST(XFT_LIBS)
 +        C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
 +      else
 +        CFLAGS="$OLD_CPPFLAGS"
 +        CFLAGS="$OLD_CFLAGS"
 +        LIBS="$OLD_LIBS"
 +      fi
 +    fi
 +  fi
 +fi
 +
 +HAVE_FREETYPE=no
 +### Use -lfreetype if available, unless `--with-freetype=no'.
 +if test "${HAVE_XFT}" = "yes"; then
 +  dnl As we use Xft, we anyway use freetype.
 +  dnl In this case, there's no need of additional CFLAGS and LIBS.
 +  HAVE_FREETYPE=yes
 +elif test "x${with_freetype}" != "xno"; then
 +  dnl Check if --with-pkg-config-prog has been given.
 +  if test "X${with_pkg_config_prog}" != X; then
 +    PKG_CONFIG="${with_pkg_config_prog}"
 +  fi
 +
 +  PKG_CHECK_MODULES(FREETYPE, freetype2, HAVE_FREETYPE=yes, HAVE_FREETYPE=no)
 +  if test "${HAVE_FREETYPE}" = "yes"; then
 +    PKG_CHECK_MODULES(FONTCONFIG, fontconfig, HAVE_FC=yes, HAVE_FC=no)
 +    if test "${HAVE_FC}" = "no"; then
 +      dnl Witout fontconfig, we can't use freetype at the moment.
 +      HAVE_FREETYPE=no
 +    fi
 +  fi
 +fi
 +if test "${HAVE_FREETYPE}" = "yes"; then
 +  AC_DEFINE(HAVE_FREETYPE, 1,
 +           [Define to 1 if you have freetype and fontconfig libraries.])
 +  AC_CHECK_PROG(HAVE_LIBOTF, libotf-config, yes, no)
 +  if test "${HAVE_LIBOTF}" = "yes"; then
 +    AC_CHECK_LIB(otf, OTF_get_features, , HAVE_LIBOTF=no)
 +    if test "${HAVE_LIBOTF}" = "yes"; then
 +      AC_DEFINE(HAVE_LIBOTF, 1,
 +               [Define to 1 if you have libotf library.])
 +      LIBOTF_CFLAGS=`libotf-config --cflags`
 +      LIBOTF_LIBS=`libotf-config --libs`
 +    fi
 +  fi
 +fi
 +AC_SUBST(FREETYPE_CFLAGS)
 +AC_SUBST(FREETYPE_LIBS)
 +AC_SUBST(FONTCONFIG_CFLAGS)
 +AC_SUBST(FONTCONFIG_LIBS)
 +AC_SUBST(LIBOTF_CFLAGS)
 +AC_SUBST(LIBOTF_LIBS)
 +
 +fi
 +
  ### Use -lXpm if available, unless `--with-xpm=no'.
  HAVE_XPM=no
  if test "${HAVE_X11}" = "yes"; then
@@@ -2646,7 -2624,7 +2689,7 @@@ if test "${HAVE_X11}" = "yes"; the
      MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
  
    if test "X${MISSING}" != X; then
-     AC_MSG_ERROR([The following required libraries was not found:
+     AC_MSG_ERROR([The following required libraries were not found:
      $MISSING
  Maybe some development libraries/packages are missing?
  If you don't want to link with them give
@@@ -3427,6 -3405,7 +3470,7 @@@ echo "  Does Emacs use -ljpeg
  echo "  Does Emacs use -ltiff?                                  ${HAVE_TIFF}"
  echo "  Does Emacs use a gif library?                           ${HAVE_GIF} $ac_gif_lib_name"
  echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
+ echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
  echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
  echo "  Does Emacs use X toolkit scroll bars?                   ${USE_TOOLKIT_SCROLL_BARS}"
  echo
@@@ -3523,9 -3502,6 +3567,9 @@@ echo creating src/Makefil
    sed -e '1,/start of cpp stuff/d'\
        -e 's,/\*\*/#\(.*\)$,/* \1 */,' \
        < Makefile.c > junk.c
 +  if test -f ${srcdir}/admin/unidata/UnicodeData.txt; then
 +    CPPFLAGS="$CPPFLAGS -DHAVE_UNIDATA"
 +  fi
    $CPP $undefs -I. -I$srcdir/src $CPPFLAGS junk.c | \
        sed -e 's/^ /   /' -e '/^#/d' -e '/^[   \f]*$/d' > junk2.c
    cat junk1.c junk2.c > Makefile.new
diff --combined etc/PROBLEMS
index 160242e59c6beb7b6140bf86aa103359aa5953eb,e23dde604644487d54858fcb741c35946ef0d678..9a89f72fec3946e03d226b51e33d328e4d81e52b
@@@ -8,10 -8,6 +8,10 @@@ This file describes various problems th
  in compiling, installing and running GNU Emacs.  Try doing Ctl-C Ctl-t
  and browsing through the outline headers.
  
 +* Mule-UCS doesn't work in Emacs 23.
 +
 +It's completely redundant now, as far as we know.
 +
  * Emacs startup failures
  
  ** Emacs fails to start, complaining about missing fonts.
@@@ -1861,12 -1857,15 +1861,15 @@@ There appears to be a problem with the 
  Mac OS X that causes process output to be truncated.  To avoid this,
  leave process-connection-type set to its default value of nil.
  
- *** Mac OS X 10.3.9 (Carbon): QuickTime 7.0.4 updater breaks build.
- On the above environment, build fails at the link stage with the
- message like "Undefined symbols: _HICopyAccessibilityActionDescription
- referenced from QuickTime expected to be defined in Carbon".  A
- workaround is to use QuickTime 7.0.1 reinstaller.
+ *** Mac OS X 10.3.9 (Carbon): QuickTime updater breaks build.
+ Some QuickTime updaters such as 7.0.4 and 7.2.0 are known to break
+ build at the link stage with the message like "Undefined symbols:
+ _HICopyAccessibilityActionDescription referenced from QuickTime
+ expected to be defined in Carbon".  A workaround is to use a QuickTime
+ reinstaller.  Alternatively, you can link with the frameworks in the
+ corresponding SDK by specifying LDFLAGS as
+ "-Wl,-F/Developer/SDKs/MacOSX10.3.0.sdk/System/Library/Frameworks".
  
  ** FreeBSD
  
index 6db7aaf118370b456f863fb6622fb2bf5aa5329a,fdeab460c796ed386e9263259cc31ff4f252755a..2ab57f9c0d448d52d0e84b387acd2a593db886af
@@@ -31,7 -31,7 +31,7 @@@
  ;; "No matter how hard you try, you can't make a racehorse out of a pig.
  ;; You can, however, make a faster pig."
  ;;
- ;; Or, to put it another way, the emacs byte compiler is a VW Bug.  This code
+ ;; Or, to put it another way, the Emacs byte compiler is a VW Bug.  This code
  ;; makes it be a VW Bug with fuel injection and a turbocharger...  You're
  ;; still not going to make it go faster than 70 mph, but it might be easier
  ;; to get it there.
      form))
  
  (defun byte-optimize-if (form)
+   ;; (if (progn <insts> <test>) <rest>) ==> (progn <insts> (if <test> <rest>))
    ;; (if <true-constant> <then> <else...>) ==> <then>
    ;; (if <false-constant> <then> <else...>) ==> (progn <else...>)
    ;; (if <test> nil <else...>) ==> (if (not <test>) (progn <else...>))
    ;; (if <test> <then> nil) ==> (if <test> <then>)
    (let ((clause (nth 1 form)))
-     (cond ((byte-compile-trueconstp clause)
+     (cond ((and (eq (car-safe clause) 'progn)
+                 ;; `clause' is a proper list.
+                 (null (cdr (last clause))))
+            (if (null (cddr clause))
+                ;; A trivial `progn'.
+                (byte-optimize-if `(if ,(cadr clause) ,@(nthcdr 2 form)))
+              (nconc (butlast clause)
+                     (list
+                      (byte-optimize-if
+                       `(if ,(car (last clause)) ,@(nthcdr 2 form)))))))
+           ((byte-compile-trueconstp clause)
           (nth 2 form))
          ((null clause)
           (if (nthcdr 4 form)
  
  (put 'featurep 'byte-optimizer 'byte-optimize-featurep)
  (defun byte-optimize-featurep (form)
-   ;; Emacs-21's byte-code doesn't run under XEmacs anyway, so we can
-   ;; safely optimize away this test.
-   (if (equal '((quote xemacs)) (cdr-safe form))
+   ;; Emacs-21's byte-code doesn't run under XEmacs or SXEmacs anyway, so we
+   ;; can safely optimize away this test.
+   (if (member (cdr-safe form) '((quote xemacs) (quote sxemacs)))
        nil
      form))
  
         char-equal char-to-string char-width
         compare-strings concat coordinates-in-window-p
         copy-alist copy-sequence copy-marker cos count-lines
 +       decdoe-char
         decode-time default-boundp default-value documentation downcase
 -       elt exp expt encode-time error-message-string
 +       elt encode-char exp expt encode-time error-message-string
         fboundp fceiling featurep ffloor
         file-directory-p file-exists-p file-locked-p file-name-absolute-p
         file-newer-than-file-p file-readable-p file-symlink-p file-writable-p
         int-to-string intern-soft
         keymap-parent
         length local-variable-if-set-p local-variable-p log log10 logand
 -       logb logior lognot logxor lsh
 +       logb logior lognot logxor lsh langinfo
         make-list make-string make-symbol
         marker-buffer max member memq min mod multibyte-char-to-unibyte
         next-window nth nthcdr number-to-string
         string-to-int string-to-number substring sxhash symbol-function
         symbol-name symbol-plist symbol-value string-make-unibyte
         string-make-multibyte string-as-multibyte string-as-unibyte
 +       string-to-multibyte
         tan truncate
         unibyte-char-to-multibyte upcase user-full-name
         user-login-name user-original-login-name user-variable-p
         '(arrayp atom
         bobp bolp bool-vector-p
         buffer-end buffer-list buffer-size buffer-string bufferp
 -       car-safe case-table-p cdr-safe char-or-string-p commandp cons consp
 +       car-safe case-table-p cdr-safe char-or-string-p characterp
 +       charsetp commandp cons consp
         current-buffer current-global-map current-indentation
         current-local-map current-minor-mode-maps current-time
         current-time-string current-time-zone
         invocation-directory invocation-name
         keymapp
         line-beginning-position line-end-position list listp
 -       make-marker mark mark-marker markerp memory-limit minibuffer-window
 +       make-marker mark mark-marker markerp max-char
 +       memory-limit minibuffer-window
         mouse-movement-p
         natnump nlistp not null number-or-marker-p numberp
         one-window-p overlayp
 -       point point-marker point-min point-max preceding-char processp
 +       point point-marker point-min point-max preceding-char primary-charset
 +       processp
         recent-keys recursion-depth
         safe-length selected-frame selected-window sequencep
         standard-case-table standard-syntax-table stringp subrp symbolp
  ;; This list contains numbers, which are pc values,
  ;; before each instruction.
  (defun byte-decompile-bytecode (bytes constvec)
-   "Turns BYTECODE into lapcode, referring to CONSTVEC."
+   "Turn BYTECODE into lapcode, referring to CONSTVEC."
    (let ((byte-compile-constants nil)
        (byte-compile-variables nil)
        (byte-compile-tag-number 0))
index 24eb423e00fd65abcac9680d422ca5d84025c397,bfc21820b5cbece2ec7b63328ee5d754c77f49ab..f56f1c7c943513efbfd2cf3df5701746351c0ff9
@@@ -385,7 -385,7 +385,7 @@@ Elements of the list may be
  
  (defvar byte-compile-interactive-only-functions
    '(beginning-of-buffer end-of-buffer replace-string replace-regexp
-     insert-file insert-buffer insert-file-literally)
+     insert-file insert-buffer insert-file-literally previous-line next-line)
    "List of commands that are not meant to be called from Lisp.")
  
  (defvar byte-compile-not-obsolete-var nil
@@@ -814,7 -814,7 +814,7 @@@ otherwise pop it"
               (setcar (cdr bytes) (logand pc 255))
               (setcar bytes (lsh pc -8))))
        (setq patchlist (cdr patchlist))))
 -    (concat (nreverse bytes))))
 +    (string-make-unibyte (concat (nreverse bytes)))))
  
  \f
  ;;; compile-time evaluation
@@@ -1010,8 -1010,7 +1010,7 @@@ Each function's symbol gets added to `b
  (defun byte-compile-log-file ()
    (and (not (equal byte-compile-current-file byte-compile-last-logged-file))
         (not noninteractive)
-        (save-excursion
-        (set-buffer (get-buffer-create "*Compile-Log*"))
+        (with-current-buffer (get-buffer-create "*Compile-Log*")
         (goto-char (point-max))
         (let* ((inhibit-read-only t)
                (dir (and byte-compile-current-file
@@@ -1548,8 -1547,7 +1547,7 @@@ recompile every `.el' file that alread
        nil
      (save-some-buffers)
      (force-mode-line-update))
-   (save-current-buffer
-     (set-buffer (get-buffer-create "*Compile-Log*"))
+   (with-current-buffer (get-buffer-create "*Compile-Log*")
      (setq default-directory (expand-file-name directory))
      ;; compilation-mode copies value of default-directory.
      (unless (eq major-mode 'compilation-mode)
@@@ -1651,7 -1649,7 +1649,7 @@@ The value is non-nil if there were no e
        (let ((b (get-file-buffer (expand-file-name filename))))
        (if (and b (buffer-modified-p b)
                 (y-or-n-p (format "Save buffer %s first? " (buffer-name b))))
-           (save-excursion (set-buffer b) (save-buffer)))))
+           (with-current-buffer b (save-buffer)))))
  
    ;; Force logging of the file name for each file compiled.
    (setq byte-compile-last-logged-file nil)
        byte-compile-dest-file)
      (setq target-file (byte-compile-dest-file filename))
      (setq byte-compile-dest-file target-file)
-     (save-excursion
-       (setq input-buffer (get-buffer-create " *Compiler Input*"))
-       (set-buffer input-buffer)
+     (with-current-buffer 
+         (setq input-buffer (get-buffer-create " *Compiler Input*"))
        (erase-buffer)
        (setq buffer-file-coding-system nil)
        ;; Always compile an Emacs Lisp file as multibyte
@@@ -1864,7 -1861,13 +1861,13 @@@ With argument, insert value in current 
                 (not (eobp)))
          (setq byte-compile-read-position (point)
                byte-compile-last-position byte-compile-read-position)
-         (let ((form (read inbuffer)))
+         (let* ((old-style-backquotes nil)
+                  (form (read inbuffer)))
+             ;; Warn about the use of old-style backquotes.
+             (when old-style-backquotes
+               (byte-compile-warn "!! The file uses old-style backquotes !!
+ This functionality has been obsolete for more than 10 years already
+ and will be removed soon.  See (elisp)Backquote in the manual."))
            (byte-compile-file-form form)))
        ;; Compile pending forms at end of file.
        (byte-compile-flush-pending)
        (delete-region (point) (progn (re-search-forward "^(")
                                      (beginning-of-line)
                                      (point)))
 -      (insert ";;; This file contains multibyte non-ASCII characters\n"
 -              ";;; and therefore cannot be loaded into Emacs 19.\n")
 -      ;; Replace "19" or "19.29" with "20", twice.
 +      (insert ";;; This file contains utf-8 non-ASCII characters\n"
 +              ";;; and therefore cannot be loaded into Emacs 21 or earlier.\n")
 +      ;; Replace "19" or "19.29" with "22", twice.
        (re-search-forward "19\\(\\.[0-9]+\\)")
 -      (replace-match "20")
 +      (replace-match "23")
        (re-search-forward "19\\(\\.[0-9]+\\)")
 -      (replace-match "20")
 +      (replace-match "23")
        ;; Now compensate for the change in size,
        ;; to make sure all positions in the file remain valid.
        (setq delta (- (point-max) old-header-end))
      (set-buffer outbuffer)
      (goto-char (point-min))
      ;; The magic number of .elc files is ";ELC", or 0x3B454C43.  After
 -    ;; that is the file-format version number (18, 19 or 20) as a
 +    ;; that is the file-format version number (18, 19, 20, or 23) as a
      ;; byte, followed by some nulls.  The primary motivation for doing
      ;; this is to get some binary characters up in the first line of
      ;; the file so that `diff' will simply say "Binary files differ"
  
      (insert
       ";ELC"
 -     (if (byte-compile-version-cond byte-compile-compatibility) 18 20)
 +     (if (byte-compile-version-cond byte-compile-compatibility) 18 23)
       "\000\000\000\n"
       )
      (insert ";;; Compiled by "
           ;; Insert semicolons as ballast, so that byte-compile-fix-header
           ;; can delete them so as to keep the buffer positions
           ;; constant for the actual compiled code.
 -         ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"))
 +         ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"))
        ;; Here if we want Emacs 18 compatibility.
        (when dynamic-docstrings
        (error "Version-18 compatibility doesn't support dynamic doc strings"))
@@@ -2037,85 -2040,83 +2040,83 @@@ list that represents a doc string refer
    ;; We need to examine byte-compile-dynamic-docstrings
    ;; in the input buffer (now current), not in the output buffer.
    (let ((dynamic-docstrings byte-compile-dynamic-docstrings))
-     (set-buffer
-      (prog1 (current-buffer)
-        (set-buffer outbuffer)
-        (let (position)
-        ;; Insert the doc string, and make it a comment with #@LENGTH.
-        (and (>= (nth 1 info) 0)
-             dynamic-docstrings
-             (not byte-compile-compatibility)
-             (progn
-               ;; Make the doc string start at beginning of line
-               ;; for make-docfile's sake.
-               (insert "\n")
-               (setq position
-                     (byte-compile-output-as-comment
-                      (nth (nth 1 info) form) nil))
-               (setq position (- (position-bytes position) (point-min) -1))
-               ;; If the doc string starts with * (a user variable),
-               ;; negate POSITION.
-               (if (and (stringp (nth (nth 1 info) form))
-                        (> (length (nth (nth 1 info) form)) 0)
-                        (eq (aref (nth (nth 1 info) form) 0) ?*))
-                   (setq position (- position)))))
-        (if preface
-            (progn
-              (insert preface)
-              (prin1 name outbuffer)))
-        (insert (car info))
-        (let ((print-escape-newlines t)
-              (print-quoted t)
-              ;; For compatibility with code before print-circle,
-              ;; use a cons cell to say that we want
-              ;; print-gensym-alist not to be cleared
-              ;; between calls to print functions.
-              (print-gensym '(t))
-              (print-circle           ; handle circular data structures
-               (not byte-compile-disable-print-circle))
-              print-gensym-alist    ; was used before print-circle existed.
-              (print-continuous-numbering t)
-              print-number-table
-              (index 0))
-          (prin1 (car form) outbuffer)
-          (while (setq form (cdr form))
-            (setq index (1+ index))
-            (insert " ")
-            (cond ((and (numberp specindex) (= index specindex)
-                        ;; Don't handle the definition dynamically
-                        ;; if it refers (or might refer)
-                        ;; to objects already output
-                        ;; (for instance, gensyms in the arg list).
-                        (let (non-nil)
-                          (dotimes (i (length print-number-table))
-                            (if (aref print-number-table i)
-                                (setq non-nil t)))
-                          (not non-nil)))
-                   ;; Output the byte code and constants specially
-                   ;; for lazy dynamic loading.
-                   (let ((position
-                          (byte-compile-output-as-comment
-                           (cons (car form) (nth 1 form))
-                           t)))
-                     (setq position (- (position-bytes position) (point-min) -1))
-                     (princ (format "(#$ . %d) nil" position) outbuffer)
-                     (setq form (cdr form))
-                     (setq index (1+ index))))
-                  ((= index (nth 1 info))
-                   (if position
-                       (princ (format (if quoted "'(#$ . %d)"  "(#$ . %d)")
-                                      position)
-                              outbuffer)
-                     (let ((print-escape-newlines nil))
-                       (goto-char (prog1 (1+ (point))
-                                    (prin1 (car form) outbuffer)))
-                       (insert "\\\n")
-                       (goto-char (point-max)))))
-                  (t
-                   (prin1 (car form) outbuffer)))))
-        (insert (nth 2 info))))))
+     (with-current-buffer outbuffer
+       (let (position)
+         ;; Insert the doc string, and make it a comment with #@LENGTH.
+         (and (>= (nth 1 info) 0)
+              dynamic-docstrings
+              (not byte-compile-compatibility)
+              (progn
+                ;; Make the doc string start at beginning of line
+                ;; for make-docfile's sake.
+                (insert "\n")
+                (setq position
+                      (byte-compile-output-as-comment
+                       (nth (nth 1 info) form) nil))
+                (setq position (- (position-bytes position) (point-min) -1))
+                ;; If the doc string starts with * (a user variable),
+                ;; negate POSITION.
+                (if (and (stringp (nth (nth 1 info) form))
+                         (> (length (nth (nth 1 info) form)) 0)
+                         (eq (aref (nth (nth 1 info) form) 0) ?*))
+                    (setq position (- position)))))
+         (if preface
+             (progn
+               (insert preface)
+               (prin1 name outbuffer)))
+         (insert (car info))
+         (let ((print-escape-newlines t)
+               (print-quoted t)
+               ;; For compatibility with code before print-circle,
+               ;; use a cons cell to say that we want
+               ;; print-gensym-alist not to be cleared
+               ;; between calls to print functions.
+               (print-gensym '(t))
+               (print-circle             ; handle circular data structures
+                (not byte-compile-disable-print-circle))
+               print-gensym-alist     ; was used before print-circle existed.
+               (print-continuous-numbering t)
+               print-number-table
+               (index 0))
+           (prin1 (car form) outbuffer)
+           (while (setq form (cdr form))
+             (setq index (1+ index))
+             (insert " ")
+             (cond ((and (numberp specindex) (= index specindex)
+                         ;; Don't handle the definition dynamically
+                         ;; if it refers (or might refer)
+                         ;; to objects already output
+                         ;; (for instance, gensyms in the arg list).
+                         (let (non-nil)
+                           (dotimes (i (length print-number-table))
+                             (if (aref print-number-table i)
+                                 (setq non-nil t)))
+                           (not non-nil)))
+                    ;; Output the byte code and constants specially
+                    ;; for lazy dynamic loading.
+                    (let ((position
+                           (byte-compile-output-as-comment
+                            (cons (car form) (nth 1 form))
+                            t)))
+                      (setq position (- (position-bytes position) (point-min) -1))
+                      (princ (format "(#$ . %d) nil" position) outbuffer)
+                      (setq form (cdr form))
+                      (setq index (1+ index))))
+                   ((= index (nth 1 info))
+                    (if position
+                        (princ (format (if quoted "'(#$ . %d)"  "(#$ . %d)")
+                                       position)
+                               outbuffer)
+                      (let ((print-escape-newlines nil))
+                        (goto-char (prog1 (1+ (point))
+                                     (prin1 (car form) outbuffer)))
+                        (insert "\\\n")
+                        (goto-char (point-max)))))
+                   (t
+                    (prin1 (car form) outbuffer)))))
+         (insert (nth 2 info)))))
    nil)
  
  (defun byte-compile-keep-pending (form &optional handler)
  ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting.
  (defun byte-compile-output-as-comment (exp quoted)
    (let ((position (point)))
-     (set-buffer
-      (prog1 (current-buffer)
-        (set-buffer outbuffer)
-        ;; Insert EXP, and make it a comment with #@LENGTH.
-        (insert " ")
-        (if quoted
-          (prin1 exp outbuffer)
-        (princ exp outbuffer))
-        (goto-char position)
-        ;; Quote certain special characters as needed.
-        ;; get_doc_string in doc.c does the unquoting.
-        (while (search-forward "\^A" nil t)
-        (replace-match "\^A\^A" t t))
-        (goto-char position)
-        (while (search-forward "\000" nil t)
-        (replace-match "\^A0" t t))
-        (goto-char position)
-        (while (search-forward "\037" nil t)
-        (replace-match "\^A_" t t))
-        (goto-char (point-max))
-        (insert "\037")
-        (goto-char position)
-        (insert "#@" (format "%d" (- (position-bytes (point-max))
-                                   (position-bytes position))))
-        ;; Save the file position of the object.
-        ;; Note we should add 1 to skip the space
-        ;; that we inserted before the actual doc string,
-        ;; and subtract 1 to convert from an 1-origin Emacs position
-        ;; to a file position; they cancel.
-        (setq position (point))
-        (goto-char (point-max))))
+     (with-current-buffer outbuffer
+       ;; Insert EXP, and make it a comment with #@LENGTH.
+       (insert " ")
+       (if quoted
+           (prin1 exp outbuffer)
+         (princ exp outbuffer))
+       (goto-char position)
+       ;; Quote certain special characters as needed.
+       ;; get_doc_string in doc.c does the unquoting.
+       (while (search-forward "\^A" nil t)
+         (replace-match "\^A\^A" t t))
+       (goto-char position)
+       (while (search-forward "\000" nil t)
+         (replace-match "\^A0" t t))
+       (goto-char position)
+       (while (search-forward "\037" nil t)
+         (replace-match "\^A_" t t))
+       (goto-char (point-max))
+       (insert "\037")
+       (goto-char position)
+       (insert "#@" (format "%d" (- (position-bytes (point-max))
+                                    (position-bytes position))))
+       ;; Save the file position of the object.
+       ;; Note we should add 1 to skip the space
+       ;; that we inserted before the actual doc string,
+       ;; and subtract 1 to convert from an 1-origin Emacs position
+       ;; to a file position; they cancel.
+       (setq position (point))
+       (goto-char (point-max)))
      position))
  
  
@@@ -3415,8 -3414,6 +3414,8 @@@ That command is designed for interactiv
  (byte-defop-compiler-1 mapc byte-compile-funarg)
  (byte-defop-compiler-1 maphash byte-compile-funarg)
  (byte-defop-compiler-1 map-char-table byte-compile-funarg)
 +(byte-defop-compiler-1 map-char-table byte-compile-funarg-2)
 +;; map-charset-chars should be funarg but has optional third arg
  (byte-defop-compiler-1 sort byte-compile-funarg-2)
  (byte-defop-compiler-1 let)
  (byte-defop-compiler-1 let*)
index 4a0c17c0a4c5a4b716503d7ea6f6ee34ed9a8554,a46fead6eb5d6a591ed7c3314653f3d7d839f057..433daad791173805ad962e0942f37e873581576a
@@@ -283,53 -283,53 +283,53 @@@ Not documente
  ;;;;;;  do* do loop return-from return block etypecase typecase ecase
  ;;;;;;  case load-time-value eval-when destructuring-bind function*
  ;;;;;;  defmacro* defun* gentemp gensym cl-compile-time-init) "cl-macs"
 -;;;;;;  "cl-macs.el" "d1c9f68f599fbec644a06dd5cf520fb5")
 +;;;;;;  "cl-macs.el" "6990af555f962480552cf0867f3d5bab")
  ;;; Generated autoloads from cl-macs.el
  
- (autoload (quote cl-compile-time-init) "cl-macs" "\
+ (autoload 'cl-compile-time-init "cl-macs" "\
  Not documented
  
  \(fn)" nil nil)
  
- (autoload (quote gensym) "cl-macs" "\
+ (autoload 'gensym "cl-macs" "\
  Generate a new uninterned symbol.
  The name is made by appending a number to PREFIX, default \"G\".
  
  \(fn &optional PREFIX)" nil nil)
  
- (autoload (quote gentemp) "cl-macs" "\
+ (autoload 'gentemp "cl-macs" "\
  Generate a new interned symbol with a unique name.
  The name is made by appending a number to PREFIX, default \"G\".
  
  \(fn &optional PREFIX)" nil nil)
  
- (autoload (quote defun*) "cl-macs" "\
+ (autoload 'defun* "cl-macs" "\
  Define NAME as a function.
  Like normal `defun', except ARGLIST allows full Common Lisp conventions,
  and BODY is implicitly surrounded by (block NAME ...).
  
  \(fn NAME ARGLIST [DOCSTRING] BODY...)" nil (quote macro))
  
- (autoload (quote defmacro*) "cl-macs" "\
+ (autoload 'defmacro* "cl-macs" "\
  Define NAME as a macro.
  Like normal `defmacro', except ARGLIST allows full Common Lisp conventions,
  and BODY is implicitly surrounded by (block NAME ...).
  
  \(fn NAME ARGLIST [DOCSTRING] BODY...)" nil (quote macro))
  
- (autoload (quote function*) "cl-macs" "\
+ (autoload 'function* "cl-macs" "\
  Introduce a function.
  Like normal `function', except that if argument is a lambda form,
  its argument list allows full Common Lisp conventions.
  
  \(fn FUNC)" nil (quote macro))
  
- (autoload (quote destructuring-bind) "cl-macs" "\
+ (autoload 'destructuring-bind "cl-macs" "\
  Not documented
  
  \(fn ARGS EXPR &rest BODY)" nil (quote macro))
  
- (autoload (quote eval-when) "cl-macs" "\
+ (autoload 'eval-when "cl-macs" "\
  Control when BODY is evaluated.
  If `compile' is in WHEN, BODY is evaluated when compiled at top-level.
  If `load' is in WHEN, BODY is evaluated when loaded after top-level compile.
@@@ -337,13 -337,13 +337,13 @@@ If `eval' is in WHEN, BODY is evaluate
  
  \(fn (WHEN...) BODY...)" nil (quote macro))
  
- (autoload (quote load-time-value) "cl-macs" "\
+ (autoload 'load-time-value "cl-macs" "\
  Like `progn', but evaluates the body at load time.
  The result of the body appears to the compiler as a quoted constant.
  
  \(fn FORM &optional READ-ONLY)" nil (quote macro))
  
- (autoload (quote case) "cl-macs" "\
+ (autoload 'case "cl-macs" "\
  Eval EXPR and choose among clauses on that value.
  Each clause looks like (KEYLIST BODY...).  EXPR is evaluated and compared
  against each key in each KEYLIST; the corresponding BODY is evaluated.
@@@ -354,13 -354,13 +354,13 @@@ Key values are compared by `eql'
  
  \(fn EXPR (KEYLIST BODY...)...)" nil (quote macro))
  
- (autoload (quote ecase) "cl-macs" "\
+ (autoload 'ecase "cl-macs" "\
  Like `case', but error if no case fits.
  `otherwise'-clauses are not allowed.
  
  \(fn EXPR (KEYLIST BODY...)...)" nil (quote macro))
  
- (autoload (quote typecase) "cl-macs" "\
+ (autoload 'typecase "cl-macs" "\
  Evals EXPR, chooses among clauses on that value.
  Each clause looks like (TYPE BODY...).  EXPR is evaluated and, if it
  satisfies TYPE, the corresponding BODY is evaluated.  If no clause succeeds,
@@@ -369,13 -369,13 +369,13 @@@ final clause, and matches if no other k
  
  \(fn EXPR (TYPE BODY...)...)" nil (quote macro))
  
- (autoload (quote etypecase) "cl-macs" "\
+ (autoload 'etypecase "cl-macs" "\
  Like `typecase', but error if no case fits.
  `otherwise'-clauses are not allowed.
  
  \(fn EXPR (TYPE BODY...)...)" nil (quote macro))
  
- (autoload (quote block) "cl-macs" "\
+ (autoload 'block "cl-macs" "\
  Define a lexically-scoped block named NAME.
  NAME may be any symbol.  Code inside the BODY forms can call `return-from'
  to jump prematurely out of the block.  This differs from `catch' and `throw'
@@@ -387,13 -387,13 +387,13 @@@ called from BODY
  
  \(fn NAME &rest BODY)" nil (quote macro))
  
- (autoload (quote return) "cl-macs" "\
+ (autoload 'return "cl-macs" "\
  Return from the block named nil.
  This is equivalent to `(return-from nil RESULT)'.
  
  \(fn &optional RESULT)" nil (quote macro))
  
- (autoload (quote return-from) "cl-macs" "\
+ (autoload 'return-from "cl-macs" "\
  Return from the block named NAME.
  This jump out to the innermost enclosing `(block NAME ...)' form,
  returning RESULT from that form (or nil if RESULT is omitted).
@@@ -402,7 -402,7 +402,7 @@@ This is compatible with Common Lisp, bu
  
  \(fn NAME &optional RESULT)" nil (quote macro))
  
- (autoload (quote loop) "cl-macs" "\
+ (autoload 'loop "cl-macs" "\
  The Common Lisp `loop' macro.
  Valid clauses are:
    for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
  
  \(fn CLAUSE...)" nil (quote macro))
  
- (autoload (quote do) "cl-macs" "\
+ (autoload 'do "cl-macs" "\
  The Common Lisp `do' loop.
  
  \(fn ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil (quote macro))
  
- (autoload (quote do*) "cl-macs" "\
+ (autoload 'do* "cl-macs" "\
  The Common Lisp `do*' loop.
  
  \(fn ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" nil (quote macro))
  
- (autoload (quote dolist) "cl-macs" "\
+ (autoload 'dolist "cl-macs" "\
  Loop over a list.
  Evaluate BODY with VAR bound to each `car' from LIST, in turn.
  Then evaluate RESULT to get return value, default nil.
  
  \(fn (VAR LIST [RESULT]) BODY...)" nil (quote macro))
  
- (autoload (quote dotimes) "cl-macs" "\
+ (autoload 'dotimes "cl-macs" "\
  Loop a certain number of times.
  Evaluate BODY with VAR bound to successive integers from 0, inclusive,
  to COUNT, exclusive.  Then evaluate RESULT to get return value, default
@@@ -443,26 -443,26 +443,26 @@@ nil
  
  \(fn (VAR COUNT [RESULT]) BODY...)" nil (quote macro))
  
- (autoload (quote do-symbols) "cl-macs" "\
+ (autoload 'do-symbols "cl-macs" "\
  Loop over all symbols.
  Evaluate BODY with VAR bound to each interned symbol, or to each symbol
  from OBARRAY.
  
  \(fn (VAR [OBARRAY [RESULT]]) BODY...)" nil (quote macro))
  
- (autoload (quote do-all-symbols) "cl-macs" "\
+ (autoload 'do-all-symbols "cl-macs" "\
  Not documented
  
  \(fn SPEC &rest BODY)" nil (quote macro))
  
- (autoload (quote psetq) "cl-macs" "\
+ (autoload 'psetq "cl-macs" "\
  Set SYMs to the values VALs in parallel.
  This is like `setq', except that all VAL forms are evaluated (in order)
  before assigning any symbols SYM to the corresponding values.
  
  \(fn SYM VAL SYM VAL ...)" nil (quote macro))
  
- (autoload (quote progv) "cl-macs" "\
+ (autoload 'progv "cl-macs" "\
  Bind SYMBOLS to VALUES dynamically in BODY.
  The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
  Each symbol in the first list is bound to the corresponding value in the
@@@ -472,7 -472,7 +472,7 @@@ a `let' form, except that the list of s
  
  \(fn SYMBOLS VALUES &rest BODY)" nil (quote macro))
  
- (autoload (quote flet) "cl-macs" "\
+ (autoload 'flet "cl-macs" "\
  Make temporary function definitions.
  This is an analogue of `let' that operates on the function cell of FUNC
  rather than its value cell.  The FORMs are evaluated with the specified
@@@ -481,41 -481,41 +481,41 @@@ go back to their previous definitions, 
  
  \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" nil (quote macro))
  
- (autoload (quote labels) "cl-macs" "\
+ (autoload 'labels "cl-macs" "\
  Make temporary function bindings.
  This is like `flet', except the bindings are lexical instead of dynamic.
  Unlike `flet', this macro is fully compliant with the Common Lisp standard.
  
  \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" nil (quote macro))
  
- (autoload (quote macrolet) "cl-macs" "\
+ (autoload 'macrolet "cl-macs" "\
  Make temporary macro definitions.
  This is like `flet', but for macros instead of functions.
  
  \(fn ((NAME ARGLIST BODY...) ...) FORM...)" nil (quote macro))
  
- (autoload (quote symbol-macrolet) "cl-macs" "\
+ (autoload 'symbol-macrolet "cl-macs" "\
  Make symbol macro definitions.
  Within the body FORMs, references to the variable NAME will be replaced
  by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...).
  
  \(fn ((NAME EXPANSION) ...) FORM...)" nil (quote macro))
  
- (autoload (quote lexical-let) "cl-macs" "\
+ (autoload 'lexical-let "cl-macs" "\
  Like `let', but lexically scoped.
  The main visible difference is that lambdas inside BODY will create
  lexical closures as in Common Lisp.
  
  \(fn VARLIST BODY)" nil (quote macro))
  
- (autoload (quote lexical-let*) "cl-macs" "\
+ (autoload 'lexical-let* "cl-macs" "\
  Like `let*', but lexically scoped.
  The main visible difference is that lambdas inside BODY will create
  lexical closures as in Common Lisp.
  
  \(fn VARLIST BODY)" nil (quote macro))
  
- (autoload (quote multiple-value-bind) "cl-macs" "\
+ (autoload 'multiple-value-bind "cl-macs" "\
  Collect multiple return values.
  FORM must return a list; the BODY is then executed with the first N elements
  of this list bound (`let'-style) to each of the symbols SYM in turn.  This
@@@ -525,7 -525,7 +525,7 @@@ a synonym for (list A B C)
  
  \(fn (SYM...) FORM BODY)" nil (quote macro))
  
- (autoload (quote multiple-value-setq) "cl-macs" "\
+ (autoload 'multiple-value-setq "cl-macs" "\
  Collect multiple return values.
  FORM must return a list; the first N elements of this list are stored in
  each of the symbols SYM in turn.  This is analogous to the Common Lisp
@@@ -534,22 -534,22 +534,22 @@@ values.  For compatibility, (values A 
  
  \(fn (SYM...) FORM)" nil (quote macro))
  
- (autoload (quote locally) "cl-macs" "\
+ (autoload 'locally "cl-macs" "\
  Not documented
  
  \(fn &rest BODY)" nil (quote macro))
  
- (autoload (quote the) "cl-macs" "\
+ (autoload 'the "cl-macs" "\
  Not documented
  
  \(fn TYPE FORM)" nil (quote macro))
  
- (autoload (quote declare) "cl-macs" "\
+ (autoload 'declare "cl-macs" "\
  Not documented
  
  \(fn &rest SPECS)" nil (quote macro))
  
- (autoload (quote define-setf-method) "cl-macs" "\
+ (autoload 'define-setf-method "cl-macs" "\
  Define a `setf' method.
  This method shows how to handle `setf's to places of the form (NAME ARGS...).
  The argument forms ARGS are bound according to ARGLIST, as if NAME were
@@@ -560,7 -560,7 +560,7 @@@ form.  See `defsetf' for a simpler way 
  
  \(fn NAME ARGLIST BODY...)" nil (quote macro))
  
- (autoload (quote defsetf) "cl-macs" "\
+ (autoload 'defsetf "cl-macs" "\
  Define a `setf' method.
  This macro is an easy-to-use substitute for `define-setf-method' that works
  well for simple place forms.  In the simple `defsetf' form, `setf's of
@@@ -581,14 -581,14 +581,14 @@@ Example
  
  \(fn NAME [FUNC | ARGLIST (STORE) BODY...])" nil (quote macro))
  
- (autoload (quote get-setf-method) "cl-macs" "\
+ (autoload 'get-setf-method "cl-macs" "\
  Return a list of five values describing the setf-method for PLACE.
  PLACE may be any Lisp form which can appear as the PLACE argument to
  a macro like `setf' or `incf'.
  
  \(fn PLACE &optional ENV)" nil nil)
  
- (autoload (quote setf) "cl-macs" "\
+ (autoload 'setf "cl-macs" "\
  Set each PLACE to the value of its VAL.
  This is a generalized version of `setq'; the PLACEs may be symbolic
  references such as (car x) or (aref x i), as well as plain symbols.
@@@ -597,40 -597,40 +597,40 @@@ The return value is the last VAL in th
  
  \(fn PLACE VAL PLACE VAL ...)" nil (quote macro))
  
- (autoload (quote psetf) "cl-macs" "\
+ (autoload 'psetf "cl-macs" "\
  Set PLACEs to the values VALs in parallel.
  This is like `setf', except that all VAL forms are evaluated (in order)
  before assigning any PLACEs to the corresponding values.
  
  \(fn PLACE VAL PLACE VAL ...)" nil (quote macro))
  
- (autoload (quote cl-do-pop) "cl-macs" "\
+ (autoload 'cl-do-pop "cl-macs" "\
  Not documented
  
  \(fn PLACE)" nil nil)
  
- (autoload (quote remf) "cl-macs" "\
+ (autoload 'remf "cl-macs" "\
  Remove TAG from property list PLACE.
  PLACE may be a symbol, or any generalized variable allowed by `setf'.
  The form returns true if TAG was found and removed, nil otherwise.
  
  \(fn PLACE TAG)" nil (quote macro))
  
- (autoload (quote shiftf) "cl-macs" "\
+ (autoload 'shiftf "cl-macs" "\
  Shift left among PLACEs.
  Example: (shiftf A B C) sets A to B, B to C, and returns the old A.
  Each PLACE may be a symbol, or any generalized variable allowed by `setf'.
  
  \(fn PLACE... VAL)" nil (quote macro))
  
- (autoload (quote rotatef) "cl-macs" "\
+ (autoload 'rotatef "cl-macs" "\
  Rotate left among PLACEs.
  Example: (rotatef A B C) sets A to B, B to C, and C to A.  It returns nil.
  Each PLACE may be a symbol, or any generalized variable allowed by `setf'.
  
  \(fn PLACE...)" nil (quote macro))
  
- (autoload (quote letf) "cl-macs" "\
+ (autoload 'letf "cl-macs" "\
  Temporarily bind to PLACEs.
  This is the analogue of `let', but with generalized variables (in the
  sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
@@@ -642,7 -642,7 +642,7 @@@ the PLACE is not modified before execut
  
  \(fn ((PLACE VALUE) ...) BODY...)" nil (quote macro))
  
- (autoload (quote letf*) "cl-macs" "\
+ (autoload 'letf* "cl-macs" "\
  Temporarily bind to PLACEs.
  This is the analogue of `let*', but with generalized variables (in the
  sense of `setf') for the PLACEs.  Each PLACE is set to the corresponding
@@@ -654,27 -654,27 +654,27 @@@ the PLACE is not modified before execut
  
  \(fn ((PLACE VALUE) ...) BODY...)" nil (quote macro))
  
- (autoload (quote callf) "cl-macs" "\
+ (autoload 'callf "cl-macs" "\
  Set PLACE to (FUNC PLACE ARGS...).
  FUNC should be an unquoted function name.  PLACE may be a symbol,
  or any generalized variable allowed by `setf'.
  
  \(fn FUNC PLACE ARGS...)" nil (quote macro))
  
- (autoload (quote callf2) "cl-macs" "\
+ (autoload 'callf2 "cl-macs" "\
  Set PLACE to (FUNC ARG1 PLACE ARGS...).
  Like `callf', but PLACE is the second argument of FUNC, not the first.
  
  \(fn FUNC ARG1 PLACE ARGS...)" nil (quote macro))
  
- (autoload (quote define-modify-macro) "cl-macs" "\
+ (autoload 'define-modify-macro "cl-macs" "\
  Define a `setf'-like modify macro.
  If NAME is called, it combines its PLACE argument with the other arguments
  from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)
  
  \(fn NAME ARGLIST FUNC &optional DOC)" nil (quote macro))
  
- (autoload (quote defstruct) "cl-macs" "\
+ (autoload 'defstruct "cl-macs" "\
  Define a struct type.
  This macro defines a new Lisp data type called NAME, which contains data
  stored in SLOTs.  This defines a `make-NAME' constructor, a `copy-NAME'
@@@ -682,24 -682,24 +682,24 @@@ copier, a `NAME-p' predicate, and setf-
  
  \(fn (NAME OPTIONS...) (SLOT SLOT-OPTS...)...)" nil (quote macro))
  
- (autoload (quote cl-struct-setf-expander) "cl-macs" "\
+ (autoload 'cl-struct-setf-expander "cl-macs" "\
  Not documented
  
  \(fn X NAME ACCESSOR PRED-FORM POS)" nil nil)
  
- (autoload (quote typep) "cl-macs" "\
+ (autoload 'typep "cl-macs" "\
  Check that OBJECT is of type TYPE.
  TYPE is a Common Lisp-style type specifier.
  
  \(fn OBJECT TYPE)" nil nil)
  
- (autoload (quote check-type) "cl-macs" "\
+ (autoload 'check-type "cl-macs" "\
  Verify that FORM is of type TYPE; signal an error if not.
  STRING is an optional description of the desired type.
  
  \(fn FORM TYPE &optional STRING)" nil (quote macro))
  
- (autoload (quote assert) "cl-macs" "\
+ (autoload 'assert "cl-macs" "\
  Verify that FORM returns non-nil; signal an error if not.
  Second arg SHOW-ARGS means to include arguments of FORM in message.
  Other args STRING and ARGS... are arguments to be passed to `error'.
@@@ -708,13 -708,13 +708,13 @@@ omitted, a default message listing FOR
  
  \(fn FORM &optional SHOW-ARGS STRING &rest ARGS)" nil (quote macro))
  
- (autoload (quote ignore-errors) "cl-macs" "\
+ (autoload 'ignore-errors "cl-macs" "\
  Execute BODY; if an error occurs, return nil.
  Otherwise, return result of last form in BODY.
  
  \(fn &rest BODY)" nil (quote macro))
  
- (autoload (quote define-compiler-macro) "cl-macs" "\
+ (autoload 'define-compiler-macro "cl-macs" "\
  Define a compiler-only macro.
  This is like `defmacro', but macro expansion occurs only if the call to
  FUNC is compiled (i.e., not interpreted).  Compiler macros should be used
@@@ -728,7 -728,7 +728,7 @@@ and then returning foo
  
  \(fn FUNC ARGS &rest BODY)" nil (quote macro))
  
- (autoload (quote compiler-macroexpand) "cl-macs" "\
+ (autoload 'compiler-macroexpand "cl-macs" "\
  Not documented
  
  \(fn FORM)" nil nil)
diff --combined lisp/eshell/esh-opt.el
index 94b0e34386f4daab03f7bb5ca263917a47d61c47,121f568a9c42e538fe4cdeeb5ffdfe69eb0d9535..66310895131407b75d40e8dd1629ef7be22e28ef
@@@ -58,6 -58,7 +58,7 @@@ BODY-FORMS.  If instead an external com
  
  Lastly, any remaining arguments will be available in a locally
  interned variable `args' (created using a `let' form)."
+   (declare (debug (form form sexp body)))
    `(let ((temp-args
          ,(if (memq ':preserve-args (cadr options))
               macro-args
@@@ -101,7 -102,7 +102,7 @@@ This code doesn't really need to be mac
                  nil))
           (error "%s" usage-msg))))
        (throw 'eshell-external
-            (eshell-external-command ext-command args))
+              (eshell-external-command ext-command args))
      last-value))
  
  (defun eshell-show-usage (name options)
@@@ -195,7 -196,7 +196,7 @@@ switch is unrecognized.
          (setq extcmd (eshell-search-path (cadr extcmd)))
          (if extcmd
              (throw 'eshell-ext-command extcmd)
 -          (if (char-valid-p switch)
 +          (if (characterp switch)
                (error "%s: unrecognized option -%c" name switch)
              (error "%s: unrecognized option --%s" name switch))))))))
  
diff --combined lisp/format.el
index d18afd7e8be8ff790f801451fa7dc1b867775c98,6e0abd7724e9af417684390ac023bc19367bc906..480ed7def8723f57f10baffed30b4974d97a4891
           ;; Plain only exists so that there is an obvious neutral choice in
           ;; the completion list.
           nil nil nil nil nil)
 -    (ibm   "IBM Code Page 850 (DOS)"
 -         nil                          ; The original "1\\(^\\)" is obscure.
 -         "recode -f ibm-pc:latin1" "recode -f latin1:ibm-pc" t nil)
 -    (mac   "Apple Macintosh"
 -         nil
 -         "recode -f mac:latin1" "recode -f latin1:mac" t nil)
 -    (hp    "HP Roman8"
 -         nil
 -         "recode -f roman8:latin1" "recode -f latin1:roman8" t nil)
      (TeX   "TeX (encoding)"
           nil
           iso-tex2iso iso-iso2tex t nil)
@@@ -136,7 -145,7 +136,7 @@@ MODE-FN, if specified, is called when v
           that this would turn on some minor mode.
  
  PRESERVE, if non-nil, means that `format-write-file' should not remove
-           this format from `buffer-file-formats'.")
+           this format from `buffer-file-format'.")
  
  ;;; Basic Functions (called from Lisp)
  
diff --combined lisp/gnus/mml.el
index b546ff832f93e98e903736ff0ee9d73934108767,0c60bed409f9ce1f6a907299489c821bff99ae12..2fb88f5e551c7aa6a890275707196c094acd01ba
@@@ -233,7 -233,8 +233,7 @@@ part.  This is for the internal use, yo
                         (list
                          (intern (downcase (cdr (assq 'charset tag))))))
                        (t
 -                       (mm-find-mime-charset-region point (point)
 -                                                    mm-hack-charsets))))
 +                       (mm-find-mime-charset-region point (point)))))
        (when (and (not raw) (memq nil charsets))
          (if (or (memq 'unknown-encoding mml-confirmation-set)
                  (message-options-get 'unknown-encoding)
@@@ -403,7 -404,7 +403,7 @@@ If MML is non-nil, return the buffer u
        (mml-multipart-number mml-multipart-number))
      (if (not cont)
        nil
-       (with-temp-buffer
+       (mm-with-multibyte-buffer
        (if (and (consp (car cont))
                 (= (length cont) 1))
            (mml-generate-mime-1 (car cont))
                      (progn
                        (mm-enable-multibyte)
                        (insert contents)
-                       (setq charset (mm-encode-body)))
+                       (unless raw
+                         (setq charset (mm-encode-body))))
                    (insert contents)))))
              (setq encoding (mm-encode-buffer type)
                    coded (mm-string-as-multibyte (buffer-string))))
            (mml-insert-mime-headers cont type charset encoding nil)
-           (insert "\n")
-           (mm-with-unibyte-current-buffer
-             (insert coded)))))
+           (insert "\n" coded))))
         ((eq (car cont) 'external)
        (insert "Content-Type: message/external-body")
        (let ((parameters (mml-parameter-string
diff --combined lisp/info.el
index e6c2d85ba2491e0af99a94b21a79ea76661a07b2,fb6260585bc48c49f7a188d909503699f084b2aa..70edf10e0b8f7fc29ca8ac02aeb395cba346d3c6
@@@ -3262,10 -3262,14 +3262,14 @@@ If FORK is non-nil, it i spassed to `In
  (defvar info-tool-bar-map
    (if (display-graphic-p)
        (let ((map (make-sparse-keymap)))
-       (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map)
-       (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map)
-       (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
-       (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
+       (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map
+                                      :rtl "right-arrow")
+       (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map
+                                      :rtl "left-arrow")
+       (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
+                                      :rtl "next-node")
+       (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
+                                      :rtl "prev-node")
        (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
        (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
        (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
@@@ -3728,8 -3732,7 +3732,8 @@@ the variable `Info-file-list-for-emacs'
             (case-fold-search t)
             paragraph-markers
             (not-fontified-p ; the node hasn't already been fontified
 -            (not (let ((where (next-property-change (point-min))))
 +            (not (let ((where (next-single-property-change (point-min) 
 +                                                         'font-lock-face)))
                     (and where (not (= where (point-max)))))))
             (fontify-visited-p ; visited nodes need to be re-fontified
              (and Info-fontify-visited-nodes
diff --combined lisp/loadup.el
index af1e4cc87c0daac89c5a0e89df5de03e888e51df,ee9f1f7ab5c6837d77b6bcbeb5de5e54f3ea44b0..17ff7a423baa79b7d18791b0725a5b86665c25cf
@@@ -33,8 -33,6 +33,8 @@@
  ;; get autoloaded when bootstrapping
  (if (or (equal (nth 3 command-line-args) "bootstrap")
        (equal (nth 4 command-line-args) "bootstrap")
 +      (equal (nth 3 command-line-args) "unidata-gen.el")
 +      (equal (nth 4 command-line-args) "unidata-gen-files")
        ;; in case CANNOT_DUMP
        (equal (nth 0 command-line-args) "../src/bootstrap-emacs"))
      (let ((dir (car load-path)))
@@@ -81,6 -79,7 +81,7 @@@
  (message "%s" (garbage-collect))
  (load "simple")
  
+ (load "button")
  (load "help")
  
  (load "jka-cmpr-hook")
  ;; multilingual text.
  (load "international/mule-cmds")
  (load "case-table")
 -(load "international/utf-8")
 -(load "international/utf-16")
  (load "international/characters")
 +(load "composite")
 +;; This file doesn't exist when building Emacs from CVS.  It is
 +;; generated just after temacs is build.
 +(load "international/charprop.el" t)
  
 -(let ((set-case-syntax-set-multibyte t))
 -  (load "international/latin-1")
 -  (load "international/latin-2")
 -  (load "international/latin-3")
 -  (load "international/latin-4")
 -  (load "international/latin-5")
 -  (load "international/latin-8")
 -  (load "international/latin-9"))
  ;; Load language-specific files.
  (load "language/chinese")
  (load "language/cyrillic")
  (load "language/japanese")
  (load "language/korean")
  (load "language/lao")
 +(load "language/tai-viet")
  (load "language/thai")
  (load "language/tibetan")
  (load "language/vietnamese")
  (load "language/utf-8-lang")
  (load "language/georgian")
  
 -(load "international/ucs-tables")
 -
 -(update-coding-systems-internal)
 -
  (load "indent")
  (load "window")
  (load "frame")
        (equal (nth 4 command-line-args) "bootstrap"))
      (setcdr load-path nil))
  
 +(clear-charset-maps)
  (garbage-collect)
  
  ;;; At this point, we're ready to resume undo recording for scratch.
diff --combined lisp/mail/rmail.el
index b2e697a247a3b47f6de102c0ed1a7492fb13d7e2,0589824d95844d2f926a44e2ecee0b6b184b7330..53c9220f14fe4551cad4ce88f048111424e68dfa
@@@ -239,6 -239,12 +239,12 @@@ Currently known variants are 'emacs an
      (setq rmail-movemail-variant-in-use (rmail-autodetect)))
    (not (null (member rmail-movemail-variant-in-use variants))))
  
+ ;; Call for effect, to set rmail-movemail-program (if not set by the
+ ;; user), and rmail-movemail-variant-in-use. Used by various functions.
+ ;; I'm not sure if M-x rmail is the only entry point to this package.
+ ;; If so, this can be moved there.
+ (rmail-movemail-variant-p)
  ;;;###autoload
  (defcustom rmail-dont-reply-to-names nil "\
  *A regexp specifying addresses to prune from a reply message.
@@@ -934,17 -940,17 +940,17 @@@ Note:    it means the file has no messa
      (unless (and coding-system
                 (coding-system-p coding-system))
        (setq coding-system
 -          ;; Emacs 21.1 and later writes RMAIL files in emacs-mule, but
 -          ;; earlier versions did that with the current buffer's encoding.
 -          ;; So we want to favor detection of emacs-mule (whose normal
 -          ;; priority is quite low), but still allow detection of other
 -          ;; encodings if emacs-mule won't fit.  The call to
 -          ;; detect-coding-with-priority below achieves that.
 -          (car (detect-coding-with-priority
 -                from to
 -                '((coding-category-emacs-mule . emacs-mule))))))
 -    (unless (memq coding-system
 -                '(undecided undecided-unix))
 +          ;; If rmail-file-coding-system is nil, Emacs 21 writes
 +          ;; RMAIL files in emacs-mule, Emacs 22 in utf-8, but
 +          ;; earlier versions did that with the current buffer's
 +          ;; encoding.  So we want to favor detection of emacs-mule
 +          ;; (whose normal priority is quite low) and utf-8, but
 +          ;; still allow detection of other encodings if they won't
 +          ;; fit.  The call to with-coding-priority below achieves
 +          ;; that.
 +          (with-coding-priority '(emacs-mule utf-8)
 +            (detect-coding-region from to 'highest))))
 +    (unless (eq (coding-system-type coding-system) 'undecided)
        (set-buffer-modified-p t)               ; avoid locking when decoding
        (let ((buffer-undo-list t))
        (decode-coding-region from to coding-system))
@@@ -1818,10 -1824,7 +1824,7 @@@ is non-nil if the user has supplied th
                 (buffer-disable-undo errors)
                 (let ((args
                        (append
-                        (list (or rmail-movemail-program
-                                  (expand-file-name "movemail"
-                                                    exec-directory))
-                              nil errors nil)
+                        (list rmail-movemail-program nil errors nil)
                         (if rmail-preserve-inbox
                             (list "-p")
                           nil)
diff --combined lisp/play/gamegrid.el
index dab015eb67b7f1a6eef4dc3cbd181279170cfef8,54e766a5878379ff3239fdb596e17aa394c31c7b..b041bbd2522af21477b6dd361d81833c829a3bf4
@@@ -320,14 -320,7 +320,14 @@@ static unsigned char gamegrid_bits[] = 
                          (< max-height height))
                      (setq max-height height))))))
        (when (and max-height (< max-height 1))
 -      (set-face-attribute gamegrid-face nil :height max-height)))))
 +      (let ((default-font-height (face-attribute 'default :height))
 +            (resy (/ (display-pixel-height) (/ (display-mm-height) 25.4)))
 +            point-size pixel-size)
 +        (setq point-size (/ (* (float default-font-height) max-height) 10)
 +              pixel-size (floor (* resy (/ point-size 72.27)))
 +              point-size (* (/ pixel-size resy) 72.27))
 +        (set-face-attribute gamegrid-face nil
 +                            :height (floor (* point-size 10))))))))
  
  (defun gamegrid-initialize-display ()
    (setq gamegrid-display-mode (gamegrid-display-type))
  (defun gamegrid-init (options)
    (setq buffer-read-only t
        truncate-lines t
+       line-spacing 0
        gamegrid-display-options options)
    (buffer-disable-undo (current-buffer))
    (gamegrid-initialize-display))
index 2e7e641096b23d9801cc8526ebb5f0360091fe83,809ed7a9f36b20b3474a4cdfc3c9b5893bd6eb86..bb71491da2d46eaa8df0e0825d831af262bf2352
@@@ -320,7 -320,7 +320,7 @@@ The expansion is entirely correct becau
      (while (< (point) limit)
        (cond
         ((or (null (setq char (nth 3 state)))
 -            (and (char-valid-p char) (eq (char-syntax (nth 3 state)) ?\")))
 +            (and (characterp char) (eq (char-syntax (nth 3 state)) ?\")))
          ;; Normal text, or comment, or docstring, or normal string.
          nil)
         ((eq (nth 3 state) ?\n)
    "*Indentation of Perl statements with respect to containing block."
    :type 'integer
    :group 'perl)
- (put 'perl-indent-level 'safe-local-variable 'integerp)
+ ;; Is is not unusual to put both perl-indent-level and
+ ;; cperl-indent-level in the local variable section of a file. If only
+ ;; one of perl-mode and cperl-mode is in use, a warning will be issued
+ ;; about the variable. Autoload this here, so that no warning is
+ ;; issued when using either perl-mode or cperl-mode.
+ ;;;###autoload(put 'perl-indent-level 'safe-local-variable 'integerp)
  (defcustom perl-continued-statement-offset 4
    "*Extra indent for lines not starting new statements."
    :type 'integer
diff --combined lisp/simple.el
index bcdac1bf598e2de5d95e68e8090dad7d903e0acd,5989d9cc61fe033a1700500a8e04523ffa667930..27d7abfc8e75d8c798f37a6a851a4ccf9e464525
@@@ -963,9 -963,9 +963,9 @@@ in *Help* buffer.  See also the comman
        (if (or (not coding)
                (eq (coding-system-type coding) t))
            (setq coding default-buffer-file-coding-system))
 -      (if (not (char-valid-p char))
 +      (if (eq (char-charset char) 'eight-bit)
            (setq encoding-msg
 -                (format "(%d, #o%o, #x%x, invalid)" char char char))
 +                (format "(%d, #o%o, #x%x, raw-byte)" char char char))
          ;; Check if the character is displayed with some `display'
          ;; text property.  In that case, set under-display to the
          ;; buffer substring covered by that property.
@@@ -3639,15 -3639,6 +3639,6 @@@ Outline mode sets this.
    :type 'boolean
    :group 'editing-basics)
  
- (defun line-move-invisible-p (pos)
-   "Return non-nil if the character after POS is currently invisible."
-   (let ((prop
-        (get-char-property pos 'invisible)))
-     (if (eq buffer-invisibility-spec t)
-       prop
-       (or (memq prop buffer-invisibility-spec)
-         (assq prop buffer-invisibility-spec)))))
  ;; Returns non-nil if partial move was done.
  (defun line-move-partial (arg noerror to-end)
    (if (< arg 0)
              (while (and (> arg 0) (not done))
                ;; If the following character is currently invisible,
                ;; skip all characters with that same `invisible' property value.
-               (while (and (not (eobp)) (line-move-invisible-p (point)))
+               (while (and (not (eobp)) (invisible-p (point)))
                  (goto-char (next-char-property-change (point))))
                ;; Move a line.
                ;; We don't use `end-of-line', since we want to escape
                    (setq done t)))
                 ((and (> arg 1)  ;; Use vertical-motion for last move
                       (not (integerp selective-display))
-                      (not (line-move-invisible-p (point))))
+                      (not (invisible-p (point))))
                  ;; We avoid vertical-motion when possible
                  ;; because that has to fontify.
                  (forward-line 1))
                    (setq done t)))
                 ((and (< arg -1) ;; Use vertical-motion for last move
                       (not (integerp selective-display))
-                      (not (line-move-invisible-p (1- (point)))))
+                      (not (invisible-p (1- (point)))))
                  (forward-line -1))
                 ((zerop (vertical-motion -1))
                  (if (not noerror)
                          ;; if our target is the middle of this line.
                          (or (zerop (or goal-column temporary-goal-column))
                              (< arg 0))
-                         (not (bobp)) (line-move-invisible-p (1- (point))))
+                         (not (bobp)) (invisible-p (1- (point))))
                    (goto-char (previous-char-property-change (point))))))))
          ;; This is the value the function returns.
          (= arg 0))
             (save-excursion
               ;; Like end-of-line but ignores fields.
               (skip-chars-forward "^\n")
-              (while (and (not (eobp)) (line-move-invisible-p (point)))
+              (while (and (not (eobp)) (invisible-p (point)))
                 (goto-char (next-char-property-change (point)))
                 (skip-chars-forward "^\n"))
               (point))))
@@@ -3941,13 -3932,13 +3932,13 @@@ and `current-column' to be able to igno
      (move-to-column col))
  
    (when (and line-move-ignore-invisible
-            (not (bolp)) (line-move-invisible-p (1- (point))))
+            (not (bolp)) (invisible-p (1- (point))))
      (let ((normal-location (point))
          (normal-column (current-column)))
        ;; If the following character is currently invisible,
        ;; skip all characters with that same `invisible' property value.
        (while (and (not (eobp))
-                 (line-move-invisible-p (point)))
+                 (invisible-p (point)))
        (goto-char (next-char-property-change (point))))
        ;; Have we advanced to a larger column position?
        (if (> (current-column) normal-column)
        ;; but with a more reasonable buffer position.
        (goto-char normal-location)
        (let ((line-beg (save-excursion (beginning-of-line) (point))))
-         (while (and (not (bolp)) (line-move-invisible-p (1- (point))))
+         (while (and (not (bolp)) (invisible-p (1- (point))))
            (goto-char (previous-char-property-change (point) line-beg))))))))
  
  (defun move-end-of-line (arg)
@@@ -3981,7 -3972,7 +3972,7 @@@ To ignore intangibility, bind `inhibit-
                 (and (line-move arg t)
                      (not (bobp))
                      (progn
-                       (while (and (not (bobp)) (line-move-invisible-p (1- (point))))
+                       (while (and (not (bobp)) (invisible-p (1- (point))))
                          (goto-char (previous-char-property-change (point))))
                        (backward-char 1)))
                 (point)))))
@@@ -4017,13 -4008,13 +4008,13 @@@ To ignore intangibility, bind `inhibit-
  
      ;; Move to beginning-of-line, ignoring fields and invisibles.
      (skip-chars-backward "^\n")
-     (while (and (not (bobp)) (line-move-invisible-p (1- (point))))
+     (while (and (not (bobp)) (invisible-p (1- (point))))
        (goto-char (previous-char-property-change (point)))
        (skip-chars-backward "^\n"))
      (setq start (point))
  
      ;; Now find first visible char in the line
-     (while (and (not (eobp)) (line-move-invisible-p (point)))
+     (while (and (not (eobp)) (invisible-p (point)))
        (goto-char (next-char-property-change (point))))
      (setq first-vis (point))
  
diff --combined lisp/startup.el
index 5bf85a169ee188c2a82ef374e9189d749d61e670,30d058afabc7afdc90cc5aae740285addffa8f3a..3dcf65cc46127bccc39438bfdc0053a5461e92f9
@@@ -308,6 -308,14 +308,14 @@@ from being initialized.
  (defvar pure-space-overflow nil
    "Non-nil if building Emacs overflowed pure space.")
  
+ (defvar tutorial-directory nil
+   "Directory containing the Emacs TUTORIAL files.")
+ ;; Get correct value in a dumped, installed Emacs.
+ (eval-at-startup
+  (setq tutorial-directory (file-name-as-directory
+                            (expand-file-name "tutorials" data-directory))))
  (defun normal-top-level-add-subdirs-to-load-path ()
    "Add all subdirectories of current directory to `load-path'.
  More precisely, this uses only the subdirectories whose names
@@@ -800,7 -808,6 +808,7 @@@ or `CVS', and any subdirectory that con
    (custom-reevaluate-setting 'file-name-shadow-mode)
    (custom-reevaluate-setting 'send-mail-function)
    (custom-reevaluate-setting 'focus-follows-mouse)
 +  (custom-reevaluate-setting 'global-auto-composition-mode)
  
    ;; Register default TTY colors for the case the terminal hasn't a
    ;; terminal init file.
@@@ -1151,7 -1158,7 +1159,7 @@@ regardless of the value of this variabl
                               en))
                      (title (with-temp-buffer
                               (insert-file-contents
-                               (expand-file-name tut data-directory)
+                               (expand-file-name tut tutorial-directory)
                                nil 0 256)
                               (search-forward ".")
                               (buffer-substring (point-min) (1- (point))))))
@@@ -1278,11 -1285,11 +1286,11 @@@ where FACE is a valid face specificatio
                            fancy-splash-image)
                           ((and (display-color-p)
                                 (image-type-available-p 'xpm))
-                           (if (and (fboundp 'x-display-planes)
-                                    (= (funcall 'x-display-planes) 8))
-                               "splash8.xpm"
-                             "splash.xpm"))
-                          (t "splash.pbm")))
+                             (if (and (fboundp 'x-display-planes)
+                                      (= (funcall 'x-display-planes) 8))
+                                 "splash8.xpm"
+                               "splash.xpm"))
+                             (t "splash.pbm")))
         (img (create-image image-file))
         (image-width (and img (car (image-size img))))
         (window-width (window-width (selected-window))))
                     'action (lambda (button) (browse-url "http://www.gnu.org/"))
                     'follow-link t)
        (insert "\n"))))
 +  (fancy-splash-insert
 +   :face '(variable-pitch :background "red")
 +   "\n!! This version is ALPHA status.  It may lose your data!!\n\n")
    (fancy-splash-insert
     :face '(variable-pitch :foreground "red")
     (if (eq system-type 'gnu/linux)
diff --combined lisp/term/mac-win.el
index 5050788f9fb7a8c86bc05dade5d23a04ae3d5445,e39e1fffeb0981c46ae4f68d9051b0a3436aee80..a89d0fe306f6af9c65b783f755597d6814bea3f4
@@@ -1,4 -1,4 +1,4 @@@
 -;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: iso-2022-7bit;-*-
 +;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: utf-8
  
  ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
  ;;   2005, 2006, 2007 Free Software Foundation, Inc.
@@@ -1130,145 -1130,95 +1130,145 @@@ correspoinding TextEncodingBase value.
  (mac-add-charset-info "mac-dingbats" 34)
  (mac-add-charset-info "iso10646-1" 126) ; for ATSUI
  
 -(cp-make-coding-system
 - mac-centraleurroman
 - [?\\e,AD\e(B ?\\e$,1  \e(B ?\\e$,1 !\e(B ?\\e,AI\e(B ?\\e$,1 $\e(B ?\\e,AV\e(B ?\\e,A\\e(B ?\\e,Aa\e(B ?\\e$,1 %\e(B ?\\e$,1 ,\e(B ?\\e,Ad\e(B ?\\e$,1 -\e(B ?\\e$,1 &\e(B ?\\e$,1 '\e(B ?\\e,Ai\e(B ?\\e$,1!9\e(B
 -  ?\\e$,1!:\e(B ?\\e$,1 .\e(B ?\\e,Am\e(B ?\\e$,1 /\e(B ?\\e$,1 2\e(B ?\\e$,1 3\e(B ?\\e$,1 6\e(B ?\\e,As\e(B ?\\e$,1 7\e(B ?\\e,At\e(B ?\\e,Av\e(B ?\\e,Au\e(B ?\\e,Az\e(B ?\\e$,1 :\e(B ?\\e$,1 ;\e(B ?\\e,A|\e(B
 -  ?\\e$,1s \e(B ?\\e,A0\e(B ?\\e$,1 8\e(B ?\\e,A#\e(B ?\\e,A'\e(B ?\\e$,1s"\e(B ?\\e,A6\e(B ?\\e,A_\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1 9\e(B ?\\e,A(\e(B ?\\e$,1y \e(B ?\\e$,1 C\e(B ?\\e$,1 N\e(B
 -  ?\\e$,1 O\e(B ?\\e$,1 J\e(B ?\\e$,1y$\e(B ?\\e$,1y%\e(B ?\\e$,1 K\e(B ?\\e$,1 V\e(B ?\\e$,1x"\e(B ?\\e$,1x1\e(B ?\\e$,1 b\e(B ?\\e$,1 [\e(B ?\\e$,1 \\e(B ?\\e$,1 ]\e(B ?\\e$,1 ^\e(B ?\\e$,1 Y\e(B ?\\e$,1 Z\e(B ?\\e$,1 e\e(B
 -  ?\\e$,1 f\e(B ?\\e$,1 c\e(B ?\\e,A,\e(B ?\\e$,1x:\e(B ?\\e$,1 d\e(B ?\\e$,1 g\e(B ?\\e$,1x&\e(B ?\\e,A+\e(B ?\\e,A;\e(B ?\\e$,1s&\e(B ?\\e,A \e(B ?\\e$,1 h\e(B ?\\e$,1 p\e(B ?\\e,AU\e(B ?\\e$,1 q\e(B ?\\e$,1 l\e(B
 -  ?\\e$,1rs\e(B ?\\e$,1rt\e(B ?\\e$,1r|\e(B ?\\e$,1r}\e(B ?\\e$,1rx\e(B ?\\e$,1ry\e(B ?\\e,Aw\e(B ?\\e$,2"*\e(B ?\\e$,1 m\e(B ?\\e$,1 t\e(B ?\\e$,1 u\e(B ?\\e$,1 x\e(B ?\\e$,1s9\e(B ?\\e$,1s:\e(B ?\\e$,1 y\e(B ?\\e$,1 v\e(B
 -  ?\\e$,1 w\e(B ?\\e$,1! \e(B ?\\e$,1rz\e(B ?\\e$,1r~\e(B ?\\e$,1!!\e(B ?\\e$,1 z\e(B ?\\e$,1 {\e(B ?\\e,AA\e(B ?\\e$,1!$\e(B ?\\e$,1!%\e(B ?\\e,AM\e(B ?\\e$,1!=\e(B ?\\e$,1!>\e(B ?\\e$,1!*\e(B ?\\e,AS\e(B ?\\e,AT\e(B
 -  ?\\e$,1!+\e(B ?\\e$,1!.\e(B ?\\e,AZ\e(B ?\\e$,1!/\e(B ?\\e$,1!0\e(B ?\\e$,1!1\e(B ?\\e$,1!2\e(B ?\\e$,1!3\e(B ?\\e,A]\e(B ?\\e,A}\e(B ?\\e$,1 W\e(B ?\\e$,1!;\e(B ?\\e$,1 a\e(B ?\\e$,1!<\e(B ?\\e$,1 B\e(B ?\\e$,1$g\e(B]
 - "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman).")
 -(coding-system-put 'mac-centraleurroman 'mime-charset 'x-mac-centraleurroman)
 -
 -(cp-make-coding-system
 - mac-cyrillic
 - [?\\e$,1(0\e(B ?\\e$,1(1\e(B ?\\e$,1(2\e(B ?\\e$,1(3\e(B ?\\e$,1(4\e(B ?\\e$,1(5\e(B ?\\e$,1(6\e(B ?\\e$,1(7\e(B ?\\e$,1(8\e(B ?\\e$,1(9\e(B ?\\e$,1(:\e(B ?\\e$,1(;\e(B ?\\e$,1(<\e(B ?\\e$,1(=\e(B ?\\e$,1(>\e(B ?\\e$,1(?\e(B
 -  ?\\e$,1(@\e(B ?\\e$,1(A\e(B ?\\e$,1(B\e(B ?\\e$,1(C\e(B ?\\e$,1(D\e(B ?\\e$,1(E\e(B ?\\e$,1(F\e(B ?\\e$,1(G\e(B ?\\e$,1(H\e(B ?\\e$,1(I\e(B ?\\e$,1(J\e(B ?\\e$,1(K\e(B ?\\e$,1(L\e(B ?\\e$,1(M\e(B ?\\e$,1(N\e(B ?\\e$,1(O\e(B
 -  ?\\e$,1s \e(B ?\\e,A0\e(B ?\\e$,1)P\e(B ?\\e,A#\e(B ?\\e,A'\e(B ?\\e$,1s"\e(B ?\\e,A6\e(B ?\\e$,1(&\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1("\e(B ?\\e$,1(r\e(B ?\\e$,1y \e(B ?\\e$,1(#\e(B ?\\e$,1(s\e(B
 -  ?\\e$,1x>\e(B ?\\e,A1\e(B ?\\e$,1y$\e(B ?\\e$,1y%\e(B ?\\e$,1(v\e(B ?\\e,A5\e(B ?\\e$,1)Q\e(B ?\\e$,1((\e(B ?\\e$,1($\e(B ?\\e$,1(t\e(B ?\\e$,1('\e(B ?\\e$,1(w\e(B ?\\e$,1()\e(B ?\\e$,1(y\e(B ?\\e$,1(*\e(B ?\\e$,1(z\e(B
 -  ?\\e$,1(x\e(B ?\\e$,1(%\e(B ?\\e,A,\e(B ?\\e$,1x:\e(B ?\\e$,1!R\e(B ?\\e$,1xh\e(B ?\\e$,1x&\e(B ?\\e,A+\e(B ?\\e,A;\e(B ?\\e$,1s&\e(B ?\\e,A \e(B ?\\e$,1(+\e(B ?\\e$,1({\e(B ?\\e$,1(,\e(B ?\\e$,1(|\e(B ?\\e$,1(u\e(B
 -  ?\\e$,1rs\e(B ?\\e$,1rt\e(B ?\\e$,1r|\e(B ?\\e$,1r}\e(B ?\\e$,1rx\e(B ?\\e$,1ry\e(B ?\\e,Aw\e(B ?\\e$,1r~\e(B ?\\e$,1(.\e(B ?\\e$,1(~\e(B ?\\e$,1(/\e(B ?\\e$,1(\7f\e(B ?\\e$,1uV\e(B ?\\e$,1(!\e(B ?\\e$,1(q\e(B ?\\e$,1(o\e(B
 -  ?\\e$,1(P\e(B ?\\e$,1(Q\e(B ?\\e$,1(R\e(B ?\\e$,1(S\e(B ?\\e$,1(T\e(B ?\\e$,1(U\e(B ?\\e$,1(V\e(B ?\\e$,1(W\e(B ?\\e$,1(X\e(B ?\\e$,1(Y\e(B ?\\e$,1(Z\e(B ?\\e$,1([\e(B ?\\e$,1(\\e(B ?\\e$,1(]\e(B ?\\e$,1(^\e(B ?\\e$,1(_\e(B
 -  ?\\e$,1(`\e(B ?\\e$,1(a\e(B ?\\e$,1(b\e(B ?\\e$,1(c\e(B ?\\e$,1(d\e(B ?\\e$,1(e\e(B ?\\e$,1(f\e(B ?\\e$,1(g\e(B ?\\e$,1(h\e(B ?\\e$,1(i\e(B ?\\e$,1(j\e(B ?\\e$,1(k\e(B ?\\e$,1(l\e(B ?\\e$,1(m\e(B ?\\e$,1(n\e(B ?\\e$,1tL\e(B]
 - "Mac Cyrillic Encoding (MIME:x-mac-cyrillic).")
 -(coding-system-put 'mac-cyrillic 'mime-charset 'x-mac-cyrillic)
 -
 -(let
 -    ((encoding-vector
 -      (vconcat
 -       (make-vector 32 nil)
 -       ;; mac-symbol (32..126) -> emacs-mule mapping
 -       [?\  ?\! ?\\e$,1x \e(B ?\# ?\\e$,1x#\e(B ?\% ?\& ?\\e$,1x-\e(B ?\( ?\) ?\\e$,1x7\e(B ?\+ ?\, ?\\e$,1x2\e(B ?\. ?\/
 -      ?\0 ?\1 ?\2 ?\3 ?\4 ?\5 ?\6 ?\7 ?\8 ?\9 ?\: ?\; ?\< ?\= ?\> ?\?
 -      ?\\e$,1xe\e(B ?\\e$,1&q\e(B ?\\e$,1&r\e(B ?\\e$,1''\e(B ?\\e$,1&t\e(B ?\\e$,1&u\e(B ?\\e$,1'&\e(B ?\\e$,1&s\e(B ?\\e$,1&w\e(B ?\\e$,1&y\e(B ?\\e$,1'Q\e(B ?\\e$,1&z\e(B ?\\e$,1&{\e(B ?\\e$,1&|\e(B ?\\e$,1&}\e(B ?\\e$,1&\7f\e(B
 -      ?\\e$,1' \e(B ?\\e$,1&x\e(B ?\\e$,1'!\e(B ?\\e$,1'#\e(B ?\\e$,1'$\e(B ?\\e$,1'%\e(B ?\\e$,1'B\e(B ?\\e$,1')\e(B ?\\e$,1&~\e(B ?\\e$,1'(\e(B ?\\e$,1&v\e(B ?\[ ?\\e$,1xT\e(B ?\] ?\\e$,1ye\e(B ?\_
 -      ?\\e$,3bE\e(B ?\\e$,1'1\e(B ?\\e$,1'2\e(B ?\\e$,1'G\e(B ?\\e$,1'4\e(B ?\\e$,1'5\e(B ?\\e$,1'F\e(B ?\\e$,1'3\e(B ?\\e$,1'7\e(B ?\\e$,1'9\e(B ?\\e$,1'U\e(B ?\\e$,1':\e(B ?\\e$,1';\e(B ?\\e$,1'<\e(B ?\\e$,1'=\e(B ?\\e$,1'?\e(B
 -      ?\\e$,1'@\e(B ?\\e$,1'8\e(B ?\\e$,1'A\e(B ?\\e$,1'C\e(B ?\\e$,1'D\e(B ?\\e$,1'E\e(B ?\\e$,1'V\e(B ?\\e$,1'I\e(B ?\\e$,1'>\e(B ?\\e$,1'H\e(B ?\\e$,1'6\e(B ?\{ ?\| ?\} ?\\e$,1x\\e(B]
 -       (make-vector (- 160 127) nil)
 -       ;; mac-symbol (160..254) -> emacs-mule mapping
 -       ;; Mapping of the following characters are changed from the
 -       ;; original one:
 -       ;; 0xE2        0x00AE+0xF87F -> 0x00AE # REGISTERED SIGN, alternate: sans serif
 -       ;; 0xE3        0x00A9+0xF87F -> 0x00A9 # COPYRIGHT SIGN, alternate: sans serif
 -       ;; 0xE4        0x2122+0xF87F -> 0x2122 # TRADE MARK SIGN, alternate: sans serif
 -       [?\\e$,1tL\e(B ?\\e$,1'R\e(B ?\\e$,1s2\e(B ?\\e$,1y$\e(B ?\\e$,1sD\e(B ?\\e$,1x>\e(B ?\\e$,1!R\e(B ?\\e$,2#c\e(B ?\\e$,2#f\e(B ?\\e$,2#e\e(B ?\\e$,2#`\e(B ?\\e$,1vt\e(B ?\\e$,1vp\e(B ?\\e$,1vq\e(B ?\\e$,1vr\e(B ?\\e$,1vs\e(B
 -      ?\\e,A0\e(B ?\\e,A1\e(B ?\\e$,1s3\e(B ?\\e$,1y%\e(B ?\\e,AW\e(B ?\\e$,1x=\e(B ?\\e$,1x"\e(B ?\\e$,1s"\e(B ?\\e,Aw\e(B ?\\e$,1y \e(B ?\\e$,1y!\e(B ?\\e$,1xh\e(B ?\\e$,1s&\e(B ?\\e$,1|p\e(B ?\\e$,1|O\e(B ?\\e$,1w5\e(B
 -      ?\\e$,1uu\e(B ?\\e$,1uQ\e(B ?\\e$,1u\\e(B ?\\e$,1uX\e(B ?\\e$,1yW\e(B ?\\e$,1yU\e(B ?\\e$,1x%\e(B ?\\e$,1xI\e(B ?\\e$,1xJ\e(B ?\\e$,1yC\e(B ?\\e$,1yG\e(B ?\\e$,1yD\e(B ?\\e$,1yB\e(B ?\\e$,1yF\e(B ?\\e$,1x(\e(B ?\\e$,1x)\e(B
 -      ?\\e$,1x@\e(B ?\\e$,1x'\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1x/\e(B ?\\e$,1x:\e(B ?\\e$,1z%\e(B ?\\e,A,\e(B ?\\e$,1xG\e(B ?\\e$,1xH\e(B ?\\e$,1wT\e(B ?\\e$,1wP\e(B ?\\e$,1wQ\e(B ?\\e$,1wR\e(B ?\\e$,1wS\e(B
 -      ?\\e$,2"*\e(B ?\\e$,2=H\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1x1\e(B ?\\e$,1|;\e(B ?\\e$,1|<\e(B ?\\e$,1|=\e(B ?\\e$,1|A\e(B ?\\e$,1|B\e(B ?\\e$,1|C\e(B ?\\e$,1|G\e(B ?\\e$,1|H\e(B ?\\e$,1|I\e(B ?\\e$,1|J\e(B
 -      ?\\e$,3b_\e(B ?\\e$,2=I\e(B ?\\e$,1xK\e(B ?\\e$,1{ \e(B ?\\e$,1|N\e(B ?\\e$,1{!\e(B ?\\e$,1|>\e(B ?\\e$,1|?\e(B ?\\e$,1|@\e(B ?\\e$,1|D\e(B ?\\e$,1|E\e(B ?\\e$,1|F\e(B ?\\e$,1|K\e(B ?\\e$,1|L\e(B ?\\e$,1|M\e(B
 -      nil]))
 -     translation-table)
 -  (setq translation-table
 -      (make-translation-table-from-vector encoding-vector))
 -;;  (define-translation-table 'mac-symbol-decoder translation-table)
 -  (define-translation-table 'mac-symbol-encoder
 -    (char-table-extra-slot translation-table 0)))
 -
 -(let
 -    ((encoding-vector
 -      (vconcat
 -       (make-vector 32 nil)
 -       ;; mac-dingbats (32..126) -> emacs-mule mapping
 -       [?\  ?\\e$,2%A\e(B ?\\e$,2%B\e(B ?\\e$,2%C\e(B ?\\e$,2%D\e(B ?\\e$,2"n\e(B ?\\e$,2%F\e(B ?\\e$,2%G\e(B ?\\e$,2%H\e(B ?\\e$,2%I\e(B ?\\e$,2"{\e(B ?\\e$,2"~\e(B ?\\e$,2%L\e(B ?\\e$,2%M\e(B ?\\e$,2%N\e(B ?\\e$,2%O\e(B
 -      ?\\e$,2%P\e(B ?\\e$,2%Q\e(B ?\\e$,2%R\e(B ?\\e$,2%S\e(B ?\\e$,2%T\e(B ?\\e$,2%U\e(B ?\\e$,2%V\e(B ?\\e$,2%W\e(B ?\\e$,2%X\e(B ?\\e$,2%Y\e(B ?\\e$,2%Z\e(B ?\\e$,2%[\e(B ?\\e$,2%\\e(B ?\\e$,2%]\e(B ?\\e$,2%^\e(B ?\\e$,2%_\e(B
 -      ?\\e$,2%`\e(B ?\\e$,2%a\e(B ?\\e$,2%b\e(B ?\\e$,2%c\e(B ?\\e$,2%d\e(B ?\\e$,2%e\e(B ?\\e$,2%f\e(B ?\\e$,2%g\e(B ?\\e$,2"e\e(B ?\\e$,2%i\e(B ?\\e$,2%j\e(B ?\\e$,2%k\e(B ?\\e$,2%l\e(B ?\\e$,2%m\e(B ?\\e$,2%n\e(B ?\\e$,2%o\e(B
 -      ?\\e$,2%p\e(B ?\\e$,2%q\e(B ?\\e$,2%r\e(B ?\\e$,2%s\e(B ?\\e$,2%t\e(B ?\\e$,2%u\e(B ?\\e$,2%v\e(B ?\\e$,2%w\e(B ?\\e$,2%x\e(B ?\\e$,2%y\e(B ?\\e$,2%z\e(B ?\\e$,2%{\e(B ?\\e$,2%|\e(B ?\\e$,2%}\e(B ?\\e$,2%~\e(B ?\\e$,2%\7f\e(B
 -      ?\\e$,2& \e(B ?\\e$,2&!\e(B ?\\e$,2&"\e(B ?\\e$,2&#\e(B ?\\e$,2&$\e(B ?\\e$,2&%\e(B ?\\e$,2&&\e(B ?\\e$,2&'\e(B ?\\e$,2&(\e(B ?\\e$,2&)\e(B ?\\e$,2&*\e(B ?\\e$,2&+\e(B ?\\e$,2"/\e(B ?\\e$,2&-\e(B ?\\e$,2!`\e(B ?\\e$,2&/\e(B
 -      ?\\e$,2&0\e(B ?\\e$,2&1\e(B ?\\e$,2&2\e(B ?\\e$,2!r\e(B ?\\e$,2!|\e(B ?\\e$,2"&\e(B ?\\e$,2&6\e(B ?\\e$,2"7\e(B ?\\e$,2&8\e(B ?\\e$,2&9\e(B ?\\e$,2&:\e(B ?\\e$,2&;\e(B ?\\e$,2&<\e(B ?\\e$,2&=\e(B ?\\e$,2&>\e(B
 -       nil
 -       ;; mac-dingbats (128..141) -> emacs-mule mapping
 -       ?\\e$,2&H\e(B ?\\e$,2&I\e(B ?\\e$,2&J\e(B ?\\e$,2&K\e(B ?\\e$,2&L\e(B ?\\e$,2&M\e(B ?\\e$,2&N\e(B ?\\e$,2&O\e(B ?\\e$,2&P\e(B ?\\e$,2&Q\e(B ?\\e$,2&R\e(B ?\\e$,2&S\e(B ?\\e$,2&T\e(B ?\\e$,2&U\e(B]
 -       (make-vector (- 161 142) nil)
 -       ;; mac-dingbats (161..239) -> emacs-mule mapping
 -       [?\\e$,2&A\e(B ?\\e$,2&B\e(B ?\\e$,2&C\e(B ?\\e$,2&D\e(B ?\\e$,2&E\e(B ?\\e$,2&F\e(B ?\\e$,2&G\e(B ?\\e$,2#c\e(B ?\\e$,2#f\e(B ?\\e$,2#e\e(B ?\\e$,2#`\e(B ?\\e$,1~@\e(B ?\\e$,1~A\e(B ?\\e$,1~B\e(B ?\\e$,1~C\e(B
 -      ?\\e$,1~D\e(B ?\\e$,1~E\e(B ?\\e$,1~F\e(B ?\\e$,1~G\e(B ?\\e$,1~H\e(B ?\\e$,1~I\e(B ?\\e$,2&V\e(B ?\\e$,2&W\e(B ?\\e$,2&X\e(B ?\\e$,2&Y\e(B ?\\e$,2&Z\e(B ?\\e$,2&[\e(B ?\\e$,2&\\e(B ?\\e$,2&]\e(B ?\\e$,2&^\e(B ?\\e$,2&_\e(B
 -      ?\\e$,2&`\e(B ?\\e$,2&a\e(B ?\\e$,2&b\e(B ?\\e$,2&c\e(B ?\\e$,2&d\e(B ?\\e$,2&e\e(B ?\\e$,2&f\e(B ?\\e$,2&g\e(B ?\\e$,2&h\e(B ?\\e$,2&i\e(B ?\\e$,2&j\e(B ?\\e$,2&k\e(B ?\\e$,2&l\e(B ?\\e$,2&m\e(B ?\\e$,2&n\e(B ?\\e$,2&o\e(B
 -      ?\\e$,2&p\e(B ?\\e$,2&q\e(B ?\\e$,2&r\e(B ?\\e$,2&s\e(B ?\\e$,2&t\e(B ?\\e$,1vr\e(B ?\\e$,1vt\e(B ?\\e$,1vu\e(B ?\\e$,2&x\e(B ?\\e$,2&y\e(B ?\\e$,2&z\e(B ?\\e$,2&{\e(B ?\\e$,2&|\e(B ?\\e$,2&}\e(B ?\\e$,2&~\e(B ?\\e$,2&\7f\e(B
 -      ?\\e$,2' \e(B ?\\e$,2'!\e(B ?\\e$,2'"\e(B ?\\e$,2'#\e(B ?\\e$,2'$\e(B ?\\e$,2'%\e(B ?\\e$,2'&\e(B ?\\e$,2''\e(B ?\\e$,2'(\e(B ?\\e$,2')\e(B ?\\e$,2'*\e(B ?\\e$,2'+\e(B ?\\e$,2',\e(B ?\\e$,2'-\e(B ?\\e$,2'.\e(B ?\\e$,2'/\e(B
 -      nil
 -       ;; mac-dingbats (241..254) -> emacs-mule mapping
 -      ?\\e$,2'1\e(B ?\\e$,2'2\e(B ?\\e$,2'3\e(B ?\\e$,2'4\e(B ?\\e$,2'5\e(B ?\\e$,2'6\e(B ?\\e$,2'7\e(B ?\\e$,2'8\e(B ?\\e$,2'9\e(B ?\\e$,2':\e(B ?\\e$,2';\e(B ?\\e$,2'<\e(B ?\\e$,2'=\e(B ?\\e$,2'>\e(B
 -      nil]))
 -     translation-table)
 -  (setq translation-table
 -      (make-translation-table-from-vector encoding-vector))
 -;;  (define-translation-table 'mac-dingbats-decoder translation-table)
 -  (define-translation-table 'mac-dingbats-encoder
 -    (char-table-extra-slot translation-table 0)))
 +(define-charset 'mac-centraleurroman
 +  "Mac Central European Roman"
 +  :short-name "Mac CE"
 +  :ascii-compatible-p t
 +  :code-space [0 255]
 +  :map
 +  (let ((tbl
 +       [?\Ä ?\Ā ?\ā ?\É ?\Ą ?\Ö ?\Ü ?\á ?\ą ?\Č ?\ä ?\č ?\Ć ?\ć ?\é ?\Ź
 +        ?\ź ?\Ď ?\í ?\ď ?\Ē ?\ē ?\Ė ?\ó ?\ė ?\ô ?\ö ?\õ ?\ú ?\Ě ?\ě ?\ü
 +        ?\† ?\° ?\Ę ?\£ ?\§ ?\• ?\¶ ?\ß ?\® ?\© ?\™ ?\ę ?\¨ ?\≠ ?\ģ ?\Į
 +        ?\į ?\Ī ?\≤ ?\≥ ?\ī ?\Ķ ?\∂ ?\∑ ?\ł ?\Ļ ?\ļ ?\Ľ ?\ľ ?\Ĺ ?\ĺ ?\Ņ
 +        ?\ņ ?\Ń ?\¬ ?\√ ?\ń ?\Ň ?\∆ ?\« ?\» ?\… ?\  ?\ň ?\Ő ?\Õ ?\ő ?\Ō
 +        ?\– ?\— ?\“ ?\” ?\‘ ?\’ ?\÷ ?\◊ ?\ō ?\Ŕ ?\ŕ ?\Ř ?\‹ ?\› ?\ř ?\Ŗ
 +        ?\ŗ ?\Š ?\‚ ?\„ ?\š ?\Ś ?\ś ?\Á ?\Ť ?\ť ?\Í ?\Ž ?\ž ?\Ū ?\Ó ?\Ô
 +        ?\ū ?\Ů ?\Ú ?\ů ?\Ű ?\ű ?\Ų ?\ų ?\Ý ?\ý ?\ķ ?\Ż ?\Ł ?\ż ?\Ģ ?\ˇ])
 +      (map (make-vector 512 nil)))
 +    (or (= (length tbl) 128)
 +      (error "Invalid vector length: %d" (length tbl)))
 +    (dotimes (i 128)
 +      (aset map (* i 2) i)
 +      (aset map (1+ (* i 2)) i))
 +    (dotimes (i 128)
 +      (aset map (+ 256 (* i 2)) (+ 128 i))
 +      (aset map (+ 256 (1+ (* i 2))) (aref tbl i)))
 +    map))
 +
 +(define-coding-system 'mac-centraleurroman
 +  "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman)."
 +  :coding-type 'charset
 +  :mnemonic ?*
 +  :charset-list '(mac-centraleurroman)
 +  :mime-charset 'x-mac-centraleurroman)
 +
 +(define-charset 'mac-cyrillic
 +  "Mac Cyrillic"
 +  :short-name "Mac CYRILLIC"
 +  :ascii-compatible-p t
 +  :code-space [0 255]
 +  :map
 +  (let ((tbl
 +       [?\А ?\Б ?\В ?\Г ?\Д ?\Е ?\Ж ?\З ?\И ?\Й ?\К ?\Л ?\М ?\Н ?\О ?\П
 +        ?\Р ?\С ?\Т ?\У ?\Ф ?\Х ?\Ц ?\Ч ?\Ш ?\Щ ?\Ъ ?\Ы ?\Ь ?\Э ?\Ю ?\Я
 +        ?\† ?\° ?\Ґ ?\£ ?\§ ?\• ?\¶ ?\І ?\® ?\© ?\™ ?\Ђ ?\ђ ?\≠ ?\Ѓ ?\ѓ
 +        ?\∞ ?\± ?\≤ ?\≥ ?\і ?\µ ?\ґ ?\Ј ?\Є ?\є ?\Ї ?\ї ?\Љ ?\љ ?\Њ ?\њ
 +        ?\ј ?\Ѕ ?\¬ ?\√ ?\ƒ ?\≈ ?\∆ ?\« ?\» ?\… ?\  ?\Ћ ?\ћ ?\Ќ ?\ќ ?\ѕ
 +        ?\– ?\— ?\“ ?\” ?\‘ ?\’ ?\÷ ?\„ ?\Ў ?\ў ?\Џ ?\џ ?\№ ?\Ё ?\ё ?\я
 +        ?\а ?\б ?\в ?\г ?\д ?\е ?\ж ?\з ?\и ?\й ?\к ?\л ?\м ?\н ?\о ?\п
 +        ?\р ?\с ?\т ?\у ?\ф ?\х ?\ц ?\ч ?\ш ?\щ ?\ъ ?\ы ?\ь ?\э ?\ю ?\€])
 +      (map (make-vector 512 nil)))
 +    (or (= (length tbl) 128)
 +      (error "Invalid vector length: %d" (length tbl)))
 +    (dotimes (i 128)
 +      (aset map (* i 2) i)
 +      (aset map (1+ (* i 2)) i))
 +    (dotimes (i 128)
 +      (aset map (+ 256 (* i 2)) (+ 128 i))
 +      (aset map (+ 256 (1+ (* i 2))) (aref tbl i)))
 +    map))
 +
 +(define-coding-system 'mac-cyrillic
 +  "Mac Cyrillic Encoding (MIME:x-mac-cyrillic)."
 +  :coding-type 'charset
 +  :mnemonic ?*
 +  :charset-list '(mac-cyrillic)
 +  :mime-charset 'x-mac-cyrillic)
 +
 +(define-charset 'mac-symbol
 +  "Mac Symbol"
 +  :short-name "Mac SYMBOL"
 +  :code-space [32 254]
 +  :map
 +  (let ((tbl-32-126
 +       [?\  ?\! ?\∀ ?\# ?\∃ ?\% ?\& ?\∍ ?\( ?\) ?\∗ ?\+ ?\, ?\− ?\. ?\/
 +        ?\0 ?\1 ?\2 ?\3 ?\4 ?\5 ?\6 ?\7 ?\8 ?\9 ?\: ?\; ?\< ?\= ?\> ?\?
 +        ?\≅ ?\Α ?\Β ?\Χ ?\Δ ?\Ε ?\Φ ?\Γ ?\Η ?\Ι ?\ϑ ?\Κ ?\Λ ?\Μ ?\Ν ?\Ο
 +        ?\Π ?\Θ ?\Ρ ?\Σ ?\Τ ?\Υ ?\ς ?\Ω ?\Ξ ?\Ψ ?\Ζ ?\[ ?\∴ ?\] ?\⊥ ?\_
 +        ?\ ?\α ?\β ?\χ ?\δ ?\ε ?\φ ?\γ ?\η ?\ι ?\ϕ ?\κ ?\λ ?\μ ?\ν ?\ο
 +        ?\π ?\θ ?\ρ ?\σ ?\τ ?\υ ?\ϖ ?\ω ?\ξ ?\ψ ?\ζ ?\{ ?\| ?\} ?\∼])
 +      (map-32-126 (make-vector (* (1+ (- 126 32)) 2) nil))
 +      (tbl-160-254
 +       ;; Mapping of the following characters are changed from the
 +       ;; original one:
 +       ;; 0xE2 0x00AE+0xF87F->0x00AE # REGISTERED SIGN, alternate: sans serif
 +       ;; 0xE3 0x00A9+0xF87F->0x00A9 # COPYRIGHT SIGN, alternate: sans serif
 +       ;; 0xE4 0x2122+0xF87F->0x2122 # TRADE MARK SIGN, alternate: sans serif
 +       [?\€ ?\ϒ ?\′ ?\≤ ?\⁄ ?\∞ ?\ƒ ?\♣ ?\♦ ?\♥ ?\♠ ?\↔ ?\← ?\↑ ?\→ ?\↓
 +        ?\° ?\± ?\″ ?\≥ ?\× ?\∝ ?\∂ ?\• ?\÷ ?\≠ ?\≡ ?\≈ ?\… ?\⏐ ?\⎯ ?\↵
 +        ?\ℵ ?\ℑ ?\ℜ ?\℘ ?\⊗ ?\⊕ ?\∅ ?\∩ ?\∪ ?\⊃ ?\⊇ ?\⊄ ?\⊂ ?\⊆ ?\∈ ?\∉
 +        ?\∠ ?\∇ ?\® ?\© ?\™ ?\∏ ?\√ ?\⋅ ?\¬ ?\∧ ?\∨ ?\⇔ ?\⇐ ?\⇑ ?\⇒ ?\⇓
 +        ?\◊ ?\〈 ?\® ?\© ?\™ ?\∑ ?\⎛ ?\⎜ ?\⎝ ?\⎡ ?\⎢ ?\⎣ ?\⎧ ?\⎨ ?\⎩ ?\⎪
 +        ?\ ?\〉 ?\∫ ?\⌠ ?\⎮ ?\⌡ ?\⎞ ?\⎟ ?\⎠ ?\⎤ ?\⎥ ?\⎦ ?\⎫ ?\⎬ ?\⎭])
 +      (map-160-254 (make-vector (* (1+ (- 254 160)) 2) nil)))
 +    (dotimes (i (1+ (- 126 32)))
 +      (aset map-32-126 (* i 2) (+ 32 i))
 +      (aset map-32-126 (1+ (* i 2)) (aref tbl-32-126 i)))
 +    (dotimes (i (1+ (- 254 160)))
 +      (aset map-160-254 (* i 2) (+ 160 i))
 +      (aset map-160-254 (1+ (* i 2)) (aref tbl-160-254 i)))
 +    (vconcat map-32-126 map-160-254)))
 +
 +(define-charset 'mac-dingbats
 +  "Mac Dingbats"
 +  :short-name "Mac Dingbats"
 +  :code-space [32 254]
 +  :map
 +  (let ((tbl-32-126
 +       [?\  ?\✁ ?\✂ ?\✃ ?\✄ ?\☎ ?\✆ ?\✇ ?\✈ ?\✉ ?\☛ ?\☞ ?\✌ ?\✍ ?\✎ ?\✏
 +        ?\✐ ?\✑ ?\✒ ?\✓ ?\✔ ?\✕ ?\✖ ?\✗ ?\✘ ?\✙ ?\✚ ?\✛ ?\✜ ?\✝ ?\✞ ?\✟
 +        ?\✠ ?\✡ ?\✢ ?\✣ ?\✤ ?\✥ ?\✦ ?\✧ ?\★ ?\✩ ?\✪ ?\✫ ?\✬ ?\✭ ?\✮ ?\✯
 +        ?\✰ ?\✱ ?\✲ ?\✳ ?\✴ ?\✵ ?\✶ ?\✷ ?\✸ ?\✹ ?\✺ ?\✻ ?\✼ ?\✽ ?\✾ ?\✿
 +        ?\❀ ?\❁ ?\❂ ?\❃ ?\❄ ?\❅ ?\❆ ?\❇ ?\❈ ?\❉ ?\❊ ?\❋ ?\● ?\❍ ?\■ ?\❏
 +        ?\❐ ?\❑ ?\❒ ?\▲ ?\▼ ?\◆ ?\❖ ?\◗ ?\❘ ?\❙ ?\❚ ?\❛ ?\❜ ?\❝ ?\❞])
 +      (map-32-126 (make-vector (* (1+ (- 126 32)) 2) nil))
 +      (tbl-128-141
 +       [?\❨ ?\❩ ?\❪ ?\❫ ?\❬ ?\❭ ?\❮ ?\❯ ?\❰ ?\❱ ?\❲ ?\❳ ?\❴ ?\❵])
 +      (map-128-141 (make-vector (* (1+ (- 141 128)) 2) nil))
 +      (tbl-161-239
 +       [?\❡ ?\❢ ?\❣ ?\❤ ?\❥ ?\❦ ?\❧ ?\♣ ?\♦ ?\♥ ?\♠ ?\① ?\② ?\③ ?\④
 +        ?\⑤ ?\⑥ ?\⑦ ?\⑧ ?\⑨ ?\⑩ ?\❶ ?\❷ ?\❸ ?\❹ ?\❺ ?\❻ ?\❼ ?\❽ ?\❾ ?\❿
 +        ?\➀ ?\➁ ?\➂ ?\➃ ?\➄ ?\➅ ?\➆ ?\➇ ?\➈ ?\➉ ?\➊ ?\➋ ?\➌ ?\➍ ?\➎ ?\➏
 +        ?\➐ ?\➑ ?\➒ ?\➓ ?\➔ ?\→ ?\↔ ?\↕ ?\➘ ?\➙ ?\➚ ?\➛ ?\➜ ?\➝ ?\➞ ?\➟
 +        ?\➠ ?\➡ ?\➢ ?\➣ ?\➤ ?\➥ ?\➦ ?\➧ ?\➨ ?\➩ ?\➪ ?\➫ ?\➬ ?\➭ ?\➮ ?\➯])
 +      (map-161-239 (make-vector (* (1+ (- 239 161)) 2) nil))
 +      (tbl-241-254
 +       [?\➱ ?\➲ ?\➳ ?\➴ ?\➵ ?\➶ ?\➷ ?\➸ ?\➹ ?\➺ ?\➻ ?\➼ ?\➽ ?\➾])
 +      (map-241-254 (make-vector (* (1+ (- 254 241)) 2) nil)))
 +    (dotimes (i (1+ (- 126 32)))
 +      (aset map-32-126 (* i 2) (+ 32 i))
 +      (aset map-32-126 (1+ (* i 2)) (aref tbl-32-126 i)))
 +    (dotimes (i (1+ (- 141 128)))
 +      (aset map-128-141 (* i 2) (+ 128 i))
 +      (aset map-128-141 (1+ (* i 2)) (aref tbl-128-141 i)))
 +    (dotimes (i (1+ (- 239 161)))
 +      (aset map-161-239 (* i 2) (+ 161 i))
 +      (aset map-161-239 (1+ (* i 2)) (aref tbl-161-239 i)))
 +    (dotimes (i (1+ (- 254 241)))
 +      (aset map-241-254 (* i 2) (+ 241 i))
 +      (aset map-241-254 (1+ (* i 2)) (aref tbl-241-254 i)))
 +    (vconcat map-32-126 map-128-141 map-161-239 map-241-254)))
  
  (defconst mac-system-coding-system
    (let ((base (or (cdr (assq mac-system-script-code
              (setq str nil)
            ;; ASCII-only?
            (unless (mac-code-convert-string data nil mac-text-encoding-ascii)
 -            (subst-char-in-string ?\x5c ?\\e(J\\e(B str t)
 +            (subst-char-in-string ?\x5c ?\¥ str t)
              (subst-char-in-string ?\x80 ?\\ str t)))))
      (or str
        (decode-coding-string data
                   (eq coding-system 'japanese-shift-jis-mac))
          (setq encoding mac-text-encoding-mac-japanese-basic-variant)
          (setq str (subst-char-in-string ?\\ ?\x80 str))
 -        (subst-char-in-string ?\\e(J\\e(B ?\x5c str t)
 +        (subst-char-in-string ?\¥ ?\x5c str t)
          ;; ASCII-only?
          (if (string-match "\\`[\x00-\x7f]*\\'" str)
              (setq str nil)))
    (or coding-system (setq coding-system mac-system-coding-system))
    (prog1 (setq data (decode-coding-string data coding-system))
      (when (eq (coding-system-base coding-system) 'japanese-shift-jis)
 -      ;; (subst-char-in-string ?\x5c ?\\e(J\\e(B data t)
 +      ;; (subst-char-in-string ?\x5c ?\¥ data t)
        (subst-char-in-string ?\x80 ?\\ data t))))
  
  (defun mac-string-to-TEXT (string &optional coding-system)
        (coding-system-change-eol-conversion coding-system 'mac))
    (when (eq coding-system 'japanese-shift-jis-mac)
      ;; (setq string (subst-char-in-string ?\\ ?\x80 string))
 -    (setq string (subst-char-in-string ?\\e(J\\e(B ?\x5c string)))
 +    (setq string (subst-char-in-string ?\¥ ?\x5c string)))
    (encode-coding-string string coding-system))
  
  (defun mac-furl-to-string (data)
@@@ -1848,12 -1798,12 +1848,12 @@@ Currently the `mailto' scheme is suppor
    "Toggle visibility of tool-bars in response to EVENT.
  With no keyboard modifiers, it toggles the visibility of the
  frame where the tool-bar toggle button was pressed.  With some
- modifiers, it changes global tool-bar visibility setting."
+ modifiers, it changes the global tool-bar visibility setting."
    (interactive "e")
    (let ((ae (mac-event-ae event)))
      (if (mac-ae-keyboard-modifiers ae)
        ;; Globally toggle tool-bar-mode if some modifier key is pressed.
-       (tool-bar-mode)
+       (tool-bar-mode 'toggle)
        (let ((frame (mac-ae-frame ae)))
        (set-frame-parameter frame 'tool-bar-lines
                             (if (= (frame-parameter frame 'tool-bar-lines) 0)
@@@ -2372,23 -2322,164 +2372,23 @@@ See also `mac-dnd-known-types'.
  
  (setq frame-creation-function 'x-create-frame-with-faces)
  
 -(defvar mac-font-encoder-list
 -  '(("mac-roman" mac-roman-encoder
 -     ccl-encode-mac-roman-font "%s")
 -    ("mac-centraleurroman" encode-mac-centraleurroman
 -     ccl-encode-mac-centraleurroman-font "%s ce")
 -    ("mac-cyrillic" encode-mac-cyrillic
 -     ccl-encode-mac-cyrillic-font "%s cy")
 -    ("mac-symbol" mac-symbol-encoder
 -     ccl-encode-mac-symbol-font "symbol")
 -    ("mac-dingbats" mac-dingbats-encoder
 -     ccl-encode-mac-dingbats-font "zapf dingbats")))
 -
 -(let ((encoder-list
 -       (mapcar (lambda (lst) (nth 1 lst)) mac-font-encoder-list))
 -      (charset-list
 -       '(latin-iso8859-2
 -       latin-iso8859-3 latin-iso8859-4
 -       cyrillic-iso8859-5 greek-iso8859-7 hebrew-iso8859-8
 -       latin-iso8859-9 latin-iso8859-14 latin-iso8859-15)))
 -  (dolist (encoder encoder-list)
 -    (let ((table (get encoder 'translation-table)))
 -      (dolist (charset charset-list)
 -      (dotimes (i 96)
 -        (let* ((c (make-char charset (+ i 32)))
 -               (mu (aref ucs-mule-to-mule-unicode c))
 -               (mac-encoded (and mu (aref table mu))))
 -          (if mac-encoded
 -              (aset table c mac-encoded))))))))
 -
 -;; We assume none of official dim2 charsets (0x90..0x99) are encoded
 -;; to these fonts.
 -
 -(define-ccl-program ccl-encode-mac-roman-font
 -  `(0
 -    (if (r0 <= ?\xef)
 -      (translate-character mac-roman-encoder r0 r1)
 -      ((r1 <<= 7)
 -       (r1 |= r2)
 -       (translate-character mac-roman-encoder r0 r1))))
 -  "CCL program for Mac Roman font")
 -
 -(define-ccl-program ccl-encode-mac-centraleurroman-font
 -  `(0
 -    (if (r0 <= ?\xef)
 -      (translate-character encode-mac-centraleurroman r0 r1)
 -      ((r1 <<= 7)
 -       (r1 |= r2)
 -       (translate-character encode-mac-centraleurroman r0 r1))))
 -  "CCL program for Mac Central European Roman font")
 -
 -(define-ccl-program ccl-encode-mac-cyrillic-font
 -  `(0
 -    (if (r0 <= ?\xef)
 -      (translate-character encode-mac-cyrillic r0 r1)
 -      ((r1 <<= 7)
 -       (r1 |= r2)
 -       (translate-character encode-mac-cyrillic r0 r1))))
 -  "CCL program for Mac Cyrillic font")
 -
 -(define-ccl-program ccl-encode-mac-symbol-font
 -  `(0
 -    (if (r0 <= ?\xef)
 -      (translate-character mac-symbol-encoder r0 r1)
 -      ((r1 <<= 7)
 -       (r1 |= r2)
 -       (translate-character mac-symbol-encoder r0 r1))))
 -  "CCL program for Mac Symbol font")
 -
 -(define-ccl-program ccl-encode-mac-dingbats-font
 -  `(0
 -    (if (r0 <= ?\xef)
 -      (translate-character mac-dingbats-encoder r0 r1)
 -      ((r1 <<= 7)
 -       (r1 |= r2)
 -       (translate-character mac-dingbats-encoder r0 r1))))
 -  "CCL program for Mac Dingbats font")
 -
 -
 -(setq font-ccl-encoder-alist
 -      (nconc
 -       (mapcar (lambda (lst) (cons (nth 0 lst) (nth 2 lst)))
 -             mac-font-encoder-list)
 -       font-ccl-encoder-alist))
 -
 -(defconst mac-char-fontspec-list
 -  ;; Directly operate on a char-table instead of a fontset so that it
 -  ;; may not create a dummy fontset.
 -  (let ((template (make-char-table 'fontset)))
 -    (dolist
 -      (font-encoder
 -       (nreverse
 -        (mapcar (lambda (lst)
 -                  (cons (cons (nth 3 lst) (nth 0 lst)) (nth 1 lst)))
 -                mac-font-encoder-list)))
 -      (let ((font (car font-encoder))
 -          (encoder (cdr font-encoder)))
 -      (map-char-table
 -       (lambda (key val)
 -         (or (null val)
 -             (generic-char-p key)
 -             (memq (char-charset key)
 -                   '(ascii eight-bit-control eight-bit-graphic))
 -             (aset template key font)))
 -       (get encoder 'translation-table))))
 -
 -    ;; Like fontset-info, but extend a range only if its "to" part is
 -    ;; the predecessor of the current char.
 -    (let* ((last '((0 nil)))
 -         (accumulator last)
 -         last-char-or-range last-char last-elt)
 -      (map-char-table
 -       (lambda (char elt)
 -       (when elt
 -         (setq last-char-or-range (car (car last))
 -               last-char (if (consp last-char-or-range)
 -                             (cdr last-char-or-range)
 -                           last-char-or-range)
 -               last-elt (cdr (car last)))
 -         (if (and (eq elt last-elt)
 -                  (= char (1+ last-char))
 -                  (eq (char-charset char) (char-charset last-char)))
 -             (if (consp last-char-or-range)
 -                 (setcdr last-char-or-range char)
 -               (setcar (car last) (cons last-char char)))
 -           (setcdr last (list (cons char elt)))
 -           (setq last (cdr last)))))
 -       template)
 -      (cdr accumulator))))
 +(setq font-encoding-alist
 +      (append
 +       '(("mac-roman" . mac-roman)
 +       ("mac-centraleurroman" . mac-centraleurroman)
 +       ("mac-cyrillic" . mac-cyrillic)
 +       ("mac-symbol" . mac-symbol)
 +       ("mac-dingbats" . mac-dingbats))
 +       font-encoding-alist))
  
  (defun fontset-add-mac-fonts (fontset &optional base-family)
 -  "Add font-specs for Mac fonts to FONTSET.
 -The added font-specs are determined by BASE-FAMILY and the value
 -of `mac-char-fontspec-list', which is a list
 -of (CHARACTER-OR-RANGE . (FAMILY-FORMAT . REGISTRY)).  If
 -BASE-FAMILY is nil, the font family in the added font-specs is
 -also nil.  If BASE-FAMILY is a string, `%s' in FAMILY-FORMAT is
 -replaced with the string.  Otherwise, `%s' in FAMILY-FORMAT is
 -replaced with the ASCII font family name in FONTSET."
 -  (if base-family
 -      (if (stringp base-family)
 -        (setq base-family (downcase base-family))
 -      (let ((ascii-font (fontset-font fontset (charset-id 'ascii))))
 -        (if ascii-font
 -            (setq base-family
 -                  (aref (x-decompose-font-name
 -                         (downcase (x-resolve-font-name ascii-font)))
 -                        xlfd-regexp-family-subnum))))))
 -  (let (fontspec-cache fontspec)
 -    (dolist (char-fontspec mac-char-fontspec-list)
 -      (setq fontspec (cdr (assq (cdr char-fontspec) fontspec-cache)))
 -      (when (null fontspec)
 -      (setq fontspec
 -            (cons (and base-family
 -                       (format (car (cdr char-fontspec)) base-family))
 -                  (cdr (cdr char-fontspec))))
 -      (setq fontspec-cache (cons (cons (cdr char-fontspec) fontspec)
 -                                 fontspec-cache)))
 -      (set-fontset-font fontset (car char-fontspec) fontspec))))
 +  (dolist (elt `((latin . (,(or base-family "Monaco") . "mac-roman"))
 +               (mac-roman . (,base-family . "mac-roman"))
 +               (mac-centraleurroman . (,base-family . "mac-centraleurroman"))
 +               (mac-cyrillic . (,base-family . "mac-cyrillic"))
 +               (mac-symbol . (,base-family . "mac-symbol"))
 +               (mac-dingbats . (,base-family . "mac-dingbats"))))
 +    (set-fontset-font fontset (car elt) (cdr elt))))
  
  (defun create-fontset-from-mac-roman-font (font &optional resolved-font
                                                fontset-name)
@@@ -2403,14 -2494,10 +2403,14 @@@ Optional 2nd arg FONTSET-NAME is a stri
  an appropriate name is generated automatically.
  
  It returns a name of the created fontset."
 -  (let ((fontset
 -       (create-fontset-from-ascii-font font resolved-font fontset-name)))
 -    (fontset-add-mac-fonts fontset t)
 -    fontset))
 +  (or resolved-font
 +      (setq resolved-font (x-resolve-font-name font)))
 +  (let ((base-family (aref (x-decompose-font-name resolved-font)
 +                         xlfd-regexp-family-subnum)))
 +    (if (string= base-family "*")
 +      (setq base-family nil))
 +    (new-fontset fontset-name (list (cons 'ascii resolved-font)))
 +    (fontset-add-mac-fonts fontset-name base-family)))
  
  ;; Adjust Courier font specifications in x-fixed-font-alist.
  (let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
  
  ;; Setup the default fontset.
  (setup-default-fontset)
 -(cond ((x-list-fonts "*-iso10646-1" nil nil 1)
 -       ;; Use ATSUI (if available) for the following charsets.
 -       (dolist
 -         (charset '(latin-iso8859-1
 -                    latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
 -                    thai-tis620 greek-iso8859-7 arabic-iso8859-6
 -                    hebrew-iso8859-8 cyrillic-iso8859-5
 -                    latin-iso8859-9 latin-iso8859-15 latin-iso8859-14
 -                    japanese-jisx0212 chinese-sisheng ipa
 -                    vietnamese-viscii-lower vietnamese-viscii-upper
 -                    lao ethiopic tibetan))
 -       (set-fontset-font nil charset '(nil . "iso10646-1"))))
 -      ((null (x-list-fonts "*-iso8859-1" nil nil 1))
 -       ;; Add Mac-encoding fonts unless ETL fonts are installed.
 -       (fontset-add-mac-fonts "fontset-default")))
  
  ;; Create a fontset that uses mac-roman font.  With this fontset,
 -;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
 -;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
 -(create-fontset-from-fontset-spec
 - "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
 -ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
 -(fontset-add-mac-fonts "fontset-standard" t)
 +;; characters belonging to mac-roman charset (that contains ASCII and
 +;; more Latin characters) are displayed by a mac-roman font.
 +(create-fontset-from-mac-roman-font
 + "-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman" nil
 + "-apple-Monaco-normal-r-*-*-12-*-*-*-*-*-fontset-standard")
  
  ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
  (create-fontset-from-x-resource)
  
 -;; Try to create a fontset from a font specification which comes
 -;; from initial-frame-alist, default-frame-alist, or X resource.
 -;; A font specification in command line argument (i.e. -fn XXXX)
 -;; should be already in default-frame-alist as a `font'
 -;; parameter.  However, any font specifications in site-start
 -;; library, user's init file (.emacs), and default.el are not
 -;; yet handled here.
 -
 -(let ((font (or (cdr (assq 'font initial-frame-alist))
 -              (cdr (assq 'font default-frame-alist))
 -              (x-get-resource "font" "Font")))
 -      xlfd-fields resolved-name)
 -  (if (and font
 -         (not (query-fontset font))
 -         (setq resolved-name (x-resolve-font-name font))
 -         (setq xlfd-fields (x-decompose-font-name font)))
 -      (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
 -        (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
 -      ;; Create a fontset from FONT.  The fontset name is
 -      ;; generated from FONT.
 -      (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum))
 -               (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum)))
 -          (create-fontset-from-mac-roman-font font resolved-name "startup")
 -        (create-fontset-from-ascii-font font resolved-name "startup")))))
 -
  ;; Apply a geometry resource to the initial frame.  Put it at the end
  ;; of the alist, so that anything specified on the command line takes
  ;; precedence.
diff --combined lisp/term/x-win.el
index dad5a5d17ae21312d2af8db3227ff2cf0fced0ed,ed4330ee969a995be106281e00c44def2e8014c7..246b38a6c9f19ee4ffef7dc2f15e46740e78d380
@@@ -1270,10 -1270,9 +1270,10 @@@ as returned by `x-server-vendor'.
         ;; This is used by DEC's X server.
         '((65280 . remove)))))
  
 +;; Latin-1
  (let ((i 160))
    (while (< i 256)
 -    (puthash i (make-char 'latin-iso8859-1 i) x-keysym-table)
 +    (puthash i i x-keysym-table)
      (setq i (1+ i))))
  
  ;; Table from Kuhn's proposed additions to the `KEYSYM Encoding'
        ;; Kana: Fixme: needs conversion to Japanese charset -- seems
        ;; to require jisx0213, for which the Unicode translation
        ;; isn't clear.
 -      (#x47e . ?\e$,1s>\e(B)
 -      (#x4a1 . ?\e$,2=B\e(B)
 -      (#x4a2 . ?\\e$,2=L\e(B)
 -      (#x4a3 . ?\\e$,2=M\e(B)
 -      (#x4a4 . ?\e$,2=A\e(B)
 -      (#x4a5 . ?\e$,2?{\e(B)
 -      (#x4a6 . ?\e$,2?r\e(B)
 -      (#x4a7 . ?\e$,2?!\e(B)
 -      (#x4a8 . ?\e$,2?#\e(B)
 -      (#x4a9 . ?\e$,2?%\e(B)
 -      (#x4aa . ?\e$,2?'\e(B)
 -      (#x4ab . ?\e$,2?)\e(B)
 -      (#x4ac . ?\e$,2?c\e(B)
 -      (#x4ad . ?\e$,2?e\e(B)
 -      (#x4ae . ?\e$,2?g\e(B)
 -      (#x4af . ?\e$,2?C\e(B)
 -      (#x4b0 . ?\e$,2?|\e(B)
 -      (#x4b1 . ?\e$,2?"\e(B)
 -      (#x4b2 . ?\e$,2?$\e(B)
 -      (#x4b3 . ?\e$,2?&\e(B)
 -      (#x4b4 . ?\e$,2?(\e(B)
 -      (#x4b5 . ?\e$,2?*\e(B)
 -      (#x4b6 . ?\e$,2?+\e(B)
 -      (#x4b7 . ?\e$,2?-\e(B)
 -      (#x4b8 . ?\e$,2?/\e(B)
 -      (#x4b9 . ?\e$,2?1\e(B)
 -      (#x4ba . ?\e$,2?3\e(B)
 -      (#x4bb . ?\e$,2?5\e(B)
 -      (#x4bc . ?\e$,2?7\e(B)
 -      (#x4bd . ?\e$,2?9\e(B)
 -      (#x4be . ?\e$,2?;\e(B)
 -      (#x4bf . ?\e$,2?=\e(B)
 -      (#x4c0 . ?\e$,2??\e(B)
 -      (#x4c1 . ?\e$,2?A\e(B)
 -      (#x4c2 . ?\e$,2?D\e(B)
 -      (#x4c3 . ?\e$,2?F\e(B)
 -      (#x4c4 . ?\e$,2?H\e(B)
 -      (#x4c5 . ?\e$,2?J\e(B)
 -      (#x4c6 . ?\e$,2?K\e(B)
 -      (#x4c7 . ?\e$,2?L\e(B)
 -      (#x4c8 . ?\e$,2?M\e(B)
 -      (#x4c9 . ?\e$,2?N\e(B)
 -      (#x4ca . ?\e$,2?O\e(B)
 -      (#x4cb . ?\e$,2?R\e(B)
 -      (#x4cc . ?\e$,2?U\e(B)
 -      (#x4cd . ?\e$,2?X\e(B)
 -      (#x4ce . ?\e$,2?[\e(B)
 -      (#x4cf . ?\e$,2?^\e(B)
 -      (#x4d0 . ?\e$,2?_\e(B)
 -      (#x4d1 . ?\e$,2?`\e(B)
 -      (#x4d2 . ?\e$,2?a\e(B)
 -      (#x4d3 . ?\e$,2?b\e(B)
 -      (#x4d4 . ?\e$,2?d\e(B)
 -      (#x4d5 . ?\e$,2?f\e(B)
 -      (#x4d6 . ?\e$,2?h\e(B)
 -      (#x4d7 . ?\e$,2?i\e(B)
 -      (#x4d8 . ?\e$,2?j\e(B)
 -      (#x4d9 . ?\e$,2?k\e(B)
 -      (#x4da . ?\e$,2?l\e(B)
 -      (#x4db . ?\e$,2?m\e(B)
 -      (#x4dc . ?\e$,2?o\e(B)
 -      (#x4dd . ?\e$,2?s\e(B)
 -      (#x4de . ?\e$,2>{\e(B)
 -      (#x4df . ?\e$,2>|\e(B)
 +      (#x47e . ?\e(J~\e(B)
 +      (#x4a1 . ?\e$A!#\e(B)
 +      (#x4a2 . ?\\e$A!8\e(B)
 +      (#x4a3 . ?\\e$A!9\e(B)
 +      (#x4a4 . ?\e$A!"\e(B)
 +      (#x4a5 . ?\e$A!$\e(B)
 +      (#x4a6 . ?\e$A%r\e(B)
 +      (#x4a7 . ?\e$A%!\e(B)
 +      (#x4a8 . ?\e$A%#\e(B)
 +      (#x4a9 . ?\e$A%%\e(B)
 +      (#x4aa . ?\e$A%'\e(B)
 +      (#x4ab . ?\e$A%)\e(B)
 +      (#x4ac . ?\e$A%c\e(B)
 +      (#x4ad . ?\e$A%e\e(B)
 +      (#x4ae . ?\e$A%g\e(B)
 +      (#x4af . ?\e$A%C\e(B)
 +      (#x4b0 . ?\e$B!<\e(B)
 +      (#x4b1 . ?\e$A%"\e(B)
 +      (#x4b2 . ?\e$A%$\e(B)
 +      (#x4b3 . ?\e$A%&\e(B)
 +      (#x4b4 . ?\e$A%(\e(B)
 +      (#x4b5 . ?\e$A%*\e(B)
 +      (#x4b6 . ?\e$A%+\e(B)
 +      (#x4b7 . ?\e$A%-\e(B)
 +      (#x4b8 . ?\e$A%/\e(B)
 +      (#x4b9 . ?\e$A%1\e(B)
 +      (#x4ba . ?\e$A%3\e(B)
 +      (#x4bb . ?\e$A%5\e(B)
 +      (#x4bc . ?\e$A%7\e(B)
 +      (#x4bd . ?\e$A%9\e(B)
 +      (#x4be . ?\e$A%;\e(B)
 +      (#x4bf . ?\e$A%=\e(B)
 +      (#x4c0 . ?\e$A%?\e(B)
 +      (#x4c1 . ?\e$A%A\e(B)
 +      (#x4c2 . ?\e$A%D\e(B)
 +      (#x4c3 . ?\e$A%F\e(B)
 +      (#x4c4 . ?\e$A%H\e(B)
 +      (#x4c5 . ?\e$A%J\e(B)
 +      (#x4c6 . ?\e$A%K\e(B)
 +      (#x4c7 . ?\e$A%L\e(B)
 +      (#x4c8 . ?\e$A%M\e(B)
 +      (#x4c9 . ?\e$A%N\e(B)
 +      (#x4ca . ?\e$A%O\e(B)
 +      (#x4cb . ?\e$A%R\e(B)
 +      (#x4cc . ?\e$A%U\e(B)
 +      (#x4cd . ?\e$A%X\e(B)
 +      (#x4ce . ?\e$A%[\e(B)
 +      (#x4cf . ?\e$A%^\e(B)
 +      (#x4d0 . ?\e$A%_\e(B)
 +      (#x4d1 . ?\e$A%`\e(B)
 +      (#x4d2 . ?\e$A%a\e(B)
 +      (#x4d3 . ?\e$A%b\e(B)
 +      (#x4d4 . ?\e$A%d\e(B)
 +      (#x4d5 . ?\e$A%f\e(B)
 +      (#x4d6 . ?\e$A%h\e(B)
 +      (#x4d7 . ?\e$A%i\e(B)
 +      (#x4d8 . ?\e$A%j\e(B)
 +      (#x4d9 . ?\e$A%k\e(B)
 +      (#x4da . ?\e$A%l\e(B)
 +      (#x4db . ?\e$A%m\e(B)
 +      (#x4dc . ?\e$A%o\e(B)
 +      (#x4dd . ?\e$A%s\e(B)
 +      (#x4de . ?\e$B!+\e(B)
 +      (#x4df . ?\e$B!,\e(B)
        ;; Arabic
        (#x5ac . ?\e,G,\e(B)
        (#x5bb . ?\e,G;\e(B)
        (#x7f9 . ?\e,Fy\e(B)
         ;; Technical
        (#x8a1 . ?\e$,1|W\e(B)
 -      (#x8a2 . ?\e$,2 ,\e(B)
 -      (#x8a3 . ?\e$,2  \e(B)
 +      (#x8a2 . ?\e$A)0\e(B)
 +      (#x8a3 . ?\e$A)$\e(B)
        (#x8a4 . ?\e$,1{ \e(B)
        (#x8a5 . ?\e$,1{!\e(B)
 -      (#x8a6 . ?\e$,2 "\e(B)
 +      (#x8a6 . ?\e$A)&\e(B)
        (#x8a7 . ?\e$,1|A\e(B)
        (#x8a8 . ?\e$,1|C\e(B)
        (#x8a9 . ?\e$,1|D\e(B)
        (#x8ae . ?\e$,1|@\e(B)
        (#x8af . ?\e$,1|H\e(B)
        (#x8b0 . ?\e$,1|L\e(B)
 -      (#x8bc . ?\e$,1y$\e(B)
 -      (#x8bd . ?\e$,1y \e(B)
 -      (#x8be . ?\e$,1y%\e(B)
 -      (#x8bf . ?\e$,1xK\e(B)
 -      (#x8c0 . ?\e$,1xT\e(B)
 -      (#x8c1 . ?\e$,1x=\e(B)
 -      (#x8c2 . ?\e$,1x>\e(B)
 -      (#x8c5 . ?\e$,1x'\e(B)
 -      (#x8c8 . ?\e$,1x\\e(B)
 -      (#x8c9 . ?\e$,1xc\e(B)
 -      (#x8cd . ?\e$,1wT\e(B)
 -      (#x8ce . ?\e$,1wR\e(B)
 -      (#x8cf . ?\e$,1y!\e(B)
 -      (#x8d6 . ?\e$,1x:\e(B)
 -      (#x8da . ?\e$,1yB\e(B)
 -      (#x8db . ?\e$,1yC\e(B)
 -      (#x8dc . ?\e$,1xI\e(B)
 -      (#x8dd . ?\e$,1xJ\e(B)
 -      (#x8de . ?\e$,1xG\e(B)
 -      (#x8df . ?\e$,1xH\e(B)
 -      (#x8ef . ?\e$,1x"\e(B)
 +      (#x8bc . ?\e$A!\\e(B)
 +      (#x8bd . ?\e$A!Y\e(B)
 +      (#x8be . ?\e$A!]\e(B)
 +      (#x8bf . ?\e$A!R\e(B)
 +      (#x8c0 . ?\e$A!`\e(B)
 +      (#x8c1 . ?\e$A!X\e(B)
 +      (#x8c2 . ?\e$A!^\e(B)
 +      (#x8c5 . ?\e$B"`\e(B)
 +      (#x8c8 . ?\e$(G"D\e(B)
 +      (#x8c9 . ?\e$(O"l\e(B)
 +      (#x8cd . ?\e$B"N\e(B)
 +      (#x8ce . ?\e$B"M\e(B)
 +      (#x8cf . ?\e$A!T\e(B)
 +      (#x8d6 . ?\e$A!L\e(B)
 +      (#x8da . ?\e$B">\e(B)
 +      (#x8db . ?\e$B"?\e(B)
 +      (#x8dc . ?\e$A!I\e(B)
 +      (#x8dd . ?\e$A!H\e(B)
 +      (#x8de . ?\e$A!D\e(B)
 +      (#x8df . ?\e$A!E\e(B)
 +      (#x8ef . ?\e$B"_\e(B)
        (#x8f6 . ?\e$,1!R\e(B)
 -      (#x8fb . ?\e$,1vp\e(B)
 -      (#x8fc . ?\e$,1vq\e(B)
 -      (#x8fd . ?\e$,1vr\e(B)
 -      (#x8fe . ?\e$,1vs\e(B)
 +      (#x8fb . ?\e$A!{\e(B)
 +      (#x8fc . ?\e$A!|\e(B)
 +      (#x8fd . ?\e$A!z\e(B)
 +      (#x8fe . ?\e$A!}\e(B)
        ;; Special
 -      (#x9e0 . ?\e$,2"&\e(B)
 -      (#x9e1 . ?\e$,2!R\e(B)
 -      (#x9e2 . ?\e$,1}I\e(B)
 -      (#x9e3 . ?\e$,1}L\e(B)
 -      (#x9e4 . ?\e$,1}M\e(B)
 -      (#x9e5 . ?\e$,1}J\e(B)
 +      (#x9e0 . ?\e$A!t\e(B)
 +      (#x9e1 . ?\e$(C"F\e(B)
 +      (#x9e2 . ?\e$(GB*\e(B)
 +      (#x9e3 . ?\e$(GB-\e(B)
 +      (#x9e4 . ?\e$(GB.\e(B)
 +      (#x9e5 . ?\e$(GB+\e(B)
        (#x9e8 . ?\e$,1}d\e(B)
 -      (#x9e9 . ?\e$,1}K\e(B)
 -      (#x9ea . ?\e$,2 8\e(B)
 -      (#x9eb . ?\e$,2 0\e(B)
 -      (#x9ec . ?\e$,2 ,\e(B)
 -      (#x9ed . ?\e$,2 4\e(B)
 -      (#x9ee . ?\e$,2 \\e(B)
 +      (#x9e9 . ?\e$(GB,\e(B)
 +      (#x9ea . ?\e$A)<\e(B)
 +      (#x9eb . ?\e$A)4\e(B)
 +      (#x9ec . ?\e$A)0\e(B)
 +      (#x9ed . ?\e$A)8\e(B)
 +      (#x9ee . ?\e$A)`\e(B)
        (#x9ef . ?\e$,1|Z\e(B)
        (#x9f0 . ?\e$,1|[\e(B)
 -      (#x9f1 . ?\e$,2  \e(B)
 +      (#x9f1 . ?\e$A)$\e(B)
        (#x9f2 . ?\e$,1|\\e(B)
        (#x9f3 . ?\e$,1|]\e(B)
 -      (#x9f4 . ?\e$,2 <\e(B)
 -      (#x9f5 . ?\e$,2 D\e(B)
 -      (#x9f6 . ?\e$,2 T\e(B)
 -      (#x9f7 . ?\e$,2 L\e(B)
 -      (#x9f8 . ?\e$,2 "\e(B)
 +      (#x9f4 . ?\e$A)@\e(B)
 +      (#x9f5 . ?\e$A)H\e(B)
 +      (#x9f6 . ?\e$A)X\e(B)
 +      (#x9f7 . ?\e$A)P\e(B)
 +      (#x9f8 . ?\e$A)&\e(B)
        ;; Publishing
        (#xaa1 . ?\e$,1rc\e(B)
        (#xaa2 . ?\e$,1rb\e(B)
        (#xaa6 . ?\e$,1rh\e(B)
        (#xaa7 . ?\e$,1ri\e(B)
        (#xaa8 . ?\e$,1rj\e(B)
 -      (#xaa9 . ?\e$,1rt\e(B)
 -      (#xaaa . ?\e$,1rs\e(B)
 -      (#xaae . ?\e$,1s&\e(B)
 -      (#xaaf . ?\e$,1s%\e(B)
 -      (#xab0 . ?\e$,1v3\e(B)
 -      (#xab1 . ?\e$,1v4\e(B)
 -      (#xab2 . ?\e$,1v5\e(B)
 +      (#xaa9 . ?\e$(G!7\e(B)
 +      (#xaaa . ?\e$(G!9\e(B)
 +      (#xaae . ?\e$A!-\e(B)
 +      (#xaaf . ?\e$(G!-\e(B)
 +      (#xab0 . ?\e$(O'x\e(B)
 +      (#xab1 . ?\e$(O'y\e(B)
 +      (#xab2 . ?\e$(O'z\e(B)
        (#xab3 . ?\e$,1v6\e(B)
        (#xab4 . ?\e$,1v7\e(B)
        (#xab5 . ?\e$,1v8\e(B)
        (#xab6 . ?\e$,1v9\e(B)
        (#xab7 . ?\e$,1v:\e(B)
 -      (#xab8 . ?\e$,1uE\e(B)
 +      (#xab8 . ?\e$(G""\e(B)
        (#xabb . ?\e$,1rr\e(B)
        (#xabc . ?\e$,1{)\e(B)
        (#xabe . ?\e$,1{*\e(B)
 -      (#xac3 . ?\e$,1v;\e(B)
 -      (#xac4 . ?\e$,1v<\e(B)
 -      (#xac5 . ?\e$,1v=\e(B)
 -      (#xac6 . ?\e$,1v>\e(B)
 -      (#xac9 . ?\e$,1ub\e(B)
 +      (#xac3 . ?\e$(C({\e(B)
 +      (#xac4 . ?\e$(C(|\e(B)
 +      (#xac5 . ?\e$(C(}\e(B)
 +      (#xac6 . ?\e$(C(~\e(B)
 +      (#xac9 . ?\e$(D"o\e(B)
        (#xaca . ?\e$,2"s\e(B)
 -      (#xacc . ?\e$,2"!\e(B)
 -      (#xacd . ?\e$,2!w\e(B)
 -      (#xace . ?\e$,2"+\e(B)
 +      (#xacc . ?\e$(O##\e(B)
 +      (#xacd . ?\e$(O#!\e(B)
 +      (#xace . ?\e$A!p\e(B)
        (#xacf . ?\e$,2!o\e(B)
 -      (#xad0 . ?\e$,1rx\e(B)
 -      (#xad1 . ?\e$,1ry\e(B)
 -      (#xad2 . ?\e$,1r|\e(B)
 -      (#xad3 . ?\e$,1r}\e(B)
 +      (#xad0 . ?\e,F!\e(B)
 +      (#xad1 . ?\e,F"\e(B)
 +      (#xad2 . ?\e,Y4\e(B)
 +      (#xad3 . ?\e,Y!\e(B)
        (#xad4 . ?\e$,1u^\e(B)
 -      (#xad6 . ?\e$,1s2\e(B)
 -      (#xad7 . ?\e$,1s3\e(B)
 +      (#xad6 . ?\e$A!d\e(B)
 +      (#xad7 . ?\e$A!e\e(B)
        (#xad9 . ?\e$,2%]\e(B)
        (#xadb . ?\e$,2!l\e(B)
 -      (#xadc . ?\e$,2" \e(B)
 -      (#xadd . ?\e$,2!v\e(B)
 -      (#xade . ?\e$,2"/\e(B)
 +      (#xadc . ?\e$(O#$\e(B)
 +      (#xadd . ?\e$(O#"\e(B)
 +      (#xade . ?\e$A!q\e(B)
        (#xadf . ?\e$,2!n\e(B)
 -      (#xae0 . ?\e$,2"F\e(B)
 +      (#xae0 . ?\e$(O#?\e(B)
        (#xae1 . ?\e$,2!k\e(B)
        (#xae2 . ?\e$,2!m\e(B)
 -      (#xae3 . ?\e$,2!s\e(B)
 -      (#xae4 . ?\e$,2!}\e(B)
 -      (#xae5 . ?\e$,2"f\e(B)
 -      (#xae6 . ?\e$,1s"\e(B)
 +      (#xae3 . ?\e$A!w\e(B)
 +      (#xae4 . ?\e$(G!}\e(B)
 +      (#xae5 . ?\e$A!n\e(B)
 +      (#xae6 . ?\e$(O#@\e(B)
        (#xae7 . ?\e$,2!j\e(B)
 -      (#xae8 . ?\e$,2!r\e(B)
 -      (#xae9 . ?\e$,2!|\e(B)
 -      (#xaea . ?\e$,2"|\e(B)
 -      (#xaeb . ?\e$,2"~\e(B)
 -      (#xaec . ?\e$,2#c\e(B)
 -      (#xaed . ?\e$,2#f\e(B)
 -      (#xaee . ?\e$,2#e\e(B)
 +      (#xae8 . ?\e$A!x\e(B)
 +      (#xae9 . ?\e$(G!~\e(B)
 +      (#xaea . ?\e$(C"P\e(B)
 +      (#xaeb . ?\e$(O-~\e(B)
 +      (#xaec . ?\e$(O&@\e(B)
 +      (#xaed . ?\e$(O&<\e(B)
 +      (#xaee . ?\e$(O&>\e(B)
        (#xaf0 . ?\e$,2%`\e(B)
 -      (#xaf1 . ?\e$,1s \e(B)
 -      (#xaf2 . ?\e$,1s!\e(B)
 -      (#xaf3 . ?\e$,2%S\e(B)
 +      (#xaf1 . ?\e$B"w\e(B)
 +      (#xaf2 . ?\e$B"x\e(B)
 +      (#xaf3 . ?\e$(O'{\e(B)
        (#xaf4 . ?\e$,2%W\e(B)
 -      (#xaf5 . ?\e$,2#o\e(B)
 -      (#xaf6 . ?\e$,2#m\e(B)
 -      (#xaf7 . ?\e$,2#B\e(B)
 -      (#xaf8 . ?\e$,2#@\e(B)
 -      (#xaf9 . ?\e$,2"n\e(B)
 +      (#xaf5 . ?\e$B"t\e(B)
 +      (#xaf6 . ?\e$B"u\e(B)
 +      (#xaf7 . ?\e$A!a\e(B)
 +      (#xaf8 . ?\e$A!b\e(B)
 +      (#xaf9 . ?\e$(O&g\e(B)
        (#xafa . ?\e$,1zu\e(B)
        (#xafb . ?\e$,1uW\e(B)
        (#xafc . ?\e$,1s8\e(B)
        (#xafd . ?\e$,1rz\e(B)
 -      (#xafe . ?\e$,1r~\e(B)
 +      (#xafe . ?\e,Y%\e(B)
        ;; APL
        (#xba3 . ?<)
        (#xba6 . ?>)
 -      (#xba8 . ?\e$,1xH\e(B)
 -      (#xba9 . ?\e$,1xG\e(B)
 +      (#xba8 . ?\e$A!E\e(B)
 +      (#xba9 . ?\e$A!D\e(B)
        (#xbc0 . ?\e,A/\e(B)
 -      (#xbc2 . ?\e$,1ye\e(B)
 -      (#xbc3 . ?\e$,1xI\e(B)
 +      (#xbc2 . ?\e$A!M\e(B)
 +      (#xbc3 . ?\e$A!I\e(B)
        (#xbc4 . ?\e$,1zj\e(B)
        (#xbc6 . ?_)
        (#xbca . ?\e$,1x8\e(B)
        (#xbcc . ?\e$,1|5\e(B)
        (#xbce . ?\e$,1yd\e(B)
 -      (#xbcf . ?\e$,2"+\e(B)
 +      (#xbcf . ?\e$A!p\e(B)
        (#xbd3 . ?\e$,1zh\e(B)
 -      (#xbd6 . ?\e$,1xJ\e(B)
 -      (#xbd8 . ?\e$,1yC\e(B)
 -      (#xbda . ?\e$,1yB\e(B)
 +      (#xbd6 . ?\e$A!H\e(B)
 +      (#xbd8 . ?\e$B"?\e(B)
 +      (#xbda . ?\e$B">\e(B)
        (#xbdc . ?\e$,1yb\e(B)
        (#xbfc . ?\e$,1yc\e(B)
        ;; Hebrew
        ;; Latin-9
        (#x13bc . ?\e,b<\e(B)
        (#x13bd . ?\e,b=\e(B)
 -      (#x13be . ?\e,b>\e(B)
 +      (#x13be . ?\e,_/\e(B)
        ;; Currency
        (#x20a0 . ?\e$,1t@\e(B)
        (#x20a1 . ?\e$,1tA\e(B)
@@@ -2430,6 -2429,28 +2430,6 @@@ order until succeed."
  ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
  (create-fontset-from-x-resource)
  
 -;; Try to create a fontset from a font specification which comes
 -;; from initial-frame-alist, default-frame-alist, or X resource.
 -;; A font specification in command line argument (i.e. -fn XXXX)
 -;; should be already in default-frame-alist as a `font'
 -;; parameter.  However, any font specifications in site-start
 -;; library, user's init file (.emacs), and default.el are not
 -;; yet handled here.
 -
 -(let ((font (or (cdr (assq 'font initial-frame-alist))
 -              (cdr (assq 'font default-frame-alist))
 -              (x-get-resource "font" "Font")))
 -      xlfd-fields resolved-name)
 -  (if (and font
 -         (not (query-fontset font))
 -         (setq resolved-name (x-resolve-font-name font))
 -         (setq xlfd-fields (x-decompose-font-name font)))
 -      (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
 -        (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
 -      ;; Create a fontset from FONT.  The fontset name is
 -      ;; generated from FONT.
 -      (create-fontset-from-ascii-font font resolved-name "startup"))))
 -
  ;; Apply a geometry resource to the initial frame.  Put it at the end
  ;; of the alist, so that anything specified on the command line takes
  ;; precedence.
  (and (fboundp 'menu-bar-open)
       (global-set-key [f10] 'x-menu-bar-open))
  
+ (defcustom x-gtk-stock-map
+   '(
+     ("new" . "gtk-new")
+     ("open" . "gtk-open")
+     ("diropen" . "gtk-directory")
+     ("close" . "gtk-close")
+     ("save" . "gtk-save")
+     ("saveas" . "gtk-save-as")
+     ("undo" . "gtk-undo")
+     ("cut" . "gtk-cut")
+     ("copy" . "gtk-copy")
+     ("paste" . "gtk-paste")
+     ("search" . "gtk-find")
+     ("print" . "gtk-print")
+     ("preferences" . "gtk-preferences")
+     ("help" . "gtk-help")
+     ("left-arrow" . "gtk-go-back")
+     ("right-arrow" . "gtk-go-forward")
+     ("home" . "gtk-home")
+     ("jump-to" . "gtk-jump-to")
+     ("index" . "gtk-index")
+     ("search" . "gtk-find")
+     ("exit" . "gtk-quit"))
+   "How icons for tool bars are mapped to Gtk+ stock items.
+ Emacs must be compiled with the Gtk+ toolkit for this to have any effect."
+   :version "23.0"
+   :type 'alist
+   :group 'x)
+ (defun x-gtk-map-stock (file)
+   "Map icon with file name FILE to a Gtk+ stock name, using `x-gtk-stock-map'."
+   (let ((value (and file
+                   (assoc-string (file-name-sans-extension 
+                                  (file-name-nondirectory file))
+                                 x-gtk-stock-map))))
+     (and value (cdr value))))
  ;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
  ;;; x-win.el ends here
diff --combined make-dist
index 2c77940002a2e85bbc31791cecbe48f974203175,54cd3aca9d8086ec80f40a5db4f848d5d2a8914d..99f2d79110128128749522465f5ea56a3ec8f136
+++ b/make-dist
@@@ -317,11 -317,12 +317,12 @@@ for subdir in lisp site-lisp lispref li
              leim/SKK-DIC leim/ja-dic leim/quail \
              src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
              nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
 -            etc etc/e \
 +            etc etc/charsets etc/e \
              etc/images etc/images/ezimage etc/images/gnus etc/images/gud \
              etc/images/icons etc/images/low-color etc/images/mail \
-             etc/images/smilies etc/tree-widget etc/tree-widget/default \
-             etc/tree-widget/folder info man m4 msdos vms mac mac/inc \
+             etc/images/smilies etc/images/tree-widget \
+             etc/images/tree-widget/default etc/images/tree-widget/folder \
+             etc/refcards etc/tutorials info man m4 msdos vms mac mac/inc \
              mac/inc/sys mac/src mac/Emacs.app mac/Emacs.app/Contents \
              mac/Emacs.app/Contents/MacOS mac/Emacs.app/Contents/Resources \
              mac/Emacs.app/Contents/Resources/English.lproj
@@@ -572,7 -573,7 +573,7 @@@ echo "Making links to \`etc'
  ### Don't distribute gfdl.1, since no man page references it.
  (cd etc
   files=`ls -d * | grep -v CVS | grep -v RCS | grep -v 'Old' | grep -v '^e$' \
-         | grep -v '^charsets$' | grep -v '^images$' | grep -v '^tree-widget$'`
 -        | grep -v '^images$' | grep -v '^refcards$' | grep -v '^tutorials$'`
++        | grep -v '^charsets$' | grep -v '^images$' | grep -v '^refcards$' | grep -v '^tutorials$'`
   ln $files ../${tempdir}/etc
   ## If we ended up with a symlink, or if we did not get anything
   ## due to a cross-device symlink, copy the file.
   rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
   rm -f TAGS)
  
- echo "Making links to \`etc/charsets'"
- (cd etc/charsets
-  ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/etc/charsets
-  cd ../../${tempdir}/etc/charsets
-  rm -f *~ \#*\# *,v =* core)
- echo "Making links to \`etc/e'"
- (cd etc/e
-  ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/etc/e
-  cd ../../${tempdir}/etc/e
-  rm -f *~ \#*\# *,v =* core)
 -for dir in etc/e etc/tutorials etc/refcards ; do
++for dir in etc/charsets etc/e etc/tutorials etc/refcards ; do
+     echo "Making links to \`${dir}'"
+     (cd ${dir}
+       ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/${dir}
+       cd ../../${tempdir}/${dir}
+       rm -f *~ \#*\# *,v =* core)
+ done
  
  echo "Making links to \`etc/images'"
  (cd etc/images
   done)
  
  for dir in etc/images/ezimage etc/images/gnus etc/images/gud etc/images/icons \
-            etc/images/low-color etc/images/mail etc/images/smilies \
-            etc/tree-widget/default etc/tree-widget/folder ; do
+            etc/images/low-color etc/images/mail etc/images/smilies ; do
      echo "Making links to \`${dir}'"
      (cd ${dir}
       ln `ls -d * | grep -v CVS | grep -v RCS` ../../../${tempdir}/${dir}
       rm -f *~ \#*\# *,v =* core)
  done
  
+ for dir in etc/images/tree-widget/default etc/images/tree-widget/folder ; do
+     echo "Making links to \`${dir}'"
+     (cd ${dir}
+      ln `ls -d * | grep -v CVS | grep -v RCS` ../../../../${tempdir}/${dir}
+      cd ../../../../${tempdir}/${dir}
+      rm -f *~ \#*\# *,v =* core)
+ done
  echo "Making links to \`info'"
  # Don't distribute backups or autosaves.
  (cd info
diff --combined src/ChangeLog
index 06fcf372e81a9e1062f642fe546c4a5aa1f14257,231f18dd312409d392da35da00917b670372bc97..e2ff82ff975037e71082ce86491794ea7b2b7af8
+ 2007-08-28  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+       * keyboard.c: Qrtl is new.
+       (parse_tool_bar_item): Handle :rtl keyword.
+       (syms_of_keyboard): Intern :rtl keyword.
+       * dispextern.h (enum tool_bar_item_idx): Add TOOL_BAR_ITEM_RTL_IMAGE.
+       * gtkutil.c (xg_tool_bar_expose_callback): Just do SET_FRAME_GARBAGED
+       so no Lisp code is executed.
+       (file_for_image, find_rtl_image): New functions.
+       (xg_get_image_for_pixmap): Use file_for_image
+       (update_frame_tool_bar): If direction is RTL, use RTL image if
+       defined.  Use Gtk stock images if defined.
+ 2007-08-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+       * macterm.c (x_draw_composite_glyph_string_foreground): Draw rectangle
+       for nonexistent or zero-width glyph in composition glyph.
+ 2007-08-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * m/amdx86-64.h: Redirect to intel386.h if compiling for i386.
+       * xdisp.c (Finvisible_p): New function.
+       (syms_of_xdisp): defsubr it.
+ 2007-08-24  Juanma Barranquero  <lekktu@gmail.com>
+       * image.c (syms_of_image) <image-library-alist, cross-disabled-images>:
+       Doc fixes.
+ 2007-08-24  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+       * mac.c [MAC_OSX] (select_and_poll_event, sys_select): Fix last changes.
+ 2007-08-24  Martin Rudalics  <rudalics@gmx.at>
+       * fileio.c (Finsert_file_contents): Consult CHARS_MODIFF to tell
+       whether decoding has modified buffer contents.
+ 2007-08-24  Jason Rumney  <jasonr@gnu.org>
+       * image.c [HAVE_NTGUI]: Define dynamic loaded functions for SVG.
+       (Qgdk_pixbuf, Qglib) [HAVE_NTGUI]: New symbols.
+       (syms_of_image) [HAVE_NTGUI]: Intern and staticpro them.
+       (init_svg_functions) [HAVE_NTGUI]: New function.
+       (fn_g_type_init, fn_g_object_unref, fn_g_error_free): New #defines.
+       (svg_load_image): Use them.
+       (svg_load_image) [HAVE_NTGUI]: Implement background.
+ 2007-08-23  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+       * Makefile.in (RSVG_LIBS, RSVG_CFLAGS): New variables.
+       (ALL_CFLAGS): Use ${RSVG_CFLAGS} instead of @RSVG_CFLAGS@.
+       (LIBX): Remove @RSVG_LIBS@.
+       (LIBES): Add $(RSVG_LIBS).
+       * image.c (svg_load_image): Blend with specified background if exists.
+       Use IMAGE_BACKGROUND.  Add Mac OS Support.
+       * mac.c (wakeup_from_rne_enabled_p) [MAC_OSX]: Remove variable.
+       (ENABLE_WAKEUP_FROM_RNE, DISABLE_WAKEUP_FROM_RNE) [MAC_OSX]:
+       Remove macros.
+       [MAC_OSX] (socket_callback): Do nothing.
+       [MAC_OSX] (select_and_poll_event): Use CFRunLoopRunInMode instead of
+       ReceiveNextEvent.
+       [MAC_OSX] (sys_select): Likewise.  Don't set context as argument to
+       socket_callback.
+       (mac_wakeup_from_rne) [MAC_OSX]: Do nothing.
+ 2007-08-22  Glenn Morris  <rgm@gnu.org>
+       * image.c (x_find_image_file): Search in etc/images/ rather than etc/.
+ 2007-08-22  Paul Pogonyshev  <pogonyshev@gmx.net>
+       * Makefile.in (ALL_CFLAGS, LIBX): Add RSVG_LIBS.
+       * image.c: Add support for SVG images.  Some additional comments
+       by Joakim Verona <joakim@verona.se>.  When HAVE_RSVG is defined:
+       (svg_image_p): New function to test for SVG image.
+       (svg_load): New function to load SVG image.
+       (svg_load_image): New function, helper for svg_load.
+       (Qsvg): New Lisp_object.
+       (svg_keyword_index): New enum.
+       (svg_format): New static `image_keyword' struct.
+       (svg_type): New static `image_type' struct.
+       (librsvg/rsvg.h): Include it.
+ 2007-08-23  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * lread.c (load_warn_old_style_backquotes): Fix up array size typo.
+ 2007-08-22  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * lread.c (Qold_style_backquotes): New var.
+       (syms_of_lread): Init and staticpro it.
+       (load_warn_old_style_backquotes): New fun.
+       (Fload): Use them to warn about old style backquotes.
+       (end_of_file_error, Fload): Remove unused vars.
+       * lisp.h (Fclear_face_cache, Fx_send_client_event): Declare.
+       * lread.c (Vold_style_backquotes): New var.
+       (syms_of_lread): Init and export it to Elisp.
+       (read1): Set it when we find an old-style (back)quote.
+ 2007-08-22  Jason Rumney  <jasonr@gnu.org>
+       * w32reg.c (SYSTEM_DEFAULT_RESOURCES): Add missing NULL terminator.
+ 2007-08-22  Katsumi Yamaoka  <yamaoka@jpl.org>
+       * puresize.h (BASE_PURESIZE): Increase to 1140000.
  2007-08-19  Richard Stallman  <rms@gnu.org>
  
        * eval.c (Ffunction, Fquote): Signal error if not 1 argument.
        (mac_valid_selection_target_p): Rename from valid_scrap_target_type_p.
        (mac_clear_selection): Rename from clear_scrap.
        (get_flavor_type_from_symbol): New argument SEL and subsume function of
-       scrap_has_target_type.   All uses changed.
+       scrap_has_target_type.  All uses changed.
        (mac_get_selection_ownership_info, mac_valid_selection_value_p)
        (mac_selection_has_target_p): New functions.
        (mac_put_selection_value): Rename from put_scrap_string.
        * regex.c (re_error_msgid): Add an entry for REG_ERANGEX.
        (regex_compile): Return REG_ERANGEX if appropriate.
  
 -2004-10-22  Kenichi Handa  <handa@m17n.org>
 -
 -      * editfns.c (Ftranslate_region_internal): New function.
 -      (syms_of_editfns): Defsubr it.
 -
  2004-10-22  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
  
        * xfns.c (xic_create_xfontset): Initialize missing_list to NULL.
diff --combined src/Makefile.in
index f4d548b746024ce812441171f503ab8c1ce4c449,d34c272faa47285c42b3f4f2d747be5aa848091e..217e9846e23fba2893dcf78ae64060adcb287963
@@@ -51,7 -51,6 +51,7 @@@ LIBOBJS = @LIBOBJS
  dot = .
  dotdot = ${dot}${dot}
  lispsource = ${srcdir}/$(dot)$(dot)/lisp/
 +admindir = $(srcdir)/$(dot)$(dot)/admin/
  libsrc = $(dot)$(dot)/lib-src/
  etc = $(dot)$(dot)/etc/
  oldXMenudir = $(dot)$(dot)/oldXMenu/
@@@ -282,7 -281,7 +282,7 @@@ TOOLKIT_DEFINES 
  
  /* 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 $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@
 -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${CFLAGS}
++ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@
  .c.o:
        $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
  
@@@ -470,6 -469,9 +470,9 @@@ LIBX= $(LIBXMENU) LD_SWITCH_X_SITE -lX1
  LIBSOUND= @LIBSOUND@
  CFLAGS_SOUND= @CFLAGS_SOUND@
  
+ RSVG_LIBS= @RSVG_LIBS@
+ RSVG_CFLAGS= @RSVG_CFLAGS@
  #ifndef ORDINARY_LINK
  /* Fix linking if compiled with GCC.  */
  #ifdef __GNUC__
@@@ -589,27 -591,10 +592,27 @@@ emacsapp = $(PWD)/$(mac)Emacs.app
  emacsappsrc = ${srcdir}/../mac/Emacs.app/
  #endif
  
 +#ifdef HAVE_WINDOW_SYSTEM
 +#ifdef USE_FONT_BACKEND
 +FONTSRC = font.h
 +#ifdef HAVE_X_WINDOWS
 +#if defined (HAVE_XFT)
 +FONTOBJ = font.o xfont.o ftfont.o xftfont.o ftxfont.o
 +#elif defined (HAVE_FREETYPE)
 +FONTOBJ = font.o xfont.o ftfont.o ftxfont.o
 +#else /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */
 +FONTOBJ = font.o xfont.o
 +#endif /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */
 +#else /* ! HAVE_X_WINDOWS */
 +FONTOBJ = font.o
 +#endif /* ! HAVE_X_WINDOWS */
 +#endif /* USE_FONT_BACKEND */
 +#endif /* HAVE_WINDOW_SYSTEM */
 +
  /* lastfile must follow all files
     whose initialized data areas should be dumped as pure by dump-emacs.  */
  obj=    dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \
 -      charset.o coding.o category.o ccl.o \
 +      charset.o coding.o category.o ccl.o character.o chartab.o \
        cm.o term.o xfaces.o $(XOBJ) $(GTK_OBJ)\
        emacs.o keyboard.o macros.o keymap.o sysdep.o \
        buffer.o filelock.o insdel.o marker.o \
        process.o callproc.o \
        region-cache.o sound.o atimer.o \
        doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \
 -      $(MSDOS_OBJ) $(MAC_OBJ) $(CYGWIN_OBJ)
 +      $(MSDOS_OBJ) $(MAC_OBJ) $(CYGWIN_OBJ) $(FONTOBJ)
  
  /* Object files used on some machine or other.
     These go in the DOC file on all machines
@@@ -630,7 -615,7 +633,7 @@@ SOME_MACHINE_OBJECTS = sunfns.o dosfns.
    xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
    mac.o macterm.o macfns.o macmenu.o macselect.o fontset.o \
    w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
 -  w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o
 +  w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONTOBJ)
  
  
  #ifdef TERMINFO
@@@ -758,7 -743,6 +761,7 @@@ lisp= 
        ${lispsource}buff-menu.elc \
        ${lispsource}button.elc \
        ${lispsource}emacs-lisp/byte-run.elc \
 +      ${lispsource}composite.elc \
        ${lispsource}cus-face.elc \
        ${lispsource}cus-start.elc \
        ${lispsource}custom.elc \
        ${lispsource}international/mule-conf.el \
        ${lispsource}international/mule-cmds.elc \
        ${lispsource}international/characters.elc \
 -      ${lispsource}international/ucs-tables.elc \
 -      ${lispsource}international/utf-8.elc \
 -      ${lispsource}international/utf-16.elc \
 -      ${lispsource}international/latin-1.el \
 -      ${lispsource}international/latin-2.el \
 -      ${lispsource}international/latin-3.el \
 -      ${lispsource}international/latin-4.el \
 -      ${lispsource}international/latin-5.el \
 -      ${lispsource}international/latin-8.el \
 -      ${lispsource}international/latin-9.el \
 +      ${lispsource}international/charprop.el \
        ${lispsource}case-table.elc \
 -      ${lispsource}language/chinese.elc \
 -      ${lispsource}language/cyrillic.elc \
 -      ${lispsource}language/indian.elc \
 +      ${lispsource}language/chinese.el \
 +      ${lispsource}language/cyrillic.el \
 +      ${lispsource}language/indian.el \
        ${lispsource}language/devanagari.el \
        ${lispsource}language/kannada.el \
        ${lispsource}language/malayalam.el \
        ${lispsource}language/japanese.el \
        ${lispsource}language/korean.el \
        ${lispsource}language/lao.el \
 +      ${lispsource}language/tai-viet.el \
        ${lispsource}language/thai.el \
        ${lispsource}language/tibetan.elc \
 -      ${lispsource}language/vietnamese.elc \
 +      ${lispsource}language/vietnamese.el \
        ${lispsource}language/misc-lang.el \
        ${lispsource}language/utf-8-lang.el \
        ${lispsource}language/georgian.el \
@@@ -850,7 -842,6 +853,7 @@@ shortlisp= 
        ../lisp/buff-menu.elc \
        ../lisp/button.elc \
        ../lisp/emacs-lisp/byte-run.elc \
 +      ../lisp/composite.elc \
        ../lisp/cus-face.elc \
        ../lisp/cus-start.elc \
        ../lisp/custom.elc \
        ../lisp/international/mule-conf.el \
        ../lisp/international/mule-cmds.elc \
        ../lisp/international/characters.elc \
 -      ../lisp/international/ucs-tables.elc \
 -      ../lisp/international/utf-8.elc \
 -      ../lisp/international/utf-16.elc \
 -      ../lisp/international/latin-1.el \
 -      ../lisp/international/latin-2.el \
 -      ../lisp/international/latin-3.el \
 -      ../lisp/international/latin-4.el \
 -      ../lisp/international/latin-5.el \
 -      ../lisp/international/latin-8.el \
 -      ../lisp/international/latin-9.el \
        ../lisp/case-table.elc \
 -      ../lisp/language/chinese.elc \
 -      ../lisp/language/cyrillic.elc \
 -      ../lisp/language/indian.elc \
 +      ../lisp/language/chinese.el \
 +      ../lisp/language/cyrillic.el \
 +      ../lisp/language/indian.el \
        ../lisp/language/devanagari.el \
        ../lisp/language/kannada.el \
        ../lisp/language/malayalam.el \
        ../lisp/language/japanese.el \
        ../lisp/language/korean.el \
        ../lisp/language/lao.el \
 +      ../lisp/language/tai-viet.el \
        ../lisp/language/thai.el \
        ../lisp/language/tibetan.elc \
 -      ../lisp/language/vietnamese.elc \
 +      ../lisp/language/vietnamese.el \
        ../lisp/language/misc-lang.el \
        ../lisp/language/utf-8-lang.el \
        ../lisp/language/georgian.el \
@@@ -949,11 -949,10 +952,11 @@@ SOME_MACHINE_LISP = ${dotdot}/lisp/mous
     Note that SunOS needs -lm to come before -lc; otherwise, you get
     duplicated symbols.  If the standard libraries were compiled
     with GCC, we might need gnulib again after them.  */
- LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) LIBGPM \
+ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) LIBGPM \
     LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
 -   LIBS_DEBUG $(GETLOADAVG_LIBS) $(GNULIB_VAR) LIB_MATH LIB_STANDARD \
 -   $(GNULIB_VAR)
 +   LIBS_DEBUG $(GETLOADAVG_LIBS) \
 +   @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ \
 +   $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR)
  
  /* Enable recompilation of certain other files depending on system type.  */
  
  #define OBJECTS_MACHINE
  #endif
  
 -RUN_TEMACS = ./temacs
 +#ifdef HAVE_SHM
 +RUN_TEMACS = `/bin/pwd`/temacs -nl
 +#else
 +RUN_TEMACS = `/bin/pwd`/temacs
 +#endif
  
  all: emacs${EXEEXT} OTHER_FILES
  
@@@ -978,7 -973,11 +981,7 @@@ emacs${EXEEXT}: temacs${EXEEXT} ${etc}D
        rm -f emacs${EXEEXT}
        ln temacs${EXEEXT} emacs${EXEEXT}
  #else
 -#ifdef HAVE_SHM
 -      LC_ALL=C $(RUN_TEMACS) -nl -batch -l loadup dump
 -#else /* ! defined (HAVE_SHM) */
        LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump
 -#endif /* ! defined (HAVE_SHM) */
  #endif /* ! defined (CANNOT_DUMP) */
        -./emacs -q -batch -f list-load-path-shadows
  
@@@ -998,16 -997,6 +1001,16 @@@ ${etc}DOC: ${libsrc}make-docfile${EXEEX
  ${libsrc}make-docfile${EXEEXT}:
        cd ${libsrc}; ${MAKE} ${MFLAGS} make-docfile${EXEEXT}
  
 +#ifdef HAVE_UNIDATA
 +UNIDATA=${admindir}unidata/UnicodeData.txt
 +
 +${lispsource}international/charprop.el: temacs${EXEEXT} ${UNIDATA}
 +      RUNEMACS="$(RUN_TEMACS)"; \
 +      cd ${admindir}unidata; \
 +      $(MAKE) $(MFLAGS) \
 +        RUNEMACS="$${RUNEMACS}" DSTDIR=${lispsource}international
 +#endif
 +
  /* Some systems define this to cause parallel Make-ing.  */
  #ifndef MAKE_PARALLEL
  #define MAKE_PARALLEL
@@@ -1114,81 -1103,72 +1117,81 @@@ alloca.o: alloca.c blockinput.h atimer.
     it is so often changed in ways that do not require any recompilation
     and so rarely changed in ways that do require any.  */
  
 -abbrev.o: abbrev.c buffer.h window.h dispextern.h commands.h charset.h \
 +abbrev.o: abbrev.c buffer.h window.h dispextern.h commands.h character.h \
        syntax.h $(config_h)
  buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
 -   dispextern.h $(INTERVAL_SRC) blockinput.h atimer.h systime.h charset.h \
 +   dispextern.h $(INTERVAL_SRC) blockinput.h atimer.h systime.h character.h \
     $(config_h)
  callint.o: callint.c window.h commands.h buffer.h keymap.h \
     keyboard.h dispextern.h $(config_h)
  callproc.o: callproc.c epaths.h buffer.h commands.h $(config_h) \
 -      process.h systty.h syssignal.h charset.h coding.h ccl.h msdos.h \
 +      process.h systty.h syssignal.h character.h coding.h ccl.h msdos.h \
          composite.h w32.h blockinput.h atimer.h systime.h
 -casefiddle.o: casefiddle.c syntax.h commands.h buffer.h composite.h \
 +casefiddle.o: casefiddle.c syntax.h commands.h buffer.h character.h \
 +   composite.h \
        charset.h keymap.h $(config_h)
  casetab.o: casetab.c buffer.h $(config_h)
 -category.o: category.c category.h buffer.h charset.h keymap.h $(config_h)
 -ccl.o: ccl.c ccl.h charset.h coding.h $(config_h)
 -charset.o: charset.c charset.h buffer.h coding.h composite.h disptab.h \
 -      $(config_h)
 -coding.o: coding.c coding.h ccl.h buffer.h charset.h intervals.h composite.h \
 +category.o: category.c category.h buffer.h charset.h keymap.h \
 +      character.h $(config_h)
 +ccl.o: ccl.c ccl.h charset.h character.h coding.h $(config_h)
 +character.o: character.c character.h buffer.h charset.h composite.h disptab.h \
 +   $(config.h)
 +charset.o: charset.c charset.h character.h buffer.h coding.h composite.h \
 +   disptab.h $(config_h)
 +chartab.o: charset.h character.h $(config.h)
 +coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h intervals.h composite.h \
        window.h dispextern.h $(config_h)
  cm.o: cm.c cm.h termhooks.h $(config_h)
 -cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \
 +cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h $(config_h) \
        msdos.h dispextern.h keyboard.h keymap.h
  pre-crt0.o: pre-crt0.c
  ecrt0.o: ecrt0.c $(config_h)
        CRT0_COMPILE ${srcdir}/ecrt0.c
 -dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \
 -   systime.h blockinput.h atimer.h
 +dired.o: dired.c commands.h buffer.h $(config_h) character.h charset.h \
 +   coding.h regex.h systime.h blockinput.h atimer.h
  dispnew.o: dispnew.c  systty.h systime.h commands.h process.h frame.h \
     window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \
     disptab.h indent.h intervals.h \
 -   xterm.h blockinput.h atimer.h charset.h msdos.h composite.h keyboard.h \
 +   xterm.h blockinput.h atimer.h character.h msdos.h composite.h keyboard.h \
     $(config_h)
 -doc.o: doc.c $(config_h) epaths.h buffer.h keyboard.h keymap.h charset.h
 -doprnt.o: doprnt.c charset.h $(config_h)
 +doc.o: doc.c $(config_h) epaths.h buffer.h keyboard.h keymap.h character.h
 +doprnt.o: doprnt.c character.h $(config_h)
  dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \
     msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \
     $(config_h)
 -editfns.o: editfns.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
 +editfns.o: editfns.c window.h buffer.h systime.h $(INTERVAL_SRC) character.h \
     coding.h dispextern.h frame.h blockinput.h atimer.h $(config_h)
  emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
     termhooks.h buffer.h atimer.h systime.h $(INTERVAL_SRC) $(config_h) \
     window.h dispextern.h keyboard.h keymap.h
 -fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
 +fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) character.h \
     coding.h msdos.h dispextern.h blockinput.h atimer.h $(config_h)
 -filelock.o: filelock.c buffer.h charset.h coding.h systime.h epaths.h $(config_h)
 +filelock.o: filelock.c buffer.h character.h charset.h coding.h systime.h \
 +   epaths.h $(config_h)
  filemode.o: filemode.c  $(config_h)
  frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
 -   blockinput.h atimer.h systime.h buffer.h charset.h fontset.h \
 +   blockinput.h atimer.h systime.h buffer.h character.h fontset.h \
     msdos.h dosfns.h dispextern.h w32term.h macterm.h $(config_h)
  fringe.o: fringe.c dispextern.h frame.h window.h buffer.h $(config_h)
 -fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h charset.h frame.h \
 -   keyboard.h $(config_h)
 +font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \
 +   font.h $(config_h)
 +ftfont.o: dispextern.h frame.h character.h charset.h font.h $(config_h)
 +fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h character.h \
 +   charset.h frame.h keyboard.h $(FONTSRC) $(config_h)
  getloadavg.o: getloadavg.c $(config_h)
  image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \
     systime.h xterm.h w32term.h w32gui.h macterm.h macgui.h $(config_h)
  indent.o: indent.c frame.h window.h indent.h buffer.h $(config_h) termchar.h \
 -   termopts.h disptab.h region-cache.h charset.h composite.h dispextern.h \
 -   keyboard.h
 -insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h charset.h \
 +   termopts.h disptab.h region-cache.h character.h category.h composite.h \
 +   dispextern.h keyboard.h
 +insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h character.h \
     dispextern.h atimer.h systime.h region-cache.h $(config_h)
 -keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h charset.h \
 +keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \
     commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
     systty.h systime.h dispextern.h syntax.h $(INTERVAL_SRC) blockinput.h \
     atimer.h xterm.h puresize.h msdos.h keymap.h w32term.h macterm.h $(config_h)
  keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
 -   atimer.h systime.h puresize.h charset.h intervals.h keymap.h window.h \
 +   atimer.h systime.h puresize.h character.h intervals.h keymap.h window.h \
     $(config_h)
  lastfile.o: lastfile.c  $(config_h)
  macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \
@@@ -1197,36 -1177,34 +1200,36 @@@ malloc.o: malloc.c $(config_h
  gmalloc.o: gmalloc.c $(config_h)
  ralloc.o: ralloc.c $(config_h)
  vm-limit.o: vm-limit.c mem-limits.h $(config_h)
 -marker.o: marker.c buffer.h charset.h $(config_h)
 +marker.o: marker.c buffer.h character.h $(config_h)
  md5.o: md5.c md5.h $(config_h)
  minibuf.o: minibuf.c syntax.h dispextern.h frame.h window.h keyboard.h \
 -   buffer.h commands.h charset.h msdos.h $(INTERVAL_SRC) keymap.h $(config_h)
 +   buffer.h commands.h character.h msdos.h $(INTERVAL_SRC) keymap.h $(config_h)
  mktime.o: mktime.c $(config_h)
  msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \
 -   termopts.h termchar.h charset.h coding.h ccl.h disptab.h window.h \
 +   termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \
     keyboard.h intervals.h buffer.h commands.h blockinput.h atimer.h $(config_h)
  process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
     commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \
     blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \
     keyboard.h $(config_h)
 -regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h
 +regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h character.h \
 +   charset.h
  region-cache.o: region-cache.c buffer.h region-cache.h $(config_h)
  scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
     $(config_h)
  search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
 -   blockinput.h atimer.h systime.h category.h charset.h composite.h \
 -   $(INTERVAL_SRC) $(config_h)
 +   blockinput.h atimer.h systime.h category.h character.h charset.h \
 +   composite.h $(INTERVAL_SRC) \
 +   $(config_h)
  strftime.o: strftime.c $(config_h)
 -syntax.o: syntax.c syntax.h buffer.h commands.h category.h charset.h \
 +syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \
     composite.h keymap.h regex.h $(INTERVAL_SRC) $(config_h)
  sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
     process.h dispextern.h termhooks.h termchar.h termopts.h \
     frame.h atimer.h window.h msdos.h dosfns.h keyboard.h  $(config_h)
  term.o: term.c termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \
 -   disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h \
 -   window.h keymap.h blockinput.h atimer.h systime.h
 +   disptab.h dispextern.h keyboard.h character.h charset.h coding.h ccl.h \
 +   msdos.h window.h keymap.h blockinput.h atimer.h systime.h
  termcap.o: termcap.c $(config_h)
  terminfo.o: terminfo.c $(config_h)
  tparam.o: tparam.c $(config_h)
@@@ -1243,32 -1221,23 +1246,32 @@@ window.o: window.c indent.h commands.h 
     termhooks.h disptab.h keyboard.h dispextern.h msdos.h composite.h \
     keymap.h blockinput.h atimer.h systime.h $(INTERVAL_SRC) \
     xterm.h w32term.h macterm.h $(config_h)
 -xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h coding.h \
 -   termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \
 -   keyboard.h $(INTERVAL_SRC) region-cache.h xterm.h w32term.h macterm.h \
 -   msdos.h composite.h fontset.h blockinput.h atimer.h systime.h keymap.h
 -xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \
 -   window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h \
 -   keyboard.h fontset.h w32term.h macterm.h $(INTERVAL_SRC) $(config_h)
 +xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \
 +   coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h     \
 +   charset.h $(config_h) keyboard.h $(INTERVAL_SRC) region-cache.h xterm.h    \
 +   w32term.h macterm.h msdos.h composite.h fontset.h blockinput.h atimer.h    \
 +   systime.h keymap.h $(FONTSRC)
 +xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \
 +   window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h       \
 +   systime.h keyboard.h fontset.h w32term.h macterm.h $(INTERVAL_SRC) \
 +   $(FONTSRC) $(config_h)
  xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
     $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
 -   charset.h gtkutil.h $(config_h)
 +   character.h charset.h coding.h gtkutil.h $(config_h) termhooks.h \
 +   fontset.h $(FONTSRC)
 +xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
 +   font.h $(config_h)
 +xftfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
 +   font.h $(config_h)
 +ftxfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
 +   font.h $(config_h)
  xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
 -   keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h \
 -   gtkutil.h msdos.h coding.h $(config_h)
 +   charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \
 +   systime.h gtkutil.h msdos.h coding.h $(config_h)
  xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
 -  dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
 -  keyboard.h gnu.h charset.h ccl.h fontset.h composite.h \
 -  coding.h process.h gtkutil.h $(config_h)
 +   dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
 +   keyboard.h gnu.h character.h charset.h ccl.h fontset.h composite.h \
 +   coding.h process.h gtkutil.h $(FONTSRC) $(config_h)
  xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \
    buffer.h atimer.h systime.h $(config_h)
  xrdb.o: xrdb.c $(config_h) epaths.h
@@@ -1285,31 -1254,29 +1288,31 @@@ atimer.o: atimer.c atimer.h systime.h $
  /* The files of Lisp proper */
  
  alloc.o: alloc.c process.h frame.h window.h buffer.h  puresize.h syssignal.h keyboard.h \
 - blockinput.h atimer.h systime.h charset.h dispextern.h $(config_h) $(INTERVAL_SRC)
 -bytecode.o: bytecode.c buffer.h syntax.h charset.h window.h dispextern.h \
 + blockinput.h atimer.h systime.h character.h dispextern.h $(config_h) \
 + $(INTERVAL_SRC)
 +bytecode.o: bytecode.c buffer.h syntax.h character.h window.h dispextern.h \
    frame.h xterm.h $(config_h)
 -data.o: data.c buffer.h puresize.h charset.h syssignal.h keyboard.h frame.h $(config_h)
 +data.o: data.c buffer.h puresize.h character.h syssignal.h keyboard.h frame.h \
 + $(config_h)
  eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \
    dispextern.h $(config_h)
  floatfns.o: floatfns.c $(config_h)
 -fns.o: fns.c commands.h $(config_h) frame.h buffer.h charset.h keyboard.h \
 +fns.o: fns.c commands.h $(config_h) frame.h buffer.h character.h keyboard.h \
   keymap.h frame.h window.h dispextern.h $(INTERVAL_SRC) coding.h md5.h \
   blockinput.h atimer.h systime.h xterm.h
 -print.o: print.c process.h frame.h window.h buffer.h keyboard.h charset.h \
 -   $(config_h) dispextern.h termchar.h $(INTERVAL_SRC) msdos.h composite.h \
 +print.o: print.c process.h frame.h window.h buffer.h keyboard.h character.h \
 +   $(config_h) dispextern.h termchar.h $(INTERVAL_SRC) msdos.h composite.h  \
     blockinput.h atimer.h systime.h
 -lread.o: lread.c commands.h keyboard.h buffer.h epaths.h charset.h \
 - $(config_h) $(INTERVAL_SRC) termhooks.h coding.h msdos.h blockinput.h \
 - atimer.h systime.h
 +lread.o: lread.c commands.h keyboard.h buffer.h epaths.h character.h \
 + charset.h $(config_h) $(INTERVAL_SRC) termhooks.h coding.h msdos.h \
 + blockinput.h atimer.h systime.h
  
  /* Text properties support */
  textprop.o: textprop.c buffer.h window.h dispextern.h $(INTERVAL_SRC) \
        $(config_h)
  intervals.o: intervals.c buffer.h $(INTERVAL_SRC) keyboard.h puresize.h \
        keymap.h $(config_h)
 -composite.o: composite.c buffer.h  charset.h $(INTERVAL_SRC) $(config_h)
 +composite.o: composite.c buffer.h  character.h $(INTERVAL_SRC) $(config_h)
  
  /* System-specific programs to be made.
     OTHER_FILES and OBJECTS_MACHINE
@@@ -1427,10 -1394,14 +1430,10 @@@ bootstrap: bootstrap-emacs${EXEEXT
  /* Dump an Emacs executable named bootstrap-emacs containing the
     files from loadup.el in source form.  */
  
 -bootstrap-emacs${EXEEXT}: temacs${EXEEXT}
 +bootstrap-emacs${EXEEXT}: temacs${EXEEXT} ${lispsource}international/charprop.el
  #ifdef CANNOT_DUMP
        ln temacs${EXEEXT} bootstrap-emacs${EXEEXT}
  #else
 -#ifdef HAVE_SHM
 -      $(RUN_TEMACS) -nl -batch -l loadup bootstrap
 -#else /* ! defined (HAVE_SHM) */
        $(RUN_TEMACS) --batch --load loadup bootstrap
 -#endif /* ! defined (HAVE_SHM) */
        mv -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}
  #endif /* ! defined (CANNOT_DUMP) */
diff --combined src/config.in
index abe5119add8f8f6ac1ac44382e892206932e9334,e050ceae44f2569f23f3041e1789559083f96b3e..f2636c50626c75c776430516be0b26a62b60d3fc
@@@ -156,9 -156,6 +156,9 @@@ Boston, MA 02110-1301, USA.  *
  /* Define to 1 if you have the `fpathconf' function. */
  #undef HAVE_FPATHCONF
  
 +/* Define to 1 if you have freetype and fontconfig libraries. */
 +#undef HAVE_FREETYPE
 +
  /* Define to 1 if you have the `frexp' function. */
  #undef HAVE_FREXP
  
  /* Define to 1 if you have the `ncurses' library (-lncurses). */
  #undef HAVE_LIBNCURSES
  
 +/* Define to 1 if you have libotf library. */
 +#undef HAVE_LIBOTF
 +
  /* Define to 1 if you have the <libpng/png.h> header file. */
  #undef HAVE_LIBPNG_PNG_H
  
  /* Define to 1 if you have the `rmdir' function. */
  #undef HAVE_RMDIR
  
+ /* Define to 1 if using librsvg. */
+ #undef HAVE_RSVG
  /* Define to 1 if you have the `select' function. */
  #undef HAVE_SELECT
  
  /* Define to 1 if you have the Xft library. */
  #undef HAVE_XFT
  
 +/* Define to 1 if you have the Xft library. */
 +#undef HAVE_XFT
 +
  /* Define to 1 if XIM is available */
  #undef HAVE_XIM
  
  /* Define to the unexec source file name. */
  #undef UNEXEC_SRC
  
 +/* Define to 1 if we should use font-backend. */
 +#undef USE_FONT_BACKEND
 +
  /* Define to 1 if we should use toolkit scroll bars. */
  #undef USE_TOOLKIT_SCROLL_BARS
  
diff --combined src/dispextern.h
index 58ba3a91ee347c2ffc3df01927d761ac81823a7d,9e899f9ccb2f3466a4957733dba513831bbf54fd..c07b4b36f925f0cbefc772b30db5c02587a341cc
@@@ -1220,11 -1220,6 +1220,11 @@@ struct glyph_strin
       *clip_tail, not including their overhangs.  */
    struct glyph_string *clip_head, *clip_tail;
  
 +#ifdef USE_FONT_BACKEND
 +  /* The current clipping area.  */
 +  int clip_x, clip_y, clip_width, clip_height;
 +#endif        /* USE_FONT_BACKEND */
 +
    struct glyph_string *next, *prev;
  };
  
@@@ -1396,7 -1391,6 +1396,7 @@@ enum lface_attribute_inde
    LFACE_FONT_INDEX,
    LFACE_INHERIT_INDEX,
    LFACE_AVGWIDTH_INDEX,
 +  LFACE_FONTSET_INDEX,
    LFACE_VECTOR_SIZE
  };
  
@@@ -1481,12 -1475,10 +1481,12 @@@ struct fac
       reallocated.  */
    int font_info_id;
  
 -  /* Fontset ID if this face uses a fontset, or -1.  This is only >= 0
 -     if the face was realized for a composition sequence.
 -     Otherwise, a specific font is loaded from the set of fonts
 -     specified by the fontset given by the family attribute of the face.  */
 +#ifdef USE_FONT_BACKEND
 +  struct font_info *font_info;
 +#endif        /* USE_FONT_BACKEND */
 +
 +  /* Fontset ID if for this face's fontset.  Non-ASCII faces derived
 +     from the same ASCII face have the same fontset.  */
    int fontset;
  
    /* Pixmap width and height.  */
    /* The hash value of this face.  */
    unsigned hash;
  
 -  /* The charset for which this face was realized if it was realized
 -     for use in multibyte text.  If fontset >= 0, this is the charset
 -     of the first character of the composition sequence.  A value of
 -     charset < 0 means the face was realized for use in unibyte text
 -     where the idea of Emacs charsets isn't applicable.  */
 -  int charset;
 -
    /* Non-zero if text in this face should be underlined, overlined,
       strike-through or have a box drawn around it.  */
    unsigned underline_p : 1;
    /* Next and previous face in hash collision list of face cache.  */
    struct face *next, *prev;
  
 -  /* If this face is for ASCII characters, this points this face
 -     itself.  Otherwise, this points a face for ASCII characters.  */
 +  /* If this face is an ASCII face, this points to this face itself.
 +     Otherwise, this points to an ASCII face that has the same
 +     attributes except the font.  */
    struct face *ascii_face;
 +
 +#ifdef USE_FONT_BACKEND
 +  /* Extra member that a font-driver uses privately.  */
 +  void *extra;
 +#endif        /* USE_FONT_BACKEND */
  };
  
  
@@@ -1659,7 -1652,7 +1659,7 @@@ struct face_cach
  /* Non-zero if FACE is suitable for displaying character CHAR.  */
  
  #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR)  \
 -  (SINGLE_BYTE_CHAR_P (CHAR)                  \
 +  (ASCII_CHAR_P (CHAR)                                \
     ? (FACE) == (FACE)->ascii_face             \
     : face_suitable_for_char_p ((FACE), (CHAR)))
  
     with id ID but is suitable for displaying character CHAR.
     This macro is only meaningful for multibyte character CHAR.  */
  
 -#define FACE_FOR_CHAR(F, FACE, CHAR)  \
 -  (SINGLE_BYTE_CHAR_P (CHAR)          \
 -   ? (FACE)->ascii_face->id           \
 -   : face_for_char ((F), (FACE), (CHAR)))
 +#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT)     \
 +  (ASCII_CHAR_P (CHAR)                                        \
 +   ? (FACE)->ascii_face->id                           \
 +   : face_for_char ((F), (FACE), (CHAR), (POS), (OBJECT)))
  
  #else /* not HAVE_WINDOW_SYSTEM */
  
  #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR) 1
 -#define FACE_FOR_CHAR(F, FACE, CHAR) ((FACE)->id)
 +#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) ((FACE)->id)
  
  #endif /* not HAVE_WINDOW_SYSTEM */
  
@@@ -1793,7 -1786,6 +1793,7 @@@ enum display_element_typ
  
  enum prop_idx
  {
 +  AUTO_COMPOSED_PROP_IDX,
    FONTIFIED_PROP_IDX,
    FACE_PROP_IDX,
    INVISIBLE_PROP_IDX,
@@@ -2335,9 -2327,7 +2335,9 @@@ struct redisplay_interfac
     the two-byte form of C.  Encoding is returned in *CHAR2B.  If
     TWO_BYTE_P is non-null, return non-zero there if font is two-byte.  */
    int (*encode_char) P_ ((int c, XChar2b *char2b,
 -                        struct font_info *font_into, int *two_byte_p));
 +                        struct font_info *font_into,
 +                        struct charset *charset,
 +                        int *two_byte_p));
  
  /* Compute left and right overhang of glyph string S.
     A NULL pointer if platform does not support this. */
@@@ -2589,6 -2579,9 +2589,9 @@@ enum tool_bar_item_id
    /* Help string.  */
    TOOL_BAR_ITEM_HELP,
  
+   /* Icon file name of right to left image when an RTL locale is used.  */
+   TOOL_BAR_ITEM_RTL_IMAGE,
    /* Sentinel = number of slots in tool_bar_items occupied by one
       tool-bar item.  */
    TOOL_BAR_ITEM_NSLOTS
@@@ -2849,17 -2842,15 +2852,17 @@@ void clear_face_cache P_ ((int))
  unsigned long load_color P_ ((struct frame *, struct face *, Lisp_Object,
                              enum lface_attribute_index));
  void unload_color P_ ((struct frame *, unsigned long));
 -int face_font_available_p P_ ((struct frame *, Lisp_Object));
 +char *choose_face_font P_ ((struct frame *, Lisp_Object *, Lisp_Object,
 +                          int *));
  int ascii_face_of_lisp_face P_ ((struct frame *, int));
  void prepare_face_for_display P_ ((struct frame *, struct face *));
  int xstricmp P_ ((const unsigned char *, const unsigned char *));
 -int lookup_face P_ ((struct frame *, Lisp_Object *, int, struct face *));
 -int lookup_named_face P_ ((struct frame *, Lisp_Object, int, int));
 +int lookup_face P_ ((struct frame *, Lisp_Object *));
 +int lookup_non_ascii_face P_ ((struct frame *, int, struct face *));
 +int lookup_named_face P_ ((struct frame *, Lisp_Object, int));
  int smaller_face P_ ((struct frame *, int, int));
  int face_with_height P_ ((struct frame *, int, int));
 -int lookup_derived_face P_ ((struct frame *, Lisp_Object, int, int, int));
 +int lookup_derived_face P_ ((struct frame *, Lisp_Object, int, int));
  void init_frame_faces P_ ((struct frame *));
  void free_frame_faces P_ ((struct frame *));
  void recompute_basic_faces P_ ((struct frame *));
@@@ -2870,12 -2861,10 +2873,12 @@@ int face_at_string_position P_ ((struc
  int merge_faces P_ ((struct frame *, Lisp_Object, int, int));
  int compute_char_face P_ ((struct frame *, int, Lisp_Object));
  void free_all_realized_faces P_ ((Lisp_Object));
 +void free_realized_face P_ ((struct frame *, struct face *));
  extern Lisp_Object Qforeground_color, Qbackground_color;
  extern Lisp_Object Qframe_set_background_mode;
  extern char unspecified_fg[], unspecified_bg[];
 -void free_realized_multibyte_face P_ ((struct frame *, int));
 +extern Lisp_Object split_font_name_into_vector P_ ((Lisp_Object));
 +extern Lisp_Object build_font_name_from_vector P_ ((Lisp_Object));
  
  /* Defined in xfns.c  */
  
diff --combined src/fileio.c
index 983bd72d2820e8184388808b087f19a519335e82,62331122a249b21ab9d54d514a1fdab18ff21ca5..58c3e75111c16eb34cfb8494ffd8deb9eb17c6ba
@@@ -74,7 -74,7 +74,7 @@@ extern int errno
  #include "lisp.h"
  #include "intervals.h"
  #include "buffer.h"
 -#include "charset.h"
 +#include "character.h"
  #include "coding.h"
  #include "window.h"
  #include "blockinput.h"
@@@ -271,12 -271,9 +271,12 @@@ report_file_error (string, data
  {
    Lisp_Object errstring;
    int errorno = errno;
 +  char *str;
  
    synchronize_system_messages_locale ();
 -  errstring = code_convert_string_norecord (build_string (strerror (errorno)),
 +  str = strerror (errorno);
 +  errstring = code_convert_string_norecord (make_unibyte_string (str,
 +                                                               strlen (str)),
                                            Vlocale_coding_system, 0);
  
    while (1)
@@@ -314,7 -311,6 +314,7 @@@ restore_point_unwind (location
    Fset_marker (location, Qnil, Qnil);
    return Qnil;
  }
 +
  \f
  Lisp_Object Qexpand_file_name;
  Lisp_Object Qsubstitute_in_file_name;
@@@ -2295,8 -2291,7 +2295,8 @@@ duplicates what `expand-file-name' does
               convert what we substitute into multibyte.  */
            while (*o)
              {
 -              int c = unibyte_char_to_multibyte (*o++);
 +              int c = *o++;
 +              c = unibyte_char_to_multibyte (c);
                x += CHAR_STRING (c, x);
              }
          }
@@@ -3733,7 -3728,7 +3733,7 @@@ variable `last-coding-system-used' to t
    unsigned char buffer[1 << 14];
    int replace_handled = 0;
    int set_coding_system = 0;
 -  int coding_system_decided = 0;
 +  Lisp_Object coding_system;
    int read_quit = 0;
    Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
    int we_locked_file = 0;
    CHECK_STRING (filename);
    filename = Fexpand_file_name (filename, Qnil);
  
 +  /* The value Qnil means that the coding system is not yet
 +     decided.  */
 +  coding_system = Qnil;
 +
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
    handler = Ffind_file_name_handler (filename, Qinsert_file_contents);
  
    if (EQ (Vcoding_system_for_read, Qauto_save_coding))
      {
 -      /* We use emacs-mule for auto saving... */
 -      setup_coding_system (Qemacs_mule, &coding);
 -      /* ... but with the special flag to indicate to read in a
 -       multibyte sequence for eight-bit-control char as is.  */
 -      coding.flags = 1;
 -      coding.src_multibyte = 0;
 -      coding.dst_multibyte
 -      = !NILP (current_buffer->enable_multibyte_characters);
 -      coding.eol_type = CODING_EOL_LF;
 -      coding_system_decided = 1;
 +      coding_system = coding_inherit_eol_type (Qutf_8_emacs, Qunix);
 +      setup_coding_system (coding_system, &coding);
 +      /* Ensure we set Vlast_coding_system_used.  */
 +      set_coding_system = 1;
      }
    else if (BEG < Z)
      {
        /* Decide the coding system to use for reading the file now
           because we can't use an optimized method for handling
           `coding:' tag if the current buffer is not empty.  */
 -      Lisp_Object val;
 -      val = Qnil;
 -
        if (!NILP (Vcoding_system_for_read))
 -      val = Vcoding_system_for_read;
 +      coding_system = Vcoding_system_for_read;
        else
        {
          /* Don't try looking inside a file for a coding system
  
                  insert_1_both (read_buf, nread, nread, 0, 0, 0);
                  TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
 -                val = call2 (Vset_auto_coding_function,
 -                             filename, make_number (nread));
 +                coding_system = call2 (Vset_auto_coding_function,
 +                                       filename, make_number (nread));
                  set_buffer_internal (prev);
  
                  /* Discard the unwind protect for recovering the
                }
            }
  
 -        if (NILP (val))
 +        if (NILP (coding_system))
            {
              /* If we have not yet decided a coding system, check
                   file-coding-system-alist.  */
 -            Lisp_Object args[6], coding_systems;
 +            Lisp_Object args[6];
  
              args[0] = Qinsert_file_contents, args[1] = orig_filename;
              args[2] = visit, args[3] = beg, args[4] = end, args[5] = replace;
 -            coding_systems = Ffind_operation_coding_system (6, args);
 -            if (CONSP (coding_systems))
 -              val = XCAR (coding_systems);
 +            coding_system = Ffind_operation_coding_system (6, args);
 +            if (CONSP (coding_system))
 +              coding_system = XCAR (coding_system);
            }
        }
  
 -      setup_coding_system (Fcheck_coding_system (val), &coding);
 -      /* Ensure we set Vlast_coding_system_used.  */
 -      set_coding_system = 1;
 +      if (NILP (coding_system))
 +      coding_system = Qundecided;
 +      else
 +      CHECK_CODING_SYSTEM (coding_system);
  
 -      if (NILP (current_buffer->enable_multibyte_characters)
 -        && ! NILP (val))
 +      if (NILP (current_buffer->enable_multibyte_characters))
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
 -      setup_raw_text_coding_system (&coding);
 +      coding_system = raw_text_coding_system (coding_system);
  
 -      coding.src_multibyte = 0;
 -      coding.dst_multibyte
 -      = !NILP (current_buffer->enable_multibyte_characters);
 -      coding_system_decided = 1;
 +      setup_coding_system (coding_system, &coding);
 +      /* Ensure we set Vlast_coding_system_used.  */
 +      set_coding_system = 1;
      }
  
    /* If requested, replace the accessible part of the buffer
       and let the following if-statement handle the replace job.  */
    if (!NILP (replace)
        && BEGV < ZV
 -      && !(coding.common_flags & CODING_REQUIRE_DECODING_MASK))
 +      && (NILP (coding_system)
 +        || ! CODING_REQUIRE_DECODING (&coding)))
      {
        /* same_at_start and same_at_end count bytes,
         because file access counts bytes
          else if (nread == 0)
            break;
  
 -        if (coding.type == coding_type_undecided)
 -          detect_coding (&coding, buffer, nread);
 -        if (coding.common_flags & CODING_REQUIRE_DECODING_MASK)
 -          /* We found that the file should be decoded somehow.
 -               Let's give up here.  */
 +        if (CODING_REQUIRE_DETECTION (&coding))
            {
 -            giveup_match_end = 1;
 -            break;
 +            coding_system = detect_coding_system (buffer, nread, nread, 1, 0,
 +                                                  coding_system);
 +            setup_coding_system (coding_system, &coding);
            }
  
 -        if (coding.eol_type == CODING_EOL_UNDECIDED)
 -          detect_eol (&coding, buffer, nread);
 -        if (coding.eol_type != CODING_EOL_UNDECIDED
 -            && coding.eol_type != CODING_EOL_LF)
 -          /* We found that the format of eol should be decoded.
 +        if (CODING_REQUIRE_DECODING (&coding))
 +          /* We found that the file should be decoded somehow.
                 Let's give up here.  */
            {
              giveup_match_end = 1;
      {
        int same_at_start = BEGV_BYTE;
        int same_at_end = ZV_BYTE;
 +      int same_at_start_charpos;
 +      int inserted_chars;
        int overlap;
        int bufpos;
 -      /* Make sure that the gap is large enough.  */
 -      int bufsize = 2 * st.st_size;
 -      unsigned char *conversion_buffer = (unsigned char *) xmalloc (bufsize);
 +      unsigned char *decoded;
        int temp;
 +      int this_count = SPECPDL_INDEX ();
 +      int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
 +      Lisp_Object conversion_buffer;
 +
 +      conversion_buffer = code_conversion_save (1, multibyte);
  
        /* First read the whole file, performing code conversion into
         CONVERSION_BUFFER.  */
  
        if (lseek (fd, XINT (beg), 0) < 0)
 -      {
 -        xfree (conversion_buffer);
 -        report_file_error ("Setting file position",
 -                           Fcons (orig_filename, Qnil));
 -      }
 +      report_file_error ("Setting file position",
 +                         Fcons (orig_filename, Qnil));
  
        total = st.st_size;     /* Total bytes in the file.  */
        how_much = 0;           /* Bytes read from file so far.  */
        inserted = 0;           /* Bytes put into CONVERSION_BUFFER so far.  */
        unprocessed = 0;                /* Bytes not processed in previous loop.  */
  
 +      GCPRO1 (conversion_buffer);
        while (how_much < total)
        {
 +        /* We read one bunch by one (READ_BUF_SIZE bytes) to allow
 +           quitting while reading a huge while.  */
          /* try is reserved in some compilers (Microsoft C) */
          int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed);
 -        unsigned char *destination = read_buf + unprocessed;
          int this;
  
          /* Allow quitting out of the actual I/O.  */
          immediate_quit = 1;
          QUIT;
 -        this = emacs_read (fd, destination, trytry);
 +        this = emacs_read (fd, read_buf + unprocessed, trytry);
          immediate_quit = 0;
  
 -        if (this < 0 || this + unprocessed == 0)
 +        if (this <= 0)
            {
 -            how_much = this;
 +            if (this < 0)
 +              how_much = this;
              break;
            }
  
          how_much += this;
  
 -        if (CODING_MAY_REQUIRE_DECODING (&coding))
 -          {
 -            int require, result;
 -
 -            this += unprocessed;
 -
 -            /* If we are using more space than estimated,
 -               make CONVERSION_BUFFER bigger.  */
 -            require = decoding_buffer_size (&coding, this);
 -            if (inserted + require + 2 * (total - how_much) > bufsize)
 -              {
 -                bufsize = inserted + require + 2 * (total - how_much);
 -                conversion_buffer = (unsigned char *) xrealloc (conversion_buffer, bufsize);
 -              }
 -
 -            /* Convert this batch with results in CONVERSION_BUFFER.  */
 -            if (how_much >= total)  /* This is the last block.  */
 -              coding.mode |= CODING_MODE_LAST_BLOCK;
 -            if (coding.composing != COMPOSITION_DISABLED)
 -              coding_allocate_composition_data (&coding, BEGV);
 -            result = decode_coding (&coding, read_buf,
 -                                    conversion_buffer + inserted,
 -                                    this, bufsize - inserted);
 -
 -            /* Save for next iteration whatever we didn't convert.  */
 -            unprocessed = this - coding.consumed;
 -            bcopy (read_buf + coding.consumed, read_buf, unprocessed);
 -            if (!NILP (current_buffer->enable_multibyte_characters))
 -              this = coding.produced;
 -            else
 -              this = str_as_unibyte (conversion_buffer + inserted,
 -                                     coding.produced);
 -          }
 -
 -        inserted += this;
 +        BUF_SET_PT (XBUFFER (conversion_buffer),
 +                    BUF_Z (XBUFFER (conversion_buffer)));
 +        decode_coding_c_string (&coding, read_buf, unprocessed + this,
 +                                conversion_buffer);
 +        unprocessed = coding.carryover_bytes;
 +        if (coding.carryover_bytes > 0)
 +          bcopy (coding.carryover, read_buf, unprocessed);
        }
 +      UNGCPRO;
 +      emacs_close (fd);
  
 -      /* At this point, INSERTED is how many characters (i.e. bytes)
 -       are present in CONVERSION_BUFFER.
 -       HOW_MUCH should equal TOTAL,
 -       or should be <= 0 if we couldn't read the file.  */
 +      /* At this point, HOW_MUCH should equal TOTAL, or should be <= 0
 +       if we couldn't read the file.  */
  
        if (how_much < 0)
 +      error ("IO error reading %s: %s",
 +             SDATA (orig_filename), emacs_strerror (errno));
 +
 +      if (unprocessed > 0)
        {
 -        xfree (conversion_buffer);
 -        coding_free_composition_data (&coding);
 -        error ("IO error reading %s: %s",
 -               SDATA (orig_filename), emacs_strerror (errno));
 +        coding.mode |= CODING_MODE_LAST_BLOCK;
 +        decode_coding_c_string (&coding, read_buf, unprocessed,
 +                                conversion_buffer);
 +        coding.mode &= ~CODING_MODE_LAST_BLOCK;
        }
  
 -      /* Compare the beginning of the converted file
 -       with the buffer text.  */
 +      decoded = BUF_BEG_ADDR (XBUFFER (conversion_buffer));
 +      inserted = (BUF_Z_BYTE (XBUFFER (conversion_buffer))
 +                - BUF_BEG_BYTE (XBUFFER (conversion_buffer)));
 +
 +      /* Compare the beginning of the converted string with the buffer
 +       text.  */
  
        bufpos = 0;
        while (bufpos < inserted && same_at_start < same_at_end
 -           && FETCH_BYTE (same_at_start) == conversion_buffer[bufpos])
 +           && FETCH_BYTE (same_at_start) == decoded[bufpos])
        same_at_start++, bufpos++;
  
 -      /* If the file matches the buffer completely,
 +      /* If the file matches the head of buffer completely,
         there's no need to replace anything.  */
  
        if (bufpos == inserted)
        {
 -        xfree (conversion_buffer);
 -        coding_free_composition_data (&coding);
 -        emacs_close (fd);
          specpdl_ptr--;
          /* Truncate the buffer to the size of the file.  */
          del_range_byte (same_at_start, same_at_end, 0);
          inserted = 0;
 +
 +        unbind_to (this_count, Qnil);
          goto handled;
        }
  
 -      /* Extend the start of non-matching text area to multibyte
 -       character boundary.  */
 +      /* Extend the start of non-matching text area to the previous
 +       multibyte character boundary.  */
        if (! NILP (current_buffer->enable_multibyte_characters))
        while (same_at_start > BEGV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start)))
        /* Compare with same_at_start to avoid counting some buffer text
         as matching both at the file's beginning and at the end.  */
        while (bufpos > 0 && same_at_end > same_at_start
 -           && FETCH_BYTE (same_at_end - 1) == conversion_buffer[bufpos - 1])
 +           && FETCH_BYTE (same_at_end - 1) == decoded[bufpos - 1])
        same_at_end--, bufpos--;
  
 -      /* Extend the end of non-matching text area to multibyte
 -       character boundary.  */
 +      /* Extend the end of non-matching text area to the next
 +       multibyte character boundary.  */
        if (! NILP (current_buffer->enable_multibyte_characters))
        while (same_at_end < ZV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end)))
  
        /* Replace the chars that we need to replace,
         and update INSERTED to equal the number of bytes
 -       we are taking from the file.  */
 +       we are taking from the decoded string.  */
        inserted -= (ZV_BYTE - same_at_end) + (same_at_start - BEGV_BYTE);
  
        if (same_at_end != same_at_start)
        }
        /* Insert from the file at the proper position.  */
        SET_PT_BOTH (temp, same_at_start);
 -      insert_1 (conversion_buffer + same_at_start - BEGV_BYTE, inserted,
 -              0, 0, 0);
 -      if (coding.cmp_data && coding.cmp_data->used)
 -      coding_restore_composition (&coding, Fcurrent_buffer ());
 -      coding_free_composition_data (&coding);
 -
 +      same_at_start_charpos
 +      = buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
 +                                same_at_start);
 +      inserted_chars
 +      = (buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
 +                                 same_at_start + inserted)
 +         - same_at_start_charpos);
 +      /* This binding is to avoid ask-user-about-supersession-threat
 +       being called in insert_from_buffer (via in
 +       prepare_to_modify_buffer).  */
 +      specbind (intern ("buffer-file-name"), Qnil);
 +      insert_from_buffer (XBUFFER (conversion_buffer),
 +                        same_at_start_charpos, inserted_chars, 0);
        /* Set `inserted' to the number of inserted characters.  */
        inserted = PT - temp;
        /* Set point before the inserted characters.  */
        SET_PT_BOTH (temp, same_at_start);
  
 -      xfree (conversion_buffer);
 -      emacs_close (fd);
 -      specpdl_ptr--;
 +      unbind_to (this_count, Qnil);
  
        goto handled;
      }
    inserted = 0;
  
    /* Here, we don't do code conversion in the loop.  It is done by
 -     code_convert_region after all data are read into the buffer.  */
 +     decode_coding_gap after all data are read into the buffer.  */
    {
      int gap_size = GAP_SIZE;
  
  
   notfound:
  
 -  if (! coding_system_decided)
 +  if (NILP (coding_system))
      {
        /* The coding system is not yet decided.  Decide it by an
         optimized method for handling `coding:' tag.
  
         Note that we can get here only if the buffer was empty
         before the insertion.  */
 -      Lisp_Object val;
 -      val = Qnil;
  
        if (!NILP (Vcoding_system_for_read))
 -      val = Vcoding_system_for_read;
 +      coding_system = Vcoding_system_for_read;
        else
        {
          /* Since we are sure that the current buffer was empty
             before the insertion, we can toggle
             enable-multibyte-characters directly here without taking
 -           care of marker adjustment and byte combining problem.  By
 -           this way, we can run Lisp program safely before decoding
 -           the inserted text.  */
 +           care of marker adjustment.  By this way, we can run Lisp
 +           program safely before decoding the inserted text.  */
          Lisp_Object unwind_data;
          int count = SPECPDL_INDEX ();
  
  
          if (inserted > 0 && ! NILP (Vset_auto_coding_function))
            {
 -            val = call2 (Vset_auto_coding_function,
 -                         filename, make_number (inserted));
 +            coding_system = call2 (Vset_auto_coding_function,
 +                                   filename, make_number (inserted));
            }
  
 -        if (NILP (val))
 +        if (NILP (coding_system))
            {
              /* If the coding system is not yet decided, check
                 file-coding-system-alist.  */
 -            Lisp_Object args[6], coding_systems;
 +            Lisp_Object args[6];
  
              args[0] = Qinsert_file_contents, args[1] = orig_filename;
              args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil;
 -            coding_systems = Ffind_operation_coding_system (6, args);
 -            if (CONSP (coding_systems))
 -              val = XCAR (coding_systems);
 +            coding_system = Ffind_operation_coding_system (6, args);
 +            if (CONSP (coding_system))
 +              coding_system = XCAR (coding_system);
            }
          unbind_to (count, Qnil);
          inserted = Z_BYTE - BEG_BYTE;
        }
  
 -      /* The following kludgy code is to avoid some compiler bug.
 -       We can't simply do
 -       setup_coding_system (val, &coding);
 -       on some system.  */
 -      {
 -      struct coding_system temp_coding;
 -      setup_coding_system (Fcheck_coding_system (val), &temp_coding);
 -      bcopy (&temp_coding, &coding, sizeof coding);
 -      }
 -      /* Ensure we set Vlast_coding_system_used.  */
 -      set_coding_system = 1;
 +      if (NILP (coding_system))
 +      coding_system = Qundecided;
 +      else
 +      CHECK_CODING_SYSTEM (coding_system);
  
 -      if (NILP (current_buffer->enable_multibyte_characters)
 -        && ! NILP (val))
 +      if (NILP (current_buffer->enable_multibyte_characters))
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
 -      setup_raw_text_coding_system (&coding);
 -      coding.src_multibyte = 0;
 -      coding.dst_multibyte
 -      = !NILP (current_buffer->enable_multibyte_characters);
 +      coding_system = raw_text_coding_system (coding_system);
 +      setup_coding_system (coding_system, &coding);
 +      /* Ensure we set Vlast_coding_system_used.  */
 +      set_coding_system = 1;
      }
  
 -  if (!NILP (visit)
 -      /* Can't do this if part of the buffer might be preserved.  */
 -      && NILP (replace)
 -      && (coding.type == coding_type_no_conversion
 -        || coding.type == coding_type_raw_text))
 +  if (!NILP (visit))
      {
 -      /* Visiting a file with these coding system makes the buffer
 -         unibyte. */
 -      current_buffer->enable_multibyte_characters = Qnil;
 -      coding.dst_multibyte = 0;
 +      /* When we visit a file by raw-text, we change the buffer to
 +       unibyte.  */
 +      if (CODING_FOR_UNIBYTE (&coding)
 +        /* Can't do this if part of the buffer might be preserved.  */
 +        && NILP (replace))
 +      /* Visiting a file with these coding system makes the buffer
 +         unibyte. */
 +      current_buffer->enable_multibyte_characters = Qnil;
      }
  
 -  if (inserted > 0 || coding.type == coding_type_ccl)
 +  coding.dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
 +  if (CODING_MAY_REQUIRE_DECODING (&coding)
 +      && (inserted > 0 || CODING_REQUIRE_FLUSHING (&coding)))
      {
 -      if (CODING_MAY_REQUIRE_DECODING (&coding))
 -      {
 -        code_convert_region (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted,
 -                             &coding, 0, 0);
 -        inserted = coding.produced_char;
 -      }
 -      else
 -      adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted,
 -                           inserted);
 +      move_gap_both (PT, PT_BYTE);
 +      GAP_SIZE += inserted;
 +      ZV_BYTE -= inserted;
 +      Z_BYTE -= inserted;
 +      ZV -= inserted;
 +      Z -= inserted;
 +      decode_coding_gap (&coding, inserted, inserted);
 +      inserted = coding.produced_char;
 +      coding_system = CODING_ID_NAME (coding.id);
      }
 +  else if (inserted > 0)
 +    adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted,
 +                       inserted);
  
    /* Now INSERTED is measured in characters.  */
  
    /* Use the conversion type to determine buffer-file-type
       (find-buffer-file-type is now used to help determine the
       conversion).  */
 -  if ((coding.eol_type == CODING_EOL_UNDECIDED
 -       || coding.eol_type == CODING_EOL_LF)
 +  if ((VECTORP (CODING_ID_EOL_TYPE (coding.id))
 +       || EQ (CODING_ID_EOL_TYPE (coding.id), Qunix))
        && ! CODING_REQUIRE_DECODING (&coding))
      current_buffer->buffer_file_type = Qt;
    else
      }
  
    if (set_coding_system)
 -    Vlast_coding_system_used = coding.symbol;
 +    Vlast_coding_system_used = coding_system;
  
    if (! NILP (Ffboundp (Qafter_insert_file_set_coding)))
      {
          int opoint = PT;
          int opoint_byte = PT_BYTE;
          int oinserted = ZV - BEGV;
+         int ochars_modiff = CHARS_MODIFF;
          
          TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); 
          insval = call3 (Qformat_decode,
                          Qnil, make_number (oinserted), visit);
          CHECK_NUMBER (insval);
-         if (XINT (insval) == oinserted)
+         if (ochars_modiff == CHARS_MODIFF)
+           /* format_decode didn't modify buffer's characters => move
+              point back to position before inserted text and leave
+              value of inserted alone. */
            SET_PT_BOTH (opoint, opoint_byte);
-         inserted = XFASTINT (insval);
+         else
+           /* format_decode modified buffer's characters => consider
+              entire buffer changed and leave point at point-min. */
+           inserted = XFASTINT (insval);
        }
  
        /* For consistency with format-decode call these now iff inserted > 0
              int opoint = PT;
              int opoint_byte = PT_BYTE;
              int oinserted = ZV - BEGV;
+             int ochars_modiff = CHARS_MODIFF;
+             
              TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
              insval = call1 (XCAR (p), make_number (oinserted));
              if (!NILP (insval))
                {
                  CHECK_NUMBER (insval);
-                 if (XINT (insval) == oinserted)
+                 if (ochars_modiff == CHARS_MODIFF)
+                   /* after_insert_file_functions didn't modify
+                      buffer's characters => move point back to
+                      position before inserted text and leave value of
+                      inserted alone. */
                    SET_PT_BOTH (opoint, opoint_byte);
-                 inserted = XFASTINT (insval);
+                 else
+                   /* after_insert_file_functions did modify buffer's
+                      characters => consider entire buffer changed and
+                      leave point at point-min. */
+                   inserted = XFASTINT (insval);
                }
            }
  
  }
  \f
  static Lisp_Object build_annotations P_ ((Lisp_Object, Lisp_Object));
 -static Lisp_Object build_annotations_2 P_ ((Lisp_Object, Lisp_Object,
 -                                          Lisp_Object, Lisp_Object));
  
  /* If build_annotations switched buffers, switch back to BUF.
     Kill the temporary buffer that was selected in the meantime.
@@@ -4833,21 -4874,26 +4849,21 @@@ build_annotations_unwind (buf
  
  /* Decide the coding-system to encode the data with.  */
  
 -void
 +static Lisp_Object
  choose_write_coding_system (start, end, filename,
                            append, visit, lockname, coding)
       Lisp_Object start, end, filename, append, visit, lockname;
       struct coding_system *coding;
  {
    Lisp_Object val;
 +  Lisp_Object eol_parent = Qnil;
  
    if (auto_saving
        && NILP (Fstring_equal (current_buffer->filename,
                              current_buffer->auto_save_file_name)))
      {
 -      /* We use emacs-mule for auto saving... */
 -      setup_coding_system (Qemacs_mule, coding);
 -      /* ... but with the special flag to indicate not to strip off
 -       leading code of eight-bit-control chars.  */
 -      coding->flags = 1;
 -      /* We force LF for end-of-line because that is faster.  */
 -      coding->eol_type = CODING_EOL_LF;
 -      goto done_setup_coding;
 +      val = Qutf_8_emacs;
 +      eol_parent = Qunix;
      }
    else if (!NILP (Vcoding_system_for_write))
      {
            val = XCDR (coding_systems);
        }
  
 -      if (NILP (val)
 -        && !NILP (current_buffer->buffer_file_coding_system))
 +      if (NILP (val))
        {
          /* If we still have not decided a coding system, use the
             default value of buffer-file-coding-system.  */
          using_default_coding = 1;
        }
  
 +      if (! NILP (val) && ! force_raw_text)
 +      {
 +        Lisp_Object spec, attrs;
 +
 +        CHECK_CODING_SYSTEM_GET_SPEC (val, spec);
 +        attrs = AREF (spec, 0);
 +        if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text))
 +          force_raw_text = 1;
 +      }
 +
        if (!force_raw_text
          && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
        /* Confirm that VAL can surely encode the current region.  */
        val = call5 (Vselect_safe_coding_system_function,
                     start, end, val, Qnil, filename);
  
 -      setup_coding_system (Fcheck_coding_system (val), coding);
 -      if (coding->eol_type == CODING_EOL_UNDECIDED
 -        && !using_default_coding)
 -      {
 -        if (! EQ (default_buffer_file_coding.symbol,
 -                  buffer_defaults.buffer_file_coding_system))
 -          setup_coding_system (buffer_defaults.buffer_file_coding_system,
 -                               &default_buffer_file_coding);
 -        if (default_buffer_file_coding.eol_type != CODING_EOL_UNDECIDED)
 -          {
 -            Lisp_Object subsidiaries;
 -
 -            coding->eol_type = default_buffer_file_coding.eol_type;
 -            subsidiaries = Fget (coding->symbol, Qeol_type);
 -            if (VECTORP (subsidiaries)
 -                && XVECTOR (subsidiaries)->size == 3)
 -              coding->symbol
 -                = XVECTOR (subsidiaries)->contents[coding->eol_type];
 -          }
 -      }
 +      /* If the decided coding-system doesn't specify end-of-line
 +       format, we use that of
 +       `default-buffer-file-coding-system'.  */
 +      if (! using_default_coding
 +        && ! NILP (buffer_defaults.buffer_file_coding_system))
 +      val = (coding_inherit_eol_type
 +             (val, buffer_defaults.buffer_file_coding_system));
  
 +      /* If we decide not to encode text, use `raw-text' or one of its
 +       subsidiaries.  */
        if (force_raw_text)
 -      setup_raw_text_coding_system (coding);
 -      goto done_setup_coding;
 +      val = raw_text_coding_system (val);
      }
  
 -  setup_coding_system (Fcheck_coding_system (val), coding);
 +  val = coding_inherit_eol_type (val, eol_parent);
 +  setup_coding_system (val, coding);
  
 - done_setup_coding:
 -  if (coding->eol_type == CODING_EOL_UNDECIDED)
 -    coding->eol_type = system_eol_type;
    if (!STRINGP (start) && !NILP (current_buffer->selective_display))
      coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
 +  return val;
  }
  
  DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7,
@@@ -4983,6 -5033,7 +4999,6 @@@ This does code conversion according to 
    int save_errno = 0;
    const unsigned char *fn;
    struct stat st;
 -  int tem;
    int count = SPECPDL_INDEX ();
    int count1;
  #ifdef VMS
       We used to make this choice before calling build_annotations, but that
       leads to problems when a write-annotate-function takes care of
       unsavable chars (as was the case with X-Symbol).  */
 -  choose_write_coding_system (start, end, filename,
 -                            append, visit, lockname, &coding);
 -  Vlast_coding_system_used = coding.symbol;
 -
 -  given_buffer = current_buffer;
 -  if (! STRINGP (start))
 -    {
 -      annotations = build_annotations_2 (start, end,
 -                                       coding.pre_write_conversion, annotations);
 -      if (current_buffer != given_buffer)
 -      {
 -        XSETFASTINT (start, BEGV);
 -        XSETFASTINT (end, ZV);
 -      }
 -    }
 +  Vlast_coding_system_used
 +    = choose_write_coding_system (start, end, filename,
 +                                append, visit, lockname, &coding);
  
  #ifdef CLASH_DETECTION
    if (!auto_saving)
    if (GPT > BEG && GPT_ADDR[-1] != '\n')
      move_gap (find_next_newline (GPT, 1));
  #else
 +#if 0
 +  /* The new encoding routine doesn't require the following.  */
 +
    /* Whether VMS or not, we must move the gap to the next of newline
       when we must put designation sequences at beginning of line.  */
    if (INTEGERP (start)
        move_gap_both (PT, PT_BYTE);
        SET_PT_BOTH (opoint, opoint_byte);
      }
 +#endif
  #endif
  
    failure = 0;
      }
    else if (XINT (start) != XINT (end))
      {
 -      tem = CHAR_TO_BYTE (XINT (start));
 -
 -      if (XINT (start) < GPT)
 -      {
 -        failure = 0 > a_write (desc, Qnil, XINT (start),
 -                               min (GPT, XINT (end)) - XINT (start),
 -                               &annotations, &coding);
 -        save_errno = errno;
 -      }
 -
 -      if (XINT (end) > GPT && !failure)
 -      {
 -        tem = max (XINT (start), GPT);
 -        failure = 0 > a_write (desc, Qnil, tem , XINT (end) - tem,
 -                               &annotations, &coding);
 -        save_errno = errno;
 -      }
 +      failure = 0 > a_write (desc, Qnil,
 +                           XINT (start), XINT (end) - XINT (start),
 +                           &annotations, &coding);
 +      save_errno = errno;
      }
    else
      {
      {
        /* We have to flush out a data. */
        coding.mode |= CODING_MODE_LAST_BLOCK;
 -      failure = 0 > e_write (desc, Qnil, 0, 0, &coding);
 +      failure = 0 > e_write (desc, Qnil, 1, 1, &coding);
        save_errno = errno;
      }
  
@@@ -5467,6 -5539,30 +5483,6 @@@ build_annotations (start, end
    return annotations;
  }
  
 -static Lisp_Object
 -build_annotations_2 (start, end, pre_write_conversion, annotations)
 -     Lisp_Object start, end, pre_write_conversion, annotations;
 -{
 -  struct gcpro gcpro1;
 -  Lisp_Object res;
 -
 -  GCPRO1 (annotations);
 -  /* At last, do the same for the function PRE_WRITE_CONVERSION
 -     implied by the current coding-system.  */
 -  if (!NILP (pre_write_conversion))
 -    {
 -      struct buffer *given_buffer = current_buffer;
 -      Vwrite_region_annotations_so_far = annotations;
 -      res = call2 (pre_write_conversion, start, end);
 -      Flength (res);
 -      annotations = (current_buffer != given_buffer
 -                   ? res
 -                   : merge (annotations, res, Qcar_less_than_car));
 -    }
 -
 -  UNGCPRO;
 -  return annotations;
 -}
  \f
  /* Write to descriptor DESC the NCHARS chars starting at POS of STRING.
     If STRING is nil, POS is the character position in the current buffer.
@@@ -5522,6 -5618,9 +5538,6 @@@ a_write (desc, string, pos, nchars, ann
    return 0;
  }
  
 -#ifndef WRITE_BUF_SIZE
 -#define WRITE_BUF_SIZE (16 * 1024)
 -#endif
  
  /* Write text in the range START and END into descriptor DESC,
     encoding them with coding system CODING.  If STRING is nil, START
@@@ -5535,77 -5634,78 +5551,77 @@@ e_write (desc, string, start, end, codi
       int start, end;
       struct coding_system *coding;
  {
 -  register char *addr;
 -  register int nbytes;
 -  char buf[WRITE_BUF_SIZE];
 -  int return_val = 0;
 -
 -  if (start >= end)
 -    coding->composing = COMPOSITION_DISABLED;
 -  if (coding->composing != COMPOSITION_DISABLED)
 -    coding_save_composition (coding, start, end, string);
 -
    if (STRINGP (string))
      {
 -      addr = SDATA (string);
 -      nbytes = SBYTES (string);
 -      coding->src_multibyte = STRING_MULTIBYTE (string);
 -    }
 -  else if (start < end)
 -    {
 -      /* It is assured that the gap is not in the range START and END-1.  */
 -      addr = CHAR_POS_ADDR (start);
 -      nbytes = CHAR_TO_BYTE (end) - CHAR_TO_BYTE (start);
 -      coding->src_multibyte
 -      = !NILP (current_buffer->enable_multibyte_characters);
 -    }
 -  else
 -    {
 -      addr = "";
 -      nbytes = 0;
 -      coding->src_multibyte = 1;
 +      start = 0;
 +      end = SCHARS (string);
      }
  
    /* We used to have a code for handling selective display here.  But,
       now it is handled within encode_coding.  */
 -  while (1)
 -    {
 -      int result;
  
 -      result = encode_coding (coding, addr, buf, nbytes, WRITE_BUF_SIZE);
 -      if (coding->produced > 0)
 +  while (start < end)
 +    {
 +      if (STRINGP (string))
        {
 -        coding->produced -= emacs_write (desc, buf, coding->produced);
 -        if (coding->produced)
 +        coding->src_multibyte = SCHARS (string) < SBYTES (string);
 +        if (CODING_REQUIRE_ENCODING (coding))
            {
 -            return_val = -1;
 -            break;
 +            encode_coding_object (coding, string,
 +                                  start, string_char_to_byte (string, start),
 +                                  end, string_char_to_byte (string, end), Qt);
 +          }
 +        else
 +          {
 +            coding->dst_object = string;
 +            coding->consumed_char = SCHARS (string);
 +            coding->produced = SBYTES (string);
            }
        }
 -      nbytes -= coding->consumed;
 -      addr += coding->consumed;
 -      if (result == CODING_FINISH_INSUFFICIENT_SRC
 -        && nbytes > 0)
 +      else
        {
 -        /* The source text ends by an incomplete multibyte form.
 -             There's no way other than write it out as is.  */
 -        nbytes -= emacs_write (desc, addr, nbytes);
 -        if (nbytes)
 +        int start_byte = CHAR_TO_BYTE (start);
 +        int end_byte = CHAR_TO_BYTE (end);
 +
 +        coding->src_multibyte = (end - start) < (end_byte - start_byte);
 +        if (CODING_REQUIRE_ENCODING (coding))
            {
 -            return_val = -1;
 -            break;
 +            encode_coding_object (coding, Fcurrent_buffer (),
 +                                  start, start_byte, end, end_byte, Qt);
 +          }
 +        else
 +          {
 +            coding->dst_object = Qnil;
 +            coding->dst_pos_byte = start_byte;
 +            if (start >= GPT || end <= GPT)
 +              {
 +                coding->consumed_char = end - start;
 +                coding->produced = end_byte - start_byte;
 +              }
 +            else
 +              {
 +                coding->consumed_char = GPT - start;
 +                coding->produced = GPT_BYTE - start_byte;
 +              }
            }
        }
 -      if (nbytes <= 0)
 -      break;
 +
 +      if (coding->produced > 0)
 +      {
 +        coding->produced -=
 +          emacs_write (desc,
 +                       STRINGP (coding->dst_object)
 +                       ? SDATA (coding->dst_object)
 +                       : BYTE_POS_ADDR (coding->dst_pos_byte),
 +                       coding->produced);
 +
 +        if (coding->produced)
 +          return -1;
 +      }
        start += coding->consumed_char;
 -      if (coding->cmp_data)
 -      coding_adjust_composition_offset (coding, start);
      }
  
 -  if (coding->cmp_data)
 -    coding_free_composition_data (coding);
 -
 -  return return_val;
 +  return 0;
  }
  \f
  DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
@@@ -5906,7 -6006,7 +5922,7 @@@ A non-nil CURRENT-ONLY argument means s
       couldn't handle some ange-ftp'd file.  */
  
    for (do_handled_files = 0; do_handled_files < 2; do_handled_files++)
 -    for (tail = Vbuffer_alist; GC_CONSP (tail); tail = XCDR (tail))
 +    for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
        {
        buf = XCDR (XCAR (tail));
        b = XBUFFER (buf);
@@@ -6182,9 -6282,9 +6198,9 @@@ DEFUN ("read-file-name-internal", Fread
            {
              Lisp_Object tem = XCAR (all);
              int len;
 -            if (STRINGP (tem)
 -                && (len = SBYTES (tem), len > 0)
 -                && IS_DIRECTORY_SEP (SREF (tem, len-1)))
 +            if (STRINGP (tem) &&
 +                (len = SBYTES (tem), len > 0) &&
 +                IS_DIRECTORY_SEP (SREF (tem, len-1)))
                comp = Fcons (tem, comp);
            }
        }
diff --combined src/keyboard.c
index c55faba6f7ff4c9be7769cb29b51eed52ac898ac,adbbbcf85ddf00bcb8299c4bb16b2d41cf057c11..d202fc4fc9ac183b913365b28b8966a999bcb094
@@@ -33,7 -33,7 +33,7 @@@ Boston, MA 02110-1301, USA.  *
  #include "window.h"
  #include "commands.h"
  #include "buffer.h"
 -#include "charset.h"
 +#include "character.h"
  #include "disptab.h"
  #include "dispextern.h"
  #include "syntax.h"
@@@ -1751,7 -1751,7 +1751,7 @@@ command_loop_1 (
                          : (lose >= 0x20 && lose < 0x7f))
                      /* To extract the case of continuation on
                           wide-column characters.  */
 -                    && (WIDTH_BY_CHAR_HEAD (FETCH_BYTE (PT_BYTE)) == 1)
 +                    && ASCII_BYTE_P (lose)
                      && (XFASTINT (XWINDOW (selected_window)->last_modified)
                          >= MODIFF)
                      && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified)
                {
                  unsigned int c
                    = translate_char (Vtranslation_table_for_input,
 -                                    XFASTINT (last_command_char), 0, 0, 0);
 +                                    XFASTINT (last_command_char));
                  int value;
                  if (NILP (Vexecuting_kbd_macro)
                      && !EQ (minibuf_window, selected_window))
@@@ -1984,7 -1984,7 +1984,7 @@@ adjust_point_for_property (last_pt, mod
       int last_pt;
       int modified;
  {
 -  int beg, end;
 +  EMACS_INT beg, end;
    Lisp_Object val, overlay, tmp;
    int check_composition = 1, check_display = 1, check_invisible = 1;
    int orig_pt = PT;
@@@ -3111,7 -3111,7 +3111,7 @@@ read_char (commandflag, nmaps, maps, pr
          || (VECTORP (Vkeyboard_translate_table)
              && XVECTOR (Vkeyboard_translate_table)->size > (unsigned) XFASTINT (c))
          || (CHAR_TABLE_P (Vkeyboard_translate_table)
 -            && CHAR_VALID_P (XINT (c), 0)))
 +            && CHARACTERP (c)))
        {
          Lisp_Object d;
          d = Faref (Vkeyboard_translate_table, c);
@@@ -7907,10 -7907,11 +7907,11 @@@ static Lisp_Object tool_bar_item_proper
  
  static int ntool_bar_items;
  
- /* The symbols `tool-bar', and `:image'.  */
+ /* The symbols `tool-bar', `:image' and `:rtl'.  */
  
  extern Lisp_Object Qtool_bar;
  Lisp_Object QCimage;
+ Lisp_Object Qrtl;
  
  /* Function prototypes.  */
  
@@@ -8196,6 -8197,9 +8197,9 @@@ parse_tool_bar_item (key, item
        /* Value is either a single image specification or a vector
           of 4 such specifications for the different button states.  */
        PROP (TOOL_BAR_ITEM_IMAGES) = value;
+       else if (EQ (key, Qrtl))
+         /* ':rtl STRING' */
+       PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value;
      }
  
    /* If got a filter apply it on binding.  */
@@@ -9769,8 -9773,9 +9773,8 @@@ read_key_sequence (keybuf, bufsize, pro
        if (first_binding >= nmaps
          && fkey.start >= t && keytran.start >= t
          && INTEGERP (key)
 -        && ((((XINT (key) & 0x3ffff)
 -              < XCHAR_TABLE (current_buffer->downcase_table)->size)
 -             && UPPERCASEP (XINT (key) & 0x3ffff))
 +        && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK))
 +             && UPPERCASEP (XINT (key) & ~CHAR_MODIFIER_MASK))
              || (XINT (key) & shift_modifier)))
        {
          Lisp_Object new_key;
          if (XINT (key) & shift_modifier)
            XSETINT (new_key, XINT (key) & ~shift_modifier);
          else
 -          XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff)
 -                             | (XINT (key) & ~0x3ffff)));
 +          XSETINT (new_key, (DOWNCASE (XINT (key) & ~CHAR_MODIFIER_MASK)
 +                             | (XINT (key) & ~CHAR_MODIFIER_MASK)));
  
          /* We have to do this unconditionally, regardless of whether
             the lower-case char is defined in the keymaps, because they
@@@ -11222,6 -11227,9 +11226,9 @@@ syms_of_keyboard (
    staticpro (&Qhelp_echo);
    Qhelp_echo = intern ("help-echo");
  
+   staticpro (&Qrtl);
+   Qrtl = intern (":rtl");
    staticpro (&item_properties);
    item_properties = Qnil;
  
diff --combined src/lread.c
index fcc344d58756cce5258130f52db96f7c4ca0805d,a67fff1fc92208e83612e0fad9c8eaf7a2c8eff2..6bec084c5c69a22714c60778fa201f1d091d1c18
@@@ -30,9 -30,7 +30,9 @@@ Boston, MA 02110-1301, USA.  *
  #include "lisp.h"
  #include "intervals.h"
  #include "buffer.h"
 +#include "character.h"
  #include "charset.h"
 +#include "coding.h"
  #include <epaths.h>
  #include "commands.h"
  #include "keyboard.h"
@@@ -92,12 -90,6 +92,12 @@@ Lisp_Object Qinhibit_file_name_operatio
  Lisp_Object Qeval_buffer_list, Veval_buffer_list;
  Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
  
 +/* Used instead of Qget_file_char while loading *.elc files compiled
 +   by Emacs 21 or older.  */
 +static Lisp_Object Qget_emacs_mule_file_char;
 +
 +static Lisp_Object Qload_force_doc_strings;
 +
  extern Lisp_Object Qevent_symbol_element_mask;
  extern Lisp_Object Qfile_exists_p;
  
@@@ -141,11 -133,6 +141,11 @@@ static int load_force_doc_strings
  /* Nonzero means read should convert strings to unibyte.  */
  static int load_convert_to_unibyte;
  
 +/* Nonzero means READCHAR should read bytes one by one (not character)
 +   when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char.
 +   This is set to 1 by read1 temporarily while handling #@NUMBER.  */
 +static int load_each_byte;
 +
  /* Function to use for loading an Emacs Lisp source file (not
     compiled) instead of readevalloop.  */
  Lisp_Object Vload_source_file_function;
@@@ -174,6 -161,9 +174,6 @@@ static int read_from_string_index
  static int read_from_string_index_byte;
  static int read_from_string_limit;
  
 -/* Number of bytes left to read in the buffer character
 -   that `readchar' has already advanced over.  */
 -static int readchar_backlog;
  /* Number of characters read in the current call to Fread or
     Fread_from_string. */
  static int readchar_count;
@@@ -203,6 -193,7 +203,7 @@@ static file_offset prev_saved_doc_strin
     Fread initializes this to zero, so we need not specbind it
     or worry about what happens to it when there is an error.  */
  static int new_backquote_flag;
+ static Lisp_Object Vold_style_backquotes, Qold_style_backquotes;
  
  /* A list of file names for files being loaded in Fload.  Used to
     check for recursive loads.  */
@@@ -217,9 -208,7 +218,9 @@@ int load_dangerous_libraries
  
  static Lisp_Object Vbytecomp_version_regexp;
  
 -static void to_multibyte P_ ((char **, char **, int *));
 +static int read_emacs_mule_char P_ ((int, int (*) (int, Lisp_Object),
 +                                   Lisp_Object));
 +
  static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object,
                              Lisp_Object (*) (), int,
                              Lisp_Object, Lisp_Object,
@@@ -231,41 -220,29 +232,41 @@@ static void invalid_syntax P_ ((const c
  static void end_of_file_error P_ (()) NO_RETURN;
  
  \f
 +/* Functions that read one byte from the current source READCHARFUN
 +   or unreads one byte.  If the integer argument C is -1, it returns
 +   one read byte, or -1 when there's no more byte in the source.  If C
 +   is 0 or positive, it unreads C, and the return value is not
 +   interesting.  */
 +
 +static int readbyte_for_lambda P_ ((int, Lisp_Object));
 +static int readbyte_from_file P_ ((int, Lisp_Object));
 +static int readbyte_from_string P_ ((int, Lisp_Object));
 +
  /* Handle unreading and rereading of characters.
     Write READCHAR to read a character,
     UNREAD(c) to unread c to be read again.
  
 -   The READCHAR and UNREAD macros are meant for reading/unreading a
 -   byte code; they do not handle multibyte characters.  The caller
 -   should manage them if necessary.
 -
 -   [ Actually that seems to be a lie; READCHAR will definitely read
 -     multibyte characters from buffer sources, at least.  Is the
 -     comment just out of date?
 -     -- Colin Walters <walters@gnu.org>, 22 May 2002 16:36:50 -0400 ]
 - */
 +   These macros correctly read/unread multibyte characters.  */
  
  #define READCHAR readchar (readcharfun)
  #define UNREAD(c) unreadchar (readcharfun, c)
  
 +/* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char,
 +   Qlambda, or a cons, we use this to keep an unread character because
 +   a file stream can't handle multibyte-char unreading.  The value -1
 +   means that there's no unread character. */
 +static int unread_char;
 +
  static int
  readchar (readcharfun)
       Lisp_Object readcharfun;
  {
    Lisp_Object tem;
    register int c;
 +  int (*readbyte) P_ ((int, Lisp_Object));
 +  unsigned char buf[MAX_MULTIBYTE_LENGTH];
 +  int i, len;
 +  int emacs_mule_encoding = 0;
  
    readchar_count++;
  
        register struct buffer *inbuffer = XBUFFER (readcharfun);
  
        int pt_byte = BUF_PT_BYTE (inbuffer);
 -      int orig_pt_byte = pt_byte;
 -
 -      if (readchar_backlog > 0)
 -      /* We get the address of the byte just passed,
 -         which is the last byte of the character.
 -         The other bytes in this character are consecutive with it,
 -         because the gap can't be in the middle of a character.  */
 -      return *(BUF_BYTE_ADDRESS (inbuffer, BUF_PT_BYTE (inbuffer) - 1)
 -               - --readchar_backlog);
  
        if (pt_byte >= BUF_ZV_BYTE (inbuffer))
        return -1;
  
 -      readchar_backlog = -1;
 -
        if (! NILP (inbuffer->enable_multibyte_characters))
        {
          /* Fetch the character code from the buffer.  */
        else
        {
          c = BUF_FETCH_BYTE (inbuffer, pt_byte);
 +        if (! ASCII_BYTE_P (c))
 +          c = BYTE8_TO_CHAR (c);
          pt_byte++;
        }
        SET_BUF_PT_BOTH (inbuffer, BUF_PT (inbuffer) + 1, pt_byte);
        register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
  
        int bytepos = marker_byte_position (readcharfun);
 -      int orig_bytepos = bytepos;
 -
 -      if (readchar_backlog > 0)
 -      /* We get the address of the byte just passed,
 -         which is the last byte of the character.
 -         The other bytes in this character are consecutive with it,
 -         because the gap can't be in the middle of a character.  */
 -      return *(BUF_BYTE_ADDRESS (inbuffer, XMARKER (readcharfun)->bytepos - 1)
 -               - --readchar_backlog);
  
        if (bytepos >= BUF_ZV_BYTE (inbuffer))
        return -1;
  
 -      readchar_backlog = -1;
 -
        if (! NILP (inbuffer->enable_multibyte_characters))
        {
          /* Fetch the character code from the buffer.  */
        else
        {
          c = BUF_FETCH_BYTE (inbuffer, bytepos);
 +        if (! ASCII_BYTE_P (c))
 +          c = BYTE8_TO_CHAR (c);
          bytepos++;
        }
  
      }
  
    if (EQ (readcharfun, Qlambda))
 -    return read_bytecode_char (0);
 +    {
 +      readbyte = readbyte_for_lambda;
 +      goto read_multibyte;
 +    }
  
    if (EQ (readcharfun, Qget_file_char))
      {
 -      BLOCK_INPUT;
 -      c = getc (instream);
 -#ifdef EINTR
 -      /* Interrupted reads have been observed while reading over the network */
 -      while (c == EOF && ferror (instream) && errno == EINTR)
 -      {
 -        UNBLOCK_INPUT;
 -        QUIT;
 -        BLOCK_INPUT;
 -        clearerr (instream);
 -        c = getc (instream);
 -      }
 -#endif
 -      UNBLOCK_INPUT;
 -      return c;
 +      readbyte = readbyte_from_file;
 +      goto read_multibyte;
      }
  
    if (STRINGP (readcharfun))
        return c;
      }
  
 +  if (CONSP (readcharfun))
 +    {
 +      /* This is the case that read_vector is reading from a unibyte
 +       string that contains a byte sequence previously skipped
 +       because of #@NUMBER.  The car part of readcharfun is that
 +       string, and the cdr part is a value of readcharfun given to
 +       read_vector.  */
 +      readbyte = readbyte_from_string;
 +      if (EQ (XCDR (readcharfun), Qget_emacs_mule_file_char))
 +      emacs_mule_encoding = 1;
 +      goto read_multibyte;
 +    }
 +
 +  if (EQ (readcharfun, Qget_emacs_mule_file_char))
 +    {
 +      readbyte = readbyte_from_file;
 +      emacs_mule_encoding = 1;
 +      goto read_multibyte;
 +    }
 +
    tem = call0 (readcharfun);
  
    if (NILP (tem))
      return -1;
    return XINT (tem);
 +
 + read_multibyte:
 +  if (unread_char >= 0)
 +    {
 +      c = unread_char;
 +      unread_char = -1;
 +      return c;
 +    }
 +  c = (*readbyte) (-1, readcharfun);
 +  if (c < 0 || ASCII_BYTE_P (c) || load_each_byte)
 +    return c;
 +  if (emacs_mule_encoding)
 +    return read_emacs_mule_char (c, readbyte, readcharfun);
 +  i = 0;
 +  buf[i++] = c;
 +  len = BYTES_BY_CHAR_HEAD (c);
 +  while (i < len)
 +    {
 +      c = (*readbyte) (-1, readcharfun);
 +      if (c < 0 || ! TRAILING_CODE_P (c))
 +      {
 +        while (--i > 1)
 +          (*readbyte) (buf[i], readcharfun);
 +        return BYTE8_TO_CHAR (buf[0]);
 +      }
 +      buf[i++] = c;
 +    }
 +  return STRING_CHAR (buf, i);
  }
  
  /* Unread the character C in the way appropriate for the stream READCHARFUN.
@@@ -423,26 -380,36 +424,26 @@@ unreadchar (readcharfun, c
        struct buffer *b = XBUFFER (readcharfun);
        int bytepos = BUF_PT_BYTE (b);
  
 -      if (readchar_backlog >= 0)
 -      readchar_backlog++;
 +      BUF_PT (b)--;
 +      if (! NILP (b->enable_multibyte_characters))
 +      BUF_DEC_POS (b, bytepos);
        else
 -      {
 -        BUF_PT (b)--;
 -        if (! NILP (b->enable_multibyte_characters))
 -          BUF_DEC_POS (b, bytepos);
 -        else
 -          bytepos--;
 +      bytepos--;
  
 -        BUF_PT_BYTE (b) = bytepos;
 -      }
 +      BUF_PT_BYTE (b) = bytepos;
      }
    else if (MARKERP (readcharfun))
      {
        struct buffer *b = XMARKER (readcharfun)->buffer;
        int bytepos = XMARKER (readcharfun)->bytepos;
  
 -      if (readchar_backlog >= 0)
 -      readchar_backlog++;
 +      XMARKER (readcharfun)->charpos--;
 +      if (! NILP (b->enable_multibyte_characters))
 +      BUF_DEC_POS (b, bytepos);
        else
 -      {
 -        XMARKER (readcharfun)->charpos--;
 -        if (! NILP (b->enable_multibyte_characters))
 -          BUF_DEC_POS (b, bytepos);
 -        else
 -          bytepos--;
 +      bytepos--;
  
 -        XMARKER (readcharfun)->bytepos = bytepos;
 -      }
 +      XMARKER (readcharfun)->bytepos = bytepos;
      }
    else if (STRINGP (readcharfun))
      {
        read_from_string_index_byte
        = string_char_to_byte (readcharfun, read_from_string_index);
      }
 +  else if (CONSP (readcharfun))
 +    {
 +      unread_char = c;
 +    }
    else if (EQ (readcharfun, Qlambda))
 -    read_bytecode_char (1);
 -  else if (EQ (readcharfun, Qget_file_char))
 +    {
 +      unread_char = c;
 +    }
 +  else if (EQ (readcharfun, Qget_file_char)
 +         || EQ (readcharfun, Qget_emacs_mule_file_char))
 +    {
 +      if (load_each_byte)
 +      {
 +        BLOCK_INPUT;
 +        ungetc (c, instream);
 +        UNBLOCK_INPUT;
 +      }
 +      else
 +      unread_char = c;
 +    }
 +  else
 +    call1 (readcharfun, make_number (c));
 +}
 +
 +static int
 +readbyte_for_lambda (c, readcharfun)
 +     int c;
 +     Lisp_Object readcharfun;
 +{
 +  return read_bytecode_char (c >= 0);
 +}
 +
 +
 +static int
 +readbyte_from_file (c, readcharfun)
 +     int c;
 +     Lisp_Object readcharfun;
 +{
 +  if (c >= 0)
      {
        BLOCK_INPUT;
        ungetc (c, instream);
        UNBLOCK_INPUT;
 +      return 0;
 +    }
 +
 +  BLOCK_INPUT;
 +  c = getc (instream);
 +
 +#ifdef EINTR
 +  /* Interrupted reads have been observed while reading over the network */
 +  while (c == EOF && ferror (instream) && errno == EINTR)
 +    {
 +      UNBLOCK_INPUT;
 +      QUIT;
 +      BLOCK_INPUT;
 +      clearerr (instream);
 +      c = getc (instream);
      }
 +#endif
 +
 +  UNBLOCK_INPUT;
 +
 +  return (c == EOF ? -1 : c);
 +}
 +
 +static int
 +readbyte_from_string (c, readcharfun)
 +     int c;
 +     Lisp_Object readcharfun;
 +{
 +  Lisp_Object string = XCAR (readcharfun);
 +
 +  if (c >= 0)
 +    {
 +      read_from_string_index--;
 +      read_from_string_index_byte
 +      = string_char_to_byte (string, read_from_string_index);
 +    }
 +
 +  if (read_from_string_index >= read_from_string_limit)
 +    c = -1;
    else
 -    call1 (readcharfun, make_number (c));
 +    FETCH_STRING_CHAR_ADVANCE (c, string,
 +                             read_from_string_index,
 +                             read_from_string_index_byte);
 +  return c;
  }
  
 +
 +/* Read one non-ASCII character from INSTREAM.  The character is
 +   encoded in `emacs-mule' and the first byte is already read in
 +   C.  */
 +
 +extern char emacs_mule_bytes[256];
 +
 +static int
 +read_emacs_mule_char (c, readbyte, readcharfun)
 +     int c;
 +     int (*readbyte) P_ ((int, Lisp_Object));
 +     Lisp_Object readcharfun;
 +{
 +  /* Emacs-mule coding uses at most 4-byte for one character.  */
 +  unsigned char buf[4];
 +  int len = emacs_mule_bytes[c];
 +  struct charset *charset;
 +  int i;
 +  unsigned code;
 +
 +  if (len == 1)
 +    /* C is not a valid leading-code of `emacs-mule'.  */
 +    return BYTE8_TO_CHAR (c);
 +
 +  i = 0;
 +  buf[i++] = c;
 +  while (i < len)
 +    {
 +      c = (*readbyte) (-1, readcharfun);
 +      if (c < 0xA0)
 +      {
 +        while (--i > 1)
 +          (*readbyte) (buf[i], readcharfun);
 +        return BYTE8_TO_CHAR (buf[0]);
 +      }
 +      buf[i++] = c;
 +    }
 +
 +  if (len == 2)
 +    {
 +      charset = emacs_mule_charset[buf[0]];
 +      code = buf[1] & 0x7F;
 +    }
 +  else if (len == 3)
 +    {
 +      if (buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_11
 +        || buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_12)
 +      {
 +        charset = emacs_mule_charset[buf[1]];
 +        code = buf[2] & 0x7F;
 +      }
 +      else
 +      {
 +        charset = emacs_mule_charset[buf[0]];
 +        code = ((buf[1] << 8) | buf[2]) & 0x7F7F;
 +      }
 +    }
 +  else
 +    {
 +      charset = emacs_mule_charset[buf[1]];
 +      code = ((buf[2] << 8) | buf[3]) & 0x7F7F;
 +    }
 +  c = DECODE_CHAR (charset, code);
 +  if (c < 0)
 +    Fsignal (Qinvalid_read_syntax,
 +           Fcons (build_string ("invalid multibyte form"), Qnil));
 +  return c;
 +}
 +
 +
  static Lisp_Object read_internal_start P_ ((Lisp_Object, Lisp_Object,
                                            Lisp_Object));
  static Lisp_Object read0 P_ ((Lisp_Object));
@@@ -616,6 -436,7 +617,6 @@@ static Lisp_Object read1 P_ ((Lisp_Obje
  
  static Lisp_Object read_list P_ ((int, Lisp_Object));
  static Lisp_Object read_vector P_ ((Lisp_Object, int));
 -static int read_multibyte P_ ((int, Lisp_Object));
  
  static Lisp_Object substitute_object_recurse P_ ((Lisp_Object, Lisp_Object,
                                                  Lisp_Object));
@@@ -822,11 -643,11 +823,11 @@@ DEFUN ("get-file-char", Fget_file_char
  
  
  \f
 -/* Value is non-zero if the file asswociated with file descriptor FD
 -   is a compiled Lisp file that's safe to load.  Only files compiled
 -   with Emacs are safe to load.  Files compiled with XEmacs can lead
 -   to a crash in Fbyte_code because of an incompatible change in the
 -   byte compiler.  */
 +/* Value is a version number of byte compiled code if the file
 +   asswociated with file descriptor FD is a compiled Lisp file that's
 +   safe to load.  Only files compiled with Emacs are safe to load.
 +   Files compiled with XEmacs can lead to a crash in Fbyte_code
 +   because of an incompatible change in the byte compiler.  */
  
  static int
  safe_to_load_p (fd)
    char buf[512];
    int nbytes, i;
    int safe_p = 1;
 +  int version = 1;
  
    /* Read the first few bytes from the file, and look for a line
       specifying the byte compiler version used.  */
        buf[nbytes] = '\0';
  
        /* Skip to the next newline, skipping over the initial `ELC'
 -       with NUL bytes following it.  */
 +       with NUL bytes following it, but note the version.  */
        for (i = 0; i < nbytes && buf[i] != '\n'; ++i)
 -      ;
 +      if (i == 4)
 +        version = buf[i];
  
 -      if (i < nbytes
 -        && fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
 +      if (i == nbytes
 +        || fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
                                              buf + i) < 0)
        safe_p = 0;
      }
 +  if (safe_p)
 +    safe_p = version;
  
    lseek (fd, 0, SEEK_SET);
    return safe_p;
@@@ -882,6 -699,20 +883,20 @@@ load_error_handler (data
    return Qnil;
  }
  
+ static Lisp_Object
+ load_warn_old_style_backquotes (file)
+      Lisp_Object file;
+ {
+   if (!NILP (Vold_style_backquotes))
+     {
+       Lisp_Object args[2];
+       args[0] = build_string ("!! File %s uses old-style backquotes !!");
+       args[1] = file;
+       Fmessage (2, args);
+     }
+   return Qnil;
+ }
  DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
         doc: /* Return the suffixes that `load' should try if a suffix is \
  required.
@@@ -946,7 -777,6 +961,6 @@@ Return t if the file exists and loads s
    register FILE *stream;
    register int fd = -1;
    int count = SPECPDL_INDEX ();
-   Lisp_Object temp;
    struct gcpro gcpro1, gcpro2, gcpro3;
    Lisp_Object found, efound, hist_file_name;
    /* 1 means we printed the ".el is newer" message.  */
    int safe_p = 1;
    char *fmode = "r";
    Lisp_Object tmp[2];
 +  int version;
 +
  #ifdef DOS_NT
    fmode = "rt";
  #endif /* DOS_NT */
                                     tmp))
                      : found) ;
  
 +  version = -1;
++
+   /* Check fore the presence of old-style quotes and warn about them.  */
+   specbind (Qold_style_backquotes, Qnil);
+   record_unwind_protect (load_warn_old_style_backquotes, file);
    if (!bcmp (SDATA (found) + SBYTES (found) - 4,
 -           ".elc", 4))
 +           ".elc", 4)
 +      || (version = safe_to_load_p (fd)) > 0)
      /* Load .elc files directly, but not when they are
         remote and have no handler!  */
      {
  
          GCPRO3 (file, found, hist_file_name);
  
 -        if (!safe_to_load_p (fd))
 +        if (version < 0
 +            && ! (version = safe_to_load_p (fd)))
            {
              safe_p = 0;
              if (!load_dangerous_libraries)
    load_descriptor_list
      = Fcons (make_number (fileno (stream)), load_descriptor_list);
    load_in_progress++;
 -  readevalloop (Qget_file_char, stream, hist_file_name,
 -              Feval, 0, Qnil, Qnil, Qnil, Qnil);
 +  if (! version || version >= 22)
 +    readevalloop (Qget_file_char, stream, hist_file_name,
 +                Feval, 0, Qnil, Qnil, Qnil, Qnil);
 +  else
 +    {
 +      /* We can't handle a file which was compiled with
 +       byte-compile-dynamic by older version of Emacs.  */
 +      specbind (Qload_force_doc_strings, Qt);
 +      readevalloop (Qget_emacs_mule_file_char, stream, hist_file_name, Feval,
 +                  0, Qnil, Qnil, Qnil, Qnil);
 +    }
    unbind_to (count, Qnil);
  
    /* Run any eval-after-load forms for this file */
@@@ -1579,8 -1399,6 +1598,6 @@@ readevalloop_1 (old
  static void
  end_of_file_error ()
  {
-   Lisp_Object data;
    if (STRINGP (Vload_file_name))
      xsignal1 (Qend_of_file, Vload_file_name);
  
@@@ -1636,6 -1454,8 +1653,6 @@@ readevalloop (readcharfun, stream, sour
    record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil);
    load_convert_to_unibyte = !NILP (unibyte);
  
 -  readchar_backlog = -1;
 -
    GCPRO4 (sourcename, readfun, start, end);
  
    /* Try to ensure sourcename is a truename, except whilst preloading. */
@@@ -1892,6 -1712,7 +1909,6 @@@ read_internal_start (stream, start, end
  {
    Lisp_Object retval;
  
 -  readchar_backlog = -1;
    readchar_count = 0;
    new_backquote_flag = 0;
    read_objects = Qnil;
        || EQ (Vread_with_symbol_positions, stream))
      Vread_symbol_positions_list = Qnil;
  
 -  if (STRINGP (stream))
 +  if (STRINGP (stream)
 +      || ((CONSP (stream) && STRINGP (XCAR (stream)))))
      {
        int startval, endval;
 +      Lisp_Object string;
 +
 +      if (STRINGP (stream))
 +      string = stream;
 +      else
 +      string = XCAR (stream);
 +
        if (NILP (end))
 -      endval = SCHARS (stream);
 +      endval = SCHARS (string);
        else
        {
          CHECK_NUMBER (end);
          endval = XINT (end);
 -        if (endval < 0 || endval > SCHARS (stream))
 -          args_out_of_range (stream, end);
 +        if (endval < 0 || endval > SCHARS (string))
 +          args_out_of_range (string, end);
        }
  
        if (NILP (start))
          CHECK_NUMBER (start);
          startval = XINT (start);
          if (startval < 0 || startval > endval)
 -          args_out_of_range (stream, start);
 +          args_out_of_range (string, start);
        }
        read_from_string_index = startval;
 -      read_from_string_index_byte = string_char_to_byte (stream, startval);
 +      read_from_string_index_byte = string_char_to_byte (string, startval);
        read_from_string_limit = endval;
      }
  
@@@ -1977,19 -1790,59 +1994,19 @@@ read0 (readcharfun
  static int read_buffer_size;
  static char *read_buffer;
  
 -/* Read multibyte form and return it as a character.  C is a first
 -   byte of multibyte form, and rest of them are read from
 -   READCHARFUN.  */
 -
 -static int
 -read_multibyte (c, readcharfun)
 -     register int c;
 -     Lisp_Object readcharfun;
 -{
 -  /* We need the actual character code of this multibyte
 -     characters.  */
 -  unsigned char str[MAX_MULTIBYTE_LENGTH];
 -  int len = 0;
 -  int bytes;
 -
 -  if (c < 0)
 -    return c;
 -
 -  str[len++] = c;
 -  while ((c = READCHAR) >= 0xA0
 -       && len < MAX_MULTIBYTE_LENGTH)
 -    {
 -      str[len++] = c;
 -      readchar_count--;
 -    }
 -  UNREAD (c);
 -  if (UNIBYTE_STR_AS_MULTIBYTE_P (str, len, bytes))
 -    return STRING_CHAR (str, len);
 -  /* The byte sequence is not valid as multibyte.  Unread all bytes
 -     but the first one, and return the first byte.  */
 -  while (--len > 0)
 -    UNREAD (str[len]);
 -  return str[0];
 -}
 -
  /* Read a \-escape sequence, assuming we already read the `\'.
 -   If the escape sequence forces unibyte, store 1 into *BYTEREP.
 -   If the escape sequence forces multibyte, store 2 into *BYTEREP.
 -   Otherwise store 0 into *BYTEREP.  */
 +   If the escape sequence forces unibyte, return eight-bit char.  */
  
  static int
 -read_escape (readcharfun, stringp, byterep)
 +read_escape (readcharfun, stringp)
       Lisp_Object readcharfun;
       int stringp;
 -     int *byterep;
  {
    register int c = READCHAR;
    /* \u allows up to four hex digits, \U up to eight. Default to the
       behaviour for \u, and change this value in the case that \U is seen. */
    int unicode_hex_count = 4;
  
 -  *byterep = 0;
 -
    switch (c)
      {
      case -1:
        error ("Invalid escape character syntax");
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        return c | meta_modifier;
  
      case 'S':
        error ("Invalid escape character syntax");
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        return c | shift_modifier;
  
      case 'H':
        error ("Invalid escape character syntax");
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        return c | hyper_modifier;
  
      case 'A':
        error ("Invalid escape character syntax");
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        return c | alt_modifier;
  
      case 's':
        }
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        return c | super_modifier;
  
      case 'C':
      case '^':
        c = READCHAR;
        if (c == '\\')
 -      c = read_escape (readcharfun, 0, byterep);
 +      c = read_escape (readcharfun, 0);
        if ((c & ~CHAR_MODIFIER_MASK) == '?')
        return 0177 | (c & CHAR_MODIFIER_MASK);
        else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
              }
          }
  
 -      *byterep = 1;
 +      if (i >= 0x80 && i < 0x100)
 +        i = BYTE8_TO_CHAR (i);
        return i;
        }
  
        /* A hex escape, as in ANSI C.  */
        {
        int i = 0;
 +      int count = 0;
        while (1)
          {
            c = READCHAR;
                UNREAD (c);
                break;
              }
 +          count++;
          }
  
 -      *byterep = 2;
 +      if (count < 3 && i >= 0x80)
 +        return BYTE8_TO_CHAR (i);
        return i;
        }
  
        {
        int i = 0;
        int count = 0;
 -      Lisp_Object lisp_char;
 -      struct gcpro gcpro1;
  
        while (++count <= unicode_hex_count)
          {
              }
          }
  
 -      GCPRO1 (readcharfun);
 -      lisp_char = call2 (intern ("decode-char"), intern ("ucs"),
 -                        make_number (i));
 -      UNGCPRO;
 -
 -      if (NILP (lisp_char))
 -        {
 -          error ("Unsupported Unicode code point: U+%x", (unsigned)i);
 -        }
 -
 -      return XFASTINT (lisp_char);
 +      return i;
        }
  
      default:
 -      if (BASE_LEADING_CODE_P (c))
 -      c = read_multibyte (c, readcharfun);
        return c;
      }
  }
@@@ -2255,6 -2118,43 +2272,6 @@@ read_integer (readcharfun, radix
  }
  
  
 -/* Convert unibyte text in read_buffer to multibyte.
 -
 -   Initially, *P is a pointer after the end of the unibyte text, and
 -   the pointer *END points after the end of read_buffer.
 -
 -   If read_buffer doesn't have enough room to hold the result
 -   of the conversion, reallocate it and adjust *P and *END.
 -
 -   At the end, make *P point after the result of the conversion, and
 -   return in *NCHARS the number of characters in the converted
 -   text.  */
 -
 -static void
 -to_multibyte (p, end, nchars)
 -     char **p, **end;
 -     int *nchars;
 -{
 -  int nbytes;
 -
 -  parse_str_as_multibyte (read_buffer, *p - read_buffer, &nbytes, nchars);
 -  if (read_buffer_size < 2 * nbytes)
 -    {
 -      int offset = *p - read_buffer;
 -      read_buffer_size = 2 * max (read_buffer_size, nbytes);
 -      read_buffer = (char *) xrealloc (read_buffer, read_buffer_size);
 -      *p = read_buffer + offset;
 -      *end = read_buffer + read_buffer_size;
 -    }
 -
 -  if (nbytes != *nchars)
 -    nbytes = str_as_multibyte (read_buffer, read_buffer_size,
 -                             *p - read_buffer, nchars);
 -
 -  *p = read_buffer + nbytes;
 -}
 -
 -
  /* If the next token is ')' or ']' or '.', we store that character
     in *PCH and the return value is not interesting.  Else, we store
     zero in *PCH and we read and return one lisp object.
@@@ -2271,7 -2171,6 +2288,7 @@@ read1 (readcharfun, pch, first_in_list
    int uninterned_symbol = 0;
  
    *pch = 0;
 +  load_each_byte = 0;
  
   retry:
  
            {
              Lisp_Object tmp;
              tmp = read_vector (readcharfun, 0);
 -            if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS
 -                || XVECTOR (tmp)->size > CHAR_TABLE_STANDARD_SLOTS + 10)
 +            if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS)
                error ("Invalid size char-table");
              XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
 -            XCHAR_TABLE (tmp)->top = Qt;
              return tmp;
            }
          else if (c == '^')
              if (c == '[')
                {
                  Lisp_Object tmp;
 +                int depth, size;
 +
                  tmp = read_vector (readcharfun, 0);
 -                if (XVECTOR (tmp)->size != SUB_CHAR_TABLE_STANDARD_SLOTS)
 +                if (!INTEGERP (AREF (tmp, 0)))
 +                  error ("Invalid depth in char-table");
 +                depth = XINT (AREF (tmp, 0));
 +                if (depth < 1 || depth > 3)
 +                  error ("Invalid depth in char-table");
 +                size = XVECTOR (tmp)->size - 2;
 +                if (chartab_size [depth] != size)
                    error ("Invalid size char-table");
 -                XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
 -                XCHAR_TABLE (tmp)->top = Qnil;
 +                XSETSUB_CHAR_TABLE (tmp, XSUB_CHAR_TABLE (tmp));
                  return tmp;
                }
              invalid_syntax ("#^^", 3);
  
              UNREAD (c);
              tmp = read1 (readcharfun, pch, first_in_list);
 -            if (size_in_chars != SCHARS (tmp)
 -                /* We used to print 1 char too many
 -                   when the number of bits was a multiple of 8.
 -                   Accept such input in case it came from an old version.  */
 -                && ! (XFASTINT (length)
 -                      == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR))
 +            if (STRING_MULTIBYTE (tmp)
 +                || (size_in_chars != SCHARS (tmp)
 +                    /* We used to print 1 char too many
 +                       when the number of bits was a multiple of 8.
 +                       Accept such input in case it came from an old
 +                       version.  */
 +                    && ! (XFASTINT (length)
 +                          == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)))
                invalid_syntax ("#&...", 5);
  
              val = Fmake_bool_vector (length, Qnil);
        {
          int i, nskip = 0;
  
 +        load_each_byte = 1;
          /* Read a decimal integer.  */
          while ((c = READCHAR) >= 0
                 && c >= '0' && c <= '9')
          if (c >= 0)
            UNREAD (c);
  
 -        if (load_force_doc_strings && EQ (readcharfun, Qget_file_char))
 +        if (load_force_doc_strings
 +            && (EQ (readcharfun, Qget_file_char)
 +                || EQ (readcharfun, Qget_emacs_mule_file_char)))
            {
              /* If we are supposed to force doc strings into core right now,
                 record the last string that we skipped,
                c = READCHAR;
            }
  
 +        load_each_byte = 0;
          goto retry;
        }
        if (c == '!')
  
      case '`':
        if (first_in_list)
-       goto default_label;
+       {
+         Vold_style_backquotes = Qt;
+         goto default_label;
+       }
        else
        {
          Lisp_Object value;
          return Fcons (comma_type, Fcons (value, Qnil));
        }
        else
-       goto default_label;
+       {
+         Vold_style_backquotes = Qt;
+         goto default_label;
+       }
  
      case '?':
        {
 -      int discard;
 +      int modifiers;
        int next_char;
        int ok;
  
          return make_number (c);
  
        if (c == '\\')
 -        c = read_escape (readcharfun, 0, &discard);
 -      else if (BASE_LEADING_CODE_P (c))
 -        c = read_multibyte (c, readcharfun);
 +        c = read_escape (readcharfun, 0);
 +      modifiers = c & CHAR_MODIFIER_MASK;
 +      c &= ~CHAR_MODIFIER_MASK;
 +      if (CHAR_BYTE8_P (c))
 +        c = CHAR_TO_BYTE8 (c);
 +      c |= modifiers;
  
        next_char = READCHAR;
        if (next_char == '.')
        char *p = read_buffer;
        char *end = read_buffer + read_buffer_size;
        register int c;
 -      /* 1 if we saw an escape sequence specifying
 -         a multibyte character, or a multibyte character.  */
 +      /* Nonzero if we saw an escape sequence specifying
 +         a multibyte character.  */
        int force_multibyte = 0;
 -      /* 1 if we saw an escape sequence specifying
 +      /* Nonzero if we saw an escape sequence specifying
           a single-byte character.  */
        int force_singlebyte = 0;
 -      /* 1 if read_buffer contains multibyte text now.  */
 -      int is_multibyte = 0;
        int cancel = 0;
        int nchars = 0;
  
  
            if (c == '\\')
              {
 -              int byterep;
 +              int modifiers;
  
 -              c = read_escape (readcharfun, 1, &byterep);
 +              c = read_escape (readcharfun, 1);
  
                /* C is -1 if \ newline has just been seen */
                if (c == -1)
                    continue;
                  }
  
 -              if (byterep == 1)
 +              modifiers = c & CHAR_MODIFIER_MASK;
 +              c = c & ~CHAR_MODIFIER_MASK;
 +
 +              if (CHAR_BYTE8_P (c))
                  force_singlebyte = 1;
 -              else if (byterep == 2)
 +              else if (! ASCII_CHAR_P (c))
                  force_multibyte = 1;
 -            }
 -
 -          /* A character that must be multibyte forces multibyte.  */
 -          if (! SINGLE_BYTE_CHAR_P (c & ~CHAR_MODIFIER_MASK))
 -            force_multibyte = 1;
 +              else            /* i.e. ASCII_CHAR_P (c) */
 +                {
 +                  /* Allow `\C- ' and `\C-?'.  */
 +                  if (modifiers == CHAR_CTL)
 +                    {
 +                      if (c == ' ')
 +                        c = 0, modifiers = 0;
 +                      else if (c == '?')
 +                        c = 127, modifiers = 0;
 +                    }
 +                  if (modifiers & CHAR_SHIFT)
 +                    {
 +                      /* Shift modifier is valid only with [A-Za-z].  */
 +                      if (c >= 'A' && c <= 'Z')
 +                        modifiers &= ~CHAR_SHIFT;
 +                      else if (c >= 'a' && c <= 'z')
 +                        c -= ('a' - 'A'), modifiers &= ~CHAR_SHIFT;
 +                    }
 +
 +                  if (modifiers & CHAR_META)
 +                    {
 +                      /* Move the meta bit to the right place for a
 +                         string.  */
 +                      modifiers &= ~CHAR_META;
 +                      c = BYTE8_TO_CHAR (c | 0x80);
 +                      force_singlebyte = 1;
 +                    }
 +                }
  
 -          /* If we just discovered the need to be multibyte,
 -             convert the text accumulated thus far.  */
 -          if (force_multibyte && ! is_multibyte)
 -            {
 -              is_multibyte = 1;
 -              to_multibyte (&p, &end, &nchars);
 +              /* Any modifiers remaining are invalid.  */
 +              if (modifiers)
 +                error ("Invalid modifier in string");
 +              p += CHAR_STRING (c, (unsigned char *) p);
              }
 -
 -          /* Allow `\C- ' and `\C-?'.  */
 -          if (c == (CHAR_CTL | ' '))
 -            c = 0;
 -          else if (c == (CHAR_CTL | '?'))
 -            c = 127;
 -
 -          if (c & CHAR_SHIFT)
 +          else
              {
 -              /* Shift modifier is valid only with [A-Za-z].  */
 -              if ((c & 0377) >= 'A' && (c & 0377) <= 'Z')
 -                c &= ~CHAR_SHIFT;
 -              else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
 -                c = (c & ~CHAR_SHIFT) - ('a' - 'A');
 +              p += CHAR_STRING (c, (unsigned char *) p);
 +              if (CHAR_BYTE8_P (c))
 +                force_singlebyte = 1;
 +              else if (! ASCII_CHAR_P (c))
 +                force_multibyte = 1;
              }
 -
 -          if (c & CHAR_META)
 -            /* Move the meta bit to the right place for a string.  */
 -            c = (c & ~CHAR_META) | 0x80;
 -          if (c & CHAR_MODIFIER_MASK)
 -            error ("Invalid modifier in string");
 -
 -          if (is_multibyte)
 -            p += CHAR_STRING (c, p);
 -          else
 -            *p++ = c;
 -
            nchars++;
          }
  
        if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel)
          return make_number (0);
  
 -      if (is_multibyte || force_singlebyte)
 +      if (force_multibyte)
 +        /* READ_BUFFER already contains valid multibyte forms.  */
          ;
 -      else if (load_convert_to_unibyte)
 +      else if (force_singlebyte)
          {
 -          Lisp_Object string;
 -          to_multibyte (&p, &end, &nchars);
 -          if (p - read_buffer != nchars)
 -            {
 -              string = make_multibyte_string (read_buffer, nchars,
 -                                              p - read_buffer);
 -              return Fstring_make_unibyte (string);
 -            }
 -          /* We can make a unibyte string directly.  */
 -          is_multibyte = 0;
 -        }
 -      else if (EQ (readcharfun, Qget_file_char)
 -               || EQ (readcharfun, Qlambda))
 -        {
 -          /* Nowadays, reading directly from a file is used only for
 -             compiled Emacs Lisp files, and those always use the
 -             Emacs internal encoding.  Meanwhile, Qlambda is used
 -             for reading dynamic byte code (compiled with
 -             byte-compile-dynamic = t).  So make the string multibyte
 -             if the string contains any multibyte sequences.
 -             (to_multibyte is a no-op if not.)  */
 -          to_multibyte (&p, &end, &nchars);
 -          is_multibyte = (p - read_buffer) != nchars;
 +          nchars = str_as_unibyte (read_buffer, p - read_buffer);
 +          p = read_buffer + nchars;
          }
        else
 -        /* In all other cases, if we read these bytes as
 -           separate characters, treat them as separate characters now.  */
 +        /* Otherwise, READ_BUFFER contains only ASCII.  */
          ;
  
        /* We want readchar_count to be the number of characters, not
        /* readchar_count -= (p - read_buffer) - nchars; */
        if (read_pure)
          return make_pure_string (read_buffer, nchars, p - read_buffer,
 -                                 is_multibyte);
 +                                 (force_multibyte
 +                                  || (p - read_buffer != nchars)));
        return make_specified_string (read_buffer, nchars, p - read_buffer,
 -                                    is_multibyte);
 +                                    (force_multibyte
 +                                     || (p - read_buffer != nchars)));
        }
  
      case '.':
                  quoted = 1;
                }
  
 -            if (! SINGLE_BYTE_CHAR_P (c))
 -              p += CHAR_STRING (c, p);
 -            else
 -              *p++ = c;
 -
 +            p += CHAR_STRING (c, p);
              c = READCHAR;
            }
  
                  {
                    if (p1[-1] == '.')
                      p1[-1] = '\0';
 +                  /* Fixme: if we have strtol, use that, and check
 +                     for overflow.  */
                    if (sizeof (int) == sizeof (EMACS_INT))
                      XSETINT (val, atoi (read_buffer));
                    else if (sizeof (long) == sizeof (EMACS_INT))
@@@ -3199,7 -3108,7 +3222,7 @@@ read_vector (readcharfun, bytecodeflag
                  STRING_SET_CHARS (bytestr, SBYTES (bytestr));
                  STRING_SET_UNIBYTE (bytestr);
  
 -                item = Fread (bytestr);
 +                item = Fread (Fcons (bytestr, readcharfun));
                  if (!CONSP (item))
                    error ("Invalid byte code");
  
              /* Now handle the bytecode slot.  */
              ptr[COMPILED_BYTECODE] = read_pure ? Fpurecopy (bytestr) : bytestr;
            }
 +        else if (i == COMPILED_DOC_STRING
 +                 && STRINGP (item)
 +                 && ! STRING_MULTIBYTE (item))
 +          {
 +            if (EQ (readcharfun, Qget_emacs_mule_file_char))
 +              item = Fdecode_coding_string (item, Qemacs_mule, Qnil, Qnil);
 +            else
 +              item = Fstring_as_multibyte (item);
 +          }
        }
        ptr[i] = read_pure ? Fpurecopy (item) : item;
        otem = XCONS (tem);
@@@ -3317,15 -3217,7 +3340,15 @@@ read_list (flag, readcharfun
                  if (doc_reference == 2)
                    {
                      /* Get a doc string from the file we are loading.
 -                       If it's in saved_doc_string, get it from there.  */
 +                       If it's in saved_doc_string, get it from there.
 +
 +                       Here, we don't know if the string is a
 +                       bytecode string or a doc string.  As a
 +                       bytecode string must be unibyte, we always
 +                       return a unibyte string.  If it is actually a
 +                       doc string, caller must make it
 +                       multibyte.  */
 +
                      int pos = XINT (XCDR (val));
                      /* Position is negative for user variables.  */
                      if (pos < 0) pos = -pos;
                                saved_doc_string[to++] = c;
                            }
  
 -                        return make_string (saved_doc_string + start,
 -                                            to - start);
 +                        return make_unibyte_string (saved_doc_string + start,
 +                                                    to - start);
                        }
                      /* Look in prev_saved_doc_string the same way.  */
                      else if (pos >= prev_saved_doc_string_position
                                prev_saved_doc_string[to++] = c;
                            }
  
 -                        return make_string (prev_saved_doc_string + start,
 -                                            to - start);
 +                        return make_unibyte_string (prev_saved_doc_string
 +                                                    + start,
 +                                                    to - start);
                        }
                      else
 -                      return get_doc_string (val, 0, 0);
 +                      return get_doc_string (val, 1, 0);
                    }
  
                  return val;
@@@ -4322,6 -4213,12 +4345,12 @@@ to load.  See also `load-dangerous-libr
               doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'.  */);
    Veval_buffer_list = Qnil;
  
+   DEFVAR_LISP ("old-style-backquotes", &Vold_style_backquotes,
+              doc: /* Set to non-nil when `read' encounters an old-style backquote.  */);
+   Vold_style_backquotes = Qnil;
+   Qold_style_backquotes = intern ("old-style-backquotes");
+   staticpro (&Qold_style_backquotes);
    /* Vsource_directory was initialized in init_lread.  */
  
    load_descriptor_list = Qnil;
    Qget_file_char = intern ("get-file-char");
    staticpro (&Qget_file_char);
  
 +  Qget_emacs_mule_file_char = intern ("get-emacs-mule-file-char");
 +  staticpro (&Qget_emacs_mule_file_char);
 +
 +  Qload_force_doc_strings = intern ("load-force-doc-strings");
 +  staticpro (&Qload_force_doc_strings);
 +
    Qbackquote = intern ("`");
    staticpro (&Qbackquote);
    Qcomma = intern (",");
diff --combined src/macterm.c
index 654afcf6b1ab4abe037e7d7bad0842ff2df90776,0f2b053853dfec0e041317a3b1b3fbd743e6e84b..734bf52e180dde16096cc30c34ffb329f982fd01
@@@ -80,8 -80,6 +80,8 @@@ Boston, MA 02110-1301, USA.  *
  #include "intervals.h"
  #include "atimer.h"
  #include "keymap.h"
 +#include "character.h"
 +#include "ccl.h"
  
  \f
  
@@@ -2412,8 -2410,7 +2412,8 @@@ XTreset_terminal_modes (
  /* Function prototypes of this page.  */
  
  static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
 -static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *));
 +static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, 
 +                              struct charset *, int *));
  
  
  static void
@@@ -2557,13 -2554,13 +2557,13 @@@ mac_per_char_metric (font, char2b, font
     the two-byte form of C.  Encoding is returned in *CHAR2B.  */
  
  static int
 -mac_encode_char (c, char2b, font_info, two_byte_p)
 +mac_encode_char (c, char2b, font_info, charset, two_byte_p)
       int c;
       XChar2b *char2b;
       struct font_info *font_info;
 +     struct charset *charset;
       int *two_byte_p;
  {
 -  int charset = CHAR_CHARSET (c);
    XFontStruct *font = font_info->font;
  
    /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
        check_ccl_update (ccl);
        if (CHARSET_DIMENSION (charset) == 1)
        {
 -        ccl->reg[0] = charset;
 -        ccl->reg[1] = char2b->byte2;
 +        ccl->reg[0] = CHARSET_ID (charset);
 +        ccl->reg[1] = XCHAR2B_BYTE2 (char2b);
          ccl->reg[2] = -1;
        }
        else
        {
 -        ccl->reg[0] = charset;
 -        ccl->reg[1] = char2b->byte1;
 -        ccl->reg[2] = char2b->byte2;
 +        ccl->reg[0] = CHARSET_ID (charset);
 +        ccl->reg[1] = XCHAR2B_BYTE1 (char2b);
 +        ccl->reg[2] = XCHAR2B_BYTE2 (char2b);
        }
  
 -      ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
 +      ccl_driver (ccl, NULL, NULL, 0, 0, Qnil);
  
        /* We assume that MSBs are appropriately set/reset by CCL
         program.  */
        if (font->max_byte1 == 0)       /* 1-byte font */
 -      char2b->byte1 = 0, char2b->byte2 = ccl->reg[1];
 +      STORE_XCHAR2B (char2b, 0, ccl->reg[1]);
        else
 -      char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2];
 +      STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]);
      }
 -  else if (font_info->encoding[charset])
 +  else if (font_info->encoding_type)
      {
        /* Fixed encoding scheme.  See fontset.h for the meaning of the
         encoding numbers.  */
 -      int enc = font_info->encoding[charset];
 +      unsigned char enc = font_info->encoding_type;
  
        if ((enc == 1 || enc == 2)
          && CHARSET_DIMENSION (charset) == 2)
        char2b->byte2 |= 0x80;
  
        if (enc == 4)
 -        {
 -          int sjis1, sjis2;
 +      {
 +        int code = (char2b->byte1 << 8) | char2b->byte2;
  
 -          ENCODE_SJIS (char2b->byte1, char2b->byte2, sjis1, sjis2);
 -          char2b->byte1 = sjis1;
 -          char2b->byte2 = sjis2;
 -        }
 +        JIS_TO_SJIS (code);
 +        STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
 +      }
      }
  
    if (two_byte_p)
@@@ -2735,9 -2733,9 +2735,9 @@@ x_set_mouse_face_gc (s
      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
  
    if (s->first_glyph->type == CHAR_GLYPH)
 -    face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
 +    face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch, -1, Qnil);
    else
 -    face_id = FACE_FOR_CHAR (s->f, face, 0);
 +    face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil);
    s->face = FACE_FROM_ID (s->f, face_id);
    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
  
@@@ -3058,10 -3056,17 +3058,17 @@@ x_draw_composite_glyph_string_foregroun
    else
      {
        for (i = 0; i < s->nchars; i++, ++s->gidx)
-       mac_draw_image_string_16 (s->f, s->gc,
-                                 x + s->cmp->offsets[s->gidx * 2],
-                                 s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
-                                 s->char2b + i, 1, 0, s->face->overstrike);
+       if (mac_per_char_metric (GC_FONT (s->gc), s->char2b + i, 0) == NULL)
+         /* This is a nonexistent or zero-width glyph such as a
+            combining diacritic.  Draw a rectangle.  */
+         mac_draw_rectangle (s->f, s->gc,
+                             x + s->cmp->offsets[s->gidx * 2], s->y,
+                             FONT_WIDTH (GC_FONT (s->gc)) - 1, s->height - 1);
+       else
+         mac_draw_image_string_16 (s->f, s->gc,
+                                   x + s->cmp->offsets[s->gidx * 2],
+                                   s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
+                                   s->char2b + i, 1, 0, s->face->overstrike);
      }
  }
  
@@@ -3093,8 -3098,8 +3100,8 @@@ x_frame_of_widget (widget
  
    /* Look for a frame with that top-level widget.  Allocate the color
       on that frame to get the right gamma correction value.  */
 -  for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
 -    if (GC_FRAMEP (XCAR (tail))
 +  for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
 +    if (FRAMEP (XCAR (tail))
        && (f = XFRAME (XCAR (tail)),
            (f->output_data.nothing != 1
             && FRAME_X_DISPLAY_INFO (f) == dpyinfo))
@@@ -4410,9 -4415,9 +4417,9 @@@ mac_focus_changed (type, dpyinfo, frame
  
            /* Don't stop displaying the initial startup message
               for a switch-frame event we don't need.  */
 -          if (GC_NILP (Vterminal_frame)
 -              && GC_CONSP (Vframe_list)
 -              && !GC_NILP (XCDR (Vframe_list)))
 +          if (NILP (Vterminal_frame)
 +              && CONSP (Vframe_list)
 +              && !NILP (XCDR (Vframe_list)))
              {
                bufp->kind = FOCUS_IN_EVENT;
                XSETFRAME (bufp->frame_or_window, frame);
@@@ -4485,7 -4490,7 +4492,7 @@@ x_frame_rehighlight (dpyinfo
    if (dpyinfo->x_focus_frame)
      {
        dpyinfo->x_highlight_frame
 -      = ((GC_FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame)))
 +      = ((FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame)))
           ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame))
           : dpyinfo->x_focus_frame);
        if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
@@@ -5515,7 -5520,7 +5522,7 @@@ x_scroll_bar_handle_click (bar, part_co
  {
    int win_y, top_range;
  
 -  if (! GC_WINDOWP (bar->window))
 +  if (! WINDOWP (bar->window))
      abort ();
  
    bufp->kind = SCROLL_BAR_CLICK_EVENT;
@@@ -5590,7 -5595,7 +5597,7 @@@ x_scroll_bar_note_movement (bar, y_pos
    XSETVECTOR (last_mouse_scroll_bar, bar);
  
    /* If we're dragging the bar, display it.  */
 -  if (! GC_NILP (bar->dragging))
 +  if (! NILP (bar->dragging))
      {
        /* Where should the handle be now?  */
        int new_start = y_pos - 24;
@@@ -6549,16 -6554,11 +6556,16 @@@ x_new_font (f, fontname
       register char *fontname;
  {
    struct font_info *fontp
 -    = FS_LOAD_FONT (f, 0, fontname, -1);
 +    = FS_LOAD_FONT (f, fontname);
  
    if (!fontp)
      return Qnil;
  
 +  if (FRAME_FONT (f) == (XFontStruct *) (fontp->font))
 +    /* This font is already set in frame F.  There's nothing more to
 +       do.  */
 +    return build_string (fontp->full_name);
 +
    FRAME_FONT (f) = (XFontStruct *) (fontp->font);
    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
    FRAME_FONTSET (f) = -1;
  
    return build_string (fontp->full_name);
  }
 +\f
 +/* Give frame F the fontset named FONTSETNAME as its default fontset,
 +   and return the full name of that fontset.  FONTSETNAME may be a
 +   wildcard pattern; in that case, we choose some fontset that fits
 +   the pattern.  FONTSETNAME may be a font name for ASCII characters;
 +   in that case, we create a fontset from that font name.
  
 -/* Give frame F the fontset named FONTSETNAME as its default font, and
 -   return the full name of that fontset.  FONTSETNAME may be a wildcard
 -   pattern; in that case, we choose some fontset that fits the pattern.
 -   The return value shows which fontset we chose.  */
 +   The return value shows which fontset we chose.
 +   If FONTSETNAME specifies the default fontset, return Qt.
 +   If an ASCII font in the specified fontset can't be loaded, return
 +   Qnil.  */
  
  Lisp_Object
  x_new_fontset (f, fontsetname)
       struct frame *f;
 -     char *fontsetname;
 +     Lisp_Object fontsetname;
  {
 -  int fontset = fs_query_fontset (build_string (fontsetname), 0);
 +  int fontset = fs_query_fontset (fontsetname, 0);
    Lisp_Object result;
  
 -  if (fontset < 0)
 -    return Qnil;
 -
 -  if (FRAME_FONTSET (f) == fontset)
 +  if (fontset > 0 && FRAME_FONTSET(f) == fontset)
      /* This fontset is already set in frame F.  There's nothing more
         to do.  */
      return fontset_name (fontset);
 +  else if (fontset == 0)
 +    /* The default fontset can't be the default font.   */
 +    return Qt;
  
 -  result = x_new_font (f, (SDATA (fontset_ascii (fontset))));
 +  if (fontset > 0)
 +    result = x_new_font (f, (SDATA (fontset_ascii (fontset))));
 +  else
 +    result = x_new_font (f, SDATA (fontsetname));
  
    if (!STRINGP (result))
      /* Can't load ASCII font.  */
      return Qnil;
  
 +  if (fontset < 0)
 +    fontset = new_fontset_from_font_name (result);
 +
    /* Since x_new_font doesn't update any fontset information, do it now.  */
    FRAME_FONTSET (f) = fontset;
  
 -  return build_string (fontsetname);
 +  return fontset_name (fontset);
  }
  
  \f
@@@ -7858,12 -7846,12 +7865,12 @@@ decode_mac_font_name (name, size, codin
          coding.src_multibyte = 0;
          coding.dst_multibyte = 1;
          coding.mode |= CODING_MODE_LAST_BLOCK;
 -        coding.composing = COMPOSITION_DISABLED;
 -        buf = (char *) alloca (size);
 +        coding.dst_bytes = size;
 +        coding.destination = (unsigned char *) alloca (coding.dst_bytes);
  
 -        decode_coding (&coding, name, buf, strlen (name), size - 1);
 -        bcopy (buf, name, coding.produced);
 -        name[coding.produced] = '\0';
 +        decode_coding_c_string (&coding, name, strlen (name), Qnil);
 +        bcopy (coding.destination, name, min (coding.produced, size));
 +        name[min (coding.produced, size)] = '\0';
        }
      }
  
@@@ -9200,7 -9188,6 +9207,7 @@@ x_load_font (f, fontname, size
      bzero (fontp, sizeof (*fontp));
      fontp->font = font;
      fontp->font_idx = i;
 +    fontp->charset = -1;      /* fs_load_font sets it.  */
      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
      bcopy (fontname, fontp->name, strlen (fontname) + 1);
  
        fontp->height = max_height;
      }
  
 +    /* MAC_TODO: The script encoding is irrelevant in unicode? */
      /* The slot `encoding' specifies how to map a character
         code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to
         the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or
         (0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF,
         2:0xA020..0xFF7F).  For the moment, we don't know which charset
 -       uses this font.  So, we set information in fontp->encoding[1]
 +       uses this font.  So, we set information in fontp->encoding_type
         which is never used by any charset.  If mapping can't be
         decided, set FONT_ENCODING_NOT_DECIDED.  */
      if (font->mac_scriptcode == smJapanese)
 -      fontp->encoding[1] = 4;
 +      fontp->encoding_type = 4;
      else
        {
 -        fontp->encoding[1]
 +        fontp->encoding_type
             = (font->max_byte1 == 0
              /* 1-byte font */
              ? (font->min_char_or_byte2 < 0x80
diff --combined src/xdisp.c
index a24dea966cfdc1987dcd33f0356fb82363b041ac,d22c9a53bc3cc01f8d6e51cc0832856f9b5c0398..060a1c50d1ce83ae463f1d23aa75c795b7353106
@@@ -177,7 -177,6 +177,7 @@@ Boston, MA 02110-1301, USA.  *
  #include "termchar.h"
  #include "dispextern.h"
  #include "buffer.h"
 +#include "character.h"
  #include "charset.h"
  #include "indent.h"
  #include "commands.h"
  #include "macterm.h"
  #endif
  
 +#ifdef HAVE_WINDOW_SYSTEM
 +#ifdef USE_FONT_BACKEND
 +#include "font.h"
 +#endif        /* USE_FONT_BACKEND */
 +#endif        /* HAVE_WINDOW_SYSTEM */
 +
  #ifndef FRAME_X_OUTPUT
  #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
  #endif
@@@ -760,7 -753,6 +760,7 @@@ static enum prop_handled handle_display
  static enum prop_handled handle_composition_prop P_ ((struct it *));
  static enum prop_handled handle_overlay_change P_ ((struct it *));
  static enum prop_handled handle_fontified_prop P_ ((struct it *));
 +static enum prop_handled handle_auto_composed_prop P_ ((struct it *));
  
  /* Properties handled by iterators.  */
  
@@@ -772,7 -764,6 +772,7 @@@ static struct props it_props[] 
    {&Qface,            FACE_PROP_IDX,          handle_face_prop},
    {&Qdisplay,         DISPLAY_PROP_IDX,       handle_display_prop},
    {&Qinvisible,               INVISIBLE_PROP_IDX,     handle_invisible_prop},
 +  {&Qauto_composed,   AUTO_COMPOSED_PROP_IDX, handle_auto_composed_prop},
    {&Qcomposition,     COMPOSITION_PROP_IDX,   handle_composition_prop},
    {NULL,              0,                      NULL}
  };
@@@ -3513,7 -3504,7 +3513,7 @@@ face_before_or_after_it_pos (it, before
          struct face *face = FACE_FROM_ID (it->f, face_id);
  
          c = string_char_and_length (p, rest, &len);
 -        face_id = FACE_FOR_CHAR (it->f, face, c);
 +        face_id = FACE_FOR_CHAR (it->f, face, c, CHARPOS (pos), it->string);
        }
      }
    else
        {
          int c = FETCH_MULTIBYTE_CHAR (BYTEPOS (pos));
          struct face *face = FACE_FROM_ID (it->f, face_id);
 -        face_id = FACE_FOR_CHAR (it->f, face, c);
 +        face_id = FACE_FOR_CHAR (it->f, face, c, CHARPOS (pos), Qnil);
        }
      }
  
@@@ -4127,7 -4118,7 +4127,7 @@@ handle_single_display_spec (it, spec, o
        {
          Lisp_Object face_name = XCAR (XCDR (XCDR (spec)));
          int face_id2 = lookup_derived_face (it->f, face_name,
 -                                            'A', FRINGE_FACE_ID, 0);
 +                                            FRINGE_FACE_ID, 0);
          if (face_id2 >= 0)
            face_id = face_id2;
        }
@@@ -4478,117 -4469,6 +4478,117 @@@ string_buffer_position (w, string, arou
                        `composition' property
   ***********************************************************************/
  
 +static enum prop_handled
 +handle_auto_composed_prop (it)
 +     struct it *it;
 +{
 +  enum prop_handled handled = HANDLED_NORMALLY;
 +
 +  if (FUNCTIONP (Vauto_composition_function))
 +    {
 +      Lisp_Object val;
 +      EMACS_INT pos, this_pos;
 +
 +      if (STRINGP (it->string))
 +      pos = IT_STRING_CHARPOS (*it);
 +      else
 +      pos = IT_CHARPOS (*it);
 +      this_pos = pos;
 +
 +      val =Fget_char_property (make_number (pos), Qauto_composed, it->string);
 +      if (! NILP (val))
 +      {
 +        Lisp_Object limit = Qnil, next;
 +        
 +        /* As Fnext_single_char_property_change is very slow, we
 +           limit the search to the current line.  */
 +        if (STRINGP (it->string))
 +          limit = make_number (SCHARS (it->string));
 +        else
 +          limit = make_number (find_next_newline_no_quit (pos, 1));
 +
 +        next = (Fnext_single_property_change
 +                (make_number (pos), Qauto_composed, it->string, limit));
 +        if (XINT (next) < XINT (limit))
 +          {
 +            /* The current point is auto-composed, but there exist
 +               characters not yet composed beyond the auto-composed
 +               region.  There's a possiblity that the last
 +               characters in the region may be newly composed.  */
 +            int charpos = XINT (next) - 1, bytepos, c;
 +
 +            if (STRINGP (it->string))
 +              {
 +                bytepos = string_char_to_byte (it->string, charpos);
 +                c = SDATA (it->string)[bytepos];
 +              }
 +            else
 +              {
 +                bytepos = CHAR_TO_BYTE (charpos);
 +                c = FETCH_BYTE (bytepos);
 +              }
 +            if (c != '\n')
 +              /* If the last character is not newline, it may be
 +                 composed with the following characters.  */
 +              val = Qnil, pos = charpos + 1;
 +          }
 +      }
 +      if (NILP (val))
 +      {
 +        int count = SPECPDL_INDEX ();
 +        Lisp_Object args[4];
 +
 +        args[0] = Vauto_composition_function;
 +        specbind (Qauto_composition_function, Qnil);
 +        args[1] = make_number (pos);
 +        args[2] = it->string;
 +#ifdef USE_FONT_BACKEND
 +        if (enable_font_backend)
 +          {
 +            struct face *face = FACE_FROM_ID (it->f, it->face_id);
 +            int c;
 +
 +            if (STRINGP (it->string))
 +              {
 +                EMACS_INT pos_byte = IT_STRING_BYTEPOS (*it);
 +                const unsigned char *s = SDATA (it->string) + pos_byte;
 +
 +                if (STRING_MULTIBYTE (it->string))
 +                  it->c = STRING_CHAR (s, 0);
 +                else
 +                  it->c = *s;
 +              }
 +            else
 +              {
 +                EMACS_INT pos_byte = IT_BYTEPOS (*it);
 +
 +                it->c = FETCH_CHAR (pos_byte);
 +              }
 +            args[3] = font_at (it->c, this_pos, face, it->w, it->string);
 +          }
 +        else
 +#endif        /* USE_FONT_BACKEND */
 +          args[3] = Qnil;
 +        safe_call (4, args);
 +        unbind_to (count, Qnil);
 +
 +        if (this_pos == pos)
 +          {
 +            val = Fget_char_property (args[1], Qauto_composed, it->string);
 +            /* Return HANDLED_RECOMPUTE_PROPS only if function composed
 +               something.  This avoids an endless loop if they failed to
 +               fontify the text for which reason ever.  */
 +            if (! NILP (val))
 +              handled = HANDLED_RECOMPUTE_PROPS;
 +          }
 +        else
 +          handled = HANDLED_RECOMPUTE_PROPS;
 +      }
 +    }
 +
 +  return handled;
 +}
 +
  /* Set up iterator IT from `composition' property at its current
     position.  Called from handle_stop.  */
  
@@@ -4597,7 -4477,7 +4597,7 @@@ handle_composition_prop (it
       struct it *it;
  {
    Lisp_Object prop, string;
 -  int pos, pos_byte, end;
 +  EMACS_INT pos, pos_byte, start, end;
    enum prop_handled handled = HANDLED_NORMALLY;
  
    if (STRINGP (it->string))
    /* If there's a valid composition and point is not inside of the
       composition (in the case that the composition is from the current
       buffer), draw a glyph composed from the composition components.  */
 -  if (find_composition (pos, -1, &pos, &end, &prop, string)
 -      && COMPOSITION_VALID_P (pos, end, prop)
 -      && (STRINGP (it->string) || (PT <= pos || PT >= end)))
 +  if (find_composition (pos, -1, &start, &end, &prop, string)
 +      && COMPOSITION_VALID_P (start, end, prop)
 +      && (STRINGP (it->string) || (PT <= start || PT >= end)))
      {
 -      int id = get_composition_id (pos, pos_byte, end - pos, prop, string);
 +      int id;
 +
 +      if (start != pos)
 +      {
 +        if (STRINGP (it->string))
 +          pos_byte = string_char_to_byte (it->string, start);
 +        else
 +          pos_byte = CHAR_TO_BYTE (start);
 +      }
 +      id = get_composition_id (start, pos_byte, end - start, prop, string);
  
        if (id >= 0)
        {
          it->method = GET_FROM_COMPOSITION;
          it->cmp_id = id;
          it->cmp_len = COMPOSITION_LENGTH (prop);
 -        /* For a terminal, draw only the first character of the
 -             components.  */
 -        it->c = COMPOSITION_GLYPH (composition_table[id], 0);
 +        /* For a terminal, draw only the first (non-TAB) character
 +           of the components.  */
 +#ifdef USE_FONT_BACKEND
 +        if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING)
 +          {
 +            Lisp_Object lgstring = AREF (XHASH_TABLE (composition_hash_table)
 +                                         ->key_and_value,
 +                                         cmp->hash_index * 2);
 +
 +            it->c = XINT (LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 0)));
 +          }
 +        else
 +#endif /* USE_FONT_BACKEND */
 +          {
 +            int i;
 +
 +            for (i = 0; i < cmp->glyph_len; i++)
 +              if ((it->c = COMPOSITION_GLYPH (composition_table[id], i))
 +                  != '\t')
 +                break;
 +          }
 +        if (it->c == '\t')
 +          it->c = ' ';
          it->len = (STRINGP (it->string)
                     ? string_char_to_byte (it->string, end)
                     : CHAR_TO_BYTE (end)) - pos_byte;
@@@ -5697,26 -5548,31 +5697,26 @@@ get_next_display_element (it
             the translation.  This could easily be changed but I
             don't believe that it is worth doing.
  
 -           If it->multibyte_p is nonzero, eight-bit characters and
 -           non-printable multibyte characters are also translated to
 -           octal form.
 +           If it->multibyte_p is nonzero, non-printable non-ASCII
 +           characters are also translated to octal form.
  
             If it->multibyte_p is zero, eight-bit characters that
             don't have corresponding multibyte char code are also
             translated to octal form.  */
          else if ((it->c < ' '
 -                  && (it->area != TEXT_AREA
 -                      /* In mode line, treat \n like other crl chars.  */
 -                      || (it->c != '\t'
 -                          && it->glyph_row && it->glyph_row->mode_line_p)
 -                      || (it->c != '\n' && it->c != '\t')))
 -                 || (it->multibyte_p
 -                     ? ((it->c >= 127
 -                         && it->len == 1)
 -                        || !CHAR_PRINTABLE_P (it->c)
 +                  ? (it->area != TEXT_AREA
 +                     /* In mode line, treat \n, \t like other crl chars.  */
 +                     || (it->c != '\t'
 +                         && it->glyph_row && it->glyph_row->mode_line_p)
 +                     || (it->c != '\n' && it->c != '\t'))
 +                  : (it->multibyte_p
 +                     ? (!CHAR_PRINTABLE_P (it->c)
                          || (!NILP (Vnobreak_char_display)
 -                            && (it->c == 0x8a0 || it->c == 0x8ad
 -                                || it->c == 0x920 || it->c == 0x92d
 -                                || it->c == 0xe20 || it->c == 0xe2d
 -                                || it->c == 0xf20 || it->c == 0xf2d)))
 +                            && (it->c == 0xA0 /* NO-BREAK SPACE */
 +                                || it->c == 0xAD /* SOFT HYPHEN */)))
                       : (it->c >= 127
 -                        && (!unibyte_display_via_language_environment
 -                            || it->c == unibyte_char_to_multibyte (it->c)))))
 +                        && (! unibyte_display_via_language_environment
 +                            || (UNIBYTE_CHAR_HAS_MULTIBYTE_P (it->c)))))))
            {
              /* IT->c is a control character which must be displayed
                 either as '\003' or as `^C' where the '\\' and '^'
                 highlighting.  */
  
              if (EQ (Vnobreak_char_display, Qt)
 -                && (it->c == 0x8a0 || it->c == 0x920
 -                    || it->c == 0xe20 || it->c == 0xf20))
 +                && it->c == 0xA0)
                {
                  /* Merge the no-break-space face into the current face.  */
                  face_id = merge_faces (it->f, Qnobreak_space, 0,
                 highlighting.  */
  
              if (EQ (Vnobreak_char_display, Qt)
 -                && (it->c == 0x8ad || it->c == 0x92d
 -                    || it->c == 0xe2d || it->c == 0xf2d))
 +                && it->c == 0xAD)
                {
                  g = it->c = '-';
                  XSETINT (it->ctl_chars[0], g);
              /* Handle non-break space and soft hyphen
                 with the escape glyph.  */
  
 -            if (it->c == 0x8a0 || it->c == 0x8ad
 -                || it->c == 0x920 || it->c == 0x92d
 -                || it->c == 0xe20 || it->c == 0xe2d
 -                || it->c == 0xf20 || it->c == 0xf2d)
 +            if (it->c == 0xA0 || it->c == 0xAD)
                {
                  XSETINT (it->ctl_chars[0], escape_glyph);
 -                g = it->c = ((it->c & 0xf) == 0 ? ' ' : '-');
 +                g = it->c = (it->c == 0xA0 ? ' ' : '-');
                  XSETINT (it->ctl_chars[1], g);
                  ctl_len = 2;
                  goto display_control;
                int i;
  
                /* Set IT->ctl_chars[0] to the glyph for `\\'.  */
 -              if (SINGLE_BYTE_CHAR_P (it->c))
 -                str[0] = it->c, len = 1;
 +              if (CHAR_BYTE8_P (it->c))
 +                {
 +                  str[0] = CHAR_TO_BYTE8 (it->c);
 +                  len = 1;
 +                }
 +              else if (it->c < 256)
 +                {
 +                  str[0] = it->c;
 +                  len = 1;
 +                }
                else
                  {
 -                  len = CHAR_STRING_NO_SIGNAL (it->c, str);
 -                  if (len < 0)
 -                    {
 -                      /* It's an invalid character, which shouldn't
 -                         happen actually, but due to bugs it may
 -                         happen.  Let's print the char as is, there's
 -                         not much meaningful we can do with it.  */
 -                        str[0] = it->c;
 -                        str[1] = it->c >> 8;
 -                        str[2] = it->c >> 16;
 -                        str[3] = it->c >> 24;
 -                        len = 4;
 -                      }
 +                  /* It's an invalid character, which shouldn't
 +                     happen actually, but due to bugs it may
 +                     happen.  Let's print the char as is, there's
 +                     not much meaningful we can do with it.  */
 +                    str[0] = it->c;
 +                    str[1] = it->c >> 8;
 +                    str[2] = it->c >> 16;
 +                    str[3] = it->c >> 24;
 +                    len = 4;
                    }
  
                for (i = 0; i < len; i++)
              goto get_next;
            }
        }
 +    }
  
 -      /* Adjust face id for a multibyte character.  There are no
 -         multibyte character in unibyte text.  */
 -      if (it->multibyte_p
 -        && success_p
 -        && FRAME_WINDOW_P (it->f))
 -      {
 -        struct face *face = FACE_FROM_ID (it->f, it->face_id);
 -        it->face_id = FACE_FOR_CHAR (it->f, face, it->c);
 -      }
 +  /* Adjust face id for a multibyte character.  There are no multibyte
 +     character in unibyte text.  */
 +  if ((it->what == IT_CHARACTER || it->what == IT_COMPOSITION)
 +      && it->multibyte_p
 +      && success_p
 +      && FRAME_WINDOW_P (it->f))
 +    {
 +      struct face *face = FACE_FROM_ID (it->f, it->face_id);
 +      int pos = (it->s ? -1
 +               : STRINGP (it->string) ? IT_STRING_CHARPOS (*it)
 +               : IT_CHARPOS (*it));
 +        
 +      it->face_id = FACE_FOR_CHAR (it->f, face, it->c, pos, it->string);
      }
  
    /* Is this character the last one of a run of characters with
@@@ -6917,16 -6769,6 +6917,16 @@@ move_it_to (it, to_charpos, to_x, to_y
             the line.  */
          if (skip == MOVE_X_REACHED)
            {
 +            /* Wait!  We can conclude that TO_Y is in the line if
 +               the already scanned glyphs make the line tall enough
 +               because further scanning doesn't make it shorter.  */
 +            line_height = it->max_ascent + it->max_descent;
 +            if (to_y >= it->current_y
 +                && to_y < it->current_y + line_height)
 +              {
 +                reached = 6;
 +                break;
 +              }
              it_backup = *it;
              TRACE_MOVE ((stderr, "move_it: from %d\n", IT_CHARPOS (*it)));
              skip2 = move_it_in_display_line_to (it, to_charpos, -1,
@@@ -7463,7 -7305,7 +7463,7 @@@ message_dolog (m, nbytes, nlflag, multi
          for (i = 0; i < nbytes; i += char_bytes)
            {
              c = string_char_and_length (m + i, nbytes - i, &char_bytes);
 -            work[0] = (SINGLE_BYTE_CHAR_P (c)
 +            work[0] = (ASCII_CHAR_P (c)
                         ? c
                         : multibyte_char_to_unibyte (c, Qnil));
              insert_1_both (work, 1, 1, 1, 0, 0);
             for the *Message* buffer.  */
          for (i = 0; i < nbytes; i++)
            {
 -            c = unibyte_char_to_multibyte (msg[i]);
 +            c = msg[i];
 +            c = unibyte_char_to_multibyte (c);
              char_bytes = CHAR_STRING (c, str);
              insert_1_both (str, 1, char_bytes, 1, 0, 0);
            }
@@@ -8751,7 -8592,7 +8751,7 @@@ set_message_1 (a1, a2, nbytes, multibyt
          for (i = 0; i < nbytes; i += n)
            {
              c = string_char_and_length (s + i, nbytes - i, &n);
 -            work[0] = (SINGLE_BYTE_CHAR_P (c)
 +            work[0] = (ASCII_CHAR_P (c)
                         ? c
                         : multibyte_char_to_unibyte (c, Qnil));
              insert_1_both (work, 1, 1, 1, 0, 0);
          /* Convert a single-byte string to multibyte.  */
          for (i = 0; i < nbytes; i++)
            {
 -            c = unibyte_char_to_multibyte (msg[i]);
 +            c = msg[i];
 +            c = unibyte_char_to_multibyte (c);
              n = CHAR_STRING (c, str);
              insert_1_both (str, 1, n, 1, 0, 0);
            }
@@@ -10866,7 -10706,7 +10866,7 @@@ check_point_in_composition (prev_buf, p
       struct buffer *prev_buf, *buf;
       int prev_pt, pt;
  {
 -  int start, end;
 +  EMACS_INT start, end;
    Lisp_Object prop;
    Lisp_Object buffer;
  
@@@ -11874,24 -11714,35 +11874,24 @@@ disp_char_vector (dp, c
       struct Lisp_Char_Table *dp;
       int c;
  {
 -  int code[4], i;
    Lisp_Object val;
  
 -  if (SINGLE_BYTE_CHAR_P (c))
 -    return (dp->contents[c]);
 -
 -  SPLIT_CHAR (c, code[0], code[1], code[2]);
 -  if (code[1] < 32)
 -    code[1] = -1;
 -  else if (code[2] < 32)
 -    code[2] = -1;
 -
 -  /* Here, the possible range of code[0] (== charset ID) is
 -     128..max_charset.  Since the top level char table contains data
 -     for multibyte characters after 256th element, we must increment
 -     code[0] by 128 to get a correct index.  */
 -  code[0] += 128;
 -  code[3] = -1;               /* anchor */
 -
 -  for (i = 0; code[i] >= 0; i++, dp = XCHAR_TABLE (val))
 +  if (ASCII_CHAR_P (c))
      {
 -      val = dp->contents[code[i]];
 -      if (!SUB_CHAR_TABLE_P (val))
 -      return (NILP (val) ? dp->defalt : val);
 +      val = dp->ascii;
 +      if (SUB_CHAR_TABLE_P (val))
 +      val = XSUB_CHAR_TABLE (val)->contents[c];
      }
 +  else
 +    {
 +      Lisp_Object table;
  
 -  /* Here, val is a sub char table.  We return the default value of
 -     it.  */
 -  return (dp->defalt);
 +      XSETCHAR_TABLE (table, dp);
 +      val = char_table_ref (table, c);
 +    }
 +  if (NILP (val))
 +    val = dp->defalt;
 +  return val;
  }
  
  
@@@ -15812,7 -15663,7 +15812,7 @@@ append_space_for_newline (it, default_f
          else if (it->face_before_selective_p)
            it->face_id = it->saved_face_id;
          face = FACE_FROM_ID (it->f, it->face_id);
 -        it->face_id = FACE_FOR_CHAR (it->f, face, 0);
 +        it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil);
  
          PRODUCE_GLYPHS (it);
  
@@@ -15872,9 -15723,9 +15872,9 @@@ extend_face_to_end_of_line (it
           ASCII face.  This will be automatically undone the next time
           get_next_display_element returns a multibyte character.  Note
           that the character will always be single byte in unibyte text.  */
 -  if (!SINGLE_BYTE_CHAR_P (it->c))
 +  if (!ASCII_CHAR_P (it->c))
      {
 -      it->face_id = FACE_FOR_CHAR (f, face, 0);
 +      it->face_id = FACE_FOR_CHAR (f, face, 0, -1, Qnil);
      }
  
    if (FRAME_WINDOW_P (f))
@@@ -15980,7 -15831,7 +15980,7 @@@ highlight_trailing_whitespace (f, row
                  && glyph->u.ch == ' '))
          && trailing_whitespace_p (glyph->charpos))
        {
 -        int face_id = lookup_named_face (f, Qtrailing_whitespace, 0, 0);
 +        int face_id = lookup_named_face (f, Qtrailing_whitespace, 0);
          if (face_id < 0)
            return;
  
@@@ -17507,7 -17358,7 +17507,7 @@@ are the selected window and the window'
      {
        if (EQ (face, Qt))
        face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive);
 -      face_id = lookup_named_face (XFRAME (WINDOW_FRAME (w)), face, 0, 0);
 +      face_id = lookup_named_face (XFRAME (WINDOW_FRAME (w)), face, 0);
      }
  
    if (face_id < 0)
@@@ -17730,7 -17581,7 +17730,7 @@@ decode_mode_spec_coding (coding_system
    /* The EOL conversion we are using.  */
    Lisp_Object eoltype;
  
 -  val = Fget (coding_system, Qcoding_system);
 +  val = CODING_SYSTEM_SPEC (coding_system);
    eoltype = Qnil;
  
    if (!VECTORP (val))         /* Not yet decided.  */
      }
    else
      {
 +      Lisp_Object attrs;
        Lisp_Object eolvalue;
  
 -      eolvalue = Fget (coding_system, Qeol_type);
 +      attrs = AREF (val, 0);
 +      eolvalue = AREF (val, 2);
  
        if (multibyte)
 -      *buf++ = XFASTINT (AREF (val, 1));
 +      *buf++ = XFASTINT (CODING_ATTR_MNEMONIC (attrs));
  
        if (eol_flag)
        {
            eoltype = eol_mnemonic_undecided;
          else if (VECTORP (eolvalue)) /* Not yet decided.  */
            eoltype = eol_mnemonic_undecided;
 -        else                  /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
 -          eoltype = (XFASTINT (eolvalue) == 0
 +        else                  /* eolvalue is Qunix, Qdos, or Qmac.  */
 +          eoltype = (EQ (eolvalue, Qunix)
                       ? eol_mnemonic_unix
 -                     : (XFASTINT (eolvalue) == 1
 +                     : (EQ (eolvalue, Qdos) == 1
                          ? eol_mnemonic_dos : eol_mnemonic_mac));
        }
      }
          eol_str = SDATA (eoltype);
          eol_str_len = SBYTES (eoltype);
        }
 -      else if (INTEGERP (eoltype)
 -             && CHAR_VALID_P (XINT (eoltype), 0))
 +      else if (CHARACTERP (eoltype))
        {
          unsigned char *tmp = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH);
          eol_str_len = CHAR_STRING (XINT (eoltype), tmp);
@@@ -18180,10 -18030,8 +18180,10 @@@ decode_mode_spec (w, c, field_width, pr
          {
            /* No need to mention EOL here--the terminal never needs
               to do EOL conversion.  */
 -          p = decode_mode_spec_coding (keyboard_coding.symbol, p, 0);
 -          p = decode_mode_spec_coding (terminal_coding.symbol, p, 0);
 +          p = decode_mode_spec_coding (CODING_ID_NAME (keyboard_coding.id),
 +                                       p, 0);
 +          p = decode_mode_spec_coding (CODING_ID_NAME (terminal_coding.id),
 +                                       p, 0);
          }
        p = decode_mode_spec_coding (b->buffer_file_coding_system,
                                     p, eol_flag);
@@@ -18455,7 -18303,7 +18455,7 @@@ display_string (string, lisp_string, fa
                }
              break;
            }
 -        else if (x + glyph->pixel_width > it->first_visible_x)
 +        else if (x + glyph->pixel_width >= it->first_visible_x)
            {
              /* Glyph is at least partially visible.  */
              ++it->hpos;
@@@ -18587,6 -18435,27 +18587,27 @@@ invisible_p (propval, list
    return 0;
  }
  
+ DEFUN ("invisible-p", Finvisible_p, Sinvisible_p, 1, 1, 0,
+        doc: /* Non-nil if the property makes the text invisible.
+ POS-OR-PROP can be a marker or number, in which case it is taken to be
+ a position in the current buffer and the value of the `invisible' property
+ is checked; or it can be some other value, which is then presumed to be the
+ value of the `invisible' property of the text of interest.
+ The non-nil value returned can be t for truly invisible text or something
+ else if the text is replaced by an ellipsis.  */)
+      (pos_or_prop)
+      Lisp_Object pos_or_prop;
+ {
+   Lisp_Object prop
+     = (NATNUMP (pos_or_prop) || MARKERP (pos_or_prop)
+        ? Fget_char_property (pos_or_prop, Qinvisible, Qnil)
+        : pos_or_prop);
+   int invis = TEXT_PROP_MEANS_INVISIBLE (prop);
+   return (invis == 0 ? Qnil
+         : invis == 1 ? Qt
+         : make_number (invis));
+ }
  /* Calculate a width or height in pixels from a specification using
     the following elements:
  
@@@ -18983,80 -18852,6 +19004,80 @@@ append_glyph_string (head, tail, s
  }
  
  
 +/* Get face and two-byte form of character C in face FACE_ID on frame
 +   F.  The encoding of C is returned in *CHAR2B.  MULTIBYTE_P non-zero
 +   means we want to display multibyte text.  DISPLAY_P non-zero means
 +   make sure that X resources for the face returned are allocated.
 +   Value is a pointer to a realized face that is ready for display if
 +   DISPLAY_P is non-zero.  */
 +
 +static INLINE struct face *
 +get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p, display_p)
 +     struct frame *f;
 +     int c, face_id;
 +     XChar2b *char2b;
 +     int multibyte_p, display_p;
 +{
 +  struct face *face = FACE_FROM_ID (f, face_id);
 +
 +#ifdef USE_FONT_BACKEND
 +  if (enable_font_backend)
 +    {
 +      struct font *font = (struct font *) face->font_info;
 +
 +      if (font)
 +      {
 +        unsigned code = font->driver->encode_char (font, c);
 +
 +        if (code != FONT_INVALID_CODE)
 +          STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
 +        else
 +          STORE_XCHAR2B (char2b, 0, 0);
 +      }
 +    }
 +  else
 +#endif        /* USE_FONT_BACKEND */
 +  if (!multibyte_p)
 +    {
 +      /* Unibyte case.  We don't have to encode, but we have to make
 +       sure to use a face suitable for unibyte.  */
 +      STORE_XCHAR2B (char2b, 0, c);
 +      face_id = FACE_FOR_CHAR (f, face, c, -1, Qnil);
 +      face = FACE_FROM_ID (f, face_id);
 +    }
 +  else if (c < 128)
 +    {
 +      /* Case of ASCII in a face known to fit ASCII.  */
 +      STORE_XCHAR2B (char2b, 0, c);
 +    }
 +  else if (face->font != NULL)
 +    {
 +      struct font_info *font_info
 +      = FONT_INFO_FROM_ID (f, face->font_info_id);
 +      struct charset *charset = CHARSET_FROM_ID (font_info->charset);
 +      unsigned code = ENCODE_CHAR (charset, c);
 +
 +      if (CHARSET_DIMENSION (charset) == 1)
 +      STORE_XCHAR2B (char2b, 0, code);
 +      else
 +      STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
 +       /* Maybe encode the character in *CHAR2B.  */
 +      rif->encode_char (c, char2b, font_info, charset, NULL);
 +    }
 +
 +  /* Make sure X resources of the face are allocated.  */
 +#ifdef HAVE_X_WINDOWS
 +  if (display_p)
 +#endif
 +    {
 +      xassert (face != NULL);
 +      PREPARE_FACE_FOR_DISPLAY (f, face);
 +    }
 +
 +  return face;
 +}
 +
 +
  /* Get face and two-byte form of character glyph GLYPH on frame F.
     The encoding of GLYPH->u.ch is returned in *CHAR2B.  Value is
     a pointer to a realized face that is ready for display.  */
@@@ -19076,23 -18871,6 +19097,23 @@@ get_glyph_face_and_encoding (f, glyph, 
    if (two_byte_p)
      *two_byte_p = 0;
  
 +#ifdef USE_FONT_BACKEND
 +  if (enable_font_backend)
 +    {
 +      struct font *font = (struct font *) face->font_info;
 +
 +      if (font)
 +      {
 +        unsigned code = font->driver->encode_char (font, glyph->u.ch);
 +
 +        if (code != FONT_INVALID_CODE)
 +          STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
 +        else
 +          STORE_XCHAR2B (char2b, 0, code);
 +      }
 +    }
 +  else
 +#endif        /* USE_FONT_BACKEND */
    if (!glyph->multibyte_p)
      {
        /* Unibyte case.  We don't have to encode, but we have to make
      }
    else
      {
 -      int c1, c2, charset;
 +      struct font_info *font_info
 +      = FONT_INFO_FROM_ID (f, face->font_info_id);
 +      if (font_info)
 +      {
 +        struct charset *charset = CHARSET_FROM_ID (font_info->charset);
 +        unsigned code = ENCODE_CHAR (charset, glyph->u.ch);
  
 -      /* Split characters into bytes.  If c2 is -1 afterwards, C is
 -       really a one-byte character so that byte1 is zero.  */
 -      SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
 -      if (c2 > 0)
 -      STORE_XCHAR2B (char2b, c1, c2);
 -      else
 -      STORE_XCHAR2B (char2b, 0, c1);
 +        if (CHARSET_DIMENSION (charset) == 1)
 +          STORE_XCHAR2B (char2b, 0, code);
 +        else
 +          STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
  
 -      /* Maybe encode the character in *CHAR2B.  */
 -      if (charset != CHARSET_ASCII)
 -      {
 -        struct font_info *font_info
 -          = FONT_INFO_FROM_ID (f, face->font_info_id);
 -        if (font_info)
 -          glyph->font_type
 -            = rif->encode_char (glyph->u.ch, char2b, font_info, two_byte_p);
 +        /* Maybe encode the character in *CHAR2B.  */
 +        if (CHARSET_ID (charset) != charset_ascii)
 +          {
 +            glyph->font_type
 +              = rif->encode_char (glyph->u.ch, char2b, font_info, charset,
 +                                  two_byte_p);
 +          }
        }
      }
  
  
  /* Fill glyph string S with composition components specified by S->cmp.
  
 -   FACES is an array of faces for all components of this composition.
 +   BASE_FACE is the base face of the composition.
     S->gidx is the index of the first component for S.
  
     OVERLAPS non-zero means S should draw the foreground only, and use
     Value is the index of a component not in S.  */
  
  static int
 -fill_composite_glyph_string (s, faces, overlaps)
 +fill_composite_glyph_string (s, base_face, overlaps)
       struct glyph_string *s;
 -     struct face **faces;
 +     struct face *base_face;
       int overlaps;
  {
    int i;
  
    s->for_overlaps = overlaps;
  
 -  s->face = faces[s->gidx];
 -  s->font = s->face->font;
 -  s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
 +#ifdef USE_FONT_BACKEND
 +  if (enable_font_backend && s->cmp->method == COMPOSITION_WITH_GLYPH_STRING)
 +    {
 +      Lisp_Object gstring
 +      = AREF (XHASH_TABLE (composition_hash_table)->key_and_value,
 +              s->cmp->hash_index * 2);
 +
 +      s->face = base_face;
 +      s->font_info = s->cmp->font;
 +      s->font = s->font_info->font;
 +      for (i = 0, s->nchars = 0; i < s->cmp->glyph_len; i++, s->nchars++)
 +      {
 +        Lisp_Object g = LGSTRING_GLYPH (gstring, i);
 +        unsigned code;
 +          XChar2b * store_pos;
 +        if (NILP (LGLYPH_FROM (g)))
 +          break;
 +        code = XUINT (LGLYPH_CODE (g));
 +          store_pos = s->char2b + i;
 +        STORE_XCHAR2B (store_pos, code >> 8, code & 0xFF);
 +      }
 +      s->width = s->cmp->pixel_width;
 +    }
 +  else
 +#endif        /* USE_FONT_BACKEND */
 +    {
 +      /* For all glyphs of this composition, starting at the offset
 +       S->gidx, until we reach the end of the definition or encounter a
 +       glyph that requires the different face, add it to S.  */
 +      struct face *face;
  
 -  /* For all glyphs of this composition, starting at the offset
 -     S->gidx, until we reach the end of the definition or encounter a
 -     glyph that requires the different face, add it to S.  */
 -  ++s->nchars;
 -  for (i = s->gidx + 1; i < s->cmp->glyph_len && faces[i] == s->face; ++i)
 -    ++s->nchars;
 +      s->face = NULL;
 +      s->font = NULL;
 +      s->font_info = NULL;
 +      for (i = s->gidx; i < s->cmp->glyph_len; i++)
 +      {
 +        int c = COMPOSITION_GLYPH (s->cmp, i);
  
 -  /* All glyph strings for the same composition has the same width,
 -     i.e. the width set for the first component of the composition.  */
 +        if (c != '\t')
 +          {
 +            int face_id = FACE_FOR_CHAR (s->f, base_face, c, -1, Qnil);
  
 -  s->width = s->first_glyph->pixel_width;
 +            face = get_char_face_and_encoding (s->f, c, face_id,
 +                                               s->char2b + i, 1, 1);
 +            if (face)
 +              {
 +                if (! s->face)
 +                  {
 +                    s->face = face;
 +                    s->font = s->face->font;
 +                    s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
 +                  }
 +                else if (s->face != face)
 +                  break;
 +              }
 +          }
 +        ++s->nchars;
 +      }
 +
 +      /* All glyph strings for the same composition has the same width,
 +       i.e. the width set for the first component of the composition.  */
 +      s->width = s->first_glyph->pixel_width;
 +    }
  
    /* If the specified font could not be loaded, use the frame's
       default font, but record the fact that we couldn't load it in
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += s->first_glyph->voffset;
  
 -  xassert (s->face && s->face->gc);
 -
    /* This glyph string must always be drawn with 16-bit functions.  */
    s->two_byte_p = 1;
  
@@@ -19291,7 -19022,7 +19312,7 @@@ fill_glyph_string (s, face_id, start, e
      }
  
    s->font = s->face->font;
 -  s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
 +  s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
  
    /* If the specified font could not be loaded, use the frame's font,
       but record the fact that we couldn't load it in
@@@ -19355,7 -19086,7 +19376,7 @@@ fill_stretch_glyph_string (s, row, area
    face_id = glyph->face_id;
    s->face = FACE_FROM_ID (s->f, face_id);
    s->font = s->face->font;
 -  s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
 +  s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
    s->width = glyph->pixel_width;
    s->nchars = 1;
    voffset = glyph->voffset;
    return glyph - s->row->glyphs[s->area];
  }
  
 +static XCharStruct *
 +get_per_char_metric (font, font_info, char2b, font_type)
 +     XFontStruct *font;
 +     struct font_info *font_info;
 +     XChar2b *char2b;
 +     int font_type;
 +{
 +#ifdef USE_FONT_BACKEND
 +  if (enable_font_backend)
 +    {
 +      static XCharStruct pcm_value;
 +      unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
 +      struct font *fontp;
 +      struct font_metrics metrics;
 +
 +      if (! font_info || code == FONT_INVALID_CODE)
 +      return NULL;
 +      fontp = (struct font *) font_info;
 +      fontp->driver->text_extents (fontp, &code, 1, &metrics);
 +      pcm_value.lbearing = metrics.lbearing;
 +      pcm_value.rbearing = metrics.rbearing;
 +      pcm_value.ascent = metrics.ascent;
 +      pcm_value.descent = metrics.descent;
 +      pcm_value.width = metrics.width;
 +      return &pcm_value;
 +    }
 +#endif        /* USE_FONT_BACKEND */
 +  return rif->per_char_metric (font, char2b, font_type);
 +}
  
  /* EXPORT for RIF:
     Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
@@@ -19430,9 -19132,9 +19451,9 @@@ x_get_glyph_overhangs (glyph, f, left, 
  
        face = get_glyph_face_and_encoding (f, glyph, &char2b, NULL);
        font = face->font;
 -      font_info = FONT_INFO_FROM_ID (f, face->font_info_id);
 +      font_info = FONT_INFO_FROM_FACE (f, face);
        if (font  /* ++KFS: Should this be font_info ?  */
 -        && (pcm = rif->per_char_metric (font, &char2b, glyph->font_type)))
 +        && (pcm = get_per_char_metric (font, font_info, &char2b, glyph->font_type)))
        {
          if (pcm->rbearing > pcm->width)
            *right = pcm->rbearing - pcm->width;
            *left = -pcm->lbearing;
        }
      }
 +  else if (glyph->type == COMPOSITE_GLYPH)
 +    {
 +      struct composition *cmp = composition_table[glyph->u.cmp_id];
 +
 +      *right = cmp->rbearing - cmp->pixel_width;
 +      *left = - cmp->lbearing;
 +    }
  }
  
  
@@@ -19560,6 -19255,70 +19581,6 @@@ right_overwriting (s
  }
  
  
 -/* Get face and two-byte form of character C in face FACE_ID on frame
 -   F.  The encoding of C is returned in *CHAR2B.  MULTIBYTE_P non-zero
 -   means we want to display multibyte text.  DISPLAY_P non-zero means
 -   make sure that X resources for the face returned are allocated.
 -   Value is a pointer to a realized face that is ready for display if
 -   DISPLAY_P is non-zero.  */
 -
 -static INLINE struct face *
 -get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p, display_p)
 -     struct frame *f;
 -     int c, face_id;
 -     XChar2b *char2b;
 -     int multibyte_p, display_p;
 -{
 -  struct face *face = FACE_FROM_ID (f, face_id);
 -
 -  if (!multibyte_p)
 -    {
 -      /* Unibyte case.  We don't have to encode, but we have to make
 -       sure to use a face suitable for unibyte.  */
 -      STORE_XCHAR2B (char2b, 0, c);
 -      face_id = FACE_FOR_CHAR (f, face, c);
 -      face = FACE_FROM_ID (f, face_id);
 -    }
 -  else if (c < 128)
 -    {
 -      /* Case of ASCII in a face known to fit ASCII.  */
 -      STORE_XCHAR2B (char2b, 0, c);
 -    }
 -  else
 -    {
 -      int c1, c2, charset;
 -
 -      /* Split characters into bytes.  If c2 is -1 afterwards, C is
 -       really a one-byte character so that byte1 is zero.  */
 -      SPLIT_CHAR (c, charset, c1, c2);
 -      if (c2 > 0)
 -      STORE_XCHAR2B (char2b, c1, c2);
 -      else
 -      STORE_XCHAR2B (char2b, 0, c1);
 -
 -      /* Maybe encode the character in *CHAR2B.  */
 -      if (face->font != NULL)
 -      {
 -        struct font_info *font_info
 -          = FONT_INFO_FROM_ID (f, face->font_info_id);
 -        if (font_info)
 -          rif->encode_char (c, char2b, font_info, 0);
 -      }
 -    }
 -
 -  /* Make sure X resources of the face are allocated.  */
 -#ifdef HAVE_X_WINDOWS
 -  if (display_p)
 -#endif
 -    {
 -      xassert (face != NULL);
 -      PREPARE_FACE_FOR_DISPLAY (f, face);
 -    }
 -
 -  return face;
 -}
 -
 -
  /* Set background width of glyph string S.  START is the index of the
     first glyph following S.  LAST_X is the right-most x-position + 1
     in the drawing area.  */
@@@ -19699,9 -19458,10 +19720,9 @@@ compute_overhangs_and_x (s, x, backward
  #define BUILD_CHAR_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)          \
       do                                                                          \
         {                                                                 \
 -       int c, face_id;                                                   \
 +       int face_id;                                                      \
         XChar2b *char2b;                                                  \
                                                                           \
 -       c = (row)->glyphs[area][START].u.ch;                              \
         face_id = (row)->glyphs[area][START].face_id;                     \
                                                                           \
         s = (struct glyph_string *) alloca (sizeof *s);                   \
     x-position of the drawing area.  */
  
  #define BUILD_COMPOSITE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
 -  do {                                                                          \
 -    int cmp_id = (row)->glyphs[area][START].u.cmp_id;                   \
 -    int face_id = (row)->glyphs[area][START].face_id;                   \
 -    struct face *base_face = FACE_FROM_ID (f, face_id);                         \
 -    struct composition *cmp = composition_table[cmp_id];                \
 -    int glyph_len = cmp->glyph_len;                                     \
 -    XChar2b *char2b;                                                    \
 -    struct face **faces;                                                \
 -    struct glyph_string *first_s = NULL;                                \
 -    int n;                                                              \
 -                                                                        \
 -    base_face = base_face->ascii_face;                                          \
 -    char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len);                 \
 -    faces = (struct face **) alloca ((sizeof *faces) * glyph_len);      \
 -    /* At first, fill in `char2b' and `faces'.  */                      \
 -    for (n = 0; n < glyph_len; n++)                                     \
 -      {                                                                         \
 -      int c = COMPOSITION_GLYPH (cmp, n);                               \
 -      int this_face_id = FACE_FOR_CHAR (f, base_face, c);               \
 -      faces[n] = FACE_FROM_ID (f, this_face_id);                        \
 -      get_char_face_and_encoding (f, c, this_face_id,                   \
 -                                  char2b + n, 1, 1);                    \
 -      }                                                                         \
 -                                                                        \
 -    /* Make glyph_strings for each glyph sequence that is drawable by   \
 -       the same face, and append them to HEAD/TAIL.  */                         \
 -    for (n = 0; n < cmp->glyph_len;)                                    \
 -      {                                                                         \
 -      s = (struct glyph_string *) alloca (sizeof *s);                   \
 -      INIT_GLYPH_STRING (s, char2b + n, w, row, area, START, HL);       \
 -      append_glyph_string (&(HEAD), &(TAIL), s);                        \
 -      s->cmp = cmp;                                                     \
 -      s->gidx = n;                                                      \
 -      s->x = (X);                                                       \
 -                                                                        \
 -      if (n == 0)                                                       \
 -        first_s = s;                                                    \
 -                                                                        \
 -      n = fill_composite_glyph_string (s, faces, overlaps);             \
 -      }                                                                         \
 -                                                                        \
 -    ++START;                                                            \
 -    s = first_s;                                                        \
 +  do {                                                                            \
 +    int face_id = (row)->glyphs[area][START].face_id;                     \
 +    struct face *base_face = FACE_FROM_ID (f, face_id);                           \
 +    int cmp_id = (row)->glyphs[area][START].u.cmp_id;                     \
 +    struct composition *cmp = composition_table[cmp_id];                  \
 +    XChar2b *char2b;                                                      \
 +    struct glyph_string *first_s;                                         \
 +    int n;                                                                \
 +                                                                          \
 +    char2b = (XChar2b *) alloca ((sizeof *char2b) * cmp->glyph_len);      \
 +    base_face = base_face->ascii_face;                                            \
 +                                                                          \
 +    /* Make glyph_strings for each glyph sequence that is drawable by     \
 +       the same face, and append them to HEAD/TAIL.  */                           \
 +    for (n = 0; n < cmp->glyph_len;)                                      \
 +      {                                                                           \
 +      s = (struct glyph_string *) alloca (sizeof *s);                     \
 +      INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL);             \
 +      append_glyph_string (&(HEAD), &(TAIL), s);                          \
 +      s->cmp = cmp;                                                       \
 +      s->gidx = n;                                                        \
 +      s->x = (X);                                                         \
 +      if (n == 0)                                                         \
 +        first_s = s;                                                      \
 +      n = fill_composite_glyph_string (s, base_face, overlaps);           \
 +      }                                                                           \
 +                                                                          \
 +    ++START;                                                              \
 +    s = first_s;                                                          \
    } while (0)
  
  
                 abort ();                                                 \
               }                                                           \
                                                                           \
 -             set_glyph_string_background_width (s, START, LAST_X);       \
 -           (X) += s->width;                                              \
 +           if (s)                                                        \
 +             {                                                           \
 +               set_glyph_string_background_width (s, START, LAST_X);     \
 +               (X) += s->width;                                          \
 +             }                                                           \
              }                                                            \
         }                                                                 \
       while (0)
@@@ -19837,7 -19608,7 +19858,7 @@@ draw_glyphs (w, x, row, area, start, en
       int x;
       struct glyph_row *row;
       enum glyph_row_area area;
 -     int start, end;
 +     EMACS_INT start, end;
       enum draw_glyphs_face hl;
       int overlaps;
  {
        if (i >= 0)
        {
          clip_tail = tail;
 +        i++;                  /* We must include the Ith glyph.  */
          BUILD_GLYPH_STRINGS (end, i, h, t,
                               DRAW_NORMAL_TEXT, x, last_x);
          for (s = h; s; s = s->next)
@@@ -20547,7 -20317,7 +20568,7 @@@ calc_line_height_property (it, val, fon
        struct face *face;
        struct font_info *font_info;
  
 -      face_id = lookup_named_face (it->f, face_name, ' ', 0);
 +      face_id = lookup_named_face (it->f, face_name, 0);
        if (face_id < 0)
        return make_number (-1);
  
        if (font == NULL)
        return make_number (-1);
  
 -      font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id);
 +      font_info = FONT_INFO_FROM_FACE (it->f, face);
        boff = font_info->baseline_offset;
        if (font_info->vertical_centering)
        boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
@@@ -20620,17 -20390,23 +20641,17 @@@ x_produce_glyphs (it
        /* Maybe translate single-byte characters to multibyte, or the
         other way.  */
        it->char_to_display = it->c;
 -      if (!ASCII_BYTE_P (it->c))
 +      if (!ASCII_BYTE_P (it->c)
 +        && ! it->multibyte_p)
        {
 -        if (unibyte_display_via_language_environment
 -            && SINGLE_BYTE_CHAR_P (it->c)
 -            && (it->c >= 0240
 -                || !NILP (Vnonascii_translation_table)))
 -          {
 -            it->char_to_display = unibyte_char_to_multibyte (it->c);
 -            it->multibyte_p = 1;
 -            it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
 -            face = FACE_FROM_ID (it->f, it->face_id);
 -          }
 -        else if (!SINGLE_BYTE_CHAR_P (it->c)
 -                 && !it->multibyte_p)
 +        if (SINGLE_BYTE_CHAR_P (it->c)
 +            && unibyte_display_via_language_environment)
 +          it->char_to_display = unibyte_char_to_multibyte (it->c);
 +        if (! SINGLE_BYTE_CHAR_P (it->char_to_display))
            {
              it->multibyte_p = 1;
 -            it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
 +            it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display,
 +                                         -1, Qnil);
              face = FACE_FROM_ID (it->f, it->face_id);
            }
        }
        }
        else
        {
 -        font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id);
 +        font_info = FONT_INFO_FROM_FACE (it->f, face);
          boff = font_info->baseline_offset;
          if (font_info->vertical_centering)
            boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
  
          it->nglyphs = 1;
  
 -        pcm = rif->per_char_metric (font, &char2b,
 +        pcm = get_per_char_metric (font, font_info, &char2b,
                                      FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display));
  
          if (it->override_ascent >= 0)
  
          /* If we found a font, this font should give us the right
             metrics.  If we didn't find a font, use the frame's
 -           default font and calculate the width of the character
 -           from the charset width; this is what old redisplay code
 -           did.  */
 +           default font and calculate the width of the character by
 +           multiplying the width of font by the width of the
 +           character.  */
  
 -        pcm = rif->per_char_metric (font, &char2b,
 +        pcm = get_per_char_metric (font, font_info, &char2b,
                                      FONT_TYPE_FOR_MULTIBYTE (font, it->c));
  
          if (font_not_found_p || !pcm)
            {
 -            int charset = CHAR_CHARSET (it->char_to_display);
 +            int char_width = CHAR_WIDTH (it->char_to_display);
  
 +            if (char_width == 0)
 +              /* This is a non spacing character.  But, as we are
 +                 going to display an empty box, the box must occupy
 +                 at least one column.  */
 +              char_width = 1;
              it->glyph_not_available_p = 1;
 -            it->pixel_width = (FRAME_COLUMN_WIDTH (it->f)
 -                               * CHARSET_WIDTH (charset));
 +            it->pixel_width = FRAME_COLUMN_WIDTH (it->f) * char_width;
              it->phys_ascent = FONT_BASE (font) + boff;
              it->phys_descent = FONT_DESCENT (font) - boff;
            }
    else if (it->what == IT_COMPOSITION)
      {
        /* Note: A composition is represented as one glyph in the
 -       glyph matrix.  There are no padding glyphs.  */
 -      XChar2b char2b;
 -      XFontStruct *font;
 +       glyph matrix.  There are no padding glyphs.
 +
 +       Important is that pixel_width, ascent, and descent are the
 +       values of what is drawn by draw_glyphs (i.e. the values of
 +       the overall glyphs composed).  */
        struct face *face = FACE_FROM_ID (it->f, it->face_id);
 -      XCharStruct *pcm;
 -      int font_not_found_p;
 -      struct font_info *font_info;
        int boff;                       /* baseline offset */
        struct composition *cmp = composition_table[it->cmp_id];
 +      int glyph_len = cmp->glyph_len;
 +      XFontStruct *font = face->font;
  
 -      /* Maybe translate single-byte characters to multibyte.  */
 -      it->char_to_display = it->c;
 -      if (unibyte_display_via_language_environment
 -        && SINGLE_BYTE_CHAR_P (it->c)
 -        && (it->c >= 0240
 -            || (it->c >= 0200
 -                && !NILP (Vnonascii_translation_table))))
 -      {
 -        it->char_to_display = unibyte_char_to_multibyte (it->c);
 -      }
 -
 -      /* Get face and font to use.  Encode IT->char_to_display.  */
 -      it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
 -      face = FACE_FROM_ID (it->f, it->face_id);
 -      get_char_face_and_encoding (it->f, it->char_to_display, it->face_id,
 -                                &char2b, it->multibyte_p, 0);
 -      font = face->font;
 +      it->nglyphs = 1;
  
 -      /* When no suitable font found, use the default font.  */
 -      font_not_found_p = font == NULL;
 -      if (font_not_found_p)
 +#ifdef USE_FONT_BACKEND
 +      if (cmp->method == COMPOSITION_WITH_GLYPH_STRING)
        {
 -        font = FRAME_FONT (it->f);
 -        boff = FRAME_BASELINE_OFFSET (it->f);
 -        font_info = NULL;
 +        if (! cmp->font || cmp->font != font)
 +          font_prepare_composition (cmp);
        }
        else
 -      {
 -        font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id);
 -        boff = font_info->baseline_offset;
 -        if (font_info->vertical_centering)
 -          boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
 -      }
 -
 -      /* There are no padding glyphs, so there is only one glyph to
 -       produce for the composition.  Important is that pixel_width,
 -       ascent and descent are the values of what is drawn by
 -       draw_glyphs (i.e. the values of the overall glyphs composed).  */
 -      it->nglyphs = 1;
 -
 +#endif        /* USE_FONT_BACKEND */
        /* If we have not yet calculated pixel size data of glyphs of
         the composition for the current face font, calculate them
         now.  Theoretically, we have to check all fonts for the
         glyphs, but that requires much time and memory space.  So,
         here we check only the font of the first glyph.  This leads
 -       to incorrect display very rarely, and C-l (recenter) can
 -       correct the display anyway.  */
 -      if (cmp->font != (void *) font)
 -      {
 -        /* Ascent and descent of the font of the first character of
 -           this composition (adjusted by baseline offset).  Ascent
 -           and descent of overall glyphs should not be less than
 -           them respectively.  */
 -        int font_ascent = FONT_BASE (font) + boff;
 -        int font_descent = FONT_DESCENT (font) - boff;
 +       to incorrect display, but it's very rare, and C-l (recenter)
 +       can correct the display anyway.  */
 +      if (! cmp->font || cmp->font != font)
 +      {
 +        /* Ascent and descent of the font of the first character
 +           of this composition (adjusted by baseline offset).
 +           Ascent and descent of overall glyphs should not be less
 +           than them respectively.  */
 +        int font_ascent, font_descent, font_height;
          /* Bounding box of the overall glyphs.  */
          int leftmost, rightmost, lowest, highest;
 +        int lbearing, rbearing;
          int i, width, ascent, descent;
 +        int left_padded = 0, right_padded = 0;
 +        int face_id;
 +        int c;
 +        XChar2b char2b;
 +        XCharStruct *pcm;
 +        int font_not_found_p;
 +        struct font_info *font_info;
 +        int pos;
 +
 +        for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--)
 +          if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t')
 +            break;
 +        if (glyph_len < cmp->glyph_len)
 +          right_padded = 1;
 +        for (i = 0; i < glyph_len; i++)
 +          {
 +            if ((c = COMPOSITION_GLYPH (cmp, i)) != '\t')
 +              break;
 +            cmp->offsets[i * 2] = cmp->offsets[i * 2 + 1] = 0;
 +          }
 +        if (i > 0)
 +          left_padded = 1;
 +
 +        pos = (STRINGP (it->string) ? IT_STRING_CHARPOS (*it)
 +               : IT_CHARPOS (*it));
 +        /* When no suitable font found, use the default font.  */
 +        font_not_found_p = font == NULL;
 +        if (font_not_found_p)
 +          {
 +            face = face->ascii_face;
 +            font = face->font;
 +          }
 +        font_info = FONT_INFO_FROM_FACE (it->f, face);
 +        boff = font_info->baseline_offset;
 +        if (font_info->vertical_centering)
 +          boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
 +        font_ascent = FONT_BASE (font) + boff;
 +        font_descent = FONT_DESCENT (font) - boff;
 +        font_height = FONT_HEIGHT (font);
  
          cmp->font = (void *) font;
  
 +        pcm = NULL;
 +        if (! font_not_found_p)
 +          {
 +            get_char_face_and_encoding (it->f, c, it->face_id,
 +                                        &char2b, it->multibyte_p, 0);
 +            pcm = get_per_char_metric (font, font_info, &char2b,
 +                                       FONT_TYPE_FOR_MULTIBYTE (font, c));
 +          }
 +
          /* Initialize the bounding box.  */
 -        if (font_info
 -            && (pcm = rif->per_char_metric (font, &char2b,
 -                                            FONT_TYPE_FOR_MULTIBYTE (font, it->c))))
 +        if (pcm)
            {
              width = pcm->width;
              ascent = pcm->ascent;
              descent = pcm->descent;
 +            lbearing = pcm->lbearing;
 +            rbearing = pcm->rbearing;
            }
          else
            {
              width = FONT_WIDTH (font);
              ascent = FONT_BASE (font);
              descent = FONT_DESCENT (font);
 +            lbearing = 0;
 +            rbearing = width;
            }
  
          rightmost = width;
 +        leftmost = 0;
          lowest = - descent + boff;
          highest = ascent + boff;
 -        leftmost = 0;
  
 -        if (font_info
 +        if (! font_not_found_p
              && font_info->default_ascent
              && CHAR_TABLE_P (Vuse_default_ascent)
              && !NILP (Faref (Vuse_default_ascent,
            highest = font_info->default_ascent + boff;
  
          /* Draw the first glyph at the normal position.  It may be
 -           shifted to right later if some other glyphs are drawn at
 -           the left.  */
 -        cmp->offsets[0] = 0;
 -        cmp->offsets[1] = boff;
 +           shifted to right later if some other glyphs are drawn
 +           at the left.  */
 +        cmp->offsets[i * 2] = 0;
 +        cmp->offsets[i * 2 + 1] = boff;
 +        cmp->lbearing = lbearing;
 +        cmp->rbearing = rbearing;
  
          /* Set cmp->offsets for the remaining glyphs.  */
 -        for (i = 1; i < cmp->glyph_len; i++)
 +        for (i++; i < glyph_len; i++)
            {
              int left, right, btm, top;
              int ch = COMPOSITION_GLYPH (cmp, i);
 -            int face_id = FACE_FOR_CHAR (it->f, face, ch);
 +            int face_id;
 +            struct face *this_face;
 +            int this_boff;
 +
 +            if (ch == '\t')
 +              ch = ' ';
 +            face_id = FACE_FOR_CHAR (it->f, face, ch, pos, it->string);
 +            this_face = FACE_FROM_ID (it->f, face_id);
 +            font = this_face->font;
  
 -            face = FACE_FROM_ID (it->f, face_id);
 -            get_char_face_and_encoding (it->f, ch, face->id,
 -                                        &char2b, it->multibyte_p, 0);
 -            font = face->font;
              if (font == NULL)
 -              {
 -                font = FRAME_FONT (it->f);
 -                boff = FRAME_BASELINE_OFFSET (it->f);
 -                font_info = NULL;
 -              }
 +              pcm = NULL;
              else
                {
 -                font_info
 -                  = FONT_INFO_FROM_ID (it->f, face->font_info_id);
 -                boff = font_info->baseline_offset;
 +                font_info = FONT_INFO_FROM_FACE (it->f, this_face);
 +                this_boff = font_info->baseline_offset;
                  if (font_info->vertical_centering)
 -                  boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
 +                  this_boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
 +                get_char_face_and_encoding (it->f, ch, face_id,
 +                                            &char2b, it->multibyte_p, 0);
 +                pcm = get_per_char_metric (font, font_info, &char2b,
 +                                           FONT_TYPE_FOR_MULTIBYTE (font,
 +                                                                    ch));
                }
 -
 -            if (font_info
 -                && (pcm = rif->per_char_metric (font, &char2b,
 -                                                FONT_TYPE_FOR_MULTIBYTE (font, ch))))
 +            if (! pcm)
 +              cmp->offsets[i * 2] = cmp->offsets[i * 2 + 1] = 0;
 +            else
                {
                  width = pcm->width;
                  ascent = pcm->ascent;
                  descent = pcm->descent;
 -              }
 -            else
 -              {
 -                width = FONT_WIDTH (font);
 -                ascent = 1;
 -                descent = 0;
 -              }
 +                lbearing = pcm->lbearing;
 +                rbearing = pcm->rbearing;
 +                if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
 +                  {
 +                    /* Relative composition with or without
 +                       alternate chars.  */
 +                    left = (leftmost + rightmost - width) / 2;
 +                    btm = - descent + boff;
 +                    if (font_info->relative_compose
 +                        && (! CHAR_TABLE_P (Vignore_relative_composition)
 +                            || NILP (Faref (Vignore_relative_composition,
 +                                            make_number (ch)))))
 +                      {
  
 -            if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
 -              {
 -                /* Relative composition with or without
 -                   alternate chars.  */
 -                left = (leftmost + rightmost - width) / 2;
 -                btm = - descent + boff;
 -                if (font_info && font_info->relative_compose
 -                    && (! CHAR_TABLE_P (Vignore_relative_composition)
 -                        || NILP (Faref (Vignore_relative_composition,
 -                                        make_number (ch)))))
 +                        if (- descent >= font_info->relative_compose)
 +                          /* One extra pixel between two glyphs.  */
 +                          btm = highest + 1;
 +                        else if (ascent <= 0)
 +                          /* One extra pixel between two glyphs.  */
 +                          btm = lowest - 1 - ascent - descent;
 +                      }
 +                  }
 +                else
                    {
 +                    /* A composition rule is specified by an integer
 +                       value that encodes global and new reference
 +                       points (GREF and NREF).  GREF and NREF are
 +                       specified by numbers as below:
 +
 +                       0---1---2 -- ascent
 +                       |       |
 +                       |       |
 +                       |       |
 +                       9--10--11 -- center
 +                       |       |
 +                       ---3---4---5--- baseline
 +                       |       |
 +                       6---7---8 -- descent
 +                    */
 +                    int rule = COMPOSITION_RULE (cmp, i);
 +                    int gref, nref, grefx, grefy, nrefx, nrefy, xoff, yoff;
 +
 +                    COMPOSITION_DECODE_RULE (rule, gref, nref, xoff, yoff);
 +                    grefx = gref % 3, nrefx = nref % 3;
 +                    grefy = gref / 3, nrefy = nref / 3;
 +                    if (xoff)
 +                      xoff = font_height * (xoff - 128) / 256;
 +                    if (yoff)
 +                      yoff = font_height * (yoff - 128) / 256;
 +
 +                    left = (leftmost
 +                            + grefx * (rightmost - leftmost) / 2
 +                            - nrefx * width / 2
 +                            + xoff);
 +                
 +                    btm = ((grefy == 0 ? highest
 +                            : grefy == 1 ? 0
 +                            : grefy == 2 ? lowest
 +                            : (highest + lowest) / 2)
 +                           - (nrefy == 0 ? ascent + descent
 +                              : nrefy == 1 ? descent - boff
 +                              : nrefy == 2 ? 0
 +                              : (ascent + descent) / 2)
 +                           + yoff);
 +                  }
 +
 +                cmp->offsets[i * 2] = left;
 +                cmp->offsets[i * 2 + 1] = btm + descent;
  
 -                    if (- descent >= font_info->relative_compose)
 -                      /* One extra pixel between two glyphs.  */
 -                      btm = highest + 1;
 -                    else if (ascent <= 0)
 -                      /* One extra pixel between two glyphs.  */
 -                      btm = lowest - 1 - ascent - descent;
 +                /* Update the bounding box of the overall glyphs. */
 +                if (width > 0)
 +                  {
 +                    right = left + width;
 +                    if (left < leftmost)
 +                      leftmost = left;
 +                    if (right > rightmost)
 +                      rightmost = right;
                    }
 +                top = btm + descent + ascent;
 +                if (top > highest)
 +                  highest = top;
 +                if (btm < lowest)
 +                  lowest = btm;
 +
 +                if (cmp->lbearing > left + lbearing)
 +                  cmp->lbearing = left + lbearing;
 +                if (cmp->rbearing < left + rbearing)
 +                  cmp->rbearing = left + rbearing;
                }
 -            else
 -              {
 -                /* A composition rule is specified by an integer
 -                   value that encodes global and new reference
 -                   points (GREF and NREF).  GREF and NREF are
 -                   specified by numbers as below:
 -
 -                      0---1---2 -- ascent
 -                      |       |
 -                      |       |
 -                      |       |
 -                      9--10--11 -- center
 -                      |       |
 -                   ---3---4---5--- baseline
 -                      |       |
 -                      6---7---8 -- descent
 -                */
 -                int rule = COMPOSITION_RULE (cmp, i);
 -                int gref, nref, grefx, grefy, nrefx, nrefy;
 -
 -                COMPOSITION_DECODE_RULE (rule, gref, nref);
 -                grefx = gref % 3, nrefx = nref % 3;
 -                grefy = gref / 3, nrefy = nref / 3;
 -
 -                left = (leftmost
 -                        + grefx * (rightmost - leftmost) / 2
 -                        - nrefx * width / 2);
 -                btm = ((grefy == 0 ? highest
 -                        : grefy == 1 ? 0
 -                        : grefy == 2 ? lowest
 -                        : (highest + lowest) / 2)
 -                       - (nrefy == 0 ? ascent + descent
 -                          : nrefy == 1 ? descent - boff
 -                          : nrefy == 2 ? 0
 -                          : (ascent + descent) / 2));
 -              }
 -
 -            cmp->offsets[i * 2] = left;
 -            cmp->offsets[i * 2 + 1] = btm + descent;
 -
 -            /* Update the bounding box of the overall glyphs. */
 -            right = left + width;
 -            top = btm + descent + ascent;
 -            if (left < leftmost)
 -              leftmost = left;
 -            if (right > rightmost)
 -              rightmost = right;
 -            if (top > highest)
 -              highest = top;
 -            if (btm < lowest)
 -              lowest = btm;
            }
  
          /* If there are glyphs whose x-offsets are negative,
              for (i = 0; i < cmp->glyph_len; i++)
                cmp->offsets[i * 2] -= leftmost;
              rightmost -= leftmost;
 +            cmp->lbearing -= leftmost;
 +            cmp->rbearing -= leftmost;
 +          }
 +
 +        if (left_padded && cmp->lbearing < 0)
 +          {
 +            for (i = 0; i < cmp->glyph_len; i++)
 +              cmp->offsets[i * 2] -= cmp->lbearing;
 +            rightmost -= cmp->lbearing;
 +            cmp->rbearing -= cmp->lbearing;
 +            cmp->lbearing = 0;
 +          }
 +        if (right_padded && rightmost < cmp->rbearing)
 +          {
 +            rightmost = cmp->rbearing;
            }
  
          cmp->pixel_width = rightmost;
            cmp->descent = font_descent;
        }
  
 +      if (it->glyph_row
 +        && (cmp->lbearing < 0
 +            || cmp->rbearing > cmp->pixel_width))
 +      it->glyph_row->contains_overlapping_glyphs_p = 1;
 +
        it->pixel_width = cmp->pixel_width;
        it->ascent = it->phys_ascent = cmp->ascent;
        it->descent = it->phys_descent = cmp->descent;
@@@ -21362,8 -21078,7 +21383,8 @@@ x_insert_glyphs (start, len
    int line_height, shift_by_width, shifted_region_width;
    struct glyph_row *row;
    struct glyph *glyph;
 -  int frame_x, frame_y, hpos;
 +  int frame_x, frame_y;
 +  EMACS_INT hpos;
  
    xassert (updated_window && updated_row);
    BLOCK_INPUT;
@@@ -22313,7 -22028,7 +22334,7 @@@ cursor_in_mouse_face_p (w
  static int
  fast_find_position (w, charpos, hpos, vpos, x, y, stop)
       struct window *w;
 -     int charpos;
 +     EMACS_INT charpos;
       int *hpos, *vpos, *x, *y;
       Lisp_Object stop;
  {
  static int
  fast_find_position (w, pos, hpos, vpos, x, y, stop)
       struct window *w;
 -     int pos;
 +     EMACS_INT pos;
       int *hpos, *vpos, *x, *y;
       Lisp_Object stop;
  {
  static int
  fast_find_string_pos (w, pos, object, hpos, vpos, x, y, right_p)
       struct window *w;
 -     int pos;
 +     EMACS_INT pos;
       Lisp_Object object;
       int *hpos, *vpos, *x, *y;
       int right_p;
@@@ -24112,6 -23827,7 +24133,7 @@@ syms_of_xdisp (
    defsubr (&Slookup_image_map);
  #endif
    defsubr (&Sformat_mode_line);
+   defsubr (&Sinvisible_p);
  
    staticpro (&Qmenu_bar_update_hook);
    Qmenu_bar_update_hook = intern ("menu-bar-update-hook");