Merged from emacs@sv.gnu.org
authorKaroly Lorentey <lorentey@elte.hu>
Fri, 28 Apr 2006 14:48:18 +0000 (14:48 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Fri, 28 Apr 2006 14:48:18 +0000 (14:48 +0000)
Patches applied:

 * emacs@sv.gnu.org/emacs--devo--0--patch-234
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-235
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-236
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-237
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-238
   Merge from gnus--rel--5.10

 * emacs@sv.gnu.org/emacs--devo--0--patch-239
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-240
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-241
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-242
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-243
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-244
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-245
   (Ffield_beginning, find_field): Undo change of 2006-04-23.

 * emacs@sv.gnu.org/emacs--devo--0--patch-246
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-247
   Rcirc patch from Ryan Yeske

 * emacs@sv.gnu.org/emacs--devo--0--patch-248
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-249
   Merge from gnus--rel--5.10

 * emacs@sv.gnu.org/emacs--devo--0--patch-250
   Update from CVS

 * emacs@sv.gnu.org/emacs--devo--0--patch-251
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-87
   Merge from emacs--devo--0

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-88
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-89
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-90
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-91
   Merge from emacs--devo--0

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-92
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-93
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-94
   Update from CVS

 * emacs@sv.gnu.org/gnus--rel--5.10--patch-95
   Update from CVS

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-553

16 files changed:
1  2 
configure
lisp/faces.el
lisp/international/mule.el
lisp/startup.el
lisp/subr.el
man/emacs.texi
src/.gdbinit
src/dispextern.h
src/frame.c
src/image.c
src/keymap.c
src/macterm.c
src/print.c
src/w32term.c
src/window.c
src/xdisp.c

diff --combined configure
+++ b/configure
@@@ -2,7 -2,7 +2,7 @@@
  # Guess values for system-dependent variables and create Makefiles.
  # Generated by GNU Autoconf 2.59.
  #
- # Copyright (C) 2003 Free Software Foundation, Inc.
+ # Copyright (C) 2003, 2006 Free Software Foundation, Inc.
  # This configure script is free software; the Free Software Foundation
  # gives unlimited permission to copy, distribute and modify it.
  ## --------------------- ##
@@@ -988,7 -988,7 +988,7 @@@ esa
      else
        echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
      fi
 -    cd $ac_popdir
 +    cd "$ac_popdir"
    done
  fi
  
@@@ -3283,7 -3283,8 +3283,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3341,7 -3342,8 +3341,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3457,7 -3459,8 +3457,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3511,7 -3514,8 +3511,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3556,7 -3560,8 +3556,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3600,7 -3605,8 +3600,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -3988,7 -3994,8 +3988,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -4616,7 -4623,8 +4616,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -4842,7 -4850,8 +4842,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -4871,7 -4880,8 +4871,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -4941,7 -4951,8 +4941,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -4993,7 -5004,8 +4993,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5064,7 -5076,8 +5064,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5116,7 -5129,8 +5116,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5186,7 -5200,8 +5186,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5356,7 -5371,8 +5356,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5425,7 -5441,8 +5425,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5579,7 -5596,8 +5579,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5675,7 -5693,8 +5675,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5817,7 -5836,8 +5817,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -5936,7 -5956,8 +5936,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6101,7 -6122,8 +6101,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6164,7 -6186,8 +6164,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6237,7 -6260,8 +6237,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6323,7 -6347,8 +6323,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6396,7 -6421,8 +6396,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6466,7 -6492,8 +6466,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6525,7 -6552,8 +6525,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6594,7 -6622,8 +6594,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6655,7 -6684,8 +6655,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6721,7 -6751,8 +6721,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6867,7 -6898,8 +6867,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6931,7 -6963,8 +6931,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -6996,7 -7029,8 +6996,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7042,7 -7076,8 +7042,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7116,7 -7151,8 +7116,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7181,7 -7217,8 +7181,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7225,7 -7262,8 +7225,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7296,7 -7334,8 +7296,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7346,7 -7385,8 +7346,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7417,7 -7457,8 +7417,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7467,7 -7508,8 +7467,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7538,7 -7580,8 +7538,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7588,7 -7631,8 +7588,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7659,7 -7703,8 +7659,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7709,7 -7754,8 +7709,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7780,7 -7826,8 +7780,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7830,7 -7877,8 +7830,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -7917,7 -7965,8 +7917,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8023,7 -8072,8 +8023,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8083,7 -8133,8 +8083,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
  echo "$as_me:$LINENO: checking for X" >&5
  echo $ECHO_N "checking for X... $ECHO_C" >&6
  
 +ac_path_x_has_been_run=yes
  
  # Check whether --with-x or --without-x was given.
  if test "${with_x+set}" = set; then
@@@ -8300,7 -8350,7 +8300,7 @@@ ac_x_header_dirs=
  /usr/openwin/share/include'
  
  if test "$ac_x_includes" = no; then
 -  # Guess where to find include files, by looking for Intrinsic.h.
 +  # Guess where to find include files, by looking for a specified header file.
    # First, try using that file with no special directory specified.
    cat >conftest.$ac_ext <<_ACEOF
  /* confdefs.h.  */
@@@ -8308,7 -8358,7 +8308,7 @@@ _ACEO
  cat confdefs.h >>conftest.$ac_ext
  cat >>conftest.$ac_ext <<_ACEOF
  /* end confdefs.h.  */
 -#include <X11/Intrinsic.h>
 +#include <X11/Xlib.h>
  _ACEOF
  if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
    (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@@@ -8335,7 -8385,7 +8335,7 @@@ els
  sed 's/^/| /' conftest.$ac_ext >&5
  
    for ac_dir in $ac_x_header_dirs; do
 -  if test -r "$ac_dir/X11/Intrinsic.h"; then
 +  if test -r "$ac_dir/X11/Xlib.h"; then
      ac_x_includes=$ac_dir
      break
    fi
@@@ -8349,18 -8399,18 +8349,18 @@@ if test "$ac_x_libraries" = no; the
    # See if we find them without any special options.
    # Don't add to $LIBS permanently.
    ac_save_LIBS=$LIBS
 -  LIBS="-lXt $LIBS"
 +  LIBS="-lX11 $LIBS"
    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/Xlib.h>
  int
  main ()
  {
 -XtMalloc (0)
 +XrmInitialize ()
    ;
    return 0;
  }
@@@ -8374,7 -8424,8 +8374,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8398,7 -8449,7 +8398,7 @@@ for ac_dir in `echo "$ac_x_includes $ac
  do
    # Don't even attempt the hair of trying to link an X program!
    for ac_extension in a so sl; do
 -    if test -r $ac_dir/libXt.$ac_extension; then
 +    if test -r $ac_dir/libX11.$ac_extension; then
        ac_x_libraries=$ac_dir
        break 2
      fi
    # Update the cache value to reflect the command line values.
    ac_cv_have_x="have_x=yes \
                ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
 -  echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
 -echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
 +  # It might be that x_includes is empty (headers are found in the
 +  # standard search path. Then output the corresponding message
 +  ac_out_x_includes=$x_includes
 +  test "x$x_includes" = x && ac_out_x_includes="in standard search path"
 +  echo "$as_me:$LINENO: result: libraries $x_libraries, headers $ac_out_x_includes" >&5
 +echo "${ECHO_T}libraries $x_libraries, headers $ac_out_x_includes" >&6
  fi
  
  if test "$no_x" = yes; then
@@@ -8521,7 -8568,8 +8521,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8757,7 -8805,8 +8757,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8852,7 -8901,8 +8852,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8911,7 -8961,8 +8911,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -8995,7 -9046,8 +8995,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9179,7 -9231,8 +9179,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9431,7 -9484,8 +9431,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9498,7 -9552,8 +9498,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9567,7 -9622,8 +9567,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9652,7 -9708,8 +9652,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9729,7 -9786,8 +9729,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9783,7 -9841,8 +9783,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9852,7 -9911,8 +9852,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -9956,7 -10016,8 +9956,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10023,7 -10084,8 +10023,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10093,7 -10155,8 +10093,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
      with_toolkit_scroll_bars=yes
    fi
  
 -      HAVE_GTK_MULTIDISPLAY=no
 -
 -for ac_func in gdk_display_open
 -do
 -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 -echo "$as_me:$LINENO: checking for $ac_func" >&5
 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 -if eval "test \"\${$as_ac_var+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.  */
 -/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
 -   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
 -#define $ac_func innocuous_$ac_func
 -
 -/* System header to define __stub macros and hopefully few prototypes,
 -    which can conflict with char $ac_func (); below.
 -    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 -    <limits.h> exists even on freestanding compilers.  */
 -
 -#ifdef __STDC__
 -# include <limits.h>
 -#else
 -# include <assert.h>
 -#endif
 -
 -#undef $ac_func
 +          HAVE_GTK_MULTIDISPLAY=no
  
 -/* Override any gcc2 internal prototype to avoid an error.  */
 -#ifdef __cplusplus
 -extern "C"
 -{
 -#endif
 -/* We use char because int might match the return type of a gcc2
 -   builtin and then its argument prototype would still apply.  */
 -char $ac_func ();
 -/* The GNU C library defines this for functions which it implements
 -    to always fail with ENOSYS.  Some functions are actually named
 -    something starting with __ and the normal name is an alias.  */
 -#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 -choke me
 -#else
 -char (*f) () = $ac_func;
 -#endif
 -#ifdef __cplusplus
 -}
 -#endif
 -
 -int
 -main ()
 -{
 -return f != $ac_func;
 -  ;
 -  return 0;
 -}
 -_ACEOF
 -rm -f conftest.$ac_objext conftest$ac_exeext
 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 -  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 -  (eval $ac_try) 2>&5
 -  ac_status=$?
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); }; } &&
 -       { ac_try='test -s conftest$ac_exeext'
 -  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 -  (eval $ac_try) 2>&5
 -  ac_status=$?
 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 -  (exit $ac_status); }; }; then
 -  eval "$as_ac_var=yes"
 -else
 -  echo "$as_me: failed program was:" >&5
 -sed 's/^/| /' conftest.$ac_ext >&5
 -
 -eval "$as_ac_var=no"
 -fi
 -rm -f conftest.err conftest.$ac_objext \
 -      conftest$ac_exeext conftest.$ac_ext
 -fi
 -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 -if test `eval echo '${'$as_ac_var'}'` = yes; then
 -  cat >>confdefs.h <<_ACEOF
 -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 -_ACEOF
 - HAVE_GTK_MULTIDISPLAY=yes
 -fi
 -done
 -
 -  if test "${HAVE_GTK_MULTIDISPLAY}" = "yes"; then
 -
 -cat >>confdefs.h <<\_ACEOF
 -#define HAVE_GTK_MULTIDISPLAY 1
 -_ACEOF
 -
 -  fi
        HAVE_GTK_FILE_SELECTION=no
  
  for ac_func in gtk_file_selection_new
@@@ -10335,7 -10506,8 +10335,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10438,7 -10610,8 +10438,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10516,7 -10689,8 +10516,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10670,7 -10844,8 +10670,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10744,7 -10919,8 +10744,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10816,7 -10992,8 +10816,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10898,7 -11075,8 +10898,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -10977,7 -11155,8 +10977,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11048,7 -11227,8 +11048,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11117,7 -11297,8 +11117,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11190,7 -11371,8 +11190,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11313,7 -11495,8 +11313,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11415,7 -11598,8 +11415,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11495,7 -11679,8 +11495,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11563,7 -11748,8 +11563,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11708,7 -11894,8 +11708,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11817,7 -12004,8 +11817,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -11962,7 -12150,8 +11962,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12069,7 -12258,8 +12069,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12223,7 -12413,8 +12223,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12298,7 -12489,8 +12298,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12446,7 -12638,8 +12446,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12523,7 -12716,8 +12523,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12670,7 -12864,8 +12670,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12743,7 -12938,8 +12743,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -12944,7 -13140,8 +12944,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13017,7 -13214,8 +13017,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13162,7 -13360,8 +13162,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13238,7 -13437,8 +13238,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13301,7 -13501,8 +13301,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13382,7 -13583,8 +13382,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13523,7 -13725,8 +13523,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13668,7 -13871,8 +13668,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13744,7 -13948,8 +13744,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13817,7 -14022,8 +13817,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -13972,7 -14178,8 +13972,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -14038,7 -14245,8 +14038,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -14298,7 -14506,8 +14298,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -14365,7 -14574,8 +14365,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -14517,7 -14727,8 +14517,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -14701,7 -14912,8 +14701,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15028,7 -15240,8 +15028,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15129,7 -15342,8 +15129,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15202,7 -15416,8 +15202,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15281,7 -15496,8 +15281,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15350,7 -15566,8 +15350,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15418,7 -15635,8 +15418,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15492,7 -15710,8 +15492,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15596,7 -15815,8 +15596,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15671,7 -15891,8 +15671,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15823,7 -16044,8 +15823,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -15891,7 -16113,8 +15891,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16068,7 -16291,8 +16068,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16144,7 -16368,8 +16144,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16298,7 -16523,8 +16298,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16449,7 -16675,8 +16449,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16600,7 -16827,8 +16600,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16742,7 -16970,8 +16742,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16786,7 -17015,8 +16786,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16932,7 -17162,8 +16932,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -16976,7 -17207,8 +16976,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17041,7 -17273,8 +17041,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17131,7 -17364,8 +17131,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17318,7 -17552,8 +17318,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17388,7 -17623,8 +17388,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17457,7 -17693,8 +17457,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17589,7 -17826,8 +17589,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17691,7 -17929,8 +17691,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17760,7 -17999,8 +17760,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17867,7 -18107,8 +17867,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -17970,7 -18211,8 +17970,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18046,7 -18288,8 +18046,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18150,7 -18393,8 +18150,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18242,7 -18486,8 +18242,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18307,7 -18552,8 +18307,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18373,7 -18619,8 +18373,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18483,7 -18730,8 +18483,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18548,7 -18796,8 +18548,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18628,7 -18877,8 +18628,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18701,7 -18951,8 +18701,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18774,7 -19025,8 +18774,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18847,7 -19099,8 +18847,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18921,7 -19174,8 +18921,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -18993,7 -19247,8 +18993,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19068,7 -19323,8 +19068,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19140,7 -19396,8 +19140,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19213,7 -19470,8 +19213,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19363,7 -19621,8 +19363,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19509,7 -19768,8 +19509,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19655,7 -19915,8 +19655,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19812,7 -20073,8 +19812,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -19958,7 -20220,8 +19958,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20104,7 -20367,8 +20104,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20262,7 -20526,8 +20262,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20420,7 -20685,8 +20420,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20609,7 -20875,8 +20609,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20682,7 -20949,8 +20682,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20750,7 -21018,8 +20750,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20796,7 -21065,8 +20796,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20870,7 -21140,8 +20870,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -20934,7 -21205,8 +20934,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21072,7 -21344,8 +21072,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21133,7 -21406,8 +21133,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21278,7 -21552,8 +21278,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21434,7 -21709,8 +21434,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21605,7 -21881,8 +21605,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21673,7 -21950,8 +21673,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -21858,7 -22136,8 +21858,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
    ac_cv_func_fork_works=cross
  else
    cat >conftest.$ac_ext <<_ACEOF
 -/* By Ruediger Kuhlmann. */
 -      #include <sys/types.h>
 -      #if HAVE_UNISTD_H
 -      # include <unistd.h>
 -      #endif
 -      /* Some systems only have a dummy stub for fork() */
 -      int main ()
 -      {
 -      if (fork() < 0)
 -        exit (1);
 -      exit (0);
 -      }
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +$ac_includes_default
 +int
 +main ()
 +{
 +
 +        /* By Ruediger Kuhlmann. */
 +        if (fork() < 0)
 +          exit (1);
 +        exit (0);
 +
 +  ;
 +  return 0;
 +}
  _ACEOF
  rm -f conftest$ac_exeext
  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
@@@ -22157,7 -22430,8 +22157,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -22222,7 -22496,8 +22222,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -22285,7 -22560,8 +22285,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -22351,7 -22627,8 +22351,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -22392,7 -22669,8 +22392,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
@@@ -22459,7 -22737,8 +22459,7 @@@ if { (eval echo "$as_me:$LINENO: \"$ac_
    cat conftest.err >&5
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); } &&
 -       { ac_try='test -z "$ac_c_werror_flag"
 -                       || test ! -s conftest.err'
 +       { ac_try='test -z "$ac_c_werror_flag"                   || test ! -s conftest.err'
    { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    (eval $ac_try) 2>&5
    ac_status=$?
    *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
    esac
  
 -  if test x"$ac_file" != x-; then
 -    { echo "$as_me:$LINENO: creating $ac_file" >&5
 -echo "$as_me: creating $ac_file" >&6;}
 -    rm -f "$ac_file"
 -  fi
    # Let's still pretend it is `configure' which instantiates (i.e., don't
    # use $as_me), people would be surprised to read:
    #    /* config.h.  Generated by config.status.  */
@@@ -23614,12 -23898,6 +23614,12 @@@ echo "$as_me: error: cannot find input 
         fi;;
        esac
      done` || { (exit 1); exit 1; }
 +
 +  if test x"$ac_file" != x-; then
 +    { echo "$as_me:$LINENO: creating $ac_file" >&5
 +echo "$as_me: creating $ac_file" >&6;}
 +    rm -f "$ac_file"
 +  fi
  _ACEOF
  cat >>$CONFIG_STATUS <<_ACEOF
    sed "$ac_vpsub
diff --combined lisp/faces.el
@@@ -934,7 -934,7 +934,7 @@@ an integer value.
    (let ((valid
           (case attribute
             (:family
 -            (if window-system
 +            (if (window-system frame)
                  (mapcar #'(lambda (x) (cons (car x) (car x)))
                          (x-font-family-list))
              ;; Only one font on TTYs.
              (mapcar #'(lambda (x) (cons (symbol-name x) x))
                      (internal-lisp-face-attribute-values attribute)))
             ((:underline :overline :strike-through :box)
 -            (if window-system
 +            (if (window-system frame)
                  (nconc (mapcar #'(lambda (x) (cons (symbol-name x) x))
                                 (internal-lisp-face-attribute-values attribute))
                         (mapcar #'(lambda (c) (cons c c))
             ((:height)
              'integerp)
             (:stipple
 -            (and (memq window-system '(x w32 mac))
 +            (and (memq (window-system frame) '(x w32 mac))
                   (mapcar #'list
                           (apply #'nconc
                                  (mapcar (lambda (dir)
@@@ -1074,7 -1074,7 +1074,7 @@@ of a global face.  Value is the new att
               ;; explicitly in VALID, using color approximation code
               ;; in tty-colors.el.
               (when (and (memq attribute '(:foreground :background))
 -                        (not (memq window-system '(x w32 mac)))
 +                        (not (memq (window-system frame) '(x w32 mac)))
                          (not (member new-value
                                       '("unspecified"
                                         "unspecified-fg" "unspecified-bg"))))
@@@ -1369,14 -1369,14 +1369,14 @@@ If FRAME is nil, the current FRAME is u
            req (car conjunct)
            options (cdr conjunct)
            match (cond ((eq req 'type)
 -                       (or (memq window-system options)
 +                       (or (memq (window-system frame) options)
                             ;; FIXME: This should be revisited to use
                             ;; display-graphic-p, provided that the
                             ;; color selection depends on the number
                             ;; of supported colors, and all defface's
                             ;; are changed to look at number of colors
                             ;; instead of (type graphic) etc.
 -                           (and (null window-system)
 +                           (and (null (window-system frame))
                                  (memq 'tty options))
                             (and (memq 'motif options)
                                  (featurep 'motif))
@@@ -1589,38 -1589,35 +1589,38 @@@ variable with `setq'; this won't have t
                 (const light)
                 (const :tag "automatic" nil)))
  
 -(defvar default-frame-background-mode nil
 -  "Internal variable for the default brightness of the background.
 -Emacs sets it automatically depending on the terminal type.
 -The value `nil' means `dark'.  If Emacs runs in non-windowed
 -mode from `xterm' or a similar terminal emulator, the value is
 -`light'.  On rxvt terminals, the value depends on the environment
 -variable COLORFGBG.")
  
  (defun frame-set-background-mode (frame)
    "Set up display-dependent faces on FRAME.
  Display-dependent faces are those which have different definitions
  according to the `background-mode' and `display-type' frame parameters."
    (let* ((bg-resource
 -        (and window-system
 +        (and (window-system frame)
               (x-get-resource "backgroundMode" "BackgroundMode")))
         (bg-color (frame-parameter frame 'background-color))
 +       (tty-type (frame-parameter frame 'tty-type))
         (bg-mode
          (cond (frame-background-mode)
                (bg-resource
                 (intern (downcase bg-resource)))
 -              ((and (null window-system) (null bg-color))
 -               ;; No way to determine this automatically (?).
 -               (or default-frame-background-mode 'dark))
 -              ;; Unspecified frame background color can only happen
 -              ;; on tty's.
 -              ((member bg-color '(unspecified "unspecified-bg"))
 -               (or default-frame-background-mode 'dark))
 +              ((and (null (window-system frame))
 +                    ;; Unspecified frame background color can only
 +                    ;; happen on tty's.
 +                    (member bg-color '(nil unspecified "unspecified-bg")))
 +               ;; There is no way to determine the background mode
 +               ;; automatically, so we make a guess based on the
 +               ;; terminal type.
 +               (if (and tty-type
 +                        (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
 +                                      tty-type))
 +                   'light
 +                 'dark))
                ((equal bg-color "unspecified-fg") ; inverted colors
 -               (if (eq default-frame-background-mode 'light) 'dark 'light))
 +               (if (and tty-type
 +                        (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
 +                                      tty-type))
 +                   'dark
 +                 'light))
                ((>= (apply '+ (x-color-values bg-color frame))
                    ;; Just looking at the screen, colors whose
                    ;; values add up to .6 of the white total
                 'light)
                (t 'dark)))
         (display-type
 -        (cond ((null window-system)
 +        (cond ((null (window-system frame))
                 (if (tty-display-color-p frame) 'color 'mono))
                ((x-display-color-p frame)
                 'color)
@@@ -1725,24 -1722,15 +1725,24 @@@ the X resource ``reverseVideo'' is pres
  Value is the new frame created."
    (setq parameters (x-handle-named-frame-geometry parameters))
    (let ((visibility-spec (assq 'visibility parameters))
 -      (frame-list (frame-list))
 -      (frame (x-create-frame (cons '(visibility . nil) parameters)))
 +      (frame (x-create-frame `((visibility . nil) . ,parameters)))
        success)
      (unwind-protect
        (progn
 +        (x-setup-function-keys frame)
          (x-handle-reverse-video frame parameters)
          (frame-set-background-mode frame)
          (face-set-after-frame-default frame)
 -        (if (or (null frame-list) (null visibility-spec))
 +        ;; Arrange for the kill and yank functions to set and check the clipboard.
 +        (modify-frame-parameters
 +         frame '((interprogram-cut-function . x-select-text)))
 +        (modify-frame-parameters
 +         frame '((interprogram-paste-function . x-cut-buffer-or-selection-value)))
 +        ;; Make sure the tool-bar is ready to be enabled.  The
 +        ;; `tool-bar-lines' frame parameter will not take effect
 +        ;; without this call.
 +        (tool-bar-setup frame)
 +        (if (null visibility-spec)
              (make-frame-visible frame)
            (modify-frame-parameters frame (list visibility-spec)))
          (setq success t))
@@@ -1773,7 -1761,7 +1773,7 @@@ Initialize colors of certain faces fro
        (when (not (equal face 'default))
          (face-spec-set face (face-user-default-spec face) frame)
          (internal-merge-in-global-face face frame)
 -        (when (and (memq window-system '(x w32 mac))
 +        (when (and (memq (window-system frame) '(x w32 mac))
                     (or (not (boundp 'inhibit-default-face-x-resources))
                         (not (eq face 'default))))
            (make-face-x-resource-internal face frame)))
@@@ -1824,50 -1812,15 +1824,50 @@@ created.
    (let ((frame (make-terminal-frame parameters))
        success)
      (unwind-protect
 -      (progn
 +      (with-selected-frame frame
          (tty-handle-reverse-video frame (frame-parameters frame))
          (frame-set-background-mode frame)
          (face-set-after-frame-default frame)
 +
 +        ;; Make sure the kill and yank functions do not touch the X clipboard.
 +        (modify-frame-parameters frame '((interprogram-cut-function . nil)))
 +        (modify-frame-parameters frame '((interprogram-paste-function . nil)))
 +
 +        (set-locale-environment nil frame)
 +        (tty-run-terminal-initialization frame)
          (setq success t))
        (unless success
        (delete-frame frame)))
      frame))
  
 +(defun tty-run-terminal-initialization (frame)
 +  "Run the special initialization code for the terminal type of FRAME."
 +  ;; Load library for our terminal type.
 +  ;; User init file can set term-file-prefix to nil to prevent this.
 +  (with-selected-frame frame
 +    (unless (null term-file-prefix)
 +      (let* ((term (frame-parameter frame 'tty-type))
 +           (term2 term)
 +           hyphend term-init-func)
 +      (while (and term
 +                  (not (load (concat term-file-prefix term) t t)))
 +        ;; Strip off last hyphen and what follows, then try again
 +        (setq term
 +              (if (setq hyphend (string-match "[-_][^-_]+$" term))
 +                  (substring term 0 hyphend)
 +                nil)))
 +      ;; The terminal file has been loaded, now find and call the
 +      ;; terminal specific initialization function.
 +      (while (and term2
 +                  (not (fboundp
 +                        (setq term-init-func (intern (concat "terminal-init-" term2))))))
 +        ;; Strip off last hyphen and what follows, then try again
 +        (setq term2
 +              (if (setq hyphend (string-match "[-_][^-_]+$" term2))
 +                  (substring term2 0 hyphend)
 +                nil)))
 +      (when (fboundp term-init-func)
 +        (funcall term-init-func))))))
  
  ;; Called from C function init_display to initialize faces of the
  ;; dumped terminal frame on startup.
@@@ -2190,19 -2143,19 +2190,19 @@@ used to display the prompt text.
    :group 'frames
    :group 'basic-faces)
  
- (defface scroll-bar '()
+ (defface scroll-bar '((t nil))
    "Basic face for the scroll bar colors under X."
    :version "21.1"
    :group 'frames
    :group 'basic-faces)
  
- (defface border '()
+ (defface border '((t nil))
    "Basic face for the frame border under X."
    :version "21.1"
    :group 'frames
    :group 'basic-faces)
  
- (defface cursor '()
+ (defface cursor '((t nil))
    "Basic face for the cursor color under X.
  Note: Other faces cannot inherit from the cursor face."
    :version "21.1"
  
  (put 'cursor 'face-no-inherit t)
  
- (defface mouse '()
+ (defface mouse '((t nil))
    "Basic face for the mouse color under X."
    :version "21.1"
    :group 'mouse
@@@ -1221,17 -1221,13 +1221,17 @@@ see) to CODING-SYSTEM.
  This is normally set according to the selected language environment.
  See also the command `set-terminal-coding-system'.")
  
 -(defun set-terminal-coding-system (coding-system)
 -  "Set coding system of your terminal to CODING-SYSTEM.
 -All text output to the terminal will be encoded
 +(defun set-terminal-coding-system (coding-system &optional display)
 +  "Set coding system of terminal output to CODING-SYSTEM.
 +All text output to DISPLAY will be encoded
  with the specified coding system.
 +
  For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
  The default is determined by the selected language environment
 -or by the previous use of this command."
 +or by the previous use of this command.
 +
 +DISPLAY may be a display id, a frame, or nil for the selected frame's display.
 +The setting has no effect on graphical displays."
    (interactive
     (list (let ((default (if (and (not (terminal-coding-system))
                                 default-terminal-coding-system)
        (setq coding-system default-terminal-coding-system))
    (if coding-system
        (setq default-terminal-coding-system coding-system))
 -  (set-terminal-coding-system-internal coding-system)
 +  (set-terminal-coding-system-internal coding-system display)
    (redraw-frame (selected-frame)))
  
  (defvar default-keyboard-coding-system nil
  This is normally set according to the selected language environment.
  See also the command `set-keyboard-coding-system'.")
  
 -(defun set-keyboard-coding-system (coding-system)
 -  "Set coding system for keyboard input to CODING-SYSTEM.
 -In addition, this command enables Encoded-kbd minor mode.
 -\(If CODING-SYSTEM is nil, Encoded-kbd mode is turned off -- see
 -`encoded-kbd-mode'.)
 +(defun set-keyboard-coding-system (coding-system &optional display)
 +  "Set coding system for keyboard input on DISPLAY to CODING-SYSTEM.
 +In addition, this command calls `encoded-kbd-setup-display' to set up the
 +translation of keyboard input events to the specified coding system.
 +
  For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
  The default is determined by the selected language environment
 -or by the previous use of this command."
 +or by the previous use of this command.
 +
 +DISPLAY may be a display id, a frame, or nil for the selected frame's display.
 +The setting has no effect on graphical displays."
    (interactive
     (list (let ((default (if (and (not (keyboard-coding-system))
                                 default-keyboard-coding-system)
    (if (and coding-system
           (coding-system-get coding-system 'ascii-incompatible))
        (error "%s is not ASCII-compatible" coding-system))
 -  (set-keyboard-coding-system-internal coding-system)
 +  (set-keyboard-coding-system-internal coding-system display)
    (setq keyboard-coding-system coding-system)
 -  (encoded-kbd-mode (if coding-system 1 0)))
 +  (encoded-kbd-setup-display display))
  
  (defcustom keyboard-coding-system nil
    "Specify coding system for keyboard input.
  If you set this on a terminal which can't distinguish Meta keys from
  8-bit characters, you will have to use ESC to type Meta characters.
- See Info node `Specify Coding' and Info node `Single-Byte Character Support'.
+ See Info node `Terminal Coding' and Info node `Unibyte Mode'.
  
  On non-windowing terminals, this is set from the locale by default.
  
  Setting this variable directly does not take effect;
  use either \\[customize] or \\[set-keyboard-coding-system]."
    :type '(coding-system :tag "Coding system")
-   :link '(info-link "(emacs)Specify Coding")
-   :link '(info-link "(emacs)Single-Byte Character Support")
+   :link '(info-link "(emacs)Terminal Coding")
+   :link '(info-link "(emacs)Unibyte Mode")
    :set (lambda (symbol value)
 -       ;; Don't load encoded-kbd-mode unnecessarily.
 -       (if (or value (boundp 'encoded-kbd-mode))
 +       ;; Don't load encoded-kb unnecessarily.
 +       (if (or value (boundp 'encoded-kbd-setup-display))
             (set-keyboard-coding-system value)
           (set-default 'keyboard-coding-system nil))) ; must initialize
    :version "22.1"
diff --combined lisp/startup.el
  (defvar command-line-processed nil
    "Non-nil once command line has been processed.")
  
 +(defvar window-system initial-window-system
 +  "Name of window system the selected frame is displaying through.
 +The value is a symbol--for instance, `x' for X windows.
 +The value is nil if the selected frame is on a text-only-terminal.")
 +
 +(make-variable-frame-local 'window-system)
 +
  (defgroup initialization nil
    "Emacs start-up procedure."
    :group 'internal)
@@@ -441,19 -434,36 +441,19 @@@ or `CVS', and any subdirectory that con
        ;; for instance due to a dense colormap.
        (when (or frame-initial-frame
                  ;; If frame-initial-frame has no meaning, do this anyway.
 -                (not (and window-system
 +                (not (and initial-window-system
                            (not noninteractive)
 -                          (not (eq window-system 'pc)))))
 +                          (not (eq initial-window-system 'pc)))))
          ;; Modify the initial frame based on what .emacs puts into
          ;; ...-frame-alist.
          (if (fboundp 'frame-notice-user-settings)
              (frame-notice-user-settings))
 +        ;; Set the faces for the initial background mode even if
 +        ;; frame-notice-user-settings didn't (such as on a tty).
 +        ;; frame-set-background-mode is idempotent, so it won't
 +        ;; cause any harm if it's already been done.
          (if (fboundp 'frame-set-background-mode)
 -            ;; Set the faces for the initial background mode even if
 -            ;; frame-notice-user-settings didn't (such as on a tty).
 -            ;; frame-set-background-mode is idempotent, so it won't
 -            ;; cause any harm if it's already been done.
 -            (let ((frame (selected-frame))
 -                  term)
 -              (when (and (null window-system)
 -                         ;; Don't override default set by files in lisp/term.
 -                         (null default-frame-background-mode)
 -                         (let ((bg (frame-parameter frame 'background-color)))
 -                           (or (null bg)
 -                               (member bg '(unspecified "unspecified-bg"
 -                                                        "unspecified-fg")))))
 -
 -                (setq term (getenv "TERM"))
 -                ;; Some files in lisp/term do a better job with the
 -                ;; background mode, but we leave this here anyway, in
 -                ;; case they remove those files.
 -                (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
 -                                  term)
 -                    (setq default-frame-background-mode 'light)))
 -              (frame-set-background-mode (selected-frame)))))
 +            (frame-set-background-mode (selected-frame))))
  
        ;; Now we know the user's default font, so add it to the menu.
        (if (fboundp 'font-menu-add-default)
  (defvar tool-bar-originally-present nil
    "Non-nil if tool-bars are present before user and site init files are read.")
  
 +(defvar handle-args-function-alist '((nil . tty-handle-args))
 +  "Functions for processing window-system dependent command-line arguments.
 +Window system startup files should add their own function to this
 +alist, which should parse the command line arguments.  Those
 +pertaining to the window system should be processed and removed
 +from the returned command line.")
 +
 +(defvar window-system-initialization-alist '((nil . ignore))
 +  "Alist of window-system initialization functions.
 +Window-system startup files should add their own initialization
 +function to this list.  The function should take no arguments,
 +and initialize the window system environment to prepare for
 +opening the first frame (e.g. open a connection to an X server).")
 +
  ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
  (defun tty-handle-args (args)
    (let (rest)
      (setq eol-mnemonic-dos  "(DOS)"
            eol-mnemonic-mac  "(Mac)")))
  
 -  ;; Read window system's init file if using a window system.
 +  ;; Make sure window system's init file was loaded in loadup.el if using a window system.
    (condition-case error
 -      (if (and window-system (not noninteractive))
 -        (load (concat term-file-prefix
 -                      (symbol-name window-system)
 -                      "-win")
 -              ;; Every window system should have a startup file;
 -              ;; barf if we can't find it.
 -              nil t))
 -    ;; If we can't read it, print the error message and exit.
 +    (unless noninteractive
 +      (if (and initial-window-system
 +             (not (featurep
 +                   (intern (concat (symbol-name initial-window-system) "-win")))))
 +        (error "Unsupported window system `%s'" initial-window-system))
 +      ;; Process window-system specific command line parameters.
 +      (setq command-line-args
 +          (funcall (or (cdr (assq initial-window-system handle-args-function-alist))
 +                       (error "Unsupported window system `%s'" initial-window-system))
 +                   command-line-args))
 +      ;; Initialize the window system. (Open connection, etc.)
 +      (funcall (or (cdr (assq initial-window-system window-system-initialization-alist))
 +                 (error "Unsupported window system `%s'" initial-window-system))))
 +    ;; If there was an error, print the error message and exit.
      (error
       (princ
        (if (eq (car error) 'error)
                               (cdr error) ", "))))
        'external-debugging-output)
       (terpri 'external-debugging-output)
 -     (setq window-system nil)
 +     (setq initial-window-system nil)
       (kill-emacs)))
  
 -  ;; Windowed displays do this inside their *-win.el.
 -  (unless (or (display-graphic-p) noninteractive)
 -    (setq command-line-args (tty-handle-args command-line-args)))
 -
    (set-locale-environment nil)
  
    ;; Convert preloaded file names to absolute.
    ;; If frame was created with a menu bar, set menu-bar-mode on.
    (unless (or noninteractive
              emacs-basic-display
 -              (and (memq window-system '(x w32))
 +              (and (memq initial-window-system '(x w32))
                     (<= (frame-parameter nil 'menu-bar-lines) 0)))
      (menu-bar-mode 1))
  
    ;; Can't do this init in defcustom because the relevant variables
    ;; are not set.
    (custom-reevaluate-setting 'blink-cursor-mode)
 -  (custom-reevaluate-setting 'normal-erase-is-backspace)
    (custom-reevaluate-setting 'tooltip-mode)
    (custom-reevaluate-setting 'global-font-lock-mode)
    (custom-reevaluate-setting 'mouse-wheel-down-event)
    (custom-reevaluate-setting 'file-name-shadow-mode)
    (custom-reevaluate-setting 'send-mail-function)
  
 +  (normal-erase-is-backspace-setup-frame)
 +
    ;; Register default TTY colors for the case the terminal hasn't a
 -  ;; terminal init file.
 -  (unless (memq window-system '(x w32 mac))
 -    ;; We do this regardles of whether the terminal supports colors
 -    ;; or not, since they can switch that support on or off in
 -    ;; mid-session by setting the tty-color-mode frame parameter.
 -    (tty-register-default-colors))
 +  ;; terminal init file.  We do this regardles of whether the terminal
 +  ;; supports colors or not and regardless the current display type,
 +  ;; since users can connect to color-capable terminals and also
 +  ;; switch color support on or off in mid-session by setting the
 +  ;; tty-color-mode frame parameter.
 +  (tty-register-default-colors)
  
    ;; Record whether the tool-bar is present before the user and site
    ;; init files are processed.  frame-notice-user-settings uses this
    ;; Load library for our terminal type.
    ;; User init file can set term-file-prefix to nil to prevent this.
    (unless (or noninteractive
 -              window-system
 -              (null term-file-prefix))
 -    (let* ((TERM (getenv "TERM"))
 -           (term TERM)
 -          hyphend)
 -      (while (and term
 -                  (not (load (concat term-file-prefix term) t t)))
 -        ;; Strip off last hyphen and what follows, then try again
 -        (setq term
 -              (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
 -                  (substring term 0 hyphend)
 -                nil)))
 -      (setq term TERM)
 -      ;; The terminal file has been loaded, now call the terminal specific
 -      ;; initialization function.
 -      (while term
 -      (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
 -        (if (not (fboundp term-init-func))
 -              ;; Strip off last hyphen and what follows, then try again
 -              (setq term
 -                    (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
 -                        (substring term 0 hyphend)
 -                      nil))
 -            (setq term nil)
 -          (funcall term-init-func))))))
 +              initial-window-system)
 +    (tty-run-terminal-initialization (selected-frame)))
  
    ;; Update the out-of-memory error message based on user's key bindings
    ;; for save-some-buffers.
@@@ -1293,6 -1309,7 +1293,6 @@@ where FACE is a valid face specificatio
      (force-mode-line-update)
      (setq fancy-current-text (cdr fancy-current-text))))
  
 -
  (defun fancy-splash-default-action ()
    "Stop displaying the splash screen buffer.
  This is an internal function used to turn off the splash screen after
@@@ -1302,23 -1319,12 +1302,23 @@@ mouse.
    (if (and (memq 'down (event-modifiers last-command-event))
           (eq (posn-window (event-start last-command-event))
               (selected-window)))
 -      ;; This is a mouse-down event in the spash screen window.
 +      ;; This is a mouse-down event in the splash screen window.
        ;; Ignore it and consume the corresponding mouse-up event.
        (read-event)
      (push last-command-event unread-command-events))
    (throw 'exit nil))
  
 +(defun fancy-splash-exit ()
 +  "Exit the splash screen."
 +  (if (get-buffer "GNU Emacs")
 +      (throw 'stop-splashing nil)))
 +
 +(defun fancy-splash-delete-frame (frame)
 +  "Exit the splash screen after the frame is deleted."
 +  ;; We can not throw from `delete-frame-events', so we set up a timer
 +  ;; to exit the recursive edit as soon as Emacs is idle again.
 +  (if (frame-live-p frame)
 +      (run-at-time 0 nil 'fancy-splash-exit)))
  
  (defun fancy-splash-screens ()
    "Display fancy splash screens when Emacs starts."
        (setq splash-buffer (current-buffer))
        (catch 'stop-splashing
        (unwind-protect
 -          (let ((map (make-sparse-keymap)))
 -            (use-local-map map)
 -            (define-key map [switch-frame] 'ignore)
 +          (let* ((map (make-sparse-keymap))
 +                 (overriding-local-map map)
 +                 ;; Catch if our frame is deleted; the delete-frame
 +                 ;; event is unreliable and is handled by
 +                 ;; `special-event-map' anyway.
 +                 (delete-frame-functions (cons 'fancy-splash-delete-frame
 +                                               delete-frame-functions)))
              (define-key map [t] 'fancy-splash-default-action)
              (define-key map [mouse-movement] 'ignore)
              (define-key map [mode-line t] 'ignore)
 +            (define-key map [select-window] 'ignore)
              (setq cursor-type nil
                    display-hourglass nil
                    minor-mode-map-alist nil
          (setq display-hourglass old-hourglass
                minor-mode-map-alist old-minor-mode-map-alist
                emulation-mode-map-alists old-emulation-mode-map-alists)
 -        (kill-buffer splash-buffer))))))
 +        (kill-buffer splash-buffer)
 +        (when (frame-live-p frame)
 +          (select-frame frame)
 +          (switch-to-buffer fancy-splash-outer-buffer)))))))
  
  (defun fancy-splash-frame ()
    "Return the frame to use for the fancy splash screen.
@@@ -1448,94 -1446,94 +1448,94 @@@ More Manuals / Ordering Manuals    How 
                          "
  Copyright (C) 2006 Free Software Foundation, Inc."))
  
 -            ;; No mouse menus, so give help using kbd commands.
 -
 -            ;; If keys have their default meanings,
 -            ;; use precomputed string to save lots of time.
 -            (if (and (eq (key-binding "\C-h") 'help-command)
 -                     (eq (key-binding "\C-xu") 'advertised-undo)
 -                     (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
 -                     (eq (key-binding "\C-ht") 'help-with-tutorial)
 -                     (eq (key-binding "\C-hi") 'info)
 -                     (eq (key-binding "\C-hr") 'info-emacs-manual)
 -                     (eq (key-binding "\C-h\C-n") 'view-emacs-news))
 -                (insert "
 +          ;; No mouse menus, so give help using kbd commands.
 +
 +          ;; If keys have their default meanings,
 +          ;; use precomputed string to save lots of time.
 +          (if (and (eq (key-binding "\C-h") 'help-command)
 +                   (eq (key-binding "\C-xu") 'advertised-undo)
 +                   (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
 +                   (eq (key-binding "\C-ht") 'help-with-tutorial)
 +                   (eq (key-binding "\C-hi") 'info)
 +                   (eq (key-binding "\C-hr") 'info-emacs-manual)
 +                   (eq (key-binding "\C-h\C-n") 'view-emacs-news))
 +              (insert "
  Get help         C-h  (Hold down CTRL and press h)
  Emacs manual     C-h r
  Emacs tutorial           C-h t           Undo changes     C-x u
  Buy manuals        C-h C-m         Exit Emacs     C-x C-c
  Browse manuals     C-h i")
  
 -              (insert (substitute-command-keys
 -                       (format "\n
 +            (insert (substitute-command-keys
 +                     (format "\n
  Get help         %s
  Emacs manual     \\[info-emacs-manual]
  Emacs tutorial           \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
 -Buy manuals        \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs]
 +Buy manuals        \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-terminal]
  Browse manuals     \\[info]"
 -                               (let ((where (where-is-internal
 -                                             'help-command nil t)))
 -                                 (if where
 -                                     (key-description where)
 -                                   "M-x help"))))))
 -
 -            ;; Say how to use the menu bar with the keyboard.
 -            (if (and (eq (key-binding "\M-`") 'tmm-menubar)
 -                     (eq (key-binding [f10]) 'tmm-menubar))
 -                (insert "
 +                             (let ((where (where-is-internal
 +                                           'help-command nil t)))
 +                               (if where
 +                                   (key-description where)
 +                                 "M-x help"))))))
 +
 +          ;; Say how to use the menu bar with the keyboard.
 +          (if (and (eq (key-binding "\M-`") 'tmm-menubar)
 +                   (eq (key-binding [f10]) 'tmm-menubar))
 +              (insert "
  Activate menubar   F10  or  ESC `  or   M-`")
 -              (insert (substitute-command-keys "
 +            (insert (substitute-command-keys "
  Activate menubar     \\[tmm-menubar]")))
  
 -            ;; Many users seem to have problems with these.
 -            (insert "
 +          ;; Many users seem to have problems with these.
 +          (insert "
  \(`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.
  If you have no Meta key, you may instead type ESC followed by the character.)")
  
 -            (insert "\n\n" (emacs-version)
 -                    "
 +          (insert "\n\n" (emacs-version)
 +                  "
  Copyright (C) 2006 Free Software Foundation, Inc.")
  
 -            (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
 -                     (eq (key-binding "\C-h\C-d") 'describe-distribution)
 -                     (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
 -                (insert
 -                 "\n
 +          (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
 +                   (eq (key-binding "\C-h\C-d") 'describe-distribution)
 +                   (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
 +              (insert
 +               "\n
  GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
  Emacs is Free Software--Free as in Freedom--so you can redistribute copies
  of Emacs and modify it; type C-h C-c to see the conditions.
  Type C-h C-d for information on getting the latest version.")
 -              (insert (substitute-command-keys
 -                       "\n
 +            (insert (substitute-command-keys
 +                     "\n
  GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
  Emacs is Free Software--Free as in Freedom--so you can redistribute copies
  of Emacs and modify it; type \\[describe-copying] to see the conditions.
  Type \\[describe-distribution] for information on getting the latest version."))))
  
 -          ;; The rest of the startup screen is the same on all
 -          ;; kinds of terminals.
 -
 -          ;; Give information on recovering, if there was a crash.
 -          (and auto-save-list-file-prefix
 -               ;; Don't signal an error if the
 -               ;; directory for auto-save-list files
 -               ;; does not yet exist.
 -               (file-directory-p (file-name-directory
 -                                  auto-save-list-file-prefix))
 -               (directory-files
 -                (file-name-directory auto-save-list-file-prefix)
 -                nil
 -                (concat "\\`"
 -                        (regexp-quote (file-name-nondirectory
 -                                       auto-save-list-file-prefix)))
 -                t)
 -               (insert "\n\nIf an Emacs session crashed recently, "
 -                       "type M-x recover-session RET\nto recover"
 -                       " the files you were editing."))
 -
 -          ;; Display the input that we set up in the buffer.
 -          (set-buffer-modified-p nil)
 -          (goto-char (point-min))
 +        ;; The rest of the startup screen is the same on all
 +        ;; kinds of terminals.
 +
 +        ;; Give information on recovering, if there was a crash.
 +        (and auto-save-list-file-prefix
 +             ;; Don't signal an error if the
 +             ;; directory for auto-save-list files
 +             ;; does not yet exist.
 +             (file-directory-p (file-name-directory
 +                                auto-save-list-file-prefix))
 +             (directory-files
 +              (file-name-directory auto-save-list-file-prefix)
 +              nil
 +              (concat "\\`"
 +                      (regexp-quote (file-name-nondirectory
 +                                     auto-save-list-file-prefix)))
 +              t)
 +             (insert "\n\nIf an Emacs session crashed recently, "
 +                     "type M-x recover-session RET\nto recover"
 +                     " the files you were editing."))
 +
 +        ;; Display the input that we set up in the buffer.
 +        (set-buffer-modified-p nil)
 +        (goto-char (point-min))
            (if (or (window-minibuffer-p)
                    (window-dedicated-p (selected-window)))
                ;; There's no point is using pop-to-buffer since creating
              (save-window-excursion
                (switch-to-buffer (current-buffer))
                (sit-for 120))))
 -      ;; Unwind ... ensure splash buffer is killed
 -      (kill-buffer "GNU Emacs"))))
 +    ;; Unwind ... ensure splash buffer is killed
 +    (kill-buffer "GNU Emacs"))))
  
  
  (defun startup-echo-area-message ()
  
  (defun display-startup-echo-area-message ()
    (let ((resize-mini-windows t))
 -    (message "%s" (startup-echo-area-message))))
 +    (or noninteractive ;(input-pending-p) init-file-had-error
 +      ;; t if the init file says to inhibit the echo area startup message.
 +      (and inhibit-startup-echo-area-message
 +           user-init-file
 +           (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
 +                    (equal inhibit-startup-echo-area-message
 +                           (if (equal init-file-user "")
 +                               (user-login-name)
 +                             init-file-user)))
 +               ;; Wasn't set with custom; see if .emacs has a setq.
 +               (let ((buffer (get-buffer-create " *temp*")))
 +                 (prog1
 +                     (condition-case nil
 +                         (save-excursion
 +                           (set-buffer buffer)
 +                           (insert-file-contents user-init-file)
 +                           (re-search-forward
 +                            (concat
 +                             "([ \t\n]*setq[ \t\n]+"
 +                             "inhibit-startup-echo-area-message[ \t\n]+"
 +                             (regexp-quote
 +                              (prin1-to-string
 +                               (if (equal init-file-user "")
 +                                   (user-login-name)
 +                                 init-file-user)))
 +                             "[ \t\n]*)")
 +                            nil t))
 +                       (error nil))
 +                   (kill-buffer buffer)))))
 +      ;; display-splash-screen at the end of command-line-1 calls
 +      ;; use-fancy-splash-screens-p. This can cause image.el to be
 +      ;; loaded, putting "Loading image... done" in the echo area.
 +      ;; This hides startup-echo-area-message. So
 +      ;; use-fancy-splash-screens-p is called here simply to get the
 +      ;; loading of image.el (if needed) out of the way before
 +      ;; display-startup-echo-area-message runs.
 +      (progn
 +        (use-fancy-splash-screens-p)
 +        (message "%s" (startup-echo-area-message))))))
  
  
  (defun display-splash-screen ()
  Fancy splash screens are used on graphic displays,
  normal otherwise."
    (interactive)
 -  (if (use-fancy-splash-screens-p)
 -      (fancy-splash-screens)
 -    (normal-splash-screen)))
 -
 +  ;; Prevent recursive calls from server-process-filter.
 +  (if (not (get-buffer "GNU Emacs"))
 +      (if (use-fancy-splash-screens-p)
 +        (fancy-splash-screens)
 +      (normal-splash-screen))))
  
  (defun command-line-1 (command-line-args-left)
 -  (or noninteractive (input-pending-p) init-file-had-error
 -      ;; t if the init file says to inhibit the echo area startup message.
 -      (and inhibit-startup-echo-area-message
 -         user-init-file
 -         (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
 -                  (equal inhibit-startup-echo-area-message
 -                         (if (equal init-file-user "")
 -                             (user-login-name)
 -                           init-file-user)))
 -             ;; Wasn't set with custom; see if .emacs has a setq.
 -             (let ((buffer (get-buffer-create " *temp*")))
 -               (prog1
 -                   (condition-case nil
 -                       (save-excursion
 -                         (set-buffer buffer)
 -                         (insert-file-contents user-init-file)
 -                         (re-search-forward
 -                          (concat
 -                           "([ \t\n]*setq[ \t\n]+"
 -                           "inhibit-startup-echo-area-message[ \t\n]+"
 -                           (regexp-quote
 -                            (prin1-to-string
 -                             (if (equal init-file-user "")
 -                                 (user-login-name)
 -                               init-file-user)))
 -                           "[ \t\n]*)")
 -                          nil t))
 -                     (error nil))
 -                 (kill-buffer buffer)))))
 -      ;; display-splash-screen at the end of command-line-1 calls
 -      ;; use-fancy-splash-screens-p. This can cause image.el to be
 -      ;; loaded, putting "Loading image... done" in the echo area.
 -      ;; This hides startup-echo-area-message. So
 -      ;; use-fancy-splash-screens-p is called here simply to get the
 -      ;; loading of image.el (if needed) out of the way before
 -      ;; display-startup-echo-area-message runs.
 -      (progn
 -        (use-fancy-splash-screens-p)
 -        (display-startup-echo-area-message)))
 +  (display-startup-echo-area-message)
  
    ;; Delay 2 seconds after an init file error message
    ;; was displayed, so user can read it.
    (when init-file-had-error
      (sit-for 2))
  
+   (when (and pure-space-overflow
+            (not noninteractive))
+     (display-warning
+      'initialization
+      "Building Emacs overflowed pure space."
+      ;; FIXME: Tell the user what kind of problems are possible and how to fix
+      ;; the overflow.
+      :warning))
    (when command-line-args-left
      ;; We have command args; process them.
      (let ((dir command-line-default-directory)
diff --combined lisp/subr.el
@@@ -851,19 -851,23 +851,23 @@@ and `event-end' functions.
    (nth 3 position))
  
  (defsubst posn-string (position)
-   "Return the string object of POSITION, or nil if a buffer position.
+   "Return the string object of POSITION.
+ Value is a cons (STRING . STRING-POS), or nil if not a string.
  POSITION should be a list of the form returned by the `event-start'
  and `event-end' functions."
    (nth 4 position))
  
  (defsubst posn-image (position)
-   "Return the image object of POSITION, or nil if a not an image.
+   "Return the image object of POSITION.
+ Value is an list (image ...), or nil if not an image.
  POSITION should be a list of the form returned by the `event-start'
  and `event-end' functions."
    (nth 7 position))
  
  (defsubst posn-object (position)
    "Return the object (image or string) of POSITION.
+ Value is a list (image ...) for an image object, a cons cell
+ \(STRING . STRING-POS) for a string object, and nil for a buffer position.
  POSITION should be a list of the form returned by the `event-start'
  and `event-end' functions."
    (or (posn-image position) (posn-string position)))
@@@ -1481,7 -1485,7 +1485,7 @@@ any other non-digit terminates the char
        ;; or C-q C-x might not return immediately since ESC or C-x might be
        ;; bound to some prefix in function-key-map or key-translation-map.
        (setq translated char)
 -      (let ((translation (lookup-key function-key-map (vector char))))
 +      (let ((translation (lookup-key local-function-key-map (vector char))))
        (if (arrayp translation)
            (setq translated (aref translation 0))))
        (cond ((null translated))
@@@ -2132,23 -2136,6 +2136,23 @@@ See also `with-temp-buffer'.
         (if (window-live-p save-selected-window-window)
             (select-window save-selected-window-window 'norecord))))))
  
 +(defmacro with-selected-frame (frame &rest body)
 +  "Execute the forms in BODY with FRAME as the selected frame.
 +The value returned is the value of the last form in BODY.
 +See also `with-temp-buffer'."
 +  (declare (indent 1) (debug t))
 +  (let ((old-frame (make-symbol "old-frame"))
 +      (old-buffer (make-symbol "old-buffer")))
 +    `(let ((,old-frame (selected-frame))
 +         (,old-buffer (current-buffer)))
 +       (unwind-protect
 +         (progn (select-frame ,frame)
 +                ,@body)
 +       (if (frame-live-p ,old-frame)
 +           (select-frame ,old-frame))
 +       (if (buffer-live-p ,old-buffer)
 +           (set-buffer ,old-buffer))))))
 +
  (defmacro with-temp-file (file &rest body)
    "Create a new buffer, evaluate BODY there, and write the buffer to FILE.
  The value returned is the value of the last form in BODY.
diff --combined man/emacs.texi
@@@ -5,7 -5,7 +5,7 @@@
  
  @c The edition number appears in several places in this file
  @set EDITION   Fourteenth
 -@set EMACSVER  22.0.50
 +@set EMACSVER  22.0.51
  
  @copying
  This is the @value{EDITION} edition of the @cite{GNU Emacs Manual},
@@@ -1544,7 -1544,12 +1544,12 @@@ Public License instead of this License
  
  @include doclicense.texi
  @include cmdargs.texi
+ @iftex
+ @include xresmini.texi
+ @end iftex
+ @ifnottex
  @include xresources.texi
+ @end ifnottex
  
  @include anti.texi
  @include macos.texi
diff --combined src/.gdbinit
@@@ -88,15 -88,13 +88,13 @@@ en
  # Print out s-expressions from tool bar
  define pp1
    set $tmp = $arg0
-   echo $arg0
-   printf " = "
    set $output_debug = print_output_debug_flag
    set print_output_debug_flag = 0
    set safe_debug_print ($tmp)
    set print_output_debug_flag = $output_debug
  end
  document pp1
- Print the argument as an emacs s-expression
+ Print the argument as an emacs s-expression.
  Works only when an inferior emacs is executing.
  For use on tool bar when debugging in Emacs
  where the variable name would not otherwise
@@@ -119,8 -117,6 +117,6 @@@ en
  # Print value of lisp variable
  define pv1
    set $tmp = "$arg0"
-   echo $arg0
-   printf " = "
    set $output_debug = print_output_debug_flag
    set print_output_debug_flag = 0
    set safe_debug_print (find_symbol_value (intern ($tmp)))
@@@ -129,9 -125,8 +125,8 @@@ en
  document pv1
  Print the value of the lisp variable given as argument.
  Works only when an inferior emacs is executing.
- For use on tool bar when debugging in Emacs
- where the variable name would not otherwise
- be recorded in the GUD buffer.
+ For use when debugging in Emacs where the variable
+ name would not otherwise be recorded in the GUD buffer.
  end
  
  # Print out current buffer point and boundaries
@@@ -789,7 -784,7 +784,7 @@@ set print sevenbit-string
  
  show environment DISPLAY
  show environment TERM
 -set args -geometry 80x40+0+0
 +#set args -geometry 80x40+0+0
  
  # People get bothered when they see messages about non-existent functions...
  xgetptr Vsystem_type
@@@ -817,7 -812,7 +812,7 @@@ en
  tbreak init_sys_modes
  commands
    silent
 -  xgetptr Vwindow_system
 +  xgetptr Vinitial_window_system
    set $tem = (struct Lisp_Symbol *) $ptr
    xgetptr $tem->xname
    set $tem = (struct Lisp_String *) $ptr
diff --combined src/dispextern.h
@@@ -1029,8 -1029,13 +1029,8 @@@ extern int fonts_changed_p
  
  extern struct glyph space_glyph;
  
 -/* Frame being updated by update_window/update_frame.  */
 -
 -extern struct frame *updating_frame;
 -
  /* Window being updated by update_window.  This is non-null as long as
 -   update_window has not finished, and null otherwise.  It's role is
 -   analogous to updating_frame.  */
 +   update_window has not finished, and null otherwise.  */
  
  extern struct window *updated_window;
  
@@@ -1350,7 -1355,7 +1350,7 @@@ struct glyph_strin
        DESCENT = FONT->descent
        HEIGHT = FONT_HEIGHT (FONT)
        F_DESCENT = (FRAME_FONT (F)->descent
 -                   - F->output_data.x->baseline_offset)
 +                   - F->terminal->output_data.x->baseline_offset)
        F_HEIGHT = FRAME_LINE_HEIGHT (F)
  */
  
@@@ -2152,16 -2157,16 +2152,16 @@@ struct i
  /* Call produce_glyphs or produce_glyphs_hook, if set.  Shortcut to
     avoid the function call overhead.  */
  
 -#define PRODUCE_GLYPHS(IT)                    \
 -     do {                                     \
 -       extern int inhibit_free_realized_faces;        \
 -       if (rif != NULL)                               \
 -       rif->produce_glyphs ((IT));            \
 -       else                                   \
 -       produce_glyphs ((IT));                 \
 -       if ((IT)->glyph_row != NULL)           \
 -       inhibit_free_realized_faces = 1;       \
 -     } while (0)
 +#define PRODUCE_GLYPHS(IT)                              \
 +  do {                                                  \
 +    extern int inhibit_free_realized_faces;             \
 +    if (FRAME_RIF ((IT)->f) != NULL)                    \
 +      FRAME_RIF ((IT)->f)->produce_glyphs ((IT));       \
 +    else                                                \
 +      produce_glyphs ((IT));                            \
 +    if ((IT)->glyph_row != NULL)                        \
 +      inhibit_free_realized_faces = 1;                  \
 +  } while (0)
  
  /* Bit-flags indicating what operation move_it_to should perform.  */
  
@@@ -2335,6 -2340,10 +2335,6 @@@ struct redisplay_interfac
  #endif /* HAVE_WINDOW_SYSTEM */
  };
  
 -/* The current interface for window-based redisplay.  */
 -
 -extern struct redisplay_interface *rif;
 -
  \f
  /***********************************************************************
                                Images
@@@ -2412,6 -2421,15 +2412,15 @@@ struct imag
  #define DEFAULT_IMAGE_WIDTH 30
  #define DEFAULT_IMAGE_HEIGHT 30
  
+   /* Top/left and bottom/right corner pixel of actual image data.
+      Used by four_corners_best to consider the real image data,
+      rather than looking at the optional image margin.  */
+   int corners[4];
+ #define TOP_CORNER 0
+ #define LEFT_CORNER 1
+ #define BOT_CORNER 2
+ #define RIGHT_CORNER 3
    /* Percent of image height used as ascent.  A value of
       CENTERED_IMAGE_ASCENT means draw the image centered on the
       line.  */
@@@ -2622,6 -2640,8 +2631,6 @@@ void init_iterator_to_row_start P_ ((st
                                     struct glyph_row *));
  int get_next_display_element P_ ((struct it *));
  void set_iterator_to_next P_ ((struct it *, int));
 -void produce_glyphs P_ ((struct it *));
 -void produce_special_glyphs P_ ((struct it *, enum display_element_type));
  void start_display P_ ((struct it *, struct window *, struct text_pos));
  void move_it_to P_ ((struct it *, int, int, int, int, int));
  void move_it_vertically P_ ((struct it *, int));
@@@ -2765,11 -2785,11 +2774,11 @@@ int image_ascent P_ ((struct image *, s
  
  /* Defined in sysdep.c */
  
 -void get_frame_size P_ ((int *, int *));
 +void get_tty_size P_ ((int, int *, int *));
  void request_sigio P_ ((void));
  void unrequest_sigio P_ ((void));
 -int tabs_safe_p P_ ((void));
 -void init_baud_rate P_ ((void));
 +int tabs_safe_p P_ ((int));
 +void init_baud_rate P_ ((int));
  void init_sigio P_ ((int));
  
  /* Defined in xfaces.c */
@@@ -2908,6 -2928,8 +2917,6 @@@ void clear_glyph_row P_ ((struct glyph_
  void prepare_desired_row P_ ((struct glyph_row *));
  int line_hash_code P_ ((struct glyph_row *));
  void set_window_update_flags P_ ((struct window *, int));
 -void write_glyphs P_ ((struct glyph *, int));
 -void insert_glyphs P_ ((struct glyph *, int));
  void redraw_frame P_ ((struct frame *));
  void redraw_garbaged_frames P_ ((void));
  int scroll_cost P_ ((struct frame *, int, int, int));
@@@ -2925,44 -2947,31 +2934,44 @@@ void syms_of_display P_ ((void))
  extern Lisp_Object Qredisplay_dont_pause;
  GLYPH spec_glyph_lookup_face P_ ((struct window *, GLYPH));
  
 -/* Defined in term.c */
 +/* Defined in terminal.c */
  
 -extern void ring_bell P_ ((void));
 -extern void set_terminal_modes P_ ((void));
 -extern void reset_terminal_modes P_ ((void));
 +extern void ring_bell P_ ((struct frame *));
  extern void update_begin P_ ((struct frame *));
  extern void update_end P_ ((struct frame *));
 -extern void set_terminal_window P_ ((int));
 -extern void set_scroll_region P_ ((int, int));
 -extern void turn_off_insert P_ ((void));
 -extern void turn_off_highlight P_ ((void));
 -extern void background_highlight P_ ((void));
 -extern void clear_frame P_ ((void));
 -extern void clear_end_of_line P_ ((int));
 -extern void clear_end_of_line_raw P_ ((int));
 -extern void delete_glyphs P_ ((int));
 -extern void ins_del_lines P_ ((int, int));
 +extern void set_terminal_window P_ ((struct frame *, int));
 +extern void cursor_to P_ ((struct frame *, int, int));
 +extern void raw_cursor_to P_ ((struct frame *, int, int));
 +extern void clear_to_end P_ ((struct frame *));
 +extern void clear_frame P_ ((struct frame *));
 +extern void clear_end_of_line P_ ((struct frame *, int));
 +extern void write_glyphs P_ ((struct frame *, struct glyph *, int));
 +extern void insert_glyphs P_ ((struct frame *, struct glyph *, int));
 +extern void delete_glyphs P_ ((struct frame *, int));
 +extern void ins_del_lines P_ ((struct frame *, int, int));
 +
 +extern struct terminal *init_initial_terminal P_ ((void));
 +
 +
 +/* Defined in term.c */
 +
 +extern void tty_set_terminal_modes P_ ((struct terminal *));
 +extern void tty_reset_terminal_modes P_ ((struct terminal *));
 +extern void tty_turn_off_insert P_ ((struct tty_display_info *));
 +extern void tty_turn_off_highlight P_ ((struct tty_display_info *));
  extern int string_cost P_ ((char *));
  extern int per_line_cost P_ ((char *));
  extern void calculate_costs P_ ((struct frame *));
 +extern void produce_glyphs P_ ((struct it *));
 +extern void produce_special_glyphs P_ ((struct it *, enum display_element_type));
 +extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
  extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
 -extern void tty_setup_colors P_ ((int));
 -extern void term_init P_ ((char *));
 -void cursor_to P_ ((int, int));
 -extern int tty_capable_p P_ ((struct frame *, unsigned, unsigned long, unsigned long));
 +extern struct terminal *get_tty_terminal P_ ((Lisp_Object, int));
 +extern struct terminal *get_named_tty P_ ((char *));
 +EXFUN (Ftty_type, 1);
 +extern void create_tty_output P_ ((struct frame *));
 +extern struct terminal *init_tty P_ ((char *, char *, int));
 +
  
  /* Defined in scroll.c */
  
diff --combined src/frame.c
@@@ -42,7 -42,6 +42,7 @@@ Boston, MA 02110-1301, USA.  *
  #include "fontset.h"
  #endif
  #include "blockinput.h"
 +#include "termchar.h"
  #include "termhooks.h"
  #include "dispextern.h"
  #include "window.h"
@@@ -76,8 -75,6 +76,8 @@@ Lisp_Object Qinhibit_default_face_x_res
  
  Lisp_Object Qx_frame_parameter;
  Lisp_Object Qx_resource_name;
 +Lisp_Object Qterminal;
 +Lisp_Object Qterminal_live_p;
  
  /* Frame parameters (set or reported).  */
  
@@@ -107,16 -104,14 +107,16 @@@ Lisp_Object Qtitle, Qname
  Lisp_Object Qunsplittable;
  Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
  Lisp_Object Qleft_fringe, Qright_fringe;
 -Lisp_Object Qbuffer_predicate, Qbuffer_list;
 +Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
  Lisp_Object Qtty_color_mode;
 +Lisp_Object Qtty, Qtty_type;
 +Lisp_Object Qwindow_system;
 +Lisp_Object Qenvironment;
  
  Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
  
  Lisp_Object Qface_set_after_frame_default;
  
 -
  Lisp_Object Vterminal_frame;
  Lisp_Object Vdefault_frame_alist;
  Lisp_Object Vdefault_frame_scroll_bars;
@@@ -126,8 -121,8 +126,8 @@@ Lisp_Object Vdelete_frame_functions
  \f
  static void
  set_menu_bar_lines_1 (window, n)
 -  Lisp_Object window;
 -  int n;
 +     Lisp_Object window;
 +     int n;
  {
    struct window *w = XWINDOW (window);
  
@@@ -185,6 -180,8 +185,6 @@@ set_menu_bar_lines (f, value, oldval
  Lisp_Object Vemacs_iconified;
  Lisp_Object Vframe_list;
  
 -struct x_output tty_display;
 -
  extern Lisp_Object Vminibuffer_list;
  extern Lisp_Object get_minibuffer ();
  extern Lisp_Object Fhandle_switch_frame ();
@@@ -206,7 -203,6 +206,7 @@@ See also `frame-live-p'.  */
      return Qnil;
    switch (XFRAME (object)->output_method)
      {
 +    case output_initial: /* The initial frame is like a termcap frame. */
      case output_termcap:
        return Qt;
      case output_x_window:
  DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
         doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
  Value is nil if OBJECT is not a live frame.  If object is a live
 -frame, the return value indicates what sort of output device it is
 +frame, the return value indicates what sort of terminal device it is
  displayed on.  See the documentation of `framep' for possible
  return values.  */)
       (object)
          : Qnil);
  }
  
 +DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
 +       doc: /* The name of the window system that FRAME is displaying through.
 +The value is a symbol---for instance, 'x' for X windows.
 +The value is nil if Emacs is using a text-only terminal.
 +
 +FRAME defaults to the currently selected frame.  */)
 +  (frame)
 +     Lisp_Object frame;
 +{
 +  Lisp_Object type;
 +  if (NILP (frame))
 +    frame = selected_frame;
 +
 +  type = Fframep (frame);
 +
 +  if (NILP (type))
 +    wrong_type_argument (Qframep, frame);
 +
 +  if (EQ (type, Qt))
 +    return Qnil;
 +  else
 +    return type;
 +}      
 +
  struct frame *
  make_frame (mini_p)
       int mini_p;
    f->menu_bar_items_used = 0;
    f->buffer_predicate = Qnil;
    f->buffer_list = Qnil;
 -#ifdef MULTI_KBOARD
 -  f->kboard = initial_kboard;
 -#endif
 +  f->buried_buffer_list = Qnil;
    f->namebuf = 0;
    f->title = Qnil;
    f->menu_bar_window = Qnil;
@@@ -424,8 -398,8 +424,8 @@@ make_frame_without_minibuffer (mini_win
  
  #ifdef MULTI_KBOARD
    if (!NILP (mini_window)
 -      && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb)
 -    error ("Frame and minibuffer must be on the same display");
 +      && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
 +    error ("Frame and minibuffer must be on the same terminal");
  #endif
  
    /* Make a frame containing just a root window.  */
@@@ -501,19 -475,18 +501,19 @@@ make_minibuffer_frame (
  }
  #endif /* HAVE_WINDOW_SYSTEM */
  \f
 -/* Construct a frame that refers to the terminal (stdin and stdout).  */
 +/* Construct a frame that refers to a terminal.  */
  
 -static int terminal_frame_count;
 +static int tty_frame_count;
  
  struct frame *
 -make_terminal_frame ()
 +make_initial_frame (void)
  {
 -  register struct frame *f;
 +  struct frame *f;
 +  struct terminal *terminal;
    Lisp_Object frame;
 -  char name[20];
  
  #ifdef MULTI_KBOARD
 +  /* Create the initial keyboard. */
    if (!initial_kboard)
      {
        initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
    if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
      Vframe_list = Qnil;
  
 +  terminal = init_initial_terminal ();
 +
 +  f = make_frame (1);
 +  XSETFRAME (frame, f);
 +
 +  Vframe_list = Fcons (frame, Vframe_list);
 +
 +  tty_frame_count = 1;
 +  f->name = build_string ("F1");
 +
 +  f->visible = 1;
 +  f->async_visible = 1;
 +
 +  f->output_method = terminal->type;
 +  f->terminal = terminal;
 +  f->terminal->reference_count++;
 +  f->output_data.nothing = 0;
 +  
 +  FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
 +  FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
 +    
 +  FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
 +  FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
 +
 +  return f;
 +}
 +
 +
 +struct frame *
 +make_terminal_frame (struct terminal *terminal)
 +{
 +  register struct frame *f;
 +  Lisp_Object frame;
 +  char name[20];
 +  
    f = make_frame (1);
  
    XSETFRAME (frame, f);
    Vframe_list = Fcons (frame, Vframe_list);
  
 -  terminal_frame_count++;
 -  sprintf (name, "F%d", terminal_frame_count);
 +  tty_frame_count++;
 +  sprintf (name, "F%d", tty_frame_count);
    f->name = build_string (name);
  
    f->visible = 1;             /* FRAME_SET_VISIBLE wd set frame_garbaged. */
         for the black color.  Other frames all inherit their pixels
         from what's already in the_only_x_display.  */
        if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
 -        && f->output_data.x->background_pixel == 0
 -        && f->output_data.x->foreground_pixel == 0)
 +        && FRAME_BACKGROUND_PIXEL (f) == 0
 +        && FRAME_FOREGROUND_PIXEL (f) == 0)
        {
 -        f->output_data.x->background_pixel = FACE_TTY_DEFAULT_BG_COLOR;
 -        f->output_data.x->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR;
 +        FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
 +        FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
        }
      }
    else
  #else
  #ifdef WINDOWSNT
    f->output_method = output_termcap;
 -  f->output_data.x = &tty_display;
 +  f->output_data.x = &tty_display; /* XXX ??? */
  #else
  #ifdef MAC_OS8
    make_mac_terminal_frame (f);
  #else
 -  f->output_data.x = &tty_display;
 +  {
 +    f->output_method = output_termcap;
 +    f->terminal = terminal;
 +    f->terminal->reference_count++;
 +    create_tty_output (f);
 +    
 +    FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
 +    FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
 +    
 +    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
 +    FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
 +
 +    /* Set the top frame to the newly created frame. */
 +    if (FRAME_TTY (f)->top_frame
 +        && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
 +      XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
 +    
 +    FRAME_TTY (f)->top_frame = frame;
 +  }
 +  
  #ifdef CANNOT_DUMP
    FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
    FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
    return f;
  }
  
 +/* Get a suitable value for frame parameter PARAMETER for a newly
 +   created frame, based on (1) the user-supplied frame parameter
 +   alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
 +   fails, (3) Vdefault_frame_alist.  */
 +
 +static Lisp_Object
 +get_future_frame_param (Lisp_Object parameter,
 +                        Lisp_Object supplied_parms,
 +                        char *current_value)
 +{
 +  Lisp_Object result;
 +
 +  result = Fassq (parameter, supplied_parms);
 +  if (NILP (result))
 +    result = Fassq (parameter, XFRAME (selected_frame)->param_alist);
 +  if (NILP (result) && current_value != NULL)
 +    result = build_string (current_value);
 +  if (NILP (result))
 +    result = Fassq (parameter, Vdefault_frame_alist);
 +  if (!NILP (result) && !STRINGP (result))
 +    result = XCDR (result);
 +  if (NILP (result) || !STRINGP (result))
 +    result = Qnil;
 +
 +  return result;
 +}
 +
  DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
         1, 1, 0,
 -       doc: /* Create an additional terminal frame.
 -You can create multiple frames on a text-only terminal in this way.
 -Only the selected terminal frame is actually displayed.
 +       doc: /* Create an additional terminal frame, possibly on another terminal.
  This function takes one argument, an alist specifying frame parameters.
 -In practice, generally you don't need to specify any parameters.
 -Note that changing the size of one terminal frame automatically affects all.  */)
 +
 +You can create multiple frames on a single text-only terminal, but
 +only one of them (the selected terminal frame) is actually displayed.
 +
 +In practice, generally you don't need to specify any parameters,
 +except when you want to create a new frame on another terminal.
 +In that case, the `tty' parameter specifies the device file to open,
 +and the `tty-type' parameter specifies the terminal type.  Example:
 +
 +   (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
 +
 +Note that changing the size of one terminal frame automatically
 +affects all frames on the same terminal device.  */)
       (parms)
       Lisp_Object parms;
  {
    struct frame *f;
 +  struct terminal *t = NULL;
    Lisp_Object frame, tem;
    struct frame *sf = SELECTED_FRAME ();
  
    if (sf->output_method != output_mac)
      error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
  #else
 +#if 0                           /* This should work now! */
    if (sf->output_method != output_termcap)
      error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
  #endif
 +#endif
  #endif /* not MSDOS */
 +  
 +  {
 +    Lisp_Object terminal;
 +
 +    terminal = Fassq (Qterminal, parms);
 +    if (!NILP (terminal))
 +      {
 +        terminal = XCDR (terminal);
 +        t = get_terminal (terminal, 1);
 +      }
 +  }
 +  
 +  if (!t)
 +    { 
 +      char *name = 0, *type = 0;
 +      Lisp_Object tty, tty_type;
 +
 +      tty = get_future_frame_param
 +        (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
 +                       ? FRAME_TTY (XFRAME (selected_frame))->name
 +                       : NULL));
 +      if (!NILP (tty))
 +        {
 +          name = (char *) alloca (SBYTES (tty) + 1);
 +          strncpy (name, SDATA (tty), SBYTES (tty));
 +          name[SBYTES (tty)] = 0;
 +        }
 +      
 +      tty_type = get_future_frame_param
 +        (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
 +                            ? FRAME_TTY (XFRAME (selected_frame))->type
 +                            : NULL));
 +      if (!NILP (tty_type))
 +        {
 +          type = (char *) alloca (SBYTES (tty_type) + 1);
 +          strncpy (type, SDATA (tty_type), SBYTES (tty_type));
 +          type[SBYTES (tty_type)] = 0;
 +        }
 +
 +      t = init_tty (name, type, 0); /* Errors are not fatal. */
 +    }
  
 -  f = make_terminal_frame ();
 +  f = make_terminal_frame (t);
  
 -  change_frame_size (f, FRAME_LINES (sf),
 -                   FRAME_COLS (sf), 0, 0, 0);
 +  {
 +    int width, height;
 +    get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
 +    change_frame_size (f, height, width, 0, 0, 0);
 +  }
 +  
    adjust_glyphs (f);
    calculate_costs (f);
    XSETFRAME (frame, f);
    Fmodify_frame_parameters (frame, Vdefault_frame_alist);
    Fmodify_frame_parameters (frame, parms);
 -
 +  Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
 +  Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type,
 +                                                 build_string (t->display_info.tty->type)),
 +                                          Qnil));
 +  if (t->display_info.tty->name != NULL)
 +    Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty,
 +                                                   build_string (t->display_info.tty->name)),
 +                                            Qnil));
 +  else
 +    Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty, Qnil), Qnil));
 +  
    /* Make the frame face alist be frame-specific, so that each
       frame could change its face definitions independently.  */
    f->face_alist = Fcopy_alist (sf->face_alist);
     frame's focus to FRAME instead.
  
     FOR_DELETION non-zero means that the selected frame is being
 -   deleted, which includes the possibility that the frame's display
 +   deleted, which includes the possibility that the frame's terminal
     is dead.  */
  
  Lisp_Object
@@@ -870,15 -695,6 +870,15 @@@ do_switch_frame (frame, track, for_dele
    if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
      resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
  
 +  if (FRAME_TERMCAP_P (XFRAME (selected_frame))
 +      && FRAME_TERMCAP_P (XFRAME (frame))
 +      && FRAME_TTY (XFRAME (selected_frame)) == FRAME_TTY (XFRAME (frame)))
 +    {
 +      XFRAME (selected_frame)->async_visible = 2; /* obscured */
 +      XFRAME (frame)->async_visible = 1;
 +      FRAME_TTY (XFRAME (frame))->top_frame = frame;
 +    }
 +
    selected_frame = frame;
    if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
      last_nonminibuf_frame = XFRAME (selected_frame);
@@@ -1062,7 -878,6 +1062,7 @@@ If FRAME is the selected frame, this ma
  
    return XFRAME (frame)->selected_window = window;
  }
 +
  \f
  DEFUN ("frame-list", Fframe_list, Sframe_list,
         0, 0, 0,
@@@ -1110,10 -925,7 +1110,10 @@@ next_frame (frame, minibuf
        f = XCAR (tail);
  
        if (passed
 -          && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
 +          && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
 +                 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
 +                || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
 +                    && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))))
          {
            /* Decide whether this frame is eligible to be returned.  */
  
@@@ -1190,10 -1002,7 +1190,10 @@@ prev_frame (frame, minibuf
        if (EQ (frame, f) && !NILP (prev))
        return prev;
  
 -      if (FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
 +      if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
 +           && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
 +          || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
 +              && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))
        {
          /* Decide whether this frame is eligible to be returned,
             according to minibuf.  */
@@@ -1327,14 -1136,6 +1327,14 @@@ other_visible_frames (f
    return 1;
  }
  
 +/* Error handler for `delete-frame-functions'. */
 +static Lisp_Object
 +delete_frame_handler (Lisp_Object arg)
 +{
 +  add_to_log ("Error during `delete-frame': %s", arg, Qnil);
 +  return Qnil;
 +}
 +
  DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
         doc: /* Delete FRAME, permanently eliminating it from use.
  If omitted, FRAME defaults to the selected frame.
@@@ -1350,8 -1151,6 +1350,8 @@@ The functions are run with one arg, th
  {
    struct frame *f;
    struct frame *sf = SELECTED_FRAME ();
 +  struct kboard *kb;
 +
    int minibuffer_selected;
  
    if (EQ (frame, Qnil))
        && NILP (Fframe_parameter (frame, intern ("tooltip"))))
      {
        Lisp_Object args[2];
 +      struct gcpro gcpro1, gcpro2;
 +
 +      /* Don't let a rogue function in `delete-frame-functions'
 +       prevent the frame deletion. */
 +      GCPRO2 (args[0], args[1]);
        args[0] = intern ("delete-frame-functions");
        args[1] = frame;
 -      Frun_hook_with_args (2, args);
 +      internal_condition_case_2 (Frun_hook_with_args, 2, args,
 +                               Qt, delete_frame_handler);
 +      UNGCPRO;
      }
  
 +  /* The hook may sometimes (indirectly) cause the frame to be deleted.  */
 +  if (! FRAME_LIVE_P (f))
 +    return Qnil;
 +
    minibuffer_selected = EQ (minibuf_window, selected_window);
  
    /* Don't let the frame remain selected.  */
        {
          FOR_EACH_FRAME (tail, frame1)
            {
 -            if (! EQ (frame, frame1))
 +            if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
                break;
            }
        }
    if (EQ (f->minibuffer_window, echo_area_window))
      echo_area_window = sf->minibuffer_window;
  
 +  /* Don't allow other frames to refer to a deleted frame in their
 +     'environment parameter.  */
 +  {
 +    Lisp_Object tail, frame1;
 +    Lisp_Object env = get_frame_param (XFRAME (frame), Qenvironment);
 +    FOR_EACH_FRAME (tail, frame1)
 +      {
 +        if (EQ (frame, frame1) || !FRAME_LIVE_P (XFRAME (frame1)))
 +          continue;
 +        if (EQ (frame, get_frame_param (XFRAME (frame1), Qenvironment)))
 +          {
 +            store_frame_param (XFRAME (frame1), Qenvironment, env);
 +            if (!FRAMEP (env))
 +              env = frame1;
 +          }
 +      }
 +  }
 +  
    /* Clear any X selections for this frame.  */
  #ifdef HAVE_X_WINDOWS
    if (FRAME_X_P (f))
      xfree (FRAME_MESSAGE_BUF (f));
  
    /* Since some events are handled at the interrupt level, we may get
 -     an event for f at any time; if we zero out the frame's display
 +     an event for f at any time; if we zero out the frame's terminal
       now, then we may trip up the event-handling code.  Instead, we'll
 -     promise that the display of the frame must be valid until we have
 -     called the window-system-dependent frame destruction routine.  */
 +     promise that the terminal of the frame must be valid until we
 +     have called the window-system-dependent frame destruction
 +     routine.  */
  
 -  /* I think this should be done with a hook.  */
 -#ifdef HAVE_WINDOW_SYSTEM
 -  if (FRAME_WINDOW_P (f))
 -    x_destroy_window (f);
 -#endif
 +  if (FRAME_TERMINAL (f)->delete_frame_hook)
 +    (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
  
 -  f->output_data.nothing = 0;
 +  {
 +    struct terminal *terminal = FRAME_TERMINAL (f);
 +    f->output_data.nothing = 0; 
 +    f->terminal = 0;             /* Now the frame is dead. */
 +
 +    /* If needed, delete the terminal that this frame was on.
 +       (This must be done after the frame is killed.) */
 +    terminal->reference_count--;
 +    if (terminal->reference_count == 0)
 +      {
 +        kb = NULL;
 +        if (terminal->delete_terminal_hook)
 +          (*terminal->delete_terminal_hook) (terminal);
 +        else
 +          delete_terminal (terminal);
 +      }
 +    else
 +      kb = terminal->kboard;
 +  }
  
    /* If we've deleted the last_nonminibuf_frame, then try to find
       another one.  */
  
    /* If there's no other frame on the same kboard, get out of
       single-kboard state if we're in it for this kboard.  */
 -  {
 -    Lisp_Object frames;
 -    /* Some frame we found on the same kboard, or nil if there are none.  */
 -    Lisp_Object frame_on_same_kboard;
 +  if (kb != NULL)
 +    {
 +      Lisp_Object frames;
 +      /* Some frame we found on the same kboard, or nil if there are none.  */
 +      Lisp_Object frame_on_same_kboard;
  
 -    frame_on_same_kboard = Qnil;
 +      frame_on_same_kboard = Qnil;
  
 -    for (frames = Vframe_list;
 -       CONSP (frames);
 -       frames = XCDR (frames))
 -      {
 -      Lisp_Object this;
 -      struct frame *f1;
 +      for (frames = Vframe_list;
 +         CONSP (frames);
 +         frames = XCDR (frames))
 +      {
 +        Lisp_Object this;
 +        struct frame *f1;
  
 -      this = XCAR (frames);
 -      if (!FRAMEP (this))
 -        abort ();
 -      f1 = XFRAME (this);
 +        this = XCAR (frames);
 +        if (!FRAMEP (this))
 +          abort ();
 +        f1 = XFRAME (this);
  
 -      if (FRAME_KBOARD (f) == FRAME_KBOARD (f1))
 -        frame_on_same_kboard = this;
 -      }
 +        if (kb == FRAME_KBOARD (f1))
 +          frame_on_same_kboard = this;
 +      }
  
 -    if (NILP (frame_on_same_kboard))
 -      not_single_kboard_state (FRAME_KBOARD (f));
 -  }
 +      if (NILP (frame_on_same_kboard))
 +      not_single_kboard_state (kb);
 +    }
  
  
    /* If we've deleted this keyboard's default_minibuffer_frame, try to
       find another one.  Prefer minibuffer-only frames, but also notice
       frames with other windows.  */
 -  if (EQ (frame, FRAME_KBOARD (f)->Vdefault_minibuffer_frame))
 +  if (kb != NULL && EQ (frame, kb->Vdefault_minibuffer_frame))
      {
        Lisp_Object frames;
  
  
          /* Consider only frames on the same kboard
             and only those with minibuffers.  */
 -        if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)
 +        if (kb == FRAME_KBOARD (f1)
              && FRAME_HAS_MINIBUF_P (f1))
            {
              frame_with_minibuf = this;
                break;
            }
  
 -        if (FRAME_KBOARD (f) == FRAME_KBOARD (f1))
 +        if (kb == FRAME_KBOARD (f1))
            frame_on_same_kboard = this;
        }
  
          if (NILP (frame_with_minibuf))
            abort ();
  
 -        FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf;
 +        kb->Vdefault_minibuffer_frame = frame_with_minibuf;
        }
        else
        /* No frames left on this kboard--say no minibuffer either.  */
 -      FRAME_KBOARD (f)->Vdefault_minibuffer_frame = Qnil;
 +      kb->Vdefault_minibuffer_frame = Qnil;
      }
  
    /* Cause frame titles to update--necessary if we now have just one frame.  */
@@@ -1698,11 -1451,11 +1698,11 @@@ and returns whatever that function retu
  
  #ifdef HAVE_MOUSE
    /* It's okay for the hook to refrain from storing anything.  */
 -  if (mouse_position_hook)
 -    (*mouse_position_hook) (&f, -1,
 -                          &lispy_dummy, &party_dummy,
 -                          &x, &y,
 -                          &long_dummy);
 +  if (FRAME_TERMINAL (f)->mouse_position_hook)
 +    (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
 +                                                &lispy_dummy, &party_dummy,
 +                                                &x, &y,
 +                                                &long_dummy);
    if (! NILP (x))
      {
        col = XINT (x);
@@@ -1741,11 -1494,11 +1741,11 @@@ and nil for X and Y.  */
  
  #ifdef HAVE_MOUSE
    /* It's okay for the hook to refrain from storing anything.  */
 -  if (mouse_position_hook)
 -    (*mouse_position_hook) (&f, -1,
 -                          &lispy_dummy, &party_dummy,
 -                          &x, &y,
 -                          &long_dummy);
 +  if (FRAME_TERMINAL (f)->mouse_position_hook)
 +    (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
 +                                                &lispy_dummy, &party_dummy,
 +                                                &x, &y,
 +                                                &long_dummy);
  #endif
    XSETFRAME (lispy_dummy, f);
    return Fcons (lispy_dummy, Fcons (x, y));
@@@ -2011,19 -1764,16 +2011,19 @@@ doesn't support multiple overlapping fr
       (frame)
       Lisp_Object frame;
  {
 +  struct frame *f;
    if (NILP (frame))
      frame = selected_frame;
  
    CHECK_LIVE_FRAME (frame);
  
 +  f = XFRAME (frame);
 +  
    /* Do like the documentation says. */
    Fmake_frame_visible (frame);
  
 -  if (frame_raise_lower_hook)
 -    (*frame_raise_lower_hook) (XFRAME (frame), 1);
 +  if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
 +    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
  
    return Qnil;
  }
@@@ -2037,17 -1787,13 +2037,17 @@@ doesn't support multiple overlapping fr
       (frame)
       Lisp_Object frame;
  {
 +  struct frame *f;
 +  
    if (NILP (frame))
      frame = selected_frame;
  
    CHECK_LIVE_FRAME (frame);
  
 -  if (frame_raise_lower_hook)
 -    (*frame_raise_lower_hook) (XFRAME (frame), 0);
 +  f = XFRAME (frame);
 +  
 +  if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
 +    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
  
    return Qnil;
  }
@@@ -2081,8 -1827,6 +2081,8 @@@ The redirection lasts until `redirect-f
       (frame, focus_frame)
       Lisp_Object frame, focus_frame;
  {
 +  struct frame *f;
 +  
    /* Note that we don't check for a live frame here.  It's reasonable
       to redirect the focus of a frame you're about to delete, if you
       know what other frame should receive those keystrokes.  */
    if (! NILP (focus_frame))
      CHECK_LIVE_FRAME (focus_frame);
  
 -  XFRAME (frame)->focus_frame = focus_frame;
 +  f = XFRAME (frame);
 +  
 +  f->focus_frame = focus_frame;
  
 -  if (frame_rehighlight_hook)
 -    (*frame_rehighlight_hook) (XFRAME (frame));
 +  if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
 +    (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
  
    return Qnil;
  }
@@@ -2158,7 -1900,7 +2158,7 @@@ set_frame_buffer_list (frame, list
    XFRAME (frame)->buffer_list = list;
  }
  
 -/* Discard BUFFER from the buffer-list of each frame.  */
 +/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame.  */
  
  void
  frames_discard_buffer (buffer)
      {
        XFRAME (frame)->buffer_list
        = Fdelq (buffer, XFRAME (frame)->buffer_list);
 +      XFRAME (frame)->buried_buffer_list
 +        = Fdelq (buffer, XFRAME (frame)->buried_buffer_list);
      }
  }
  
@@@ -2230,8 -1970,8 +2230,8 @@@ set_term_frame_name (f, name
                            SBYTES (f->name)))
        return;
  
 -      terminal_frame_count++;
 -      sprintf (namebuf, "F%d", terminal_frame_count);
 +      tty_frame_count++;
 +      sprintf (namebuf, "F%d", tty_frame_count);
        name = build_string (namebuf);
      }
    else
@@@ -2259,18 -1999,13 +2259,18 @@@ store_frame_param (f, prop, val
  {
    register Lisp_Object old_alist_elt;
  
 -  /* The buffer-alist parameter is stored in a special place and is
 -     not in the alist.  */
 +  /* The buffer-list parameters are stored in a special place and not
 +     in the alist.  */
    if (EQ (prop, Qbuffer_list))
      {
        f->buffer_list = val;
        return;
      }
 +  if (EQ (prop, Qburied_buffer_list))
 +    {
 +      f->buried_buffer_list = val;
 +      return;
 +    }
  
    /* If PROP is a symbol which is supposed to have frame-local values,
       and it is set up based on this frame, switch to the global
        if ((BUFFER_LOCAL_VALUEP (valcontents)
           || SOME_BUFFER_LOCAL_VALUEP (valcontents))
          && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
 +        && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame
          && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
        swap_in_global_binding (prop);
      }
@@@ -2411,7 -2145,6 +2411,7 @@@ If FRAME is omitted, return informatio
                   : FRAME_MINIBUF_WINDOW (f)));
    store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
    store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
 +  store_in_alist (&alist, Qburied_buffer_list, XFRAME (frame)->buried_buffer_list);
  
    /* I think this should be done with a hook.  */
  #ifdef HAVE_WINDOW_SYSTEM
@@@ -2591,43 -2324,6 +2591,43 @@@ enabled such bindings for that variabl
  
    return unbind_to (count, Qnil);
  }
 +
 +DEFUN ("frame-with-environment", Fframe_with_environment, Sframe_with_environment, 0, 1, 0,
 +       doc: /* Return the frame that has the environment variable list for FRAME.
 +
 +The frame-local environment variable list is normally shared between
 +frames that were created in the same Emacsclient session.  The
 +environment list is stored in a single frame's 'environment parameter;
 +the other frames' 'environment parameter is set to this frame.  This
 +function follows the chain of 'environment references to reach the
 +frame that stores the actual local environment list, and returns that
 +frame.  */)
 +     (frame)
 +     Lisp_Object frame;
 +{
 +  Lisp_Object hare, tortoise;
 +
 +  if (NILP (frame))
 +    frame = selected_frame;
 +  CHECK_FRAME (frame);
 +
 +  hare = tortoise = get_frame_param (XFRAME (frame), Qenvironment);
 +  while (!NILP (hare) && FRAMEP (hare))
 +    {
 +      frame = hare;
 +      hare = get_frame_param (XFRAME (hare), Qenvironment);
 +      if (NILP (hare) || !FRAMEP (hare))
 +        break;
 +      frame = hare;
 +      hare = get_frame_param (XFRAME (hare), Qenvironment);
 +      tortoise = get_frame_param (XFRAME (tortoise), Qenvironment);
 +      if (EQ (hare, tortoise))
 +        error ("Cyclic frame-local environment indirection");
 +    }
 +
 +  return frame;
 +}
 +
  \f
  DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
         0, 1, 0,
@@@ -3036,8 -2732,8 +3036,8 @@@ x_set_frame_parameters (f, alist
              if (NATNUMP (param_index)
                  && (XFASTINT (param_index)
                      < sizeof (frame_parms)/sizeof (frame_parms[0]))
 -                && rif->frame_parm_handlers[XINT (param_index)])
 -              (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
 +                  && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
 +                (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
            }
        }
      }
          if (NATNUMP (param_index)
              && (XFASTINT (param_index)
                  < sizeof (frame_parms)/sizeof (frame_parms[0]))
 -            && rif->frame_parm_handlers[XINT (param_index)])
 -          (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
 +            && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
 +          (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
        }
      }
  
@@@ -3399,6 -3095,11 +3399,11 @@@ x_set_font (f, arg, oldval
        else if (!NILP (Fequal (result, oldval)))
          return;
  
+       /* Recalculate toolbar height.  */
+       f->n_tool_bar_rows = 0;
+       /* Ensure we redraw it.  */
+       clear_current_matrices (f);
        store_frame_param (f, Qfont, result);
        recompute_basic_faces (f);
      }
@@@ -4288,23 -3989,13 +4293,23 @@@ syms_of_frame (
    staticpro (&Qbuffer_predicate);
    Qbuffer_list = intern ("buffer-list");
    staticpro (&Qbuffer_list);
 +  Qburied_buffer_list = intern ("buried-buffer-list");
 +  staticpro (&Qburied_buffer_list);
    Qdisplay_type = intern ("display-type");
    staticpro (&Qdisplay_type);
    Qbackground_mode = intern ("background-mode");
    staticpro (&Qbackground_mode);
    Qtty_color_mode = intern ("tty-color-mode");
    staticpro (&Qtty_color_mode);
 -
 +  Qtty = intern ("tty");
 +  staticpro (&Qtty);
 +  Qtty_type = intern ("tty-type");
 +  staticpro (&Qtty_type);
 +  Qwindow_system = intern ("window-system");
 +  staticpro (&Qwindow_system);
 +  Qenvironment = intern ("environment");
 +  staticpro (&Qenvironment);
 +  
    Qface_set_after_frame_default = intern ("face-set-after-frame-default");
    staticpro (&Qface_set_after_frame_default);
  
    Qx_frame_parameter = intern ("x-frame-parameter");
    staticpro (&Qx_frame_parameter);
  
 +  Qterminal = intern ("terminal");
 +  staticpro (&Qterminal);
 +  Qterminal_live_p = intern ("terminal-live-p");
 +  staticpro (&Qterminal_live_p);
 +  
    {
      int i;
  
@@@ -4373,7 -4059,6 +4378,7 @@@ These may be set in your init file, lik
  These override values given in window system configuration data,
   including X Windows' defaults database.
  For values specific to the first Emacs frame, see `initial-frame-alist'.
 +For window-system specific values, see `window-system-default-frame-alist'.
  For values specific to the separate minibuffer frame, see
   `minibuffer-frame-alist'.
  The `menu-bar-lines' element of the list controls whether new frames
@@@ -4399,7 -4084,7 +4404,7 @@@ Setting this variable does not affect e
    staticpro (&Qinhibit_default_face_x_resources);
  
    DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
 -             doc: /* The initial frame-object, which represents Emacs's stdout.  */);
 +               doc: /* The initial frame-object, which represents Emacs's stdout.  */);
  
    DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
               doc: /* Non-nil if all of emacs is iconified and frame updates are not needed.  */);
@@@ -4424,14 -4109,7 +4429,14 @@@ when the mouse is over clickable text
    DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions,
               doc: /* Functions to be run before deleting a frame.
  The functions are run with one arg, the frame to be deleted.
 -See `delete-frame'.  */);
 +See `delete-frame'.
 +
 +Note that functions in this list may be called twice on the same
 +frame.  In the second invocation, the frame is already deleted, and
 +the function should do nothing.  (You can use `frame-live-p' to check
 +for this.)  This wrinkle happens when an earlier function in
 +`delete-frame-functions' (indirectly) calls delete-frame
 +recursively.  */);
    Vdelete_frame_functions = Qnil;
  
    DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
@@@ -4454,7 -4132,6 +4459,7 @@@ This variable is local to the current t
    defsubr (&Sactive_minibuffer_window);
    defsubr (&Sframep);
    defsubr (&Sframe_live_p);
 +  defsubr (&Swindow_system);
    defsubr (&Smake_terminal_frame);
    defsubr (&Shandle_switch_frame);
    defsubr (&Sselect_frame);
    defsubr (&Sframe_parameters);
    defsubr (&Sframe_parameter);
    defsubr (&Smodify_frame_parameters);
 +  defsubr (&Sframe_with_environment);
    defsubr (&Sframe_char_height);
    defsubr (&Sframe_char_width);
    defsubr (&Sframe_pixel_height);
diff --combined src/image.c
@@@ -603,7 -603,9 +603,9 @@@ x_destroy_all_bitmaps (dpyinfo
  /* Useful functions defined in the section
     `Image type independent image structures' below. */
  
- static unsigned long four_corners_best P_ ((XImagePtr ximg, unsigned long width,
+ static unsigned long four_corners_best P_ ((XImagePtr ximg,
+                                           int *corners,
+                                           unsigned long width,
                                            unsigned long height));
  
  static int x_create_x_image_and_pixmap P_ ((struct frame *f, int width, int height,
@@@ -657,7 -659,7 +659,7 @@@ x_create_bitmap_mask (f, id
        return -1;
      }
  
-   bg = four_corners_best (ximg, width, height);
+   bg = four_corners_best (ximg, NULL, width, height);
  
    for (y = 0; y < ximg->height; ++y)
      {
@@@ -732,7 -734,7 +734,7 @@@ Lisp_Object Qxbm
  /* Keywords.  */
  
  extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
- extern Lisp_Object QCdata, QCtype;
+ extern Lisp_Object QCdata, QCtype, Qcount;
  extern Lisp_Object Qcenter;
  Lisp_Object QCascent, QCmargin, QCrelief;
  Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
@@@ -1141,6 -1143,27 +1143,27 @@@ or omitted means use the selected frame
    return mask;
  }
  
+ DEFUN ("image-extension-data", Fimage_extension_data, Simage_extension_data, 1, 2, 0,
+        doc: /* Return extension data for image SPEC.
+ FRAME is the frame on which the image will be displayed.  FRAME nil
+ or omitted means use the selected frame.  */)
+      (spec, frame)
+      Lisp_Object spec, frame;
+ {
+   Lisp_Object ext;
+   ext = Qnil;
+   if (valid_image_p (spec))
+     {
+       struct frame *f = check_x_frame (frame);
+       int id = lookup_image (f, spec);
+       struct image *img = IMAGE_FROM_ID (f, id);
+       ext = img->data.lisp_val;
+     }
+   return ext;
+ }
  \f
  /***********************************************************************
                 Image type independent image structures
@@@ -1171,6 -1194,7 +1194,7 @@@ make_image (spec, hash
    img->data.lisp_val = Qnil;
    img->ascent = DEFAULT_IMAGE_ASCENT;
    img->hash = hash;
+   img->corners[BOT_CORNER] = -1;  /* Full image */
    return img;
  }
  
@@@ -1322,30 -1346,41 +1346,41 @@@ image_ascent (img, face, slice
     On W32, XIMG is assumed to a device context with the bitmap selected.  */
  
  static RGB_PIXEL_COLOR
- four_corners_best (ximg, width, height)
+ four_corners_best (ximg, corners, width, height)
       XImagePtr_or_DC ximg;
+      int *corners;
       unsigned long width, height;
  {
-   RGB_PIXEL_COLOR corners[4], best;
+   RGB_PIXEL_COLOR corner_pixels[4], best;
    int i, best_count;
  
-   /* Get the colors at the corners of ximg.  */
-   corners[0] = GET_PIXEL (ximg, 0, 0);
-   corners[1] = GET_PIXEL (ximg, width - 1, 0);
-   corners[2] = GET_PIXEL (ximg, width - 1, height - 1);
-   corners[3] = GET_PIXEL (ximg, 0, height - 1);
+   if (corners && corners[BOT_CORNER] >= 0)
+     {
+       /* Get the colors at the corner_pixels of ximg.  */
+       corner_pixels[0] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[TOP_CORNER]);
+       corner_pixels[1] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]);
+       corner_pixels[2] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1);
+       corner_pixels[3] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1);
+     }
+   else
+     {
+       /* Get the colors at the corner_pixels of ximg.  */
+       corner_pixels[0] = GET_PIXEL (ximg, 0, 0);
+       corner_pixels[1] = GET_PIXEL (ximg, width - 1, 0);
+       corner_pixels[2] = GET_PIXEL (ximg, width - 1, height - 1);
+       corner_pixels[3] = GET_PIXEL (ximg, 0, height - 1);
+     }
    /* Choose the most frequently found color as background.  */
    for (i = best_count = 0; i < 4; ++i)
      {
        int j, n;
  
        for (j = n = 0; j < 4; ++j)
-       if (corners[i] == corners[j])
+       if (corner_pixels[i] == corner_pixels[j])
          ++n;
  
        if (n > best_count)
-       best = corners[i], best_count = n;
+       best = corner_pixels[i], best_count = n;
      }
  
    return best;
@@@ -1404,7 -1439,7 +1439,7 @@@ image_background (img, f, ximg
  #endif /* !HAVE_NTGUI */
        }
  
-       img->background = four_corners_best (ximg, img->width, img->height);
+       img->background = four_corners_best (ximg, img->corners, img->width, img->height);
  
        if (free_ximg)
        Destroy_Image (ximg, prev);
@@@ -1449,7 -1484,7 +1484,7 @@@ image_background_transparent (img, f, m
            }
  
          img->background_transparent
-           = (four_corners_best (mask, img->width, img->height) == PIX_MASK_RETAIN);
+           = (four_corners_best (mask, img->corners, img->width, img->height) == PIX_MASK_RETAIN);
  
          if (free_mask)
            Destroy_Image (mask, prev);
@@@ -1791,7 -1826,7 +1826,7 @@@ lookup_image (f, spec
       struct frame *f;
       Lisp_Object spec;
  {
 -  struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
 +  struct image_cache *c;
    struct image *img;
    int i;
    unsigned hash;
    xassert (FRAME_WINDOW_P (f));
    xassert (valid_image_p (spec));
  
 +  c = FRAME_X_IMAGE_CACHE (f);
 +
    GCPRO1 (spec);
  
    /* Look up SPEC in the hash table of the image cache.  */
@@@ -4462,6 -4495,10 +4497,10 @@@ xpm_load_image (f, img, contents, end
    img->width = width;
    img->height = height;
  
+   /* Maybe fill in the background field while we have ximg handy. */
+   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
+     IMAGE_BACKGROUND (img, f, ximg);
    x_put_x_image (f, ximg, img->pixmap, width, height);
    x_destroy_x_image (ximg);
    if (have_mask)
@@@ -5356,7 -5393,7 +5395,7 @@@ x_build_heuristic_mask (f, img, how
      }
  
    if (use_img_background)
-     bg = four_corners_best (ximg, img->width, img->height);
+     bg = four_corners_best (ximg, img->corners, img->width, img->height);
  
    /* Set all bits in mask_img to 1 whose color in ximg is different
       from the background color bg.  */
@@@ -7449,6 -7486,7 +7488,7 @@@ tiff_load (f, img
  
  static int gif_image_p P_ ((Lisp_Object object));
  static int gif_load P_ ((struct frame *f, struct image *img));
+ static void gif_clear_image P_ ((struct frame *f, struct image *img));
  
  /* The symbol `gif' identifying images of this type.  */
  
@@@ -7497,10 -7535,22 +7537,22 @@@ static struct image_type gif_type 
    &Qgif,
    gif_image_p,
    gif_load,
-   x_clear_image,
+   gif_clear_image,
    NULL
  };
  
+ /* Free X resources of GIF image IMG which is used on frame F.  */
+ static void
+ gif_clear_image (f, img)
+      struct frame *f;
+      struct image *img;
+ {
+   /* IMG->data.ptr_val may contain extension data.  */
+   img->data.lisp_val = Qnil;
+   x_clear_image (f, img);
+ }
  /* Return non-zero if OBJECT is a valid GIF image specification.  */
  
  static int
@@@ -7621,7 -7671,7 +7673,7 @@@ gif_load (f, img
    GifFileType *gif;
    struct gcpro gcpro1;
    Lisp_Object image;
-   int ino, image_left, image_top, image_width, image_height;
+   int ino, image_height, image_width;
    gif_memory_source memsrc;
    unsigned char *raster;
  
        return 0;
      }
  
-   image_top = gif->SavedImages[ino].ImageDesc.Top;
-   image_left = gif->SavedImages[ino].ImageDesc.Left;
-   image_width = gif->SavedImages[ino].ImageDesc.Width;
+   img->corners[TOP_CORNER] = gif->SavedImages[ino].ImageDesc.Top;
+   img->corners[LEFT_CORNER] = gif->SavedImages[ino].ImageDesc.Left;
    image_height = gif->SavedImages[ino].ImageDesc.Height;
+   img->corners[BOT_CORNER] = img->corners[TOP_CORNER] + image_height;
+   image_width = gif->SavedImages[ino].ImageDesc.Width;
+   img->corners[RIGHT_CORNER] = img->corners[LEFT_CORNER] + image_width;
  
    width = img->width = max (gif->SWidth,
                            max (gif->Image.Left + gif->Image.Width,
-                                image_left + image_width));
+                                img->corners[RIGHT_CORNER]));
    height = img->height = max (gif->SHeight,
                              max (gif->Image.Top + gif->Image.Height,
-                                  image_top + image_height));
+                                  img->corners[BOT_CORNER]));
  
    if (!check_image_size (f, width, height))
      {
       requires more than can be done here (see the gif89 spec,
       disposal methods).  Let's simply assume that the part
       not covered by a sub-image is in the frame's background color.  */
-   for (y = 0; y < image_top; ++y)
+   for (y = 0; y < img->corners[TOP_CORNER]; ++y)
      for (x = 0; x < width; ++x)
        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
  
-   for (y = image_top + image_height; y < height; ++y)
+   for (y = img->corners[BOT_CORNER]; y < height; ++y)
      for (x = 0; x < width; ++x)
        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
  
-   for (y = image_top; y < image_top + image_height; ++y)
+   for (y = img->corners[TOP_CORNER]; y < img->corners[BOT_CORNER]; ++y)
      {
-       for (x = 0; x < image_left; ++x)
+       for (x = 0; x < img->corners[LEFT_CORNER]; ++x)
        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
-       for (x = image_left + image_width; x < width; ++x)
+       for (x = img->corners[RIGHT_CORNER]; x < width; ++x)
        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
      }
  
          for (x = 0; x < image_width; x++)
            {
              int i = raster[(y * image_width) + x];
-             XPutPixel (ximg, x + image_left, row + image_top,
-                        pixel_colors[i]);
+             XPutPixel (ximg, x + img->corners[LEFT_CORNER],
+                        row + img->corners[TOP_CORNER], pixel_colors[i]);
            }
  
          row += interlace_increment[pass];
        for (x = 0; x < image_width; ++x)
          {
            int i = raster[y * image_width + x];
-           XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
+           XPutPixel (ximg, x + img->corners[LEFT_CORNER],
+                      y + img->corners[TOP_CORNER], pixel_colors[i]);
          }
      }
  
+   /* Save GIF image extension data for `image-extension-data'.
+      Format is (count IMAGES FUNCTION "BYTES" ...).  */
+   img->data.lisp_val = Qnil;
+   if (gif->SavedImages[ino].ExtensionBlockCount > 0)
+     {
+       ExtensionBlock *ext = gif->SavedImages[ino].ExtensionBlocks;
+       for (i = 0; i < gif->SavedImages[ino].ExtensionBlockCount; i++, ext++)
+       /* Append (... FUNCTION "BYTES") */
+       img->data.lisp_val = Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount),
+                                   Fcons (make_number (ext->Function),
+                                          img->data.lisp_val));
+       img->data.lisp_val = Fnreverse (img->data.lisp_val);
+     }
+   if (gif->ImageCount > 1)
+     img->data.lisp_val = Fcons (Qcount,
+                               Fcons (make_number (gif->ImageCount),
+                                      img->data.lisp_val));
    fn_DGifCloseFile (gif);
  
    /* Maybe fill in the background field while we have ximg handy. */
@@@ -8555,6 -8626,7 +8628,7 @@@ non-numeric, there is no explicit limi
    defsubr (&Sclear_image_cache);
    defsubr (&Simage_size);
    defsubr (&Simage_mask_p);
+   defsubr (&Simage_extension_data);
  
  #if GLYPH_DEBUG
    defsubr (&Simagep);
diff --combined src/keymap.c
@@@ -28,7 -28,6 +28,7 @@@ Boston, MA 02110-1301, USA.  *
  #include "buffer.h"
  #include "charset.h"
  #include "keyboard.h"
 +#include "frame.h"
  #include "termhooks.h"
  #include "blockinput.h"
  #include "puresize.h"
@@@ -87,6 -86,14 +87,6 @@@ Lisp_Object Vminor_mode_overriding_map_
  /* List of emulation mode keymap alists.  */
  Lisp_Object Vemulation_mode_map_alists;
  
 -/* Keymap mapping ASCII function key sequences onto their preferred forms.
 -   Initialized by the terminal-specific lisp files.  See DEFVAR for more
 -   documentation.  */
 -Lisp_Object Vfunction_key_map;
 -
 -/* Keymap mapping ASCII function key sequences onto their preferred forms.  */
 -Lisp_Object Vkey_translation_map;
 -
  /* A list of all commands given new bindings since a certain time
     when nil was stored here.
     This is used to speed up recomputation of menu key equivalents
@@@ -859,7 -866,7 +859,7 @@@ static Lisp_Objec
  store_in_keymap (keymap, idx, def)
       Lisp_Object keymap;
       register Lisp_Object idx;
-      register Lisp_Object def;
+      Lisp_Object def;
  {
    /* Flush any reverse-map cache.  */
    where_is_cache = Qnil;
@@@ -2824,11 -2831,11 +2824,11 @@@ You type        Translation\n
    outbuf = Fcurrent_buffer ();
  
    /* Report on alternates for keys.  */
 -  if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix))
 +  if (STRINGP (current_kboard->Vkeyboard_translate_table) && !NILP (prefix))
      {
        int c;
 -      const unsigned char *translate = SDATA (Vkeyboard_translate_table);
 -      int translate_len = SCHARS (Vkeyboard_translate_table);
 +      const unsigned char *translate = SDATA (current_kboard->Vkeyboard_translate_table);
 +      int translate_len = SCHARS (current_kboard->Vkeyboard_translate_table);
  
        for (c = 0; c < translate_len; c++)
        if (translate[c] != c)
            insert ("\n", 1);
  
            /* Insert calls signal_after_change which may GC. */
 -          translate = SDATA (Vkeyboard_translate_table);
 +          translate = SDATA (current_kboard->Vkeyboard_translate_table);
          }
  
        insert ("\n", 1);
      }
  
 -  if (!NILP (Vkey_translation_map))
 -    describe_map_tree (Vkey_translation_map, 0, Qnil, prefix,
 +  if (!NILP (current_kboard->Vlocal_key_translation_map))
 +    describe_map_tree (current_kboard->Vlocal_key_translation_map, 0, Qnil, prefix,
                       "Key translations", nomenu, 1, 0, 0);
  
  
                     "\f\nGlobal Bindings", nomenu, 0, 1, 0);
  
    /* Print the function-key-map translations under this prefix.  */
 -  if (!NILP (Vfunction_key_map))
 -    describe_map_tree (Vfunction_key_map, 0, Qnil, prefix,
 +  if (!NILP (current_kboard->Vlocal_function_key_map))
 +    describe_map_tree (current_kboard->Vlocal_function_key_map, 0, Qnil, prefix,
                       "\f\nFunction key map translations", nomenu, 1, 0, 0);
  
    UNGCPRO;
@@@ -3912,6 -3919,37 +3912,6 @@@ the same way.  The "active" keymaps in 
  `minor-mode-map-alist' and `minor-mode-overriding-map-alist'.  */);
    Vemulation_mode_map_alists = Qnil;
  
 -
 -  DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
 -             doc: /* Keymap that translates key sequences to key sequences during input.
 -This is used mainly for mapping ASCII function key sequences into
 -real Emacs function key events (symbols).
 -
 -The `read-key-sequence' function replaces any subsequence bound by
 -`function-key-map' with its binding.  More precisely, when the active
 -keymaps have no binding for the current key sequence but
 -`function-key-map' binds a suffix of the sequence to a vector or string,
 -`read-key-sequence' replaces the matching suffix with its binding, and
 -continues with the new sequence.
 -
 -If the binding is a function, it is called with one argument (the prompt)
 -and its return value (a key sequence) is used.
 -
 -The events that come from bindings in `function-key-map' are not
 -themselves looked up in `function-key-map'.
 -
 -For example, suppose `function-key-map' binds `ESC O P' to [f1].
 -Typing `ESC O P' to `read-key-sequence' would return [f1].  Typing
 -`C-x ESC O P' would return [?\\C-x f1].  If [f1] were a prefix
 -key, typing `ESC O P x' would return [f1 x].  */);
 -  Vfunction_key_map = Fmake_sparse_keymap (Qnil);
 -
 -  DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
 -             doc: /* Keymap of key translations that can override keymaps.
 -This keymap works like `function-key-map', but comes after that,
 -and its non-prefix bindings override ordinary bindings.  */);
 -  Vkey_translation_map = Qnil;
 -
    staticpro (&Vmouse_events);
    Vmouse_events = Fcons (intern ("menu-bar"),
                  Fcons (intern ("tool-bar"),
diff --combined src/macterm.c
@@@ -2230,7 -2230,11 +2230,11 @@@ x_per_char_metric (font, char2b
  #endif
  
    return ((pcm == NULL
-          || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0))
+          || (pcm->width == 0
+ #if 0 /* Show hollow boxes for zero-width glyphs such as combining diacritics.  */
+              && (pcm->rbearing - pcm->lbearing) == 0
+ #endif
+              ))
          ? NULL : pcm);
  }
  
@@@ -7042,6 -7046,25 +7046,25 @@@ add_font_name_table_entry (char *font_n
    font_name_table[font_name_count++] = font_name;
  }
  
+ static void
+ add_mac_font_name (name, size, style, charset)
+      char *name;
+      int size;
+      Style style;
+      char *charset;
+ {
+   if (size > 0)
+     add_font_name_table_entry (mac_to_x_fontname (name, size, style, charset));
+   else
+     {
+       add_font_name_table_entry (mac_to_x_fontname (name, 0, style, charset));
+       add_font_name_table_entry (mac_to_x_fontname (name, 0, italic, charset));
+       add_font_name_table_entry (mac_to_x_fontname (name, 0, bold, charset));
+       add_font_name_table_entry (mac_to_x_fontname (name, 0, italic | bold,
+                                                   charset));
+     }
+ }
  /* Sets up the table font_name_table to contain the list of all fonts
     in the system the first time the table is used so that the Resource
     Manager need not be accessed every time this information is
@@@ -7067,16 -7090,21 +7090,21 @@@ init_font_name_table (
                           text_encoding_info_alist)))
      {
        OSErr err;
+       struct Lisp_Hash_Table *h;
+       unsigned hash_code;
        ItemCount nfonts, i;
        ATSUFontID *font_ids = NULL;
-       Ptr name, prev_name = NULL;
+       Ptr name;
        ByteCount name_len;
+       Lisp_Object family;
  
        atsu_font_id_hash =
        make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
                         make_float (DEFAULT_REHASH_SIZE),
                         make_float (DEFAULT_REHASH_THRESHOLD),
                         Qnil, Qnil, Qnil);;
+       h = XHASH_TABLE (atsu_font_id_hash);
        err = ATSUFontCount (&nfonts);
        if (err == noErr)
        {
                                    kFontNoLanguage, name_len, name,
                                    NULL, NULL);
            if (err == noErr)
-             decode_mac_font_name (name, name_len + 1, Qnil);
-           if (err == noErr
-               && *name != '.'
-               && (prev_name == NULL
-                   || strcmp (name, prev_name) != 0))
              {
-               static char *cs = "iso10646-1";
-               add_font_name_table_entry (mac_to_x_fontname (name, 0,
-                                                             normal, cs));
-               add_font_name_table_entry (mac_to_x_fontname (name, 0,
-                                                             italic, cs));
-               add_font_name_table_entry (mac_to_x_fontname (name, 0,
-                                                             bold, cs));
-               add_font_name_table_entry (mac_to_x_fontname (name, 0,
-                                                             italic | bold, cs));
-               Fputhash (make_unibyte_string (name, name_len),
-                         long_to_cons (font_ids[i]), atsu_font_id_hash);
-               xfree (prev_name);
-               prev_name = name;
+               decode_mac_font_name (name, name_len + 1, Qnil);
+               family = make_unibyte_string (name, name_len);
+               if (*name != '.'
+                   && hash_lookup (h, family, &hash_code) < 0)
+                 {
+                   add_mac_font_name (name, 0, normal, "iso10646-1");
+                   hash_put (h, family, long_to_cons (font_ids[i]),
+                             hash_code);
+                 }
              }
-           else
-             xfree (name);
+           xfree (name);
          }
-       if (prev_name)
-       xfree (prev_name);
        if (font_ids)
        xfree (font_ids);
      }
        FMFontSize size;
        TextEncoding encoding;
        TextEncodingBase sc;
-       Lisp_Object text_encoding_info;
+       Lisp_Object text_encoding_info, family;
  
        if (FMGetFontFamilyName (ff, name) != noErr)
-       break;
+       continue;
        p2cstr (name);
        if (*name == '.')
        continue;
  
        if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
-       break;
+       continue;
        sc = GetTextEncodingBase (encoding);
        text_encoding_info = assq_no_quit (make_number (sc),
                                         text_encoding_info_alist);
                                           text_encoding_info_alist);
        decode_mac_font_name (name, sizeof (name),
                            XCAR (XCDR (text_encoding_info)));
-       fm_font_family_alist = Fcons (Fcons (build_string (name),
-                                          make_number (ff)),
+       family = build_string (name);
+       if (!NILP (Fassoc (family, fm_font_family_alist)))
+       continue;
+       fm_font_family_alist = Fcons (Fcons (family, make_number (ff)),
                                    fm_font_family_alist);
  
        /* Point the instance iterator at the current font family.  */
        if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
-       break;
+       continue;
  
        while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
             == noErr)
  
          if (size > 0 || style == normal)
            for (; !NILP (rest); rest = XCDR (rest))
-             {
-               char *cs = SDATA (XCAR (rest));
-               if (size == 0)
-                 {
-                   add_font_name_table_entry (mac_to_x_fontname (name, size,
-                                                                 style, cs));
-                   add_font_name_table_entry (mac_to_x_fontname (name, size,
-                                                                 italic, cs));
-                   add_font_name_table_entry (mac_to_x_fontname (name, size,
-                                                                 bold, cs));
-                   add_font_name_table_entry (mac_to_x_fontname (name, size,
-                                                                 italic | bold,
-                                                                 cs));
-                 }
-               else
-                 {
-                   add_font_name_table_entry (mac_to_x_fontname (name, size,
-                                                                 style, cs));
-                 }
-             }
+             add_mac_font_name (name, size, style, SDATA (XCAR (rest)));
        }
      }
  
    Str255 name;
    struct FontAssoc *fat;
    struct AsscEntry *assc_entry;
-   Lisp_Object text_encoding_info_alist, text_encoding_info;
+   Lisp_Object text_encoding_info_alist, text_encoding_info, family;
    struct gcpro gcpro1;
  
    GetPort (&port);  /* save the current font number used */
        GetResInfo (font_handle, &id, &type, name);
        GetFNum (name, &fontnum);
        p2cstr (name);
-       if (fontnum == 0)
+       if (fontnum == 0 || *name == '.')
        continue;
  
        TextFont (fontnum);
                                           text_encoding_info_alist);
        decode_mac_font_name (name, sizeof (name),
                            XCAR (XCDR (text_encoding_info)));
-       fm_font_family_alist = Fcons (Fcons (build_string (name),
-                                          make_number (fontnum)),
+       family = build_string (name);
+       if (!NILP (Fassoc (family, fm_font_family_alist)))
+       continue;
+       fm_font_family_alist = Fcons (Fcons (family, make_number (fontnum)),
                                    fm_font_family_alist);
        do
        {
                  Lisp_Object rest = XCDR (XCDR (text_encoding_info));
  
                  for (; !NILP (rest); rest = XCDR (rest))
-                   {
-                     char *cs = SDATA (XCAR (rest));
-                     add_font_name_table_entry (mac_to_x_fontname (name,
-                                                                   assc_entry->fontSize,
-                                                                   assc_entry->fontStyle,
-                                                                   cs));
-                   }
+                   add_mac_font_name (name, assc_entry->fontSize,
+                                      assc_entry->fontStyle,
+                                      SDATA (XCAR (rest)));
                }
            }
  
@@@ -10869,20 -10863,19 +10863,20 @@@ mac_initialize (
    redeem_scroll_bar_hook = XTredeem_scroll_bar;
    judge_scroll_bars_hook = XTjudge_scroll_bars;
  
 -  scroll_region_ok = 1;         /* we'll scroll partial frames */
 -  char_ins_del_ok = 1;
 -  line_ins_del_ok = 1;          /* we'll just blt 'em */
 -  fast_clear_end_of_line = 1;   /* X does this well */
 -  memory_below_frame = 0;       /* we don't remember what scrolls
 -                                 off the bottom */
 +  TTY_SCROLL_REGION_OK (CURTTY ()) = 1; /* we'll scroll partial frames */
 +  TTY_CHAR_INS_DEL_OK (CURTTY ()) = 1;
 +  TTY_LINE_INS_DEL_OK (CURTTY ()) = 1; /* we'll just blt 'em */
 +  TTY_FAST_CLEAR_END_OF_LINE (CURTTY ()) = 1; /* X does this well */
 +  TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what
 +                                                         scrolls off the
 +                                                         bottom */
    baud_rate = 19200;
  
    last_tool_bar_item = -1;
    any_help_event_p = 0;
  
    /* Try to use interrupt input; if we can't, then start polling.  */
 -  Fset_input_mode (Qt, Qnil, Qt, Qnil);
 +  Fset_input_interrupt_mode (Qt);
  
    BLOCK_INPUT;
  
diff --combined src/print.c
@@@ -275,6 -275,7 +275,7 @@@ int print_output_debug_flag = 1
         else                                                           \
         insert_1_both (print_buffer, print_buffer_pos,                 \
                        print_buffer_pos_byte, 0, 1, 0);                \
+        signal_after_change (PT - print_buffer_pos, 0, print_buffer_pos);\
       }                                                                        \
     if (free_print_buffer)                                             \
       {                                                                        \
@@@ -1348,10 -1349,10 +1349,10 @@@ print_preprocess (obj
          for (i = 0; i < print_number_index; i++)
            if (EQ (PRINT_NUMBER_OBJECT (Vprint_number_table, i), obj))
              {
 -              /* OBJ appears more than once.  Let's remember that.  */
 +              /* OBJ appears more than once.  Let's remember that.  */
                PRINT_NUMBER_STATUS (Vprint_number_table, i) = Qt;
                  print_depth--;
 -                return;
 +              return;
              }
  
          /* OBJ is not yet recorded.  Let's add to the table.  */
diff --combined src/w32term.c
@@@ -3131,8 -3131,10 +3131,10 @@@ construct_mouse_wheel (result, msg, f
    result->modifiers = (msg->dwModifiers
                         | ((delta < 0 ) ? down_modifier : up_modifier));
  
-   p.x = LOWORD (msg->msg.lParam);
-   p.y = HIWORD (msg->msg.lParam);
+   /* With multiple monitors, we can legitimately get negative
+      coordinates, so cast to short to interpret them correctly.  */
+   p.x = (short) LOWORD (msg->msg.lParam);
+   p.y = (short) HIWORD (msg->msg.lParam);
    ScreenToClient (msg->msg.hwnd, &p);
    XSETINT (result->x, p.x);
    XSETINT (result->y, p.y);
@@@ -5828,8 -5830,8 +5830,8 @@@ x_free_frame_resources (f
  
    free_frame_menubar (f);
  
 -  unload_color (f, f->output_data.x->foreground_pixel);
 -  unload_color (f, f->output_data.x->background_pixel);
 +  unload_color (f, FRAME_FOREGROUND_PIXEL (f));
 +  unload_color (f, FRAME_BACKGROUND_PIXEL (f));
    unload_color (f, f->output_data.w32->cursor_pixel);
    unload_color (f, f->output_data.w32->cursor_foreground_pixel);
    unload_color (f, f->output_data.w32->border_pixel);
@@@ -6327,13 -6329,12 +6329,13 @@@ w32_initialize (
    redeem_scroll_bar_hook = w32_redeem_scroll_bar;
    judge_scroll_bars_hook = w32_judge_scroll_bars;
  
 -  scroll_region_ok = 1;         /* we'll scroll partial frames */
 -  char_ins_del_ok = 1;
 -  line_ins_del_ok = 1;          /* we'll just blt 'em */
 -  fast_clear_end_of_line = 1;   /* X does this well */
 -  memory_below_frame = 0;       /* we don't remember what scrolls
 -                                 off the bottom */
 +  TTY_SCROLL_REGION_OK (CURTTY ()) = 1; /* we'll scroll partial frames */
 +  TTY_CHAR_INS_DEL_OK (CURTTY ()) = 1;
 +  TTY_LINE_INS_DEL_OK (CURTTY ()) = 1; /* we'll just blt 'em */
 +  TTY_FAST_CLEAR_END_OF_LINE (CURTTY ()) = 1; /* X does this well */
 +  TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what
 +                                                            scrolls off the
 +                                                            bottom */
    baud_rate = 19200;
  
    w32_system_caret_hwnd = NULL;
diff --combined src/window.c
@@@ -21,8 -21,6 +21,8 @@@ the Free Software Foundation, Inc., 51 
  Boston, MA 02110-1301, USA.  */
  
  #include <config.h>
 +#include <stdio.h>
 +
  #include "lisp.h"
  #include "buffer.h"
  #include "keyboard.h"
@@@ -3439,7 -3437,7 +3439,7 @@@ displaying BUFFER, then simply raise th
  The variables `special-display-buffer-names',
  `special-display-regexps', `same-window-buffer-names', and
  `same-window-regexps' customize how certain buffer names are handled.
- The latter two take effect only if NOT-THIS-WINDOW is t.
+ The latter two take effect only if NOT-THIS-WINDOW is nil.
  
  If optional argument FRAME is `visible', search all visible frames.
  If FRAME is 0, search all visible and iconified frames.
@@@ -7009,7 -7007,7 +7009,7 @@@ and scrolling positions.  */
  void
  init_window_once ()
  {
 -  struct frame *f = make_terminal_frame ();
 +  struct frame *f = make_initial_frame ();
    XSETFRAME (selected_frame, f);
    Vterminal_frame = selected_frame;
    minibuf_window = f->minibuffer_window;
diff --combined src/xdisp.c
@@@ -578,12 -578,21 +578,12 @@@ Lisp_Object Vmessage_log_max
  
  static Lisp_Object Vmessages_buffer_name;
  
 -/* Index 0 is the buffer that holds the current (desired) echo area message,
 -   or nil if none is desired right now.
 -
 -   Index 1 is the buffer that holds the previously displayed echo area message,
 -   or nil to indicate no message.  This is normally what's on the screen now.
 -
 -   These two can point to the same buffer.  That happens when the last
 -   message output by the user (or made by echoing) has been displayed.  */
 +/* Current, index 0, and last displayed echo area message.  Either
 +   buffers from echo_buffers, or nil to indicate no message.  */
  
  Lisp_Object echo_area_buffer[2];
  
 -/* Permanent pointers to the two buffers that are used for echo area
 -   purposes.  Once the two buffers are made, and their pointers are
 -   placed here, these two slots remain unchanged unless those buffers
 -   need to be created afresh.  */
 +/* The buffers referenced from echo_area_buffer.  */
  
  static Lisp_Object echo_buffer[2];
  
@@@ -793,6 -802,10 +793,6 @@@ static int clear_face_cache_count
  static int clear_image_cache_count;
  #endif
  
 -/* Record the previous terminal frame we displayed.  */
 -
 -static struct frame *previous_terminal_frame;
 -
  /* Non-zero while redisplay_internal is in progress.  */
  
  int redisplaying_p;
@@@ -2458,7 -2471,7 +2458,7 @@@ init_iterator (it, w, charpos, bytepos
    XSETWINDOW (it->window, w);
    it->w = w;
    it->f = XFRAME (w->frame);
 -
 +  
    /* Extra space between lines (on window systems only).  */
    if (base_face_id == DEFAULT_FACE_ID
        && FRAME_WINDOW_P (it->f))
  
    /* If realized faces have been removed, e.g. because of face
       attribute changes of named faces, recompute them.  When running
 -     in batch mode, the face cache of Vterminal_frame is null.  If
 +     in batch mode, the face cache of the initial frame is null.  If
       we happen to get called, make a dummy face cache.  */
 -  if (noninteractive && FRAME_FACE_CACHE (it->f) == NULL)
 +  if (FRAME_FACE_CACHE (it->f) == NULL)
      init_frame_faces (it->f);
    if (FRAME_FACE_CACHE (it->f)->used == 0)
      recompute_basic_faces (it->f);
@@@ -3888,7 -3901,7 +3888,7 @@@ handle_single_display_spec (it, spec, o
        && EQ (XCAR (spec), Qheight)
        && CONSP (XCDR (spec)))
      {
 -      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
 +      if (!FRAME_WINDOW_P (it->f))
        return 0;
  
        it->font_height = XCAR (XCDR (spec));
        && EQ (XCAR (spec), Qspace_width)
        && CONSP (XCDR (spec)))
      {
 -      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
 +      if (!FRAME_WINDOW_P (it->f))
        return 0;
  
        value = XCAR (XCDR (spec));
      {
        Lisp_Object tem;
  
 -      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
 +      if (!FRAME_WINDOW_P (it->f))
        return 0;
  
        if (tem = XCDR (spec), CONSP (tem))
        && EQ (XCAR (spec), Qraise)
        && CONSP (XCDR (spec)))
      {
 -      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
 +      if (!FRAME_WINDOW_P (it->f))
        return 0;
  
  #ifdef HAVE_WINDOW_SYSTEM
        int face_id = DEFAULT_FACE_ID;
        int fringe_bitmap;
  
 -      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
 +      if (!FRAME_WINDOW_P (it->f))
        /* If we return here, POSITION has been advanced
           across the text with this property.  */
        return 0;
          it->left_user_fringe_face_id = face_id;
        }
        else
 -      {
 +        {
          it->right_user_fringe_bitmap = fringe_bitmap;
          it->right_user_fringe_face_id = face_id;
        }
  
    valid_p = (STRINGP (value)
  #ifdef HAVE_WINDOW_SYSTEM
 -           || (!FRAME_TERMCAP_P (it->f) && valid_image_p (value))
 +             || (FRAME_WINDOW_P (it->f) && valid_image_p (value))
  #endif /* not HAVE_WINDOW_SYSTEM */
 -           || (CONSP (value) && EQ (XCAR (value), Qspace)));
 +             || (CONSP (value) && EQ (XCAR (value), Qspace)));
  
    if (valid_p && !display_replaced_before_p)
      {
        /* Save current settings of IT so that we can restore them
         when we are finished with the glyph property value.  */
        push_it (it);
 -
        if (NILP (location))
        it->area = TEXT_AREA;
        else if (EQ (location, Qleft_margin))
  }
  
  
 -/* Check if SPEC is a display specification value whose text should be
 +/* Check if SPEC is a display sub-property value whose text should be
     treated as intangible.  */
  
  static int
@@@ -7360,8 -7374,8 +7360,8 @@@ message2_nolog (m, nbytes, multibyte
        do_pending_window_change (0);
        echo_area_display (1);
        do_pending_window_change (0);
 -      if (frame_up_to_date_hook != 0 && ! gc_in_progress)
 -      (*frame_up_to_date_hook) (f);
 +      if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
 +      (*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
      }
  }
  
@@@ -7464,8 -7478,8 +7464,8 @@@ message3_nolog (m, nbytes, multibyte
        do_pending_window_change (0);
        echo_area_display (1);
        do_pending_window_change (0);
 -      if (frame_up_to_date_hook != 0 && ! gc_in_progress)
 -      (*frame_up_to_date_hook) (f);
 +      if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
 +      (*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
      }
  }
  
@@@ -7703,10 -7717,6 +7703,10 @@@ ensure_echo_area_buffers (
     WHICH > 0 means use echo_area_buffer[1].  If that is nil, choose a
     suitable buffer from echo_buffer[] and clear it.
  
 +   If WHICH < 0, set echo_area_buffer[1] to echo_area_buffer[0], so
 +   that the current message becomes the last displayed one, make
 +   choose a suitable buffer for echo_area_buffer[0], and clear it.
 +
     Value is what FN returns.  */
  
  static int
@@@ -7731,17 -7741,6 +7731,17 @@@ with_echo_area_buffer (w, which, fn, a1
      this_one = 0, the_other = 1;
    else if (which > 0)
      this_one = 1, the_other = 0;
 +  else
 +    {
 +      this_one = 0, the_other = 1;
 +      clear_buffer_p = 1;
 +
 +      /* We need a fresh one in case the current echo buffer equals
 +       the one containing the last displayed echo area message.  */
 +      if (!NILP (echo_area_buffer[this_one])
 +        && EQ (echo_area_buffer[this_one], echo_area_buffer[the_other]))
 +      echo_area_buffer[this_one] = Qnil;
 +    }
  
    /* Choose a suitable buffer from echo_buffer[] is we don't
       have one.  */
@@@ -8379,7 -8378,7 +8379,7 @@@ set_message (s, string, nbytes, multiby
      = ((s && multibyte_p)
         || (STRINGP (string) && STRING_MULTIBYTE (string)));
  
 -  with_echo_area_buffer (0, 0, set_message_1,
 +  with_echo_area_buffer (0, -1, set_message_1,
                         (EMACS_INT) s, string, nbytes, multibyte_p);
    message_buf_print = 0;
    help_echo_showing_p = 0;
@@@ -8409,6 -8408,7 +8409,6 @@@ set_message_1 (a1, a2, nbytes, multibyt
  
    /* Insert new message at BEG.  */
    TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
 -  Ferase_buffer ();
  
    if (STRINGP (string))
      {
@@@ -8504,11 -8504,11 +8504,11 @@@ clear_garbaged_frames (
      {
        Lisp_Object tail, frame;
        int changed_count = 0;
 -
 +      
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
 -
 +        
          if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f))
            {
              if (f->resized_p)
              f->resized_p = 0;
            }
        }
 -
 +      
        frame_garbaged = 0;
        if (changed_count)
        ++windows_or_buffers_changed;
@@@ -8555,10 -8555,11 +8555,10 @@@ echo_area_display (update_frame_p
  /* The terminal frame is used as the first Emacs frame on the Mac OS.  */
  #ifndef MAC_OS8
  #ifdef HAVE_WINDOW_SYSTEM
 -  /* When Emacs starts, selected_frame may be a visible terminal
 -     frame, even if we run under a window system.  If we let this
 -     through, a message would be displayed on the terminal.  */
 -  if (EQ (selected_frame, Vterminal_frame)
 -      && !NILP (Vwindow_system))
 +  /* When Emacs starts, selected_frame may be the initial terminal
 +     frame.  If we let this through, a message would be displayed on
 +     the terminal.  */
 +  if (FRAME_INITIAL_P (XFRAME (selected_frame)))
      return 0;
  #endif /* HAVE_WINDOW_SYSTEM */
  #endif
                 Can do with a display update of the echo area,
                 unless we displayed some mode lines.  */
              update_single_window (w, 1);
 -            rif->flush_display (f);
 +            FRAME_RIF (f)->flush_display (f);
            }
          else
            update_frame (f, 1, 1);
    else if (!EQ (mini_window, selected_window))
      windows_or_buffers_changed++;
  
 -  /* The current message is now also the last one displayed.  */
 +  /* Last displayed message is now the current message.  */
    echo_area_buffer[1] = echo_area_buffer[0];
 +  /* Inform read_char that we're not echoing.  */
 +  echo_message_buffer = Qnil;
  
    /* Prevent redisplay optimization in redisplay_internal by resetting
       this_line_start_pos.  This is done because the mini-buffer now
@@@ -9157,8 -9156,8 +9157,8 @@@ x_cursor_to (vpos, hpos, y, x
      {
        BLOCK_INPUT;
        display_and_set_cursor (w, 1, hpos, vpos, x, y);
 -      if (rif->flush_display_optional)
 -      rif->flush_display_optional (SELECTED_FRAME ());
 +      if (FRAME_RIF (SELECTED_FRAME ())->flush_display_optional)
 +      FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (SELECTED_FRAME ());
        UNBLOCK_INPUT;
      }
  }
@@@ -9563,20 -9562,22 +9563,22 @@@ tool_bar_lines_needed (f, n_rows
  {
    struct window *w = XWINDOW (f->tool_bar_window);
    struct it it;
+   struct glyph_row *temp_row = w->desired_matrix->rows;
  
    /* Initialize an iterator for iteration over
       F->desired_tool_bar_string in the tool-bar window of frame F.  */
-   init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
+   init_iterator (&it, w, -1, -1, temp_row, TOOL_BAR_FACE_ID);
    it.first_visible_x = 0;
    it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
    reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
  
    while (!ITERATOR_AT_END_P (&it))
      {
-       it.glyph_row = w->desired_matrix->rows;
-       clear_glyph_row (it.glyph_row);
+       clear_glyph_row (temp_row);
+       it.glyph_row = temp_row;
        display_tool_bar_line (&it, -1);
      }
+   clear_glyph_row (temp_row);
  
    /* f->n_tool_bar_rows == 0 means "unknown"; -1 means no tool-bar.  */
    if (n_rows)
@@@ -9656,7 -9657,29 +9658,29 @@@ redisplay_tool_bar (f
    reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
  
    if (f->n_tool_bar_rows == 0)
-     (void)tool_bar_lines_needed (f, &f->n_tool_bar_rows);
+     {
+       int nlines;
+       if ((nlines = tool_bar_lines_needed (f, &f->n_tool_bar_rows),
+          nlines != WINDOW_TOTAL_LINES (w)))
+       {
+         extern Lisp_Object Qtool_bar_lines;
+         Lisp_Object frame;
+         int old_height = WINDOW_TOTAL_LINES (w);
+         XSETFRAME (frame, f);
+         clear_glyph_matrix (w->desired_matrix);
+         Fmodify_frame_parameters (frame,
+                                   Fcons (Fcons (Qtool_bar_lines,
+                                                 make_number (nlines)),
+                                          Qnil));
+         if (WINDOW_TOTAL_LINES (w) != old_height)
+           {
+             fonts_changed_p = 1;
+             return 1;
+           }
+       }
+     }
  
    /* Display as many lines as needed to display all tool-bar items.  */
  
@@@ -10542,8 -10565,6 +10566,8 @@@ select_frame_for_redisplay (frame
    Lisp_Object tail, sym, val;
    Lisp_Object old = selected_frame;
  
 +  xassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame)));
 +
    selected_frame = frame;
  
    for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail))
@@@ -10673,16 -10694,17 +10697,16 @@@ redisplay_internal (preserve_echo_area
    if (face_change_count)
      ++windows_or_buffers_changed;
  
 -  if (! FRAME_WINDOW_P (sf)
 -      && previous_terminal_frame != sf)
 +  if (FRAME_TERMCAP_P (sf)
 +      && FRAME_TTY (sf)->previous_frame != sf)
      {
 -      /* Since frames on an ASCII terminal share the same display
 -       area, displaying a different frame means redisplay the whole
 -       thing.  */
 +      /* Since frames on a single ASCII terminal share the same
 +       display area, displaying a different frame means redisplay
 +       the whole thing.  */
        windows_or_buffers_changed++;
        SET_FRAME_GARBAGED (sf);
 -      XSETFRAME (Vterminal_frame, sf);
 +      FRAME_TTY (sf)->previous_frame = sf;
      }
 -  previous_terminal_frame = sf;
  
    /* Set the visible flags for all frames.  Do this before checking
       for resized or garbaged frames; they want to know if their frames
        }
    }
  
 +  
    /* Notice any pending interrupt request to change frame size.  */
    do_pending_window_change (1);
  
        {
          struct frame *f = XFRAME (frame);
  
 -        if (FRAME_WINDOW_P (f) || f == sf)
 +        if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf)
            {
              if (! EQ (frame, selected_frame))
                /* Select the frame, for the sake of frame-local
  
              /* Mark all the scroll bars to be removed; we'll redeem
                 the ones we want when we redisplay their windows.  */
 -            if (condemn_scroll_bars_hook)
 -              condemn_scroll_bars_hook (f);
 +            if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
 +              FRAME_TERMINAL (f)->condemn_scroll_bars_hook (f);
  
              if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
                redisplay_windows (FRAME_ROOT_WINDOW (f));
  
              /* Any scroll bars which redisplay_windows should have
                 nuked should now go away.  */
 -            if (judge_scroll_bars_hook)
 -              judge_scroll_bars_hook (f);
 +            if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
 +              FRAME_TERMINAL (f)->judge_scroll_bars_hook (f);
  
              /* If fonts changed, display again.  */
              /* ??? rms: I suspect it is a mistake to jump all the way
          FOR_EACH_FRAME (tail, frame)
            {
              struct frame *f = XFRAME (frame);
 -            if (f->updated_p)
 -              {
 -                mark_window_display_accurate (f->root_window, 1);
 -                if (frame_up_to_date_hook)
 -                  frame_up_to_date_hook (f);
 -              }
 +              if (f->updated_p)
 +                {
 +                  mark_window_display_accurate (f->root_window, 1);
 +                  if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
 +                    FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
 +                }
            }
        }
      }
          /* Say overlay arrows are up to date.  */
          update_overlay_arrows (1);
  
 -        if (frame_up_to_date_hook != 0)
 -          frame_up_to_date_hook (sf);
 +        if (FRAME_TERMINAL (sf)->frame_up_to_date_hook != 0)
 +          FRAME_TERMINAL (sf)->frame_up_to_date_hook (sf);
        }
  
        update_mode_lines = 0;
@@@ -11326,9 -11347,8 +11350,9 @@@ redisplay_preserve_echo_area (from_wher
    else
      redisplay_internal (1);
  
 -  if (rif != NULL && rif->flush_display_optional)
 -    rif->flush_display_optional (NULL);
 +  if (FRAME_RIF (SELECTED_FRAME ()) != NULL
 +      && FRAME_RIF (SELECTED_FRAME ())->flush_display_optional)
 +    FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (NULL);
  }
  
  
     redisplay_internal.  Reset redisplaying_p to the value it had
     before redisplay_internal was called, and clear
     prevent_freeing_realized_faces_p.  It also selects the previously
 -   selected frame.  */
 +   selected frame, unless it has been deleted (by an X connection
 +   failure during redisplay, for example).  */
  
  static Lisp_Object
  unwind_redisplay (val)
    old_redisplaying_p = XCAR (val);
    redisplaying_p = XFASTINT (old_redisplaying_p);
    old_frame = XCDR (val);
 -  if (! EQ (old_frame, selected_frame))
 +  if (! EQ (old_frame, selected_frame)
 +      && FRAME_LIVE_P (XFRAME (old_frame)))
      select_frame_for_redisplay (old_frame);
    return Qnil;
  }
@@@ -12475,9 -12493,7 +12499,9 @@@ set_vertical_scroll_bar (w
      start = end = whole = 0;
  
    /* Indicate what this scroll bar ought to be displaying now.  */
 -  set_vertical_scroll_bar_hook (w, end - start, whole, start);
 +  if (FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
 +    (*FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
 +      (w, end - start, whole, start);
  }
  
  
@@@ -12697,8 -12713,6 +12721,6 @@@ redisplay_window (window, just_this_one
        /* IT may overshoot PT if text at PT is invisible.  */
        else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT)
        w->force_start = Qt;
      }
  
    /* Handle case where place to start displaying has been specified,
               || (XFASTINT (w->last_modified) >= MODIFF
                   && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)))
      {
+       /* If first window line is a continuation line, and window start
+        is inside the modified region, but the first change is before
+        current window start, we must select a new window start.*/
+       if (NILP (w->start_at_line_beg)
+         && CHARPOS (startp) > BEGV)
+       {
+         /* Make sure beg_unchanged and end_unchanged are up to date.
+            Do it only if buffer has really changed.  This may or may
+            not have been done by try_window_id (see which) already. */
+         if (MODIFF > SAVE_MODIFF
+             /* This seems to happen sometimes after saving a buffer.  */
+             || BEG_UNCHANGED + END_UNCHANGED > Z_BYTE)
+           {
+             if (GPT - BEG < BEG_UNCHANGED)
+               BEG_UNCHANGED = GPT - BEG;
+             if (Z - GPT < END_UNCHANGED)
+               END_UNCHANGED = Z - GPT;
+           }
+         if (CHARPOS (startp) > BEG + BEG_UNCHANGED
+             && CHARPOS (startp) <= Z - END_UNCHANGED)
+           {
+             /* There doesn't seems to be a simple way to find a new
+                window start that is near the old window start, so
+                we just recenter.  */
+             goto recenter;
+           }
+       }
  #if GLYPH_DEBUG
        debug_method_add (w, "same window start");
  #endif
          display_menu_bar (w);
  
  #ifdef HAVE_WINDOW_SYSTEM
 +      if (FRAME_WINDOW_P (f))
 +        {
  #ifdef USE_GTK
 -      redisplay_tool_bar_p = FRAME_EXTERNAL_TOOL_BAR (f);
 +          redisplay_tool_bar_p = FRAME_EXTERNAL_TOOL_BAR (f);
  #else
 -      redisplay_tool_bar_p = WINDOWP (f->tool_bar_window)
 -        && (FRAME_TOOL_BAR_LINES (f) > 0
 -            || auto_resize_tool_bars_p);
 -
 +          redisplay_tool_bar_p = WINDOWP (f->tool_bar_window)
 +            && (FRAME_TOOL_BAR_LINES (f) > 0
 +                || auto_resize_tool_bars_p);
  #endif
  
 -      if (redisplay_tool_bar_p)
 -        redisplay_tool_bar (f);
 +          if (redisplay_tool_bar_p)
 +            redisplay_tool_bar (f);
 +        }
  #endif
      }
  
  
        /* Note that we actually used the scroll bar attached to this
         window, so it shouldn't be deleted at the end of redisplay.  */
 -      redeem_scroll_bar_hook (w);
 +      if (FRAME_TERMINAL (f)->redeem_scroll_bar_hook)
 +        (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
      }
  
    /* Restore current_buffer and value of point in it.  */
@@@ -13480,10 -13521,10 +13532,10 @@@ try_window_reusing_current_matrix (w
          if (run.height > 0 && run.current_y != run.desired_y)
            {
              update_begin (f);
 -            rif->update_window_begin_hook (w);
 -            rif->clear_window_mouse_face (w);
 -            rif->scroll_run_hook (w, &run);
 -            rif->update_window_end_hook (w, 0, 0);
 +            FRAME_RIF (f)->update_window_begin_hook (w);
 +            FRAME_RIF (f)->clear_window_mouse_face (w);
 +            FRAME_RIF (f)->scroll_run_hook (w, &run);
 +            FRAME_RIF (f)->update_window_end_hook (w, 0, 0);
              update_end (f);
            }
  
        if (run.height)
        {
          update_begin (f);
 -        rif->update_window_begin_hook (w);
 -        rif->clear_window_mouse_face (w);
 -        rif->scroll_run_hook (w, &run);
 -        rif->update_window_end_hook (w, 0, 0);
 +        FRAME_RIF (f)->update_window_begin_hook (w);
 +        FRAME_RIF (f)->clear_window_mouse_face (w);
 +        FRAME_RIF (f)->scroll_run_hook (w, &run);
 +        FRAME_RIF (f)->update_window_end_hook (w, 0, 0);
          update_end (f);
        }
  
@@@ -14105,7 -14146,7 +14157,7 @@@ try_window_id (w
  
    /* Window must either use window-based redisplay or be full width.  */
    if (!FRAME_WINDOW_P (f)
 -      && (!line_ins_del_ok
 +      && (!FRAME_LINE_INS_DEL_OK (f)
          || !WINDOW_FULL_WIDTH_P (w)))
      GIVE_UP (4);
  
  
        if (FRAME_WINDOW_P (f))
        {
 -        rif->update_window_begin_hook (w);
 -        rif->clear_window_mouse_face (w);
 -        rif->scroll_run_hook (w, &run);
 -        rif->update_window_end_hook (w, 0, 0);
 +        FRAME_RIF (f)->update_window_begin_hook (w);
 +        FRAME_RIF (f)->clear_window_mouse_face (w);
 +        FRAME_RIF (f)->scroll_run_hook (w, &run);
 +        FRAME_RIF (f)->update_window_end_hook (w, 0, 0);
        }
        else
        {
            {
              /* Scroll last_unchanged_at_beg_row to the end of the
                 window down dvpos lines.  */
 -            set_terminal_window (end);
 +            set_terminal_window (f, end);
  
              /* On dumb terminals delete dvpos lines at the end
                 before inserting dvpos empty lines.  */
 -            if (!scroll_region_ok)
 -              ins_del_lines (end - dvpos, -dvpos);
 +            if (!FRAME_SCROLL_REGION_OK (f))
 +              ins_del_lines (f, end - dvpos, -dvpos);
  
              /* Insert dvpos empty lines in front of
                   last_unchanged_at_beg_row.  */
 -            ins_del_lines (from, dvpos);
 +            ins_del_lines (f, from, dvpos);
            }
          else if (dvpos < 0)
            {
              /* Scroll up last_unchanged_at_beg_vpos to the end of
                 the window to last_unchanged_at_beg_vpos - |dvpos|.  */
 -            set_terminal_window (end);
 +            set_terminal_window (f, end);
  
              /* Delete dvpos lines in front of
                 last_unchanged_at_beg_vpos.  ins_del_lines will set
                 the cursor to the given vpos and emit |dvpos| delete
                 line sequences.  */
 -            ins_del_lines (from + dvpos, dvpos);
 +            ins_del_lines (f, from + dvpos, dvpos);
  
              /* On a dumb terminal insert dvpos empty lines at the
                   end.  */
 -            if (!scroll_region_ok)
 -              ins_del_lines (end + dvpos, -dvpos);
 +            if (!FRAME_SCROLL_REGION_OK (f))
 +              ins_del_lines (f, end + dvpos, -dvpos);
            }
  
 -        set_terminal_window (0);
 +        set_terminal_window (f, 0);
        }
  
        update_end (f);
@@@ -16323,9 -16364,9 +16375,9 @@@ display_mode_line (w, face_id, format
    /* Temporarily make frame's keyboard the current kboard so that
       kboard-local variables in the mode_line_format will get the right
       values.  */
 -  push_frame_kboard (it.f);
 +  push_kboard (FRAME_KBOARD (it.f));
    display_mode_element (&it, 0, 0, 0, format, Qnil, 0);
 -  pop_frame_kboard ();
 +  pop_kboard ();
  
    unbind_to (count, Qnil);
  
@@@ -17040,9 -17081,9 +17092,9 @@@ are the selected window and the window'
        = (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil)));
      }
  
 -  push_frame_kboard (it.f);
 +  push_kboard (FRAME_KBOARD (it.f));
    display_mode_element (&it, 0, 0, 0, format, Qnil, 0);
 -  pop_frame_kboard ();
 +  pop_kboard ();
  
    if (no_props)
      {
@@@ -17653,8 -17694,8 +17705,8 @@@ 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 (FRAME_KEYBOARD_CODING (f)->symbol, p, 0);
 +          p = decode_mode_spec_coding (FRAME_TERMINAL_CODING (f)->symbol, p, 0);
          }
        p = decode_mode_spec_coding (b->buffer_file_coding_system,
                                     p, eol_flag);
@@@ -18146,8 -18187,6 +18198,8 @@@ calc_pixel_width_or_height (res, it, pr
    if (NILP (prop))
      return OK_PIXELS (0);
  
 +  xassert (FRAME_LIVE_P (it->f));
 +
    if (SYMBOLP (prop))
      {
        if (SCHARS (SYMBOL_NAME (prop)) == 2)
        if (SYMBOLP (car))
        {
  #ifdef HAVE_WINDOW_SYSTEM
 -        if (valid_image_p (prop))
 +        if (FRAME_WINDOW_P (it->f)
 +            && valid_image_p (prop))
            {
              int id = lookup_image (it->f, prop);
              struct image *img = IMAGE_FROM_ID (it->f, id);
@@@ -18507,7 -18545,7 +18559,7 @@@ get_glyph_face_and_encoding (f, glyph, 
            = 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);
 +            = FRAME_RIF (f)->encode_char (glyph->u.ch, char2b, font_info, two_byte_p);
        }
      }
  
@@@ -18694,6 -18732,7 +18746,7 @@@ fill_stretch_glyph_string (s, row, area
    s->font = s->face->font;
    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
    s->width = glyph->pixel_width;
+   s->nchars = 1;
    voffset = glyph->voffset;
  
    for (++glyph;
@@@ -18739,7 -18778,7 +18792,7 @@@ x_get_glyph_overhangs (glyph, f, left, 
        font = face->font;
        font_info = FONT_INFO_FROM_ID (f, face->font_info_id);
        if (font  /* ++KFS: Should this be font_info ?  */
 -        && (pcm = rif->per_char_metric (font, &char2b, glyph->font_type)))
 +        && (pcm = FRAME_RIF (f)->per_char_metric (font, &char2b, glyph->font_type)))
        {
          if (pcm->rbearing > pcm->width)
            *right = pcm->rbearing - pcm->width;
@@@ -18907,7 -18946,7 +18960,7 @@@ get_char_face_and_encoding (f, c, face_
          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);
 +          FRAME_RIF (f)->encode_char (c, char2b, font_info, 0);
        }
      }
  
@@@ -18970,8 -19009,8 +19023,8 @@@ compute_overhangs_and_x (s, x, backward
      {
        while (s)
        {
 -        if (rif->compute_glyph_string_overhangs)
 -          rif->compute_glyph_string_overhangs (s);
 +        if (FRAME_RIF (s->f)->compute_glyph_string_overhangs)
 +          FRAME_RIF (s->f)->compute_glyph_string_overhangs (s);
          x -= s->width;
          s->x = x;
          s = s->prev;
      {
        while (s)
        {
 -        if (rif->compute_glyph_string_overhangs)
 -          rif->compute_glyph_string_overhangs (s);
 +        if (FRAME_RIF (s->f)->compute_glyph_string_overhangs)
 +          FRAME_RIF (s->f)->compute_glyph_string_overhangs (s);
          s->x = x;
          x += s->width;
          s = s->next;
@@@ -19270,9 -19309,9 +19323,9 @@@ draw_glyphs (w, x, row, area, start, en
        struct glyph_string *h, *t;
  
        /* Compute overhangs for all glyph strings.  */
 -      if (rif->compute_glyph_string_overhangs)
 +      if (FRAME_RIF (f)->compute_glyph_string_overhangs)
        for (s = head; s; s = s->next)
 -        rif->compute_glyph_string_overhangs (s);
 +        FRAME_RIF (f)->compute_glyph_string_overhangs (s);
  
        /* Prepend glyph strings for glyphs in front of the first glyph
         string that are overwritten because of the first glyph
  
    /* Draw all strings.  */
    for (s = head; s; s = s->next)
 -    rif->draw_glyph_string (s);
 +    FRAME_RIF (f)->draw_glyph_string (s);
  
    if (area == TEXT_AREA
        && !row->full_width_p
@@@ -19839,20 -19878,6 +19892,6 @@@ produce_stretch_glyph (it
    it->descent = it->phys_descent = height - it->ascent;
    it->nglyphs = width > 0 && height > 0 ? 1 : 0;
  
-   if (width > 0 && height > 0 && face->box != FACE_NO_BOX)
-     {
-       if (face->box_line_width > 0)
-       {
-         it->ascent += face->box_line_width;
-         it->descent += face->box_line_width;
-       }
-       if (it->start_of_box_run_p)
-       it->pixel_width += abs (face->box_line_width);
-       if (it->end_of_box_run_p)
-       it->pixel_width += abs (face->box_line_width);
-     }
    take_vertical_position_into_account (it);
  }
  
@@@ -20050,20 -20075,20 +20089,20 @@@ x_produce_glyphs (it
  
          it->nglyphs = 1;
  
 -        pcm = rif->per_char_metric (font, &char2b,
 -                                    FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display));
 -
 -        if (it->override_ascent >= 0)
 -          {
 -            it->ascent = it->override_ascent;
 -            it->descent = it->override_descent;
 -            boff = it->override_boff;
 -          }
 -        else
 -          {
 -            it->ascent = FONT_BASE (font) + boff;
 -            it->descent = FONT_DESCENT (font) - boff;
 -          }
 +          pcm = FRAME_RIF (it->f)->per_char_metric
 +            (font, &char2b, FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display));
 +
 +        if (it->override_ascent >= 0)
 +          {
 +            it->ascent = it->override_ascent;
 +            it->descent = it->override_descent;
 +            boff = it->override_boff;
 +          }
 +        else
 +          {
 +            it->ascent = FONT_BASE (font) + boff;
 +            it->descent = FONT_DESCENT (font) - boff;
 +          }
  
          if (pcm)
            {
             from the charset width; this is what old redisplay code
             did.  */
  
 -        pcm = rif->per_char_metric (font, &char2b,
 -                                    FONT_TYPE_FOR_MULTIBYTE (font, it->c));
 +        pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b,
 +                                                    FONT_TYPE_FOR_MULTIBYTE (font, it->c));
  
          if (font_not_found_p || !pcm)
            {
  
          /* Initialize the bounding box.  */
          if (font_info
 -            && (pcm = rif->per_char_metric (font, &char2b,
 -                                            FONT_TYPE_FOR_MULTIBYTE (font, it->c))))
 +            && (pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b,
 +                                                            FONT_TYPE_FOR_MULTIBYTE (font, it->c))))
            {
              width = pcm->width;
              ascent = pcm->ascent;
                }
  
              if (font_info
 -                && (pcm = rif->per_char_metric (font, &char2b,
 -                                                FONT_TYPE_FOR_MULTIBYTE (font, ch))))
 +                && (pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b,
 +                                                                FONT_TYPE_FOR_MULTIBYTE (font, ch))))
                {
                  width = pcm->width;
                  ascent = pcm->ascent;
@@@ -20713,8 -20738,8 +20752,8 @@@ x_insert_glyphs (start, len
    frame_x = window_box_left (w, updated_area) + output_cursor.x;
    frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, output_cursor.y);
  
 -  rif->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width,
 -                              line_height, shift_by_width);
 +  FRAME_RIF (f)->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width,
 +                                          line_height, shift_by_width);
  
    /* Write the glyphs.  */
    hpos = start - row->glyphs[updated_area];
@@@ -20796,8 -20821,8 +20835,8 @@@ x_clear_end_of_line (to_x
    if (to_x > from_x && to_y > from_y)
      {
        BLOCK_INPUT;
 -      rif->clear_frame_area (f, from_x, from_y,
 -                           to_x - from_x, to_y - from_y);
 +      FRAME_RIF (f)->clear_frame_area (f, from_x, from_y,
 +                                       to_x - from_x, to_y - from_y);
        UNBLOCK_INPUT;
      }
  }
@@@ -21278,9 -21303,9 +21317,9 @@@ erase_phys_cursor (w
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
        y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y));
        width = min (cursor_glyph->pixel_width,
 -                 window_box_width (w, TEXT_AREA) - w->phys_cursor.x);
 +                   window_box_width (w, TEXT_AREA) - w->phys_cursor.x);
  
 -      rif->clear_frame_area (f, x, y, width, cursor_row->visible_height);
 +      FRAME_RIF (f)->clear_frame_area (f, x, y, width, cursor_row->visible_height);
      }
  
    /* Erase the cursor by redrawing the character underneath it.  */
@@@ -21377,9 -21402,9 +21416,9 @@@ display_and_set_cursor (w, on, hpos, vp
        w->phys_cursor.vpos = vpos;
      }
  
 -  rif->draw_window_cursor (w, glyph_row, x, y,
 -                         new_cursor_type, new_cursor_width,
 -                         on, active_cursor);
 +  FRAME_RIF (f)->draw_window_cursor (w, glyph_row, x, y,
 +                                     new_cursor_type, new_cursor_width,
 +                                     on, active_cursor);
  }
  
  
@@@ -21528,11 -21553,11 +21567,11 @@@ show_mouse_face (dpyinfo, draw
  
    /* Change the mouse cursor.  */
    if (draw == DRAW_NORMAL_TEXT)
 -    rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
 +    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
    else if (draw == DRAW_MOUSE_FACE)
 -    rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
 +    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
    else
 -    rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor);
 +    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor);
  }
  
  /* EXPORT:
@@@ -21971,6 -21996,7 +22010,6 @@@ on_hot_spot_p (hot_spot, x, y
          return inside;
        }
      }
 -  /* If we don't understand the format, pretend we're not in the hot-spot.  */
    return 0;
  }
  
@@@ -22050,7 -22076,7 +22089,7 @@@ define_frame_cursor1 (f, cursor, pointe
      }
  
    if (cursor != No_Cursor)
 -    rif->define_frame_cursor (f, cursor);
 +    FRAME_RIF (f)->define_frame_cursor (f, cursor);
  }
  
  /* Take proper action when mouse has moved to the mode or header line
@@@ -22373,7 -22399,7 +22412,7 @@@ note_mouse_highlight (f, x, y
    if (part == ON_VERTICAL_BORDER)
      {
        cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
-       help_echo_string = make_string ("drag-mouse-1: resize", 20);
+       help_echo_string = build_string ("drag-mouse-1: resize");
      }
    else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
           || part == ON_SCROLL_BAR)
@@@ -23013,8 -23039,8 +23052,8 @@@ phys_cursor_in_rect_p (w, r
         I assume the effect is the same -- and this is portable.  */
        return x_intersect_rectangles (&cr, r, &result);
      }
 -  else
 -    return 0;
 +  /* If we don't understand the format, pretend we're not in the hot-spot.  */
 +  return 0;
  }
  
  
  x_draw_vertical_border (w)
       struct window *w;
  {
 +  struct frame *f = XFRAME (WINDOW_FRAME (w));
 +  
    /* We could do better, if we knew what type of scroll-bar the adjacent
       windows (on either side) have...  But we don't :-(
       However, I think this works ok.  ++KFS 2003-04-25 */
        y1 -= 1;
  
        if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
 -      x1 -= 1;
 +        x1 -= 1;
  
 -      rif->draw_vertical_window_border (w, x1, y0, y1);
 +      FRAME_RIF (f)->draw_vertical_window_border (w, x1, y0, y1);
      }
    else if (!WINDOW_LEFTMOST_P (w)
           && !WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
        y1 -= 1;
  
        if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
 -      x0 -= 1;
 +        x0 -= 1;
  
 -      rif->draw_vertical_window_border (w, x0, y0, y1);
 +      FRAME_RIF (f)->draw_vertical_window_border (w, x0, y0, y1);
      }
  }