changeset 109724:7d18e1db65fe

merge trunk
author Kenichi Handa <handa@etlken>
date Mon, 09 Aug 2010 10:51:16 +0900
parents 197e874deb67 (current diff) 028db67bd5dd (diff)
children b5ae5029d51c
files lisp/vc/diff-mode.el src/s/usg5-4-common.h src/s/usg5-4.h src/unexcoff.c src/unexec.c
diffstat 234 files changed, 6507 insertions(+), 3423 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,25 @@
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* configure.in: Check for util.h.
+	Use -Wimplicit-function-declaration if compiler supports it.
+
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* configure.in (UNEXEC_OBJ): Rename unexec.o => unexcoff.o.
+
+2010-08-04  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* configure.in: Restore accidentally removed use of
+	GCC_TEST_OPTIONS/NON_GCC_TEST_OPTIONS.
+
+2010-07-29  Chad Brown  <yandros@mit.edu>
+
+	* configure.in: Check for dirent.h.
+
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in: Remove reference to usg5-4, unused.
+
 2010-07-25  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* configure.in: Check for __executable_start.
--- a/admin/CPP-DEFINES	Mon Jul 26 13:29:08 2010 +0900
+++ b/admin/CPP-DEFINES	Mon Aug 09 10:51:16 2010 +0900
@@ -65,7 +65,6 @@
 EXPLICIT_SIGN_EXTEND
 LOAD_AVE_CVT
 LOAD_AVE_TYPE
-NO_REMAP
 VIRT_ADDR_VARIES
 WORDS_BIG_ENDIAN
 
@@ -101,7 +100,6 @@
 DATA_SEG_BITS
 DATA_START
 DBL_MIN_REPLACEMENT
-DECLARE_GETPWUID_WITH_UID_T
 DEFAULT_SOUND_DEVICE
 DEVICE_SEP
 DIRECTORY_SEP
@@ -190,7 +188,6 @@
 HAVE_UNISTD_H
 HAVE_UTIMES
 HAVE_UTIME_H
-HAVE_VOLATILE
 HAVE_WINDOW_SYSTEM
 HAVE_WORKING_VFORK
 HAVE_XRMSETDATABASE
@@ -237,7 +234,6 @@
 PURESIZE
 RUN_TIME_REMAP
 SA_RESTART
-SECTION_ALIGNMENT  -- was only used by s/lynxos.h, maybe all code depending on it can be removed.
 SEGMENT_MASK
 SETPGRP_RELEASES_CTTY
 SETUP_SLAVE_PTY
@@ -252,14 +248,12 @@
 SIGTYPE
 SOLARIS2
 STDC_HEADERS
-SYMS_SYSTEM
 SYSTEM_PURESIZE_EXTRA
 SYSTEM_MALLOC
 SYSV_SYSTEM_DIR
 TAB3
 TABDLY
 TERM
-THIS_IS_CONFIGURE
 TIME_WITH_SYS_TIME
 TIOCSIGSEND
 TM_IN_SYS_TIME
--- a/admin/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/admin/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,7 @@
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* MAINTAINERS: Rename src/unexec.c => src/unexcoff.c.
+
 2010-07-24  Christoph Scholtes  <cschol2112@gmail.com>
 
 	* admin.el: Write version number to nt/makefile.w32-in.
--- a/admin/MAINTAINERS	Mon Jul 26 13:29:08 2010 +0900
+++ b/admin/MAINTAINERS	Mon Aug 09 10:51:16 2010 +0900
@@ -191,7 +191,7 @@
 src/undo.c
 src/unexaix.c
 src/unexalpha.c
-src/unexec.c
+src/unexcoff.c
 src/unexelf.c
 src/unexhp9k800.c
 src/unexw32.c
--- a/configure	Mon Jul 26 13:29:08 2010 +0900
+++ b/configure	Mon Aug 09 10:51:16 2010 +0900
@@ -1,11 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.66 for emacs 24.0.50.
+# Generated by GNU Autoconf 2.65 for emacs 24.0.50.
 #
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -316,7 +316,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -356,19 +356,19 @@
 fi # as_fn_arith
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -530,7 +530,7 @@
 exec 6>&1
 
 # Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -950,7 +950,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -976,7 +976,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1180,7 +1180,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1196,7 +1196,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1226,8 +1226,8 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
     ;;
 
   *=*)
@@ -1235,7 +1235,7 @@
     # Reject names that are not valid shell variable names.
     case $ac_envvar in #(
       '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
     esac
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
@@ -1253,13 +1253,13 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
+  as_fn_error "missing argument to $ac_option"
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
@@ -1282,7 +1282,7 @@
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1296,8 +1296,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1312,9 +1312,9 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
+  as_fn_error "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
+  as_fn_error "pwd does not report name of working directory"
 
 
 # Find the source files, if location was not specified.
@@ -1353,11 +1353,11 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1397,7 +1397,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
+  -q, --quiet, --silent   do not print \`checking...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1613,9 +1613,9 @@
 if $ac_init_version; then
   cat <<\_ACEOF
 emacs configure 24.0.50
-generated by GNU Autoconf 2.66
-
-Copyright (C) 2010 Free Software Foundation, Inc.
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1755,10 +1755,10 @@
 ac_fn_c_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -1821,7 +1821,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -1885,7 +1885,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1907,18 +1907,15 @@
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
+# ac_fn_c_check_decl LINENO SYMBOL VAR
+# ------------------------------------
+# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
 ac_fn_c_check_decl ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
+$as_echo_n "checking whether $2 is declared... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1927,12 +1924,8 @@
 int
 main ()
 {
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
+#ifndef $2
+  (void) $2;
 #endif
 
   ;
@@ -1961,7 +1954,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1991,7 +1984,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
 $as_echo_n "checking for $2.$3... " >&6; }
-if eval "test \"\${$4+set}\"" = set; then :
+if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2047,7 +2040,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2115,7 +2108,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=no"
@@ -2164,7 +2157,7 @@
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.66.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   $ $0 $@
 
@@ -2274,9 +2267,11 @@
   {
     echo
 
-    $as_echo "## ---------------- ##
+    cat <<\_ASBOX
+## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##"
+## ---------------- ##
+_ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -2310,9 +2305,11 @@
 )
     echo
 
-    $as_echo "## ----------------- ##
+    cat <<\_ASBOX
+## ----------------- ##
 ## Output variables. ##
-## ----------------- ##"
+## ----------------- ##
+_ASBOX
     echo
     for ac_var in $ac_subst_vars
     do
@@ -2325,9 +2322,11 @@
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      cat <<\_ASBOX
+## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##"
+## ------------------- ##
+_ASBOX
       echo
       for ac_var in $ac_subst_files
       do
@@ -2341,9 +2340,11 @@
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      cat <<\_ASBOX
+## ----------- ##
 ## confdefs.h. ##
-## ----------- ##"
+## ----------- ##
+_ASBOX
       echo
       cat confdefs.h
       echo
@@ -2398,12 +2399,7 @@
 ac_site_file1=NONE
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_file1=$CONFIG_SITE
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
   ac_site_file2=$prefix/etc/config.site
@@ -2418,11 +2414,7 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
+    . "$ac_site_file"
   fi
 done
 
@@ -2503,7 +2495,7 @@
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
@@ -2677,7 +2669,7 @@
 	    g | gt | gtk  )	val=gtk ;;
 	    gtk3  )	val=gtk3 ;;
 	    * )
-as_fn_error $? "\`--with-x-toolkit=$withval' is invalid;
+as_fn_error "\`--with-x-toolkit=$withval' is invalid;
 this option's value should be \`yes', \`no', \`lucid', \`athena', \`motif', \`gtk' or
 \`gtk3'.  \`yes' and \`gtk' are synonyms. \`athena' and \`lucid' are synonyms." "$LINENO" 5
 	    ;;
@@ -2956,7 +2948,7 @@
 	stringfreelist) ac_gc_check_string_free_list=1 ;;
 	xmallocoverrun)	ac_xmalloc_overrun=1 ;;
 	conslist)	ac_gc_check_cons_list=1 ;;
-	*)	as_fn_error $? "unknown check category $check" "$LINENO" 5 ;;
+	*)	as_fn_error "unknown check category $check" "$LINENO" 5 ;;
 	esac
 done
 IFS="$ac_save_IFS"
@@ -3074,22 +3066,16 @@
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -3103,7 +3089,7 @@
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 $as_echo_n "checking build system type... " >&6; }
@@ -3114,16 +3100,16 @@
 test "x$ac_build_alias" = x &&
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
 $as_echo "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
 esac
 build=$ac_cv_build
 ac_save_IFS=$IFS; IFS='-'
@@ -3148,7 +3134,7 @@
   ac_cv_host=$ac_cv_build
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
@@ -3156,7 +3142,7 @@
 $as_echo "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
 esac
 host=$ac_cv_host
 ac_save_IFS=$IFS; IFS='-'
@@ -3450,7 +3436,7 @@
 
 
 if test $unported = yes; then
-  as_fn_error $? "Emacs hasn't been ported to \`${canonical}' systems.
+  as_fn_error "Emacs hasn't been ported to \`${canonical}' systems.
 Check \`etc/MACHINES' for recognized configuration names." "$LINENO" 5
 fi
 
@@ -3764,8 +3750,8 @@
 
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -3879,8 +3865,9 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
@@ -3922,8 +3909,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -3980,9 +3967,9 @@
     else
 	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
+as_fn_error "cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
+See \`config.log' for more details." "$LINENO" 5; }
     fi
   fi
 fi
@@ -4033,8 +4020,8 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
@@ -4318,6 +4305,12 @@
   CC="$NON_GNU_CC"
 fi
 
+if test x$GCC = xyes; then
+  test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
+else
+  test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
+fi
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4445,8 +4438,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -4507,7 +4500,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_GREP=$GREP
@@ -4573,7 +4566,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_EGREP=$EGREP
@@ -4705,7 +4698,8 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -4871,6 +4865,38 @@
 unset has_option
 unset SAVE_CFLAGS
 
+### Use -Wimplicit-function-declaration if the compiler supports it
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands -Wimplicit-function-declaration" >&5
+$as_echo_n "checking whether gcc understands -Wimplicit-function-declaration... " >&6; }
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wimplicit-function-declaration"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  has_option=yes
+else
+  has_option=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_option" >&5
+$as_echo "$has_option" >&6; }
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
+
 
 
 #### Some other nice autoconf tests.
@@ -5002,8 +5028,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -5440,7 +5466,7 @@
   if test "x${with_makeinfo}" = "xno"; then
     MAKEINFO=off
   elif test ! -e $srcdir/info/emacs; then
-    as_fn_error $? "You do not seem to have makeinfo >= 4.6, and your
+    as_fn_error "You do not seem to have makeinfo >= 4.6, and your
 source tree does not seem to have pre-built manuals in the \`info' directory.
 Either install a suitable version of makeinfo, or re-run configure
 with the \`--without-makeinfo' option to build without the manuals. " "$LINENO" 5
@@ -5503,7 +5529,7 @@
 
 UNEXEC_OBJ=unexelf.o
 case "$opsys" in
-  # MSDOS uses unexec.o
+  # MSDOS uses unexcoff.o
   # MSWindows uses unexw32.o
   aix4-2)
    UNEXEC_OBJ=unexaix.o
@@ -5594,7 +5620,7 @@
     if test "x$GCC" = "xyes"; then
       C_SWITCH_MACHINE="-fno-common"
     else
-      as_fn_error $? "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
+      as_fn_error "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
     fi
   else
     UNEXEC_OBJ=unexalpha.o
@@ -5872,7 +5898,7 @@
   ## Some platforms don't use any of these files, so it is not
   ## appropriate to put this test outside the if block.
   test -e $CRT_DIR/crtn.o || test -e $CRT_DIR/crt0.o || \
-    as_fn_error $? "crt*.o not found in specified location." "$LINENO" 5
+    as_fn_error "crt*.o not found in specified location." "$LINENO" 5
 
 fi
 
@@ -5927,7 +5953,8 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -6118,7 +6145,7 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       if test "$emacs_alsa_subdir" != yes; then
-        as_fn_error $? "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
+        as_fn_error "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
       fi
       ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
     fi
@@ -6149,11 +6176,12 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h utmp.h
+  sys/utsname.h pwd.h utmp.h dirent.h util.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -6995,7 +7023,7 @@
 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
@@ -7003,7 +7031,7 @@
 all:
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 case `${MAKE-make} -f conftest.make 2>/dev/null` in
   *@@@%%%=?*=@@@%%%*)
     eval ac_cv_prog_make_${ac_make}_set=yes;;
@@ -7139,7 +7167,7 @@
   have_x=disabled
 else
   case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
+    *\'*) as_fn_error "cannot use X directory names containing '" "$LINENO" 5;; #(
     *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
@@ -7157,7 +7185,7 @@
 	@echo libdir='${LIBDIR}'
 _ACEOF
   if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
     for ac_var in incroot usrlibdir libdir; do
       eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
     done
@@ -7426,7 +7454,7 @@
 if test "x$ac_cv_header_AppKit_AppKit_h" = x""yes; then :
   HAVE_NS=yes
 else
-  as_fn_error $? "\`--with-ns' was specified, but the include
+  as_fn_error "\`--with-ns' was specified, but the include
   files are missing or cannot be compiled." "$LINENO" 5
 fi
 
@@ -7542,7 +7570,7 @@
    if test "$HAVE_XSERVER" = true ||
       test -n "$DISPLAY" ||
       test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
-        as_fn_error $? "You seem to be running X, but no X development libraries
+        as_fn_error "You seem to be running X, but no X development libraries
 were found.  You should install the relevant development files for X
 and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
 sure you have development files for image handling, i.e.
@@ -7665,7 +7693,8 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -7771,7 +7800,6 @@
 main ()
 {
   char *data, *data2, *data3;
-  const char *cdata2;
   int i, pagesize;
   int fd, fd2;
 
@@ -7796,10 +7824,10 @@
   fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
   if (fd2 < 0)
     return 4;
-  cdata2 = "";
-  if (write (fd2, cdata2, 1) != 1)
+  data2 = "";
+  if (write (fd2, data2, 1) != 1)
     return 5;
-  data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
+  data2 = mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
   if (data2 == MAP_FAILED)
     return 6;
   for (i = 0; i < pagesize; ++i)
@@ -8172,7 +8200,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -8453,7 +8482,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 
@@ -8559,7 +8588,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 fi
@@ -8586,7 +8615,7 @@
 
   if test "${GTK_COMPILES}" != "yes"; then
     if test "$USE_X_TOOLKIT" != "maybe"; then
-      as_fn_error $? "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
+      as_fn_error "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
     fi
   else
     HAVE_GTK=yes
@@ -8716,7 +8745,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -9081,7 +9111,7 @@
       USE_X_TOOLKIT=LUCID
       LUCID_LIBW=-lXaw
     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
-      as_fn_error $? "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
+      as_fn_error "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no; do not use toolkit by default" >&5
 $as_echo "no; do not use toolkit by default" >&6; }
@@ -10258,7 +10288,8 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -10510,7 +10541,7 @@
     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
 
   if test "X${MISSING}" != X; then
-    as_fn_error $? "The following required libraries were not found:
+    as_fn_error "The following required libraries were not found:
     $MISSING
 Maybe some development libraries/packages are missing?
 If you don't want to link with them give
@@ -10845,7 +10876,8 @@
   for ac_func in _getb67 GETB67 getb67; do
     as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define CRAY_STACKSEG_END $ac_func
@@ -10909,7 +10941,7 @@
 
 
 if test x"$ac_cv_func_alloca_works" != xyes; then
-   as_fn_error $? "a system implementation of alloca is required " "$LINENO" 5
+   as_fn_error "a system implementation of alloca is required " "$LINENO" 5
 fi
 
 # fmod, logb, and frexp are found in -lm on most systems.
@@ -11105,7 +11137,7 @@
 
 
   if test $ac_cv_prog_liblockfile = yes; then
-    as_fn_error $? "Shared liblockfile found but can't link against it.
+    as_fn_error "Shared liblockfile found but can't link against it.
 This probably means that movemail could lose mail.
 There may be a \`development' package to install containing liblockfile." "$LINENO" 5
   fi
@@ -11194,7 +11226,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11225,7 +11258,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11277,8 +11311,8 @@
 static time_t time_t_min;
 
 /* Values we'll use to set the TZ environment variable.  */
-static const char *tz_strings[] = {
-  (const char *) 0, "TZ=GMT0", "TZ=JST-9",
+static char *tz_strings[] = {
+  (char *) 0, "TZ=GMT0", "TZ=JST-9",
   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
 };
 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
@@ -11295,7 +11329,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
 
   tm.tm_year = 98;
   tm.tm_mon = 3;
@@ -11308,14 +11342,16 @@
 }
 
 static int
-mktime_test1 (time_t now)
+mktime_test1 (now)
+     time_t now;
 {
   struct tm *lt;
   return ! (lt = localtime (&now)) || mktime (lt) == now;
 }
 
 static int
-mktime_test (time_t now)
+mktime_test (now)
+     time_t now;
 {
   return (mktime_test1 (now)
 	  && mktime_test1 ((time_t) (time_t_max - now))
@@ -11339,7 +11375,8 @@
 }
 
 static int
-bigtime_test (int j)
+bigtime_test (j)
+     int j;
 {
   struct tm tm;
   time_t now;
@@ -11383,7 +11420,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
 
   t = mktime (&tm);
 
@@ -11418,7 +11455,7 @@
   for (i = 0; i < N_STRINGS; i++)
     {
       if (tz_strings[i])
-	putenv ((char*) tz_strings[i]);
+	putenv (tz_strings[i]);
 
       for (t = 0; t <= time_t_max - delta; t += delta)
 	if (! mktime_test (t))
@@ -11470,7 +11507,7 @@
 
 # Make sure getloadavg.c is where it belongs, at configure-time.
 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
-  as_fn_error $? "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
+  as_fn_error "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
 
 ac_save_LIBS=$LIBS
 
@@ -12339,7 +12376,7 @@
 fi
 
 if test "$have_tputs_et_al" != true; then
-  as_fn_error $? "I couldn't find termcap functions (tputs and friends).
+  as_fn_error "I couldn't find termcap functions (tputs and friends).
 Maybe some development libraries/packages are missing?  Try installing
 libncurses-dev(el), libterminfo-dev(el) or similar." "$LINENO" 5
 fi
@@ -13486,7 +13523,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -13860,14 +13898,14 @@
    && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
    && test x"`echo $CFLAGS | grep '\-O[23]'`" != x \
    && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
-   as_fn_error $? "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5
+   as_fn_error "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5
 fi
 
 #### Find out which version of Emacs this is.
 version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \
 	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
 if test x"${version}" = x; then
-  as_fn_error $? "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
+  as_fn_error "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
 fi
 if test x"${version}" != x"$PACKAGE_VERSION"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: version mismatch between \`${srcdir}/configure.in' and \`${srcdir}/src/emacs.c'." >&5
@@ -14149,7 +14187,7 @@
 ORDINARY_LINK=
 case "$opsys" in
   ## gnu: GNU needs its own crt0.
-  aix4-2|cygwin|darwin|gnu|usg5-4|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
+  aix4-2|cygwin|darwin|gnu|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
 
   ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
   ## library search parth, i.e. it won't search /usr/lib for libc and
@@ -14425,7 +14463,6 @@
 
 ac_libobjs=
 ac_ltlibobjs=
-U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -14587,19 +14624,19 @@
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -14795,7 +14832,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -14849,7 +14886,7 @@
 # values after options handling.
 ac_log="
 This file was extended by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.66.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -14915,10 +14952,10 @@
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 emacs config.status 24.0.50
-configured by $0, generated by GNU Autoconf 2.66,
+configured by $0, generated by GNU Autoconf 2.65,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2009 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -14972,7 +15009,7 @@
     ac_need_defaults=false;;
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
+    as_fn_error "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
@@ -14981,7 +15018,7 @@
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
+  -*) as_fn_error "unrecognized option: \`$1'
 Try \`$0 --help' for more information." ;;
 
   *) as_fn_append ac_config_targets " $1"
@@ -15049,7 +15086,7 @@
     "leim/Makefile") CONFIG_FILES="$CONFIG_FILES leim/Makefile" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
 done
 
@@ -15087,7 +15124,7 @@
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -15121,7 +15158,7 @@
 fi
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
+  ac_cs_awk_cr='\r'
 else
   ac_cs_awk_cr=$ac_cr
 fi
@@ -15138,7 +15175,7 @@
   echo "_ACEOF"
 } >conf$$files.sh &&
 . ./conf$$files.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
 rm -f conf$$files.sh
 
 {
@@ -15146,18 +15183,18 @@
   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
   if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -15252,28 +15289,20 @@
 else
   cat
 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
 s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
 s/^[^=]*=[	 ]*$//
 }'
 fi
@@ -15301,7 +15330,7 @@
   if test -z "$ac_t"; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -15386,7 +15415,7 @@
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
 fi # test -n "$CONFIG_HEADERS"
 
 
@@ -15399,7 +15428,7 @@
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
@@ -15427,7 +15456,7 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
@@ -15454,7 +15483,7 @@
 
     case $ac_tag in
     *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
     esac
     ;;
   esac
@@ -15590,22 +15619,22 @@
 else
   $AWK -f "$tmp/subs.awk" | $SHELL
 fi >$tmp/out \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
+which seems to be undefined.  Please make sure it is defined." >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
   rm -f "$tmp/stdin"
   case $ac_file in
   -) cat "$tmp/out" && rm -f "$tmp/out";;
   *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
   esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
   #
@@ -15616,19 +15645,19 @@
       $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
     } >"$tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
     if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
       mv "$tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+	|| as_fn_error "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
+      || as_fn_error "could not create -" "$LINENO" 5
   fi
  ;;
 
@@ -15665,7 +15694,7 @@
 ac_clean_files=$ac_clean_files_save
 
 test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
 
 # configure is writing to config.log, and then calls config.status.
@@ -15686,7 +15715,7 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
+  $ac_cs_success || as_fn_exit $?
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
--- a/configure.in	Mon Jul 26 13:29:08 2010 +0900
+++ b/configure.in	Mon Aug 09 10:51:16 2010 +0900
@@ -722,6 +722,12 @@
   CC="$NON_GNU_CC"
 fi
 
+if test x$GCC = xyes; then
+  test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
+else
+  test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
+fi
+
 dnl checks for Unix variants
 AC_USE_SYSTEM_EXTENSIONS
 
@@ -764,6 +770,20 @@
 CFLAGS="$SAVE_CFLAGS"
 unset has_option
 unset SAVE_CFLAGS
+
+### Use -Wimplicit-function-declaration if the compiler supports it
+AC_MSG_CHECKING([whether gcc understands -Wimplicit-function-declaration])
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wimplicit-function-declaration"
+AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
+fi
+AC_MSG_RESULT($has_option)
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
 AC_SUBST(C_WARNINGS_SWITCH)
 
 
@@ -877,7 +897,7 @@
 
 UNEXEC_OBJ=unexelf.o
 case "$opsys" in
-  # MSDOS uses unexec.o
+  # MSDOS uses unexcoff.o
   # MSWindows uses unexw32.o
   aix4-2)
    UNEXEC_OBJ=unexaix.o
@@ -1204,7 +1224,7 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h utmp.h)
+  sys/utsname.h pwd.h utmp.h dirent.h util.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
 AC_TRY_COMPILE([#include <sys/personality.h>], [personality (PER_LINUX32)],
@@ -3326,7 +3346,7 @@
 ORDINARY_LINK=
 case "$opsys" in
   ## gnu: GNU needs its own crt0.
-  aix4-2|cygwin|darwin|gnu|usg5-4|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
+  aix4-2|cygwin|darwin|gnu|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
 
   ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
   ## library search parth, i.e. it won't search /usr/lib for libc and
--- a/doc/emacs/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/emacs/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,12 @@
+2010-07-31  Eli Zaretskii  <eliz@gnu.org>
+
+	* files.texi (Visiting): Add more index entries for
+	large-file-warning-threshold.
+
+2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Tool Bars): Add doc for tool-bar-position.
+
 2010-06-23  Glenn Morris  <rgm@gnu.org>
 
 	* abbrevs.texi, basic.texi, buffers.texi, building.texi, calendar.texi:
--- a/doc/emacs/files.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/emacs/files.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -202,6 +202,8 @@
 to reread it.
 
 @vindex large-file-warning-threshold
+@cindex file, warning when size is large
+@cindex size of file, warning when visiting
 @cindex maximum buffer size exceeded, error message
   If you try to visit a file larger than
 @code{large-file-warning-threshold} (the default is 10000000, which is
--- a/doc/emacs/frames.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/emacs/frames.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -1270,6 +1270,12 @@
 the same as for the desktop in the Gnome case.  If no default is found,
 the tool bar uses just images.
 
+@cindex Tool Bar position
+  You can also control the placement of the tool bar for the GTK+ tool bar
+with the frame parameter @code{tool-bar-position}.
+For a detailed description of frame parameters and customization,
+see @ref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}.
+
 @node Dialog Boxes
 @section Using Dialog Boxes
 @cindex dialog boxes
--- a/doc/lispref/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,33 @@
+2010-08-08  Christoph  <cschol2112@googlemail.com>
+
+	* control.texi (Handling Errors) <error-message-string>: Fix arg name.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* modes.texi (Defining Minor Modes): Use C-backspace, not C-delete.
+	Suggested by Štěpán Němec <stepnem@gmail.com>.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.texi (High-Level Completion): Document args of
+	`read-buffer-function' (bug#5625).
+
+2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Layout Parameters): Add doc for tool-bar-position.
+
+2010-07-29  Michael Albinus  <michael.albinus@gmx.de>
+
+	* processes.texi (Process Information): Explain process property
+	`remote-tty'.
+
+2010-07-27  Juanma Barranquero  <lekktu@gmail.com>
+
+	* modes.texi (Defining Minor Modes): Use C-delete in examples,
+	instead of "\C-\^?" (bug#6334).
+
+	* text.texi (Special Properties): Fix typo.
+
 2010-07-09  Eli Zaretskii  <eliz@gnu.org>
 
 	* internals.texi (Writing Emacs Primitives): Adapt to ANSI C
--- a/doc/lispref/control.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/control.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -1039,7 +1039,7 @@
 @xref{Definition of signal}.
 @end defspec
 
-@defun error-message-string error-description
+@defun error-message-string error-descriptor
 This function returns the error message string for a given error
 descriptor.  It is useful if you want to handle an error by printing the
 usual error message for that error.  @xref{Definition of signal}.
--- a/doc/lispref/frames.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/frames.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -677,6 +677,11 @@
 means don't display a tool bar.  (GTK and Nextstep allow at most one
 tool bar line; they treat larger values as 1.)
 
+@item tool-bar-position
+The position of the tool bar.  Currently only for the GTK tool bar.
+Value can be one of @code{top}, @code{bottom} @code{left}, @code{right}.
+The default is  @code{top}.
+
 @item line-spacing
 Additional space to leave below each text line, in pixels (a positive
 integer).  @xref{Line Height}, for more information.
--- a/doc/lispref/minibuf.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/minibuf.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -1222,10 +1222,11 @@
 @end defun
 
 @defopt read-buffer-function
-This variable specifies how to read buffer names.  For example, if you
-set this variable to @code{iswitchb-read-buffer}, all Emacs commands
-that call @code{read-buffer} to read a buffer name will actually use the
-@code{iswitchb} package to read it.
+This variable specifies how to read buffer names.  The function is
+called with the arguments passed to @code{read-buffer}.  For example,
+if you set this variable to @code{iswitchb-read-buffer}, all Emacs
+commands that call @code{read-buffer} to read a buffer name will
+actually use the @code{iswitchb} package to read it.
 @end defopt
 
 @defopt read-buffer-completion-ignore-case
--- a/doc/lispref/modes.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/modes.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -1494,7 +1494,7 @@
  ;; The indicator for the mode line.
  " Hungry"
  ;; The minor mode bindings.
- '(("\C-\^?" . hungry-electric-delete))
+ '(([C-backspace] . hungry-electric-delete))
  :group 'hunger)
 @end smallexample
 
@@ -1526,8 +1526,8 @@
  :lighter " Hungry"
  ;; The minor mode bindings.
  :keymap
- '(("\C-\^?" . hungry-electric-delete)
-   ("\C-\M-\^?"
+ '(([C-backspace] . hungry-electric-delete)
+   ([C-M-backspace]
     . (lambda ()
         (interactive)
         (hungry-electric-delete t))))
--- a/doc/lispref/processes.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/processes.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -868,7 +868,9 @@
 This function returns the terminal name that @var{process} is using for
 its communication with Emacs---or @code{nil} if it is using pipes
 instead of a terminal (see @code{process-connection-type} in
-@ref{Asynchronous Processes}).
+@ref{Asynchronous Processes}).  If @var{process} represents a program
+running on a remote host, the terminal name used by that program on
+the remote host is provided as process property @code{remote-tty}.
 @end defun
 
 @defun process-coding-system process
--- a/doc/lispref/text.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/lispref/text.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -3035,7 +3035,7 @@
 property when Font Lock mode is enabled.  When Font Lock mode is disabled,
 @code{font-lock-face} has no effect.
 
-The @code{font-lock-mode} property is useful for special modes that
+The @code{font-lock-face} property is useful for special modes that
 implement their own highlighting.  @xref{Precalculated Fontification}.
 
 @item mouse-face
--- a/doc/misc/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/misc/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,35 @@
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* org.texi (Footnotes, Tables in HTML export): Fix typos.
+
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc.texi (Making Selections, Selecting Subformulas)
+	(Customizing Calc): Mention how to use faces to emphasize selected
+	sub-formulas.
+
+2010-08-05  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (External packages): File attributes cache flushing
+	for asynchronous processes.
+
+2010-08-01  Alan Mackenzie  <acm@muc.de>
+
+	Enhance the manual for the latest Java Mode.
+
+	* cc-mode.texi (Syntactic Symbols): New symbols annotation-top-cont and
+	annotation-var-cont.
+	(Java Symbols): Page renamed from Anonymous Class Symbol.  Document the
+	two new symbols.
+
+2010-07-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (Traces and Profiles): Describe verbose level 9.
+
+2010-07-27  Chong Yidong  <cyd@stupidchicken.com>
+
+	* nxml-mode.texi (Limitations): Remove obsolete discussion (Bug#6708).
+
 2010-07-19  Juanma Barranquero  <lekktu@gmail.com>
 
 	* org.texi: Fix typo in previous change (revno:100847).
--- a/doc/misc/calc.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/misc/calc.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -21513,7 +21513,11 @@
 
 @noindent
 Every character not part of the sub-formula @samp{b} has been changed
-to a dot.  The @samp{*} next to the line number is to remind you that
+to a dot. (If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the characters
+not part of the sub-formula are de-emphasized by using a less
+noticeable face instead of using dots. @pxref{Displaying Selections}.)
+The @samp{*} next to the line number is to remind you that
 the formula has a portion of it selected.  (In this case, it's very
 obvious, but it might not always be.  If Embedded mode is enabled,
 the word @samp{Sel} also appears in the mode line because the stack
@@ -21726,6 +21730,9 @@
 @noindent
 @kindex j d
 @pindex calc-show-selections
+@vindex calc-highlight-selections-with-faces
+@vindex calc-selected-face
+@vindex calc-nonselected-face
 The @kbd{j d} (@code{calc-show-selections}) command controls how
 selected sub-formulas are displayed.  One of the alternatives is
 illustrated in the above examples; if we press @kbd{j d} we switch
@@ -21740,6 +21747,13 @@
         . . . .                   2 x + 1
 @end group
 @end smallexample
+If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the
+non-selected portion of the formula will be de-emphasized by using a
+less noticeable face (@code{calc-nonselected-face}) instead of dots
+and the selected sub-formula will be highlighted by using a more
+noticeable face (@code{calc-selected-face}) instead of @samp{#}
+signs. (@pxref{Customizing Calc}.)
 
 @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
 @subsection Operating on Selections
@@ -34911,7 +34925,7 @@
 
 Calc is controlled by many variables, most of which can be reset
 from within Calc.  Some variables are less involved with actual
-calculation, and can be set outside of Calc using Emacs's
+calculation and can be set outside of Calc using Emacs's
 customization facilities.  These variables are listed below.
 Typing @kbd{M-x customize-variable RET @var{variable-name} RET}
 will bring up a buffer in which the variable's value can be redefined.
@@ -35197,6 +35211,22 @@
 and @code{calc-embedded-open-close-plain-alist}.
 @end defvar
 
+@defvar calc-highlight-selections-with-faces
+@defvarx calc-selected-face
+@defvarx calc-nonselected-face
+The variable @code{calc-highlight-selections-with-faces} 
+determines how selected sub-formulas are distinguished.
+If @code{calc-highlight-selections-with-faces} is nil, then 
+a selected sub-formula is distinguished either by changing every
+character not part of the sub-formula with a dot or by changing every
+character in the sub-formula with a @samp{#} sign.  
+If @code{calc-highlight-selections-with-faces} is t,
+then a selected sub-formula is distinguished either by displaying the
+non-selected portion of the formula with @code{calc-nonselected-face} 
+or by displaying the selected sub-formula with
+@code{calc-nonselected-face}. (@pxref{Displaying Selections}.)
+@end defvar
+
 @defvar calc-multiplication-has-precedence
 The variable @code{calc-multiplication-has-precedence} determines
 whether multiplication has precedence over division in algebraic
--- a/doc/misc/cc-mode.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/misc/cc-mode.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -312,19 +312,19 @@
 
 Syntactic Symbols
 
-* Function Symbols::
-* Class Symbols::
-* Conditional Construct Symbols::
-* Switch Statement Symbols::
-* Brace List Symbols::
-* External Scope Symbols::
-* Paren List Symbols::
-* Literal Symbols::
-* Multiline Macro Symbols::
-* Objective-C Method Symbols::
-* Anonymous Class Symbol::
-* Statement Block Symbols::
-* K&R Symbols::
+* Function Symbols::            
+* Class Symbols::               
+* Conditional Construct Symbols::  
+* Switch Statement Symbols::    
+* Brace List Symbols::          
+* External Scope Symbols::      
+* Paren List Symbols::          
+* Literal Symbols::             
+* Multiline Macro Symbols::     
+* Objective-C Method Symbols::  
+* Java Symbols::
+* Statement Block Symbols::     
+* K&R Symbols::                 
 
 Customizing Indentation
 
@@ -3971,6 +3971,9 @@
 Topmost definition continuation lines.  This is only used in the parts
 that aren't covered by other symbols such as @code{func-decl-cont} and
 @code{knr-argdecl}.  @ref{Function Symbols}.
+@item annotation-top-cont
+Topmost definition continuation lines where all previous items are
+annotations.  @ref{Java Symbols}.
 @item member-init-intro
 First line in a member initialization list.  @ref{Class Symbols}.
 @item member-init-cont
@@ -3999,6 +4002,9 @@
 A statement.  @ref{Function Symbols}.
 @item statement-cont
 A continuation of a statement.  @ref{Function Symbols}.
+@item annotation-var-cont
+A continuation of a statement where all previous items are
+annotations.  @ref{Java Symbols}.
 @item statement-block-intro
 The first line in a new statement block.  @ref{Conditional Construct
 Symbols}.
@@ -4112,23 +4118,23 @@
 @item inexpr-class
 A class definition inside an expression.  This is used for anonymous
 classes in Java.  It's also used for anonymous array initializers in
-Java.  @ref{Anonymous Class Symbol}.
+Java.  @ref{Java Symbols}.
 @end table
 
 @menu
-* Function Symbols::
-* Class Symbols::
-* Conditional Construct Symbols::
-* Switch Statement Symbols::
-* Brace List Symbols::
-* External Scope Symbols::
-* Paren List Symbols::
-* Literal Symbols::
-* Multiline Macro Symbols::
-* Objective-C Method Symbols::
-* Anonymous Class Symbol::
-* Statement Block Symbols::
-* K&R Symbols::
+* Function Symbols::            
+* Class Symbols::               
+* Conditional Construct Symbols::  
+* Switch Statement Symbols::    
+* Brace List Symbols::          
+* External Scope Symbols::      
+* Paren List Symbols::          
+* Literal Symbols::             
+* Multiline Macro Symbols::     
+* Objective-C Method Symbols::  
+* Java Symbols::
+* Statement Block Symbols::     
+* K&R Symbols::                 
 @end menu
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -4233,7 +4239,7 @@
 
 @noindent
 The primary syntactic symbol for this line is @code{access-label} as
-this a label keyword that specifies access protection in C++.  However,
+this is a label keyword that specifies access protection in C++.  However,
 because this line is also a top-level construct inside a class
 definition, the analysis actually shows two syntactic symbols.  The
 other syntactic symbol assigned to this line is @code{inclass}.
@@ -4740,7 +4746,7 @@
 @xref{Custom Macros}, for more info about the treatment of macros.
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@node    Objective-C Method Symbols, Anonymous Class Symbol, Multiline Macro Symbols, Syntactic Symbols
+@node    Objective-C Method Symbols, Java Symbols, Multiline Macro Symbols, Syntactic Symbols
 @comment node-name, next, previous, up
 @subsection Objective-C Method Symbols
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -4767,34 +4773,45 @@
 assigned @code{objc-method-call-cont} syntax.
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@node    Anonymous Class Symbol, Statement Block Symbols, Objective-C Method Symbols, Syntactic Symbols
+@node    Java Symbols, Statement Block Symbols, Objective-C Method Symbols, Syntactic Symbols
 @comment node-name, next, previous, up
-@subsection Anonymous Class Symbol (Java)
+@subsection Java Symbols
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 Java has a concept of anonymous classes which can look something like
 this:
 
 @example
- 1: public void watch(Observable o) @{
- 2:     o.addObserver(new Observer() @{
- 3:             public void update(Observable o, Object arg) @{
- 4:                 history.addElement(arg);
- 5:             @}
- 6:         @});
- 7: @}
+ 1:  @@Test
+ 2:  public void watch(Observable o) @{
+ 3:      @@NonNull
+ 4:      Observer obs = new Observer() @{
+ 5:          public void update(Observable o, Object arg) @{
+ 6:              history.addElement(arg);
+ 7:          @}
+ 8:      @};
+ 9:      o.addObserver(obs);
+ 10: @}
 @end example
 
 @ssindex inexpr-class
 The brace following the @code{new} operator opens the anonymous class.
-Lines 3 and 6 are assigned the @code{inexpr-class} syntax, besides the
+Lines 5 and 8 are assigned the @code{inexpr-class} syntax, besides the
 @code{inclass} symbol used in normal classes.  Thus, the class will be
 indented just like a normal class, with the added indentation given to
 @code{inexpr-class}.  An @code{inexpr-class} syntactic element doesn't
 have an anchor position.
 
+@ssindex annotation-top-cont
+@ssindex annotation-var-cont
+Line 2 is assigned the @code{annotation-top-cont} syntax, due to it being a
+continuation of a topmost introduction with an annotation symbol preceding
+the current line.  Similarly, line 4 is assigned the @code{annotation-var-cont}
+syntax due to it being a continuation of a variable declaration where preceding
+the declaration is an annotation.
+
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@node    Statement Block Symbols, K&R Symbols, Anonymous Class Symbol, Syntactic Symbols
+@node    Statement Block Symbols, K&R Symbols, Java Symbols, Syntactic Symbols
 @comment node-name, next, previous, up
 @subsection Statement Block Symbols
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--- a/doc/misc/nxml-mode.texi	Mon Jul 26 13:29:08 2010 +0900
+++ b/doc/misc/nxml-mode.texi	Mon Aug 09 10:51:16 2010 +0900
@@ -851,11 +851,6 @@
 @item
 The restrictions on RELAX NG schemas in section 7 of the RELAX NG
 specification are not enforced.
-@item
-Unicode support has problems. This stems mostly from the fact that
-the XML (and RELAX NG) character model is based squarely on Unicode,
-whereas the Emacs character model is not.  Emacs 22 is slated to have
-full Unicode support, which should improve the situation here.
 @end itemize
 
 @bye
Binary file doc/misc/tramp.texi has changed
--- a/etc/AUTHORS	Mon Jul 26 13:29:08 2010 +0900
+++ b/etc/AUTHORS	Mon Aug 09 10:51:16 2010 +0900
@@ -1042,7 +1042,7 @@
 
 François-David Collin: changed message.el mm-decode.el
 
-Fred Fish: changed linux.h unexec.c
+Fred Fish: changed linux.h unexcoff.c
 
 Fred Oberhauser: changed nnmail.el
 
@@ -1273,7 +1273,7 @@
 Inoue Seiichiro: changed xterm.c xfns.c xterm.h
 
 International Business Machines: changed emacs.c fileio.c process.c
-  sysdep.c unexec.c
+  sysdep.c unexcoff.c
 
 Irie Tetsuya: changed gnus.texi message.texi
 
@@ -1334,7 +1334,7 @@
 
 James Troup: changed gnus-sum.el
 
-James Van Artsdalen: changed unexec.c usg5-4.h
+James Van Artsdalen: changed unexcoff.c usg5-4.h
 
 James Wright: changed em-unix.el
 
@@ -2176,7 +2176,7 @@
   simple.el vc.el configure.in dired.el and 50 other files
 
 Michael Ben-Gershon: changed acorn.h configure.in riscix1-1.h riscix1-2.h
-  unexec.c
+  unexcoff.c
 
 Michael D. Ernst: wrote reposition.el
 and changed dired-x.el uniquify.el ispell.el bibtex.el rmail.el dired.el
@@ -2200,7 +2200,7 @@
 
 Michael K. Johnson: changed configure.in emacs.c intel386.h linux.h
   mem-limits.h process.c sysdep.c syssignal.h systty.h template.h
-  unexec.c
+  unexcoff.c
 
 Michael Kifer: wrote ediff-diff.el ediff-help.el ediff-hook.el
   ediff-init.el ediff-merg.el ediff-mult.el ediff-ptch.el ediff-util.el
@@ -2259,7 +2259,7 @@
 Microelectronics and Computer Technology Corporation: changed
   emacsclient.c etags.c lisp.h movemail.c rmail.el rmailedit.el
   rmailkwd.el rmailmsc.el rmailout.el rmailsum.el scribe.el server.el
-  sysdep.c unexec.c xmenu.c
+  sysdep.c unexcoff.c xmenu.c
 
 Mikael Djurfeldt: changed xdisp.c
 
@@ -2685,7 +2685,7 @@
 Richard Mlynarik: wrote cl-indent.el ebuff-menu.el ehelp.el rfc822.el
   terminal.el yow.el
 and changed files.el sysdep.c rmail.el info.el keyboard.c bytecomp.el
-  fileio.c simple.el process.c startup.el window.c editfns.c unexec.c
+  fileio.c simple.el process.c startup.el window.c editfns.c unexcoff.c
   xfns.c keymap.c minibuf.c sendmail.el buffer.c dispnew.c emacs.c
   subr.el and 129 other files
 
@@ -2921,7 +2921,7 @@
   ls-lisp.el w32proc.c
 
 Spencer Thomas: changed dabbrev.el emacsclient.c gnus.texi server.el
-  unexec.c
+  unexcoff.c
 
 Sriram Karra: changed message.el
 
--- a/etc/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/etc/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,24 @@
+2010-08-08  Ken Brown  <kbrown@cornell.edu>
+
+	* PROBLEMS: Mention problem with Cygwin 1.5.19.
+
+2010-08-07  Eli Zaretskii  <eliz@gnu.org>
+
+	* NEWS: Mention the Hebrew translation.
+
+	* tutorials/TUTORIAL.he: Don't use acronyms.
+
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* AUTHORS: Rename unexec.o => unexcoff.o.
+	* PROBLEMS: Rename unexec.o => unexcoff.o.
+
+2010-07-31  Eli Zaretskii  <eliz@gnu.org>
+
+	* tutorials/TUTORIAL.he: New file.
+
+	* tutorials/TUTORIAL.translators: Add TUTORIAL.he.
+
 2010-07-24  Christoph Scholtes  <cschol2112@gmail.com>
 
 	* NEWS: Document new --distfiles configure.bat option and
--- a/etc/NEWS	Mon Jul 26 13:29:08 2010 +0900
+++ b/etc/NEWS	Mon Aug 09 10:51:16 2010 +0900
@@ -51,6 +51,11 @@
 This is only useful for Emacs developers to debug certain types of bugs.
 These is not a new feature; only the configure flag is new.
 
+---
+** New translation of the Emacs Tutorial in Hebrew is available
+Type `C-u C-h t' to choose it in case your language setup doesn't
+automatically select it.
+
 
 * Startup Changes in Emacs 24.1
 
@@ -99,6 +104,14 @@
 Customize `tool-bar-style' to choose style.  On a Gnome desktop, the default
 is taken from the desktop settings.
 
+** GTK tool bars can be placed on the left/right or top/bottom of the frame.
+The frame-parameter tool-bar-position controls this.  It takes the values
+top, left, tight or bottom.  The Options => Show/Hide menu has entries
+for this.
+
+** Emacs uses GTK tooltips by default if built with GTK.  You can turn that
+off by customizing x-gtk-use-system-tooltips.
+
 ** Lucid menus and dialogs can display antialiased fonts if Emacs is built
 with Xft.
 
@@ -179,7 +192,10 @@
 default, is now similar to other X applications.  In particular, kill
 and yank use the clipboard, in addition to the primary selection.
 
-*** `select-active-regions' now defaults to t.
+*** `select-active-regions' now defaults to `lazy'.
+This means that any active region made with shift-selection or mouse
+dragging, or acted on by Emacs (e.g. with M-w or C-w), is
+automatically added to the primary window selection.
 
 *** `x-select-enable-clipboard' now defaults to t.
 
@@ -250,6 +266,9 @@
 **** vc-bzr handles Author:, Date: and Fixes:
 **** vc-mtn handles Author: and Date:
 
+*** Pressing g in a *vc-diff* buffer reruns vc-diff, so it will
+produce an up to date diff.
+
 ** Directory local variables can apply to file-less buffers.
 For example, adding "(diff-mode . ((mode . whitespace)))" to your
 .dir-locals.el file, will turn on `whitespace-mode' for *vc-diff* buffers.
--- a/etc/PROBLEMS	Mon Jul 26 13:29:08 2010 +0900
+++ b/etc/PROBLEMS	Mon Aug 09 10:51:16 2010 +0900
@@ -2344,6 +2344,14 @@
 As of Emacs 22.1, there have been stability problems with Cygwin
 builds of Emacs using GCC 3.  Cygwin users are advised to use GCC 4.
 
+*** Building Emacs 23.3 and later will fail under Cygwin 1.5.19
+
+This is a consequence of a change to src/dired.c on 2010-07-27.  The
+issue is that Cygwin 1.5.19 did not have d_ino in 'struct dirent'.
+See
+
+  http://lists.gnu.org/archive/html/emacs-devel/2010-07/msg01266.html
+
 *** Building the native MS-Windows port fails due to unresolved externals
 
 The linker error messages look like this:
@@ -2740,7 +2748,7 @@
 Two causes have been seen for such problems.
 
 1) On a system where getpagesize is not a system call, it is defined
-as a macro.  If the definition (in both unexec.c and malloc.c) is wrong,
+as a macro.  If the definition (in both unex*.c and malloc.c) is wrong,
 it can cause problems like this.  You might be able to find the correct
 value in the man page for a.out (5).
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/tutorials/TUTORIAL.he	Mon Aug 09 10:51:16 2010 +0900
@@ -0,0 +1,1038 @@
+שיעור ר×שון בשימוש ב-Emacs. זכויות שימוש ר××” בסוף המסמך.
+
+פקודות רבות של Emacs משתמשות במקש CONTROL (×œ×¤×¢×ž×™× ×”×•× ×ž×¡×•×ž×Ÿ ב-CTRL ×ו CTL)
+×ו במקש META (×œ×¤×¢×ž×™× ×ž×¡×•×ž×Ÿ EDIT ×ו ALT). ×‘×ž×§×•× ×œ×¦×™×™×Ÿ ×ת כל השמות ×”×פשריי×
+בכל פע×, נשתמש ×‘×§×™×¦×•×¨×™× ×”×‘××™×:
+
+â€<תו>-C  משמעותו לחץ והחזק מקש CONTROL ו××– הקש על מקש <תו>.
+         לדוגמ×, C-f משמעותו: לחץ והחזק CONTROL והקש על f.
+â€<תו>-M  משמעותו לחץ והחזק מקש META ×ו EDIT ×ו ALT ו××– הקש על מקש <תו>.
+         ×× ×‘×ž×§×œ×“×ª ×ין ××£ ×חד ממקשי META ×ו EDIT ×ו ALT, ×פשר להקיש
+	 ולשחרר מקש ESC ו××– להקיש <תו>. ×נו נכתוב <ESC> עבור מקש ESC.
+
+הערה חשובה: כדי לצ×ת מ-Emacs יש להקיש C-x C-c (שני תוי×, משמ×ל לימין).
+כדי להפסיק פקודה ב×מצע ההקשה, יש להקיש C-g.
+המחרוזת ">>" בקצה הימני מסמנת הור×ות ×¢×‘×•×¨×›× ×›×“×™ לנסות להשתמש בפקודה כלשהי.
+לדוגמה:
+<<שורות ריקות תתווספנה סביב השורה הב××” ×¢"×™ help-with-tutorial>>
+[×מצע העמוד הוש×ר ריק למטרות לימודיות. הטקסט ממשיך להלן]
+>>  הקישו עתה C-v (הצג העמוד הב×) על-מנת ×œ×”×ª×§×“× ×œ×¢×ž×•×“ הב×. (קדימה, נסו
+    ×–×ת ×¢"×™ לחיצה והחזקה של מקש CONTROL והקשה על v.)
+    מעתה והל××”, ×¢×œ×™×›× ×œ×¢×©×•×ª ×–×ת בכל ×¤×¢× ×©×ª×¡×™×™×ž×• ×œ×§×¨×•× ×ת המוצג על המסך.
+
+שימו לב לחפיפה של שתי שורות ×›×שר ××ª× ×¢×•×‘×¨×™× ×ž×ž×¡×š למשך, מה שמבטיח רציפות
+מסוימת בעת קרי×ת הטקסט.
+
+דבר ר×שון ×©×¢×œ×™×›× ×œ×œ×ž×•×“ ×”×•× ×›×™×¦×“ לנוע ×ž×ž×§×•× ×חד למשנהו בתוך הטקסט. ×ת×
+כבר ×™×•×“×¢×™× ×›×™×¦×“ ×œ×”×ª×§×“× ×œ×¢×ž×•×“ הב×, ×¢× C-v. לחזרה לעמוד ×”×§×•×“× ×”×§×™×©×• M-v
+(החזיקו מקש META והקישו v ×ו הקישו ‭<ESC>v‬ ×× ×ין במקלדת מקש META
+×ו EDIT ×ו ALT).
+
+>>  נסו עתה כמה ×¤×¢×ž×™× ×œ×”×§×™×© M-v ו×חר-כך C-v.
+
+
+* ×¡×™×›×•× ×¢×“ ×›×ן
+--------------
+
+×œ×©× ×ª× ×•×¢×” ×‘×¢×ž×•×“×™× ×©×œ×ž×™× ×•×¦×¤×™×™×” בה×, השתמשו בפקודות הב×ות:
+
+	â€C-v	×”×ª×§×“× ×œ×¢×ž×•×“ הב×
+	â€M-v	חזור לעמוד הקוד×
+	â€C-l	נקה תצוגה והצג מחדש ×ת הטקסט,
+		כך שהטקסט ליד הסמן ×™×™×ž×¦× ×‘×ž×¨×›×– התצוגה
+		(שימו לב: CONTROL-L ×•×œ× CONTROL-1.)
+
+>> מצ×ו ×ת הסמן על-גבי התצוגה וזכרו ×ת הטקסט לידו. ל×חר מכן הקישו C-l.
+   מצ×ו ×ת הסמן שנית ושימו לב ×©×”×•× ×¢×“×™×™×Ÿ ליד ×ותו הטקסט, ×בל עכשיו
+   ×”×•× ×‘×ž×¨×›×– התצוגה.
+   ×× ×ª×§×™×©×• C-l שוב, קטע הטקסט ×”×–×” יזוז לקצה העליון של התצוגה. הקישו
+   C-l שוב ×•×”×•× ×™×–×•×– לתחתית התצוגה.
+
+×’× ×ž×§×©×™ PageUp ו-PageDn, ×× ×”× ×§×™×™×ž×™× ×‘×ž×§×œ×“×ª שלכ×, ×™×›×•×œ×™× ×œ×©×ž×© לתנועה
+×‘×¢×ž×•×“×™× ×©×œ×ž×™×, ××•×œ× ×”×©×™×ž×•×© ב-C-v ו-M-v יעיל יותר.
+
+* תנועת סמן בסיסית
+------------------
+
+תנועה ×‘×¢×ž×•×“×™× ×©×œ×ž×™× ×”×™× ×” שימושית, ×בל כיצד ניתן להגיע ×œ×ž×§×•× ×¡×¤×¦×™×¤×™
+בתוך הטקסט שעל-גבי התצוגה?
+
+ניתן לעשות ×–×ת בכמה דרכי×. ×פשר למשל להשתמש במקשי החצי×, ××•×œ× ×™×”×™×”
+×–×” יעיל יותר ×× ×ª×—×–×™×§×• ×ת ×”×™×“×™×™× ×ž×¢×œ החלק הסטנדרטי של המקלדת ותשתמשו
+בפקודות C-p, C-b, C-f ו-C-n. פקודות ×לו שוות ערך ל×רבעת מקשי החצי×,
+כדלקמן:
+
+			שורה קודמת, C-p
+				 :
+			 	 :
+	   קדימה, C-f ... ×ž×™×§×•× ×¡×ž×Ÿ נוכחי ... ×חורה, C-b
+				 :
+				 :
+			השורה הב××”, C-n
+
+>> השתמשו במקשי C-n ו-C-p על-מנת להגיע לשורה ×”×מצעית של הדי×גרמה.
+   הקישו C-l כדי למרכז ×ת הדי×גרמה על-גבי התצוגה.
+
+קל יותר לזכור ×ת ×”×ž×§×©×™× ×”×œ×œ×• ב×מצעות ×”×ž×œ×™× ×©×”× ×ž×™×™×¦×’×™×:
+P מ-previous (קוד×), N מ-Next (הב×), B מ-Backward (×חורה)
+ו-F מ-Forward (קדימה). מקשי התנועה ×”×‘×¡×™×¡×™×™× ×”×œ×œ×• ישמשו ××ª×›× ×›×œ הזמן.
+
+>> הקישו C-n כמה ×¤×¢×ž×™× ×›×“×™ ×œ×ž×§× ×ת הסמן בשורה זו.
+
+>> הניעו ×ת הסמן בתוך השורה ×¢× C-f ו×חר-כך למעלה ×¢× C-p.
+   שימו לב מה עושה C-p ×›×שר הסמן × ×ž×¦× ×‘×מצע השורה.
+
+כל שורה של טקטס מסתיימת בתו מיוחד ×”× ×§×¨× Newline. תו ×–×” מפריד בין
+השורה לזו ש×חריה. (בדרך כלל, השורה ×”×חרונה בקובץ ×ª×¡×ª×™×™× ××£ ×”×™×
+ב-Newline, ×ך Emacs ×ינו זקוק לכך.)
+
+>> נסו C-b בתחילת שורה. ×”×•× ×™×’×¨×•× ×œ×¡×ž×Ÿ לנוע לסוף השורה הקודמת. ×–×ת,
+   ×ž×©×•× ×©×”×•× × ×¢ ×חורה וחולף על-פני תו ×”-Newline.
+
+×’× C-f יכול לחלוף על-פני Newline, בדיוק כמו C-b.
+
+>> הקישו C-b עוד כמה ×¤×¢×ž×™× ×›×“×™ לקבל הרגשה היכן × ×ž×¦× ×”×¡×ž×Ÿ.
+   עתה הקישו C-f מספר ×¤×¢×ž×™× ×”×“×¨×•×© לשוב לסוף השורה. ו××– הקישו
+   C-f עוד ×¤×¢× ×חת כדי לנוע לתחילת השורה הב××”.
+
+כשהסמן ×™×•×¦× ×ž×’×‘×•×œ×•×ª הטקסט המוצג, חלקי הטקסט מעבר לחלק המוצג נכנסי×
+לתצוגה. לזה קור××™× "גלילה". גלילה מ×פשרת ל-Emacs להניע ×ת הסמן למקו×
+כלשהו בטקסט מבלי שהסמן ×™×™×¢×œ× ×ž×”×ª×¦×•×’×”.
+
+>> נסו להניע ×ת הסמן ×ל מחוץ לתצוגה ×¢"×™ הקשת C-n ושימו לב למה שקורה.
+
+×× ×ª× ×•×¢×” תו-תו ×יטית מדי, תוכלו לנוע ×ž×™×œ×™× ×©×œ×ž×•×ª. M-f â€(META-f) מזיז
+×ת הסמן מילה ×חת קדימה ו×ילו M-b ×–×– מילה ×חורה.
+
+>> הקישו M-f ו-M-b מספר פעמי×.
+
+×× ×”×¡×ž×Ÿ × ×ž×¦× ×‘×מצע מילה, M-f ×–×– לסוף המילה. ×× ×”×¡×ž×Ÿ × ×ž×¦× ×‘×™×Ÿ שתי מלי×,
+M-f עובר ×ת המילה הב××” ונעצר בסופה. M-b פועל ב×ופן דומה בכיוון הפוך.
+
+>> הקישו עתה M-f ו-M-b ×¤×¢×ž×™× ×חדות, ×•×’× C-f ו-C-b פה ×•×©× ×›×“×™ שתוכלו
+   ×œ×”×ª×¨×©× ×ž×”×ª×•×¦××” של M-f ו-M-b במקומות ×©×•× ×™× ×‘×ª×•×š ובין המלי×.
+
+שימו לב להקבלה שבין C-f ו-C-b מצד ×חד ו-M-f ו-M-b מהצד השני. לעתי×
+קרובות מ×ד ×ž×§×©×™× ×¢× META ×ž×©×ž×©×™× ×œ×¤×¢×•×œ×•×ª הקשורות ליחידות של שפה (מלי×,
+משפטי×, פסק×ות) ו×ילו ×ž×§×©×™× ×¢× CONTROL ×¤×•×¢×œ×™× ×¢×œ יחידות בסיסיות ש×ינן
+תלויות בסוג הטקסט שהינכך ×¢×•×¨×›×™× (תוי×, שורות, וכד').
+
+ההקבלה ×”×–×ת קיימת ×’× ×œ×’×‘×™ שורות ומשפטי×: C-a ו-C-e × ×¢×™× ×œ×ª×—×™×œ×ª השורה
+וסופה, בהת×מה, ו×ילו M-a ו-M-e × ×¢×™× ×œ×ª×—×™×œ×ª המשפט וסופו.
+
+>> נסו עתה שתי הקשות על C-a ו×חר-כך שתי הקשות על C-e.
+   נסו שני M-a ו×חר-כך שני M-e.
+
+שימו לב שחזרה על C-a ××™× ×” עושה דבר, ו×ילו כל הקשה חוזרת על M-a מניעה
+×ת הסמן במשפט נוסף. ××ž× × ×ין ×›×ן ×נלוגיה מושלמת, ×בל התוצ××” נר×ית
+טבעית בשני המקרי×.
+
+×ž×§×•× ×”×¡×ž×Ÿ בתוך הטקסט × ×§×¨× "point" ("נקודה"). ×‘×ž×œ×™× ×חרות, הסמן מר××”
+×ת מיקומו של "point" בתוך הטקסט.
+
+×”× ×” ×¡×™×›×•× ×©×œ פקודות פשוטות להנעת הסמן, כולל פקודות שנעות במלי×
+×•×ž×©×¤×˜×™× ×©×œ×ž×™×:
+
+	â€C-f	נוע תו ×חד קדימה
+	â€C-b	נוע תו ×חד ×חורה
+
+	â€M-f	נוע מילה קדימה
+	â€M-b	נוע מילה ×חורה
+
+	â€C-n	נוע לשורה הב××”
+	â€C-p	נוע לשורה הקודמת
+
+	â€C-a	נוע לתחילת השורה
+	â€C-e	נוע לסוף השורה
+
+	â€M-a	נוע קדימה לסוף המשפט
+	â€M-e	נוע ×חורה לתחילת המשפט
+
+>> נסו ×ת כל הפקודות הללו מספר פעמי×, ×œ×©× ×ª×¨×’×•×œ.
+   ×לו הן הפקודות הנפוצות ביותר.
+
+שתי פקודות תנועה חשובות ×חרת הן ‭M-<‬ â€(META פחות), ×שר × ×¢×” לתחילת
+הטקסט, ו-‭M->‬ â€(META יותר), ×שר × ×¢×” לסוף הטקסט.
+
+ברוב המקלדות המקש ">" × ×ž×¦× ×ž×¢×œ הפסיק, לכן כדי להקישו יש צורך ללחוץ
+ולהחזיק מקש Shift. ב×ופן דומה יש ללחוץ על Shift כדי להקיש ‭M-<‬כי
+×חרת ×”×™×” ×™×•×¦× M-פסיק.
+
+>> נסו עתה ‭M-<‬ כדי להגיע לתחילת השיעור.
+   ×חר-כך הקישו C-v מספר פעמי×, עד שתגיעו לכ×ן.
+
+>> עכשיו נסו ‭M->‬ כדי להגיע לסוף השיעור.
+   ל×חר מכן הקישו M-v כמה ×¤×¢×ž×™× ×›×“×™ לחזור לכ×ן.
+
+ניתן להזיז ×ת הסמן ×’× ×‘×¢×–×¨×ª מקשי החצי×, ×× ×”× ×§×™×™×ž×™× ×‘×ž×§×œ×“×ª שלכ×.
+×בל ×נחנו ×ž×ž×œ×™×¦×™× ×œ×œ×ž×•×“ להשתמש ב-C-b, C-f, C-n ו-C-p משלוש סיבות.
+×§×•×“× ×›×œ, ×”× ×™×¢×‘×“×• ×¢× ×›×œ מקלדת. שנית, כשתתרגלו לעבוד ×¢× Emacs, תר×ו
+×›×™ השימוש ×‘×ž×§×©×™× ×לו מהיר יותר מהשימוש ×‘×—×¦×™× (מכיון ש×ין צורך להזיז
+×ת היד מהחלק העיקרי של המקלדת). ושלישית, ×›×©×”×ž×§×©×™× ×”×œ×œ×• יהפכו להרגל,
+×™×”×™×” ×œ×›× ×§×œ יותר ללמוד פקודות מתקדמות יותר של תנועת הסמן.
+
+רוב הפקודות של Emacs מקבלות ×רגומנט נומרי; עבור רוב הפקודות ×”×רגומנט
+משמש כמונה של מספר החזרות על הפקודה. כדי לספק ×רגומנט לפקודה, יש להקיש
+C-u ו×חר-כך ספרות, וז×ת לפני ×©×ž×§×™×©×™× ×ת הפקודה עצמה. ×¢× ×‘×ž×§×œ×“×ª קיי×
+מקש META (×ו EDIT ×ו ALT), יש ×’× ×פשרות ×חרת לציין ×רגומנט נומרי:
+הקישו ×ת הספרות תוך כדי החזקת מקש META. ×נו ×ž×ž×œ×™×¦×™× ×¢×œ C-u ×ž×©×•× ×©×”×•×
+יעבוד ×¢× ×›×œ מקלדת. ×”×רגומנט הנומרי × ×§×¨× ×’× "×רגומנט קידומת" (prefix
+argument) ×ž×©×•× ×ž×§×™×©×™× ×ותו לפני הפקודה ×ליה ×”×•× ×ž×ª×™×™×—×¡.
+
+למשל, C-u 8 C-f מניע ×ת הסמן 8 ×ª×•×™× ×§×“×™×ž×”.
+
+>> נסו להקיש C-n ×ו C-p ×¢× ×רגומנט נומרי, כדי להזיז ×ת הסמן ×ל שורה
+   מסוימת בפקודה ×חת בלבד.
+
+רוב הפקודות מפרשות ×ת ×”×רגומנט הנומרי כמונה חזרות, ×בל פקודות מסוימות
+משתמשות בו בצורות ×חרות. כמה פקודות (×בל ××£ ×חת מבין ×לו שלמדנו עד ×›×”)
+משתמשות בו כדגלון -- נוכחותו של ×”×רגומנט, ×œ×œ× ×§×©×¨ לערכו המספרי, גורמת
+לפקודה להתנהג קצת ×חרת.
+
+â€C-v ו-M-v יוצ××™× ×ž×”×›×œ×œ ×”×–×” ב×ופן ×חר. כשפקודות ×לו מקבלות ×רגומנט,
+הן ×’×•×œ×œ×™× ×ת התצוגה כמספר ×”×–×” של שורות, ×•×œ× ×‘×“×¤×™×. למשל, C-u 8 C-v
+יגלול ×ת התצוגה ב-8 שורות.
+
+>> נסו עתה להקיש C-u 8 C-v.
+
+כתוצ××”, התצוגה היתה צריכה לזוז ב-8 שורות. ×× ×‘×¨×¦×•× ×›× ×œ×’×œ×•×œ בחזרה,
+×פשר להשיג ×–×ת ×¢"×™ מתן ×רגומנט ל-M-v.
+
+×× ×”×¤×¢×œ×ª× ×ת Emacs על-גבי מערכת חלונ×ית כגון X ×ו MS-Windows, ×ת×
+×¦×¨×™×›×™× ×œ×¨×ות פס צר וגבוה, ששמו פס גלילה (scroll bar) בצידו של החלון
+של Emacs. (שימו לב שבשני צידי החלון ×§×™×™×ž×™× ×¤×¡×™× × ×•×¡×¤×™×. ×לה נקר××™×
+"השוליי×" -- "fringes" -- ×•×ž×©×ž×©×™× ×œ×”×¦×’×ª סימני המשך שורה וסימוני×
+×חרי×. פס הגלילה, לעומת×, מופיע רק בצד ×חד ×•×”×•× ×”×›×™ קרוב לקצה החלון
+בצד ההו×.)
+
+>> נסו עתה להקליק בכפתור ×”×מצעי של העכבר בחלק העליון של ×”×זור המודגש
+   של פס הגלילה. פעולה זו ×מורה לגלול ×ת הטקסט בשיעור שתלוי ×‘×ž×§×•× ×‘×•
+   הקלקת×.
+
+>> נסו לגרור ×ת העכבר מעלה ומטה, תוך כדי לחיצה על הכפתור ×”×מצעי.
+   כתוצ××”, Emacs יגלול ×ת הטקסט מעלה ומטה בהת×× ×œ×ª× ×•×¢×ª העכבר.
+
+×× ×”×¢×›×‘×¨ ×©×œ×›× ×ž×¦×•×™×“ בגלגל, תוכלו להשתמש ×’× ×‘×• לגלילת הטקסט.
+
+* ×× Emacs מפסיק להגיב
+----------------------
+
+×× Emacs מפסיק להגיב לפקודות, תוכלו להפסיק ×ותו בבטחה ×¢"×™ הקשת C-g.
+פקודות שביצוען מת×רך ××£ הן ניתנות להפסקה בעזרת C-g.
+
+בנוסף, ×ª×’×¨×•× ×”×§×©×ª C-g לביטול ×”×רגומנט הנומרי ×ו תחילת הפקודה שטר×
+×”×©×œ×ž×ª× ×œ×”×§×™×© והתחרטת×.
+
+>> הקישו C-u 100 כדי לציין ×רגומנט של 100, ול×חר מכן C-g. עתה הקישו
+   C-f. ×”×•× ×¦×¨×™×š לנוע תו ×חד בלבד, שכן ×‘×™×˜×œ×ª× ×ת ×”×רגומנט בעזרת C-g.
+
+×× ×”×§×©×ª× <ESC> בטעות, ניתן לבטלו בעזרת C-g.
+
+* פקודות מנוטרלות
+-----------------
+
+מספר פקודות ב-Emacs מנוטרלות בכוונה כדי ×©×ž×©×ª×ž×©×™× ×ž×ª×—×™×œ×™× ×œ× ×™×¤×¢×™×œ×•
+×ותן בדרך מקרה.
+
+×× ×ª×§×™×©×• ×ת ×חת הפקודות הללו, Emacs יציג הודעה המת×רת ×ת הפקודה ויש×ל
+×× ×œ×‘×¦×¢ ×ת הפקודה ×ו לבטלה.
+
+×× ×כן ×‘×›×•×•× ×ª×›× ×œ× ×¡×•×ª ×ת הפקודה, הקישו <SPC> (מקש הרווח) בתשובה לש×לה.
+בדרך כלל, ×× ××™× ×›× ×ž×¢×•× ×™×™× ×™× ×œ×‘×¦×¢ ×ת הפקודה המנוטרלת, הקישו "n" בתשובה
+לש×לה הזו.
+
+* חלונות
+--------
+
+תצוגת Emacs יכולה לכלול יותר מחלון ×חד, כשכל ×חד ×ž×”× ×ž×¦×™×’ טקסט משלו.
+מ×וחר יותר נסביר כיצד להשתמש בחלונות מרובי×. כעת ברצוננו להסביר כיצד
+להפטר מחלונות ×ž× ×•×ª×¨×™× ×•×œ×—×–×•×¨ לעריכה בחלון יחיד. ×ין דבר פשוט מזה:
+
+	â€C-x 1	חלון ×חד בלבד (כלומר, סגור ×ת כל החלונות ×”×חרי×).
+
+כדי להפעיל פקודה זו, הקישו CONTROL-x ול×חריו ×ת הספרה 1. הפקודה C-x 1
+מרחיבה ×ת החלון המציג ×ת הסמן כך ×©×”×•× ×ª×•×¤×¡ ×ת כל שטח התצוגה. הפקודה
+מבטלת ×ת ש×ר החלונות.
+
+>> הניעו ×ת הסמן לתוך שורה זו והקישו C-u 0 C-l.
+>> עתה הקישו CONTROL-h k CONTROL-f.
+   שימו לב כיצד החלון הנוכחי ×ž×¦×˜×ž×¦× ×•×ž×•×¤×™×¢ חלון חדש שבו מוצג
+   התיעוד של הפקודה CONTROL-f.
+
+>> הקישו C-x 1 ושימו לב שהחלון ×¢× ×”×”×¡×‘×¨ על C-f נעל×.
+
+פקודה זו שונה מכל ש×ר הפקודות שלמדנו עד ×›×” בכך ×©×”×™× ×ž×›×™×œ×” שני תוי×.
+×”×™× ×ž×ª×—×™×œ×” ×¢× ×”×ª×• CONTROL-x. פקודות רבות מ×ד מתחילות ב-CONTROL-x; חלק
+גדול מהן עוסקות בחלונות, קבצי×, ×—×•×¦×¦×™× ×•× ×•×©××™× ×“×•×ž×™× ×חרי×. פקודות ×לו
+מכילות שני×, שלושה ו×פילו ×רבעה תוי×.
+
+
+* הכנסה ומחיקה
+-------------
+
+×× ×‘×¨×¦×•× ×›× ×œ×”×›× ×™×¡ טקסט, פשוט הקישו על ×”×ž×§×©×™× ×”×ž×ª×ימי×. ×ª×•×™× ×¨×’×™×œ×™×,
+כגון A, ×, 7, * וכד' ×ž×ª×¤×¨×©×™× ×¢"×™ Emacs כטקסט ומיד ×ž×ª×•×•×¡×¤×™× ×œ×˜×§×¡×˜
+הקיי×. הקישו <Return> (מקש חזרת גרר) כדי להכניס ×ת תו השורה החדשה
+(Newline).
+
+למחיקת התו ×”×חרון ×©×”×§×©×ª× ×”×§×™×©×• <DelBack>. המקש ש×נו קור××™× ×œ×• <DelBack>
+יכול ×œ×”×ª×§×¨× ×‘×©×ž×•×ª ×©×•× ×™× -- "Delete", "DEL" ×ו "Backspace". בדרך כלל
+זהו מקש גדול ובולט ×©× ×ž×¦× ×œ× ×”×¨×—×§ ממקש <Return>, ×•×”×•× ×ž×©×ž×© ××ª×›× ×œ×ž×—×™×§×ª
+התו ×חרון ×’× ×‘×ª×•×›× ×™×•×ª ×חרות, ×œ× ×¨×§ ב-Emacs.
+
+×× ×§×™×™× ×‘×ž×§×œ×“×ª ×©×œ×›× ×ž×§×© גדול שעליו ×¨×©×•× <Backspace>, ××– זהון המקש ×שר
+ישמש ×›-<DelBack>. ×’× ×× ×™×”×™×” מקש ×חר המסומן ב-"Delete" ×‘×ž×§×•× ×חרת ×–×”
+×ינו ×”-<DelBack> שלכ×.
+
+ב×ופן כללי יותר, <DelBack> מוחק ×ת התו ×©×§×•×“× ×œ×ž×™×§×•× ×”×¡×ž×Ÿ.
+
+>> הקישו עתה מספר תוי×, ו×חר-כך מחקו ××•×ª× ×¢"×™ הקשות ×חדות
+   על <DelBack>. ×ל תחששו לשנות ×ת הקובץ ×”×–×” -- העותק המקורי
+   של השיעור ייש×ר ×œ×œ× ×©×™× ×•×™. ××ª× ×¢×•×‘×“×™× ×¢×œ העותק ×”×ישי שלכ×.
+
+×›×שר שורה של טקסט נעשית ×רוכה משורה ×חת של תצוגה, חלק מהטקסט ממשיך
+בשורת תצוגה נוספת, ×”×™× "שורת ההמשך". תו לוכסן ("/") בסוף השורה (×ו
+×—×¥ עקלקל קטן ב×זור ×”×©×•×œ×™×™× -- "fringe") מסמל שלשורה יש שורת המשך.
+
+>> הקישו טקסט עד שתגיעו לקצה השורה, ו××– תמשיכו להקיש עוד טקסט.
+   כתוצ××”, תר×ו שמופיעה שורת המשך.
+
+>> עתה הקישו <DelBack> על-מנת למחוק טקסט עד שהשורה תיעשה קצרה מספיק
+   ותת××™× ×œ×©×•×¨×” בודדת על-גבי התצוגה. שורת ההמשך תיעל×.
+
+ניתן למחוק ×ת תו ×”-Newline כמו כל תו ×חר. מחיקת ×”-Newline בין שתי
+שורות תמזג ×ת השורות לשורה ×חת. ×× ×”×©×•×¨×” המשולבת תהיה ×רוכה מרוחב
+התצוגה, ×”×™× ×ª×•×¦×’ ×¢× ×©×•×¨×ª המשך.
+
+>> הניעו ×ת הסמן לתחילת השורה והקישו <DelBack>. כתוצ××”, השורה תתמזג
+   ×× ×§×•×“×ž×ª×”.
+
+>> עתה הקישו <Return> כדי להחזיר ×ת ×”-Newline שמחקת×.
+
+זכרו ×›×™ לרוב הפקודות ב-Emacs ×פשר לציין מספר חזרות. ×’× ×ª×•×™ טקסט
+×©×™×™×›×™× ×œ×§×‘×•×¦×ª פקודות זו. חזרה על תו טקסט מכניסה ×ותו מספר פעמי×.
+
+>> נסו ×–×ת עכשיו -- הקישו ‪C-u 8 *‬ על-מנת להכניס ********.
+
+ובכן, ×œ×ž×“×ª× ×ת ×”×ופן הבסיסי ביותר להדפיס משהו ב-Emacs ולתקן שגי×ות.
+×פשר למחוק ×’× ×ž×œ×™× ×•××£ שורות שלמות. להלן ×¡×™×›×•× ×¤×§×•×“×•×ª המחיקה:
+
+	â€<Delback>	מחק תו שלפני הסמן
+	â€C-d	        מחק תו מתחת ×ו ×חרי הסמן
+
+	â€â€­M-<Delback>‬  גזור מילה שלפני הסמן
+	â€M-d	        גזור מילה ש×חרי הסמן
+
+	â€C-k	        גזור טקסט מהסמן ועד סוף השורה
+	â€M-k	        גזור טקסט עד סוף המשפט הנוכחי.
+
+שימו לב שהיחס בין <Delback> ו-C-d לעומת M-<Delback>‎ ו-M-d ×ž×ž×©×™×›×™× ×ת
+ההקבלה שבין C-f ו-M-f (××ž× × <Delback> ×יננו תו בקרה, ×‘×•× × ×–× ×™×— ×ת
+הנקודה הזו לעת-עתה). C-k ו-M-k ×“×•×ž×™× ×œ-C-e ו-M-e, ×× × ×§×‘×™×œ שורות
+למשפטי×.
+
+בנוסף, קיימת שיטה ×חידה שמ×פשרת לגזור קטע כלשהו של טקסט. ×œ×©× ×›×š, תגיעו
+לקצה ×”×חד של חלק הטקסט והקישו C-@‎ ×ו C-<SPC>‎ (×חד מבין שני ×לו).
+(<SPC> ×”×•× ×ž×§×© הרווח.) עתה הניעו ×ת הסמן לקצה השני של חלק הטקסט והקישו
+C-w. כתוצ××”, כל הטקסט בין שני המקומות הללו ייגזר.
+
+>> הניעו ×ת הסמן ×ל ×”×ות ב בתחילת הפיסקה הקודמת.
+>> הקישו C-<SPC>‎. â€Emacs צריך להציג הודעה ×”×ומרת "Mark set" בתחתית
+   התצוגה.
+>> הניעו ×ת הסמן ×ל ×”×ות צ בשורה השניה של הפיסקה.
+>> הקישו C-w. בכך תגזרו ×ת חלק הטקסט שמתחיל ב-ב ×•×ž×¡×ª×™×™× ×œ×¤× ×™ ×”-צ.
+
+ההבדל בין "מחיקה" ("deletion") ו-"גזירה" ("killing") ×”×•× ×©×”×˜×§×¡×˜
+"הגזור" ניתן ל×חזור ולהכנסה (×‘×ž×§×•× ×›×œ×©×”×•× ×‘×˜×§×¡×˜), ו×ילו טקסט "מחוק" ל×
+ניתן להכניס מחדש בשיטה זו. (×בל ניתן לבטל ×ת מחיקה -- ר××” להלן.) ×חזור
+הטקסט הגזור × ×§×¨× "הדבקה" ("yanking"). ב×ופן כללי, פקודות ×שר עלולות
+×œ×”×¢×œ×™× ×›×ž×•×™×•×ª גדולות של טקסט תמיד גוזרות ×ת הטקסט (כך שניתן ×™×”×™×” בקלות
+לשחזרו) בעוד הפקודות שמורידות תו בודד ×ו שורות ריקות ותוי רווח --
+מוחקות (כך ×©×œ× × ×™×ª×Ÿ להדביק ×ת הטקסט שנמחק). כך, <Delback> ו-C-d מוחקי×
+×›×שר ×ž×¤×¢×™×œ×™× ××•×ª× ×œ×œ× ×רגומנט, ×בל ×’×•×–×¨×™× ×›×שר ×ž×¤×¢×™×œ×™× ××•×ª× ×¢× ×רגומנט.
+
+>> הניעו ×ת הסמן לתחילת שורה ש××™× ×” ריקה. ×חר-כך הקישו C-k כדי לגזור
+   ×ת כל הטקסט של ×ותה שורה.
+>> הקישו C-k ×¤×¢× × ×•×¡×¤×ª. שימו לב ×©×”×•× ×’×•×–×¨ ×ת ×”-Newline שבסוף השורה.
+
+שימו לב ש-C-k בודד גוזר ×ת תכולת השורה, ו-C-k נוסף גוזר ×’× ×ת השורה
+עצמה ×•×’×•×¨× ×œ×©×ר השורות לנוע כלפי מעלה. C-k מפרש ×ת ×”×רגומנט הנומרי
+ב×ופן מיוחד: ×”×•× ×’×•×–×¨ כמספר ×”×–×” שורות, כולל ×”-Newlines שלהן. ×–×” שונה
+×ž×¡×ª× ×”×¤×¢×œ×” חוזרת: C-u 2 C-k גוזר שתי שורות כולל ×”-Newlines שלהן,
+ו×ילו הקשה על C-k ×¤×¢×ž×™×™× ×œ× ×¢×•×©×” כן.
+
+×חזור הטקסט שגזרנו × ×§×¨× "הדבקה" ("yanking"). (תחשבו על ×–×” כעל שליפה
+של טקסט ×ž×ª×”×•× ×”× ×©×™×™×” ×ליה ×”×•× × ×œ×§×—.) ניתן להדביק ×ת הטקסט שגזרת×
+ב×ותו ×ž×§×•× ×ž×ž× ×• נגזר ×ו ×‘×ž×§×•× ×חר כלשהו בתוך הטקסט ש××ª× ×¢×•×¨×›×™×, ×ו
+×פילו בקובץ ×חר. ניתן להדביק ×ת ×ותו הטקסט מספר ×¤×¢×ž×™× ×•×‘×›×š ליצור
+×¢×•×ª×§×™× ×ž×¨×•×‘×™× ×ž×ž× ×•. תוכניות עריכה ×חרות משתמשות ×‘×ž×•× ×—×™× "cutting"
+ו-"pasting" ×‘×ž×§×•× "killing" ו-"yanking" (ר××” ×ת מילון ×”×ž×•× ×—×™× ×‘×¤×¨×§
+ה-"Glossary" של מדריך למשתמשי Emacs).
+
+הפקודה להדבקה ×”×™× C-y. ×”×™× ×ž×›× ×™×¡×” ×ת הטקסט הגזור ×‘×ž×§×•× ×”× ×•×›×—×™ של הסמן.
+
+>> נסו ×–×ת: הקישו C-y כדי ל×חזר טקסט ×©×’×–×¨×ª× ×§×•×“× ×œ×›×Ÿ.
+
+×× ×ª×§×™×©×• C-k מספר ×¤×¢×ž×™× ×‘×¨×¦×£, כל הטקסט ×©×’×–×¨×ª× ×‘×“×¨×š זו נשמר ביחד, כך
+ש-C-y בודד ידביק ×ת כולו בבת ×חת.
+
+>> עשו ×–×ת עתה: הקישו C-k כמה פעמי×.
+
+עכשיו ל×חזור הטקסט שגזרת×:
+
+>> הקישו C-y. ×חר-כך הניעו ×ת הסמן כמה שורות כלפי מטה והקישו C-y שוב.
+   כפי שר×ית×, כך תוכלו להעתיק חלק מהטקסט ×ž×ž×§×•× ×œ×ž×§×•×.
+
+מה לעשות ×× ×™×© ×œ×›× ×˜×§×¡×˜ להדבקה, ×בל ×‘×™× ×ª×™×™× ×’×–×¨×ª× ×˜×§×¡×˜ ×חר? C-y ידביק
+רק ×ת הגזירה ×”×חרונה. ××•×œ× ×”×˜×§×¡×˜ ×©×’×–×¨×ª× ×§×•×“× ×œ×›×Ÿ ×ינו הלך ל×יבוד. ניתן
+ל×חזרו בעזרת הפקודה M-y. ×חרי ×©×”×§×©×ª× C-y שמדביק ×ת הטקסט שגזרת×
+ל×חרונה, הקשה על M-y מחליפה ×ת הטקסט המודבק בטקסט ×©×’×–×¨×ª× ×‘×¤×¢× ×œ×¤× ×™
+×”×חרונה. הקשה חוזרת ונשנית על M-y מבי××” טקסט ×©×’×–×¨×ª× ×‘×¤×¢×ž×™× ×§×•×“×ž×•×ª יותר
+ויותר. כשתר×ו שהטקסט המודבק ×”×•× ×ž×” ×©×¨×¦×™×ª× ×œ×”×“×‘×™×§, תפסיקו להקיש M-y
+ותמשיכו בעריכה כרגיל. ×ין צורך ×‘×©×•× ×¤×§×•×“×” מיוחדת ×œ×©× ×›×š.
+
+×× ×ª×§×™×©×• M-y מספיק ×¤×¢×ž×™× ×‘×–×• ×חר זו, תגיעו חזרה לנקודת ההתחלה (טקסט
+×©×’×–×¨×ª× ×œ×חרונה).
+
+>> גזרו שורה, ×חר-כך תניעו ×ת הסמן ×× ×” ו×× ×”, ולבסוף גזרו שורה נוספת.
+   הקישו C-y כדי ל×חזר ×ת השורה השניה שגזרת×.
+   עתה הקישו M-y והשורה ש××—×–×¨×ª× ×ª×•×—×œ×£ בשורה הר×שונה שגזרת×.
+   הקישו M-y מספר ×¤×¢×ž×™× × ×•×¡×¤×•×ª ושימו לב לתוצ×ות. המשיכו להקיש M-y
+   עד שהשורה השניה ×©×’×–×¨×ª× ×ª×•×¤×™×¢ שוב, ו××– תמשיכו עוד מספר פעמי×.
+   ×× ×ª×¨×¦×•, תוכלו לנסות M-y ×¢× ×רגומנט חיובי ×ו שלילי.
+
+
+* ביטול פעולות
+--------------
+
+×× ×©×™× ×™×ª× ×ת הטקסט ו××– ×”×—×œ×˜×ª× ×©×”×©×™× ×•×™ ×”×™×” טעות, תוכלו לבטל ×ת השינוי
+בעזרת פקודת הביטול, C-x u.
+
+בדרך כלל, C-x u מבטל ×ת ×”×©×™× ×•×™×™× ×©×‘×•×¦×¢×• ×¢"×™ פקודה ×חת. הפעלה חוזרת של
+C-x u ברצף מבטלת ×©×™× ×•×™×™× ×©×œ פקודות קודמות, ×חת ×חרי השניה.
+
+שני יוצ××™× ×ž×”×›×œ×œ ×”×–×”: פקודות ש×ינן משנות טקסט (למשל פקודות הנעת הסמן
+ופקודות גלילה) ×ינן נספרות ×•×ª×•×™× ×©×ž×›× ×™×¡×™× ×ת ×¢×¦×ž× ×ž×§×•×‘×¦×™× ×‘×§×‘×•×¦×•×ª של
+עד 20, כדי להקטין ×ת מספר ×”×¤×¢×ž×™× ×©×™×© להקיש C-x u כדי לבטל הכנסת טקסט.
+
+>> גזרו שורה זו ×¢× C-k, ×חר-כך הקישו C-x u ×•×”×™× ×ª×•×¤×™×¢ שוב.
+
+â€C-_‎ ×”×™× ×” דרך חלופית להפעיל ×ת פקודת הביטול. ×”×™× ×¤×•×¢×œ×ª בדיוק כמו C-x u,
+×בל קלה יותר להקשה מספר ×¤×¢×ž×™× ×‘×–×• ×חר זו. החסרון של C-_‎ ×”×•× ×©×‘×›×ž×”
+מקלדות ×œ× ×‘×¨×•×¨ מ×ליו כיצד להקיש ×–×ת. זו הסיבה לקיומו של C-x u. במקלדות
+×חדות ניתן להקיש C-_‎ ×¢"×™ החזקת CONTROL והקשת לוכסן /.
+
+×רגומנט נומרי ל-C-_‎ ×ו ל-C-x u משמש כמספר החזרות על הפקודה.
+
+ניתן לבטל מחיקה של טקסט בדיוק כמו שניתן לבטל גזירה. ×”×”×‘×“×œ×™× ×‘×™×Ÿ מחיקה
+וגזירה ×ž×©×¤×™×¢×™× ×¢×œ ×™×›×•×œ×ª×›× ×œ×”×“×‘×™×§ ×ת הטקסט הגזור ×¢× C-y; ×”× ××™× × ×—×©×•×‘×™×
+לעניין הביטול.
+
+
+* קבצי×
+-------
+
+על-מנת שהטקסט ×©×¢×¨×›×ª× ×™×™×©×ž×¨, יש ×œ×©×™× ×ותו בקובץ. ×חרת, ×”×•× ×™×™×¢×œ× ×‘×¨×’×¢
+שתצ×ו מ-Emacs. כדי ×œ×©×™× ×ת הטקס בקובץ, יש "לפתוח" ("find") ×ת הקובץ
+לפני ×©×ž×ª×—×™×œ×™× ×œ×”×§×™×© טקסט. (×©× ×חר לכך ×”×•× "לפקוד" ×ת הקובץ - "visit".)
+
+פתיחת הקובץ משמעותה שתוכן הקובץ מוצג בתוך Emacs. מבחינות רבות הדבר
+דומה לעריכת הקובץ עצמו. ×ול×, ×”×©×•× ×™×™× ×©×œ×›× ×‘×ª×•×š Emacs ××™× × ×”×•×¤×›×™× ×—×œ×§
+מהקובץ עד ש××ª× "שומרי×" ×ת הקובץ. ×–×ת, כדי להימנע מיצירת קובץ ש×ינו
+×©×œ× ×‘×ž×¢×¨×›×ª ×©×œ× ×›×¨×¦×•× ×›×. ×פילו ×× ××ª× ×©×•×ž×¨×™× ×ת הקובץ, Emacs מש×יר ×ת
+התוכן המקורי ×‘×©× ×©×•× ×” למקרה שמ×וחר יותר תחליטו ×©×”×©×™× ×•×™×™× × ×¢×©×• בטעות.
+
+×× ×ª×‘×™×˜×• בחלק התחתון של התצוגה, תר×ו ×©× ×©×•×¨×” בולטת שמתחילה ומסתיימת
+×‘×ž×§×¤×™× ×•×œ×™×“ הקצה השמ×לי שלה כתוב "TUTORIAL.he". חלק ×–×” של התצוגה בדרך
+כלל מציג ×ת ×©× ×”×§×•×‘×¥ ×ותו ××ª× ×¤×•×§×“×™×. כרגע ××ª× ×¤×•×§×“×™× ×§×•×‘×¥ בש×
+"TUTORIAL.he" ×©×”×•× ×¢×•×ª×§ הטיוטה ×”×ישי ×©×œ×›× ×©×œ שיעור השימוש ב-Emacs.
+פתיחת קובץ כלשהו ב-Emacs תציג ×ת שמו של הקובץ ×‘×ž×§×•× ×–×”.
+
+היבט ×חד מיוחד של פתיחת קובץ ×”×•× ×©×™×© לציין ×ת ×©× ×”×§×•×‘×¥ ×שר ברצונכ×
+לפתוח. ×נו ××•×ž×¨×™× ×©×”×¤×§×•×“×” "קור×ת ×רגומנט מהמסוף" (במקרה ×–×” ×”×רגומנט
+×”×•× ×©× ×”×§×•×‘×¥). ×חרי שתקישו ×ת הפקודה
+
+	â€C-x C-f    פתח קובץ
+
+â€Emacs מבקש שתקישו ×ת ×©× ×”×§×•×‘×¥. ×©× ×”×§×•×‘×¥ שתקישו מופיע בשורה התחתונה של
+התצוגה. שורה זו נקר×ת "מיני-חוצץ" ("minibuffer") ×›×©×”×™× ×ž×©×ž×©×ª לסוג ×–×”
+של קלט. ניתן להשתמש בכל פקודות העריכה הרגילות של Emacs ×›×©×ž×§×™×©×™× ×ת
+×©× ×”×§×•×‘×¥ בחוצץ ×–×”.
+
+×× ×˜×¨× ×¡×™×™×ž×ª× ×œ×”×§×™×© ×ת ×©× ×”×§×•×‘×¥ (×ו כל סוג ×חר של קלט במיני-חוצץ),
+ניתן לבטל ×ת הפקודה בעזרת C-g.
+
+>> הקישו C-x C-f ו×חר-כך הקישו C-g. ×–×” מבטל ×ת המיני-חוצץ ×•×’× ×ž×‘×˜×œ
+   ×ת הפקודה C-x C-f שהשתמשה במיני-חוצץ. התוצ××” ×”×™× ×©××£ קובץ ×œ× × ×¤×ª×—.
+
+×ž×©×¡×™×™×ž×ª× ×œ×”×§×™×© ×ת ×©× ×”×§×•×‘×¥, הקישו <Return> ×œ×¡×™×™× ×ת הקלט. ×ו-××– תיגש
+C-x C-f לעבודה ×•×ª×ž×¦× ×•×ª×¤×ª×— ×ת הקובץ שבחרת×. המיני-חוצץ × ×¢×œ× ×›×שר
+פקודת ×”-C-x C-f ×ª×¡×™×™× ×ת עבודתה.
+
+זמן קצר ×חר-כך תוכן הקובץ יופיע על-גבי התצוגה ותוכלו לבצע בו שינויי×.
+כשתחליטו לשמור ×ת השינויי×, הקישו ×ת הפקודה הב××”:
+
+	â€C-x C-s    שמור ×ת הקובץ
+
+פקודה זו שומרת בקובץ ×ת הטקסט המוחזק בתוך Emacs. ×‘×¤×¢× ×”×¨×שונה שתפעילו
+פקודה זו, Emacs משנה ×ת ×©× ×”×§×•×‘×¥ המקורי ×œ×©× ×—×“×© כך שהמקור ×œ× ×™×œ×š
+ל×יבוד. ×”×©× ×”×—×“×© נוצר ×¢"×™ הוספת "~" בסוף ×”×©× ×”×ž×§×•×¨×™ של הקובץ.
+
+כשהשמירה מסתיימת, Emacs מציג בשורה התחתונה ×ת ×©× ×”×§×•×‘×¥ שנשמר. נסו
+לשמור ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª על-מנת להימנע מל×בד יותר מדי מהעבודה ×©×œ×›× ×× ×”×ž×—×©×‘
+ייפול (ר××” להלן פיסקה על שמירה ×וטומטית).
+
+>> הקישו C-x C-s כדי לשמור ×ת העותק ×©×œ×›× ×©×œ השיעור.
+   כתוצ××”, תופיע ההודעה "Wrote ... TUTORIAL.he" בתחתית התצוגה.
+
+ניתן לפתוח קובץ ×§×™×™× ×¢×œ-מנת לצפות בו ×ו לערוך ×ותו. ניתן ×’× ×œ×¤×ª×•×— קובץ
+ש×ינו קיי×. זו הדרך ליצור ×§×‘×¦×™× ×—×“×©×™× ×‘×¢×–×¨×ª Emacs: פתחו ×ת הקובץ
+שיהיה תחילה ריק ו××– התחילו להקיש טקסט לתוכו. כשתפעילו ×ת פקודת השמירה,
+Emacs ייצור ×ת הקובץ ×¢× ×”×˜×§×¡×˜ שהקשת×. מ×ותו רגע ו×ילך, תוכלו לחשוב
+×©×”×™× ×›× ×¢×•×¨×›×™× ×§×•×‘×¥ קיי×.
+
+
+* חוצצי×
+--------
+
+×× ×ª×¤×ª×—×• קובץ נוסף ×¢× C-x C-f, הקובץ הר×שון עדיין נש×ר פתוח ב-Emacs.
+תוכלו לחזור ×ליו ×¢"×™ C-x C-f. כך תוכלו לפתוח מספר רב של קבצי×.
+
+>> ניצור עתה קובץ ×‘×©× "foo" ×¢"×™ הקשת C-x C-f foo <Return>‎.
+   ×חר-כך הכניסו קצת טקסט, ערכו ×ותו ולבסוף שמרו בקובץ "foo"
+   ע"י C-x C-s. עתה חזרו לשיעור בעזרת C-x C-f TUTORIAL.he <Return>‎.
+
+â€Emacs מחזיק כל קובץ בתוך יישות ×‘×©× "חוצץ" ("buffer"). פתיחת קובץ יוצרת
+חוצץ חדש בתוך Emacs. כדי לר×ות ×ת רשימת ×”×—×•×¦×¦×™× ×”×§×™×™×ž×™× ×‘×ª×•×š Emacs,
+הקישו
+
+	â€C-x C-b    הצג רשימת כל החוצצי×
+
+>> נסו ×ת C-x C-b בנקודה זו.
+
+שימו לב שלכל חוצץ יש ×©× ×•×›×œ חוצץ עשוי ×’× ×œ×¦×™×™×Ÿ ×ת ×©× ×”×§×•×‘×¥ ש×ת תוכנו
+×”×•× ×ž×—×–×™×§. כל טקסט ש××ª× ×ž×§×™×©×™× ×‘×—×œ×•×Ÿ Emacs תמיד ×™×”×™×” חלק של חוצץ
+כלשהו.
+
+>> הקישו C-x 1 כדי להפטר מרשימת החוצצי×.
+
+×›×©×§×™×™×ž×™× ×ž×¡×¤×¨ חוצצי×, רק ×חד ×ž×”× ×™×›×•×œ להיות החוצץ "הנוכחי" בכל רגע
+נתון. זהו החוצץ בו ××ª× ×ž×‘×¦×¢×™× ×¢×¨×™×›×” ב×ותו רגע. ×× ×‘×¨×¦×•× ×›× ×œ×¢×¨×•×š חוצץ
+×חר, ×¢×œ×™×›× "לעבור" חוצץ. עבור ×—×•×¦×¦×™× ×©×ž×ª××™×ž×™× ×œ×§×‘×¦×™×, ניתן לעשות ×–×ת
+×¢"×™ C-x C-f שיפקוד ×ת הקובץ בשנית. ×בל קיימת דרך פשוטה יותר: שימוש
+בפקודה C-x b. פקודה זו תחייב ××•×ª×›× ×œ×”×§×™×© ×ת ×©× ×”×—×•×¦×¥.
+
+>> הקישו C-x b foo <Return>‎ כדי לחזור לחוצץ "foo" ×שר מחזיק טקסט של
+   הקובץ "foo". ×חר-כך הקישו C-x b TUTORIAL.he <Return>‎ כדי לשוב
+   לשיעור זה.
+
+ברוב ×”×ž×§×¨×™× ×©× ×”×—×•×¦×¥ ×–×”×” ×œ×©× ×”×§×•×‘×¥ (×œ×œ× ×©× ×”×ª×™×§×™×” שלו). ×בל ×ין ×–×”
+תמיד כך. רשימת ×”×—×•×¦×¦×™× ×©× ×•×¦×¨×ª ×¢"×™ C-x C-b תמיד תציג ×ת שמות כל החוצצי×
+×”×§×™×™×ž×™× ×‘-Emacs.
+
+כל טקסט שמוצג בחלון של Emacs הינו תמיד חלק של חוצץ כלשהו. קיימי×
+×—×•×¦×¦×™× ×©××™× × ×§×©×•×¨×™× ×œ×©×•× ×§×•×‘×¥. לדוגמ×, החוצץ ×‘×©× "*Buffer List*" ×ינו
+מציג ×©×•× ×§×•×‘×¥. זהו חוצץ המחזיק ×ת רשימת ×”×—×•×¦×¦×™× ×©× ×•×¦×¨ ×¢"×™ C-x C-b.
+חוצץ ×‘×©× "*Messages*" ××£ ×”×•× ×ינו קשור ×œ×©×•× ×§×•×‘×¥; ×”×•× ×ž×—×–×™×§ ×ת ההודעות
+שהופיעו בשורה התחתונה במהלך ×¢×‘×•×“×ª×›× ×‘×ª×•×š Emacs.
+
+>> הקישו C-x b *Messages* <Return>‎ כדי לצפות בחוצץ של הודעות.
+   ×חר-כך הקישו C-x b TUTORIAL.he <Return>‎ על-מנת לחזור לשיעור ×–×”.
+
+×× ×¢×©×™×ª× ×©×™× ×•×™×™× ×‘×˜×§×¡×˜ של קובץ ו×חר-כך ×¤×ª×—×ª× ×§×•×‘×¥ ×חר, ×ין הדבר שומר
+×ת ×”×©×™× ×•×™×™× ×©×¢×©×™×ª× ×œ×§×•×‘×¥ הר×שון. ×”×©×™× ×•×™×™× ×”×œ×œ×• נש××¨×™× ×‘×ª×•×š Emacs, בתוך
+החוצץ של ×ותו קובץ. יצירתו ועריכתו של הקובץ הנוסף ××™× × ×ž×©×¤×™×¢×™× ×¢×œ
+החוצץ של הקובץ הר×שון. דבר ×–×” ×”×•× ×©×™×ž×•×©×™, ×ך משמעותו ×”×™× ×©×™×© צורך
+בשיטה נוחה לשמור ×ת החוצץ של הקובץ הר×שון. ×”×™×” ×–×” מ×ד ×œ× × ×•×— ×ילו
+×œ×©× ×›×š ×”×™×™×ª× ×¦×¨×™×›×™× ×œ×¢×‘×•×¨ לחוצץ ×”×”×•× ×‘×¢×–×¨×ª C-x C-f ו××– לשמור ×¢×
+C-x C-s. לכן קיימת פקודה
+
+	â€C-x s     שמור ×—×•×¦×¦×™× ×חדי×
+
+â€C-x s עובר על כל ×”×—×•×¦×¦×™× ×שר ×ž×›×™×œ×™× ×©×™× ×•×™×™× ×©×˜×¨× × ×©×ž×¨×•. לגבי כל חוצץ
+×›×–×” ×”×•× ×©×•×ל ××ª×›× ×”×× ×œ×©×ž×•×¨ ×ותו ×ו ל×.
+
+>> הכניסו שורה של טקסט ו×חר-כך הקישו C-x s.
+   ×”×•× ×¦×¨×™×š לש×ול ×”×× ×œ×©×ž×•×¨ חוצץ ×‘×©× TUTORIAL.he.
+   השיבו בחיוב ע"י הקשה על "y".
+
+
+* הרחבת ×וסף הפקודות
+--------------------
+
+מספר הפקודות ב-Emacs גדול בהרבה ממה שניתן להפעיל ע"י כל תוי ה-control
+וה-meta. כדי להתגבר על בעיה זו, Emacs משתמש בפקודות X המרחיבות (eXtend)
+×ת ×וסף הפקודות הרגיל. פקודות הרחבה ×לו הן שתי×:
+
+	â€C-x     הרחבת תו. תו בודד ×©×‘× ×חריו ×ž×©×œ×™× ×ת הפקודה.
+	â€M-x     הרחבה ×¢"×™ ×©× ×”×¤×§×•×“×”. ×חריו ×‘× ×©× ×רוך של פקודה.
+
+בעזרת שתי ×לו ניתן להפעיל פקודות שימושיות שבהן ×ž×©×ª×ž×©×™× ×œ×¢×ª×™× ×¨×—×•×§×•×ª
+יותר מ×שר פקודות ×©×œ×ž×“×ª× ×¢×“ עכשיו. כמה מהן כבר ר×ית×: C-x C-f לפתיחת
+קובץ, ו-C-x C-s לשמירת קובץ, לדוגמ×. ×“×•×’×ž× × ×•×¡×¤×ª ×”×™× ×¤×§×•×“×” לצ×ת
+מ-Emacs -- â€C-x C-c. (כש××ª× ×ž×¤×¢×™×œ×™× C-x C-c, ×ל תד×גו ×œ×©×™× ×•×™×™× ×©×˜×¨×
+נשמרו; C-x C-c מציע לשמור כל קובץ ×©×©×™× ×™×ª× ×œ×¤× ×™ ×©×”×•× ×ž×¡×™×™× ×ת Emacs.)
+
+×× ××ª× ×ž×©×ª×ž×©×™× ×‘×¦×’ גרפי ×שר תומך במספר תוכניות במקביל, ××™× ×›× ×–×§×•×§×™×
+לפקודה מיוחדת כדי לעבור מ-Emacs לתוכנית ×חרת. ×פשר לעשות ×–×ת בעזרת
+העכבר ×ו פקודות של מנהל החלונות. ×ול×, ×›×שר ××ª× ×ž×©×ª×ž×©×™× ×‘×ª×¦×•×’×”
+טקסטו×לית שמסוגלת להציג רק תוכנית ×חת בו-זמנית, תצטרכו "להשעות"
+("suspend") ×ת Emacs על-מנת לעבור לתוכנית ×חרת.
+
+הפקודה C-z יוצ×ת מ-Emacs *ב×ופן זמני* -- כך שתוכלו לשוב ×ליו מ×וחר
+יותר ולהמשיך מ×ותה נקודה. ×›×שר Emacs רץ על תצוגת טקסט, C-z "משעה" ×ת
+Emacs: ×”×•× ×ž×—×–×™×¨ ××ª×›× ×œ×©×•×¨×ª הפקודות הבסיסית של מערכת ההפעלה ("shell"),
+×בל ×ינו ×ž×¡×™×™× ×ת Emacs. ברוב המערכות, כדי להמשיך ×‘×¢×‘×•×“×ª×›× ×‘-Emacs,
+תצטרכו להקיש ×ת הפקודה "fg" ×ו ‭"%emacs"‬.
+
+הרגע הנכון להשתמש ב-C-x C-c ×”×•× ×›×שר ××ª× ×¢×•×ž×“×™× ×œ×”×ª× ×ª×§ (log out).
+כמו-כן, תצטרכו להשתמש בו כדי לצ×ת מ-Emacs שהופעל ×¢"×™ תוכניות ×חרות
+כגון קרי×ת דו×ר ×לקטרוני -- תוכניות ×לו ×œ× ×ª×ž×™×“ יודעות להסתדר ×¢×
+השעיית Emacs.
+
+קיימות פקודות C-x רבות מ×ד. להלן רשימת ×לו שכבר למדת×:
+
+	â€C-x C-f 	פתח קובץ
+	â€C-x C-s 	שמור קובץ
+	â€C-x s  	שמור ×—×•×¦×¦×™× ×חדי×
+	â€C-x C-b 	הצג רשימת חוצצי×
+	â€C-x b  	החלף חוצץ
+	â€C-x C-c 	×¦× ×ž-Emacs
+	â€C-x 1  	הש×ר רק חלון ×חד ומחק כל הש×ר
+	â€C-x u  	בטל פקודה ×חרונה
+
+הרחבה ×¢"×™ ×©× ×”×¤×§×•×“×” שימושית ×¢× ×¤×§×•×“×•×ª עוד יותר נדירות ×ו פקודות
+ספציפיות רק ל×ופני פעולה (modes) מיוחדי×. ×“×•×’×ž× ×œ×›×š ×”×™× ×¤×§×•×“×”
+replace-string (החלף מחרוזת) ×שר מחליפה מחרוזת ×חת במשנה בכל החוצץ.
+×חרי שתקישו M-x, â€Emacs מציג M-x בתחתית התצוגה ומחכה שתקישו ×ת ש×
+הפקודה, במקרה זה "replace-string". מספיק שתקישו "repl s<TAB>‎" ו-Emacs
+×™×©×œ×™× ×ת ×”×©× ×”×ž×œ×. (<TAB> ×”×•× ×ž×§×© Tab, בדרך כלל תמצ×ו ×ותו מעל מקש
+×”-CapsLock ×ו Shift, ליד הקצה השמ×לי של המקלדת.) סיימו ×ת ×©× ×”×¤×§×•×“×”
+ע"י הקשת <Return>.
+
+הפקודה להחלפת מחרוזת זקוקה לשני ××¨×’×•×ž× ×˜×™× -- המחרוזת שתוחלף וזו שתחליף
+×ותה. סיימו הקשה של כל ×חת מהן ×¢"×™ <Return>.
+
+>> הבי×ו ×ת הסמן שתי שורות מתחת לשורה זו.
+   עתה הקישו M-x repl s<Return>changed<Return>altered<Return>‎.
+
+   שימו לב שהמילה "changed" בשורה זו שתנתה: ×–×” עתה ×”×—×œ×¤×ª× ×ת
+   המילה c-h-a-n-g-e-d במילה "altered" בכל ×ž×§×•× ×‘×• ×”×™× × ×ž×¦×ת ×חרי
+   הסמן.
+
+
+* שמירה ×וטומטית
+----------------
+
+×©×™× ×•×™×™× ×©×¢×¨×›×ª× ×‘×§×•×‘×¥ ×בל ×˜×¨× ×©×ž×¨×ª× ×¢×œ×•×œ×™× ×œ×œ×›×ª ל×יבוד ×× ×”×ž×—×©×‘ שלכ×
+נתקע. על-מנת להגן ×¢×œ×™×›× ×ž×¤× ×™ סכנה זו, Emacs שומר ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª כל קובץ
+×©× ×ž×¦× ×‘×¢×¨×™×›×”. השמירה ×”×וטומטית ×”×–×ת נעשית לקובץ נפרד ששמו מתחיל
+×•×ž×¡×ª×™×™× ×‘×ª×• #. לדוגמ×, ×× ×”×™× ×›× ×¢×•×¨×›×™× ×§×•×‘×¥ ×‘×©× "hello.c", קובץ השמירה
+×”×וטומטית שיווצר עבורו ×™×™×§×¨× "#hello.c#". שמירה רגילה של הקובץ על ידכ×
+מוחקת ×ת קובץ השמירה ×”×וטומטית.
+
+×× ×”×ž×—×©×‘ ×כן נתקע, תוכלו לנציל ×ת ×”×©×™× ×•×™×™× ×©×œ× ×”×¡×¤×§×ª× ×œ×©×ž×•×¨. ×œ×©× ×›×š,
+יש לפתוח ×ת הקובץ כרגיל (×ת הקובץ בשמו המקורי, ×œ× ×ת קובץ השמירה
+×”×וטומטית), ו×חר-כך להקיש M-x recover-file <Return>‎. כש-Emacs יבקש
+×ישור, הקישו yes<Return>‎ כדי ש-Emacs ישחזר ×ת הקובץ כפי שנשמר
+×וטומטית.
+
+
+* תצוגת הד
+----------
+
+×× Emacs מגלה ש××ª× ×ž×§×™×©×™× ×¤×§×•×“×” ל×ט, ×”×•× ×ž×¦×™×’ ×ת ×©×”×§×©×ª× ×‘×ª×—×ª×™×ª התצוגה,
+ב×זור ×©× ×§×¨× "×זור תצוגת הד". ×זור ×–×” משתמש בשורה התחתונה של התצוגה.
+
+
+* שורת סטטוס
+------------
+
+השורה שמעל ×זור תצוגת הד נקר×ת "שורת הסטטוס" (mode line). שורה זו
+מציגה משהו כמו:
+
+    -U:**-  TUTORIAL.he    63% L651    (Fundamental)-----------------------
+
+שורה זו מציגה מידע חשוב לגבי מצבו של Emacs ולגבי הטקסט ×©× ×ž×¦× ×‘×¢×¨×™×›×”.
+
+××ª× ×›×‘×¨ ×™×•×“×¢×™× ×ž×”×™ משמעותו של ×©× ×”×§×•×‘×¥ -- זהו הקובץ שפתחת×. NN%‎ מציין
+×ת ×ž×™×§×•×ž×›× ×”× ×•×›×—×™ בתוך הטקסט, ל×מור ×›×™ NN ××—×•×–×™× ×ž×”×˜×§×¡×˜ ×§×•×“×ž×™× ×œ×˜×§×¡×˜
+המוצג כרגע בחלון. ×× ×”×ž×•×¦×’ בחלון כולל ×ת תחילת הטקסט, תר×ו ×©× "Top"
+×‘×ž×§×•× "0% ". ×× ×”×ž×•×¦×’ בחלון כולל ×ת סוף הטקסט, תר×ו ×©× "Bot" â€(bottom).
+×× ×”×˜×§×¡×˜ כל-כך קצר שכולו מוצג בחלון, שורת הסטטוס תציג "All".
+
+×”×ות L והמספר ש×חריה ×ž×¦×™×™× ×™× ×ת ×”×ž×™×§×•× ×”× ×•×›×—×™ בדרך ×חרת: ×”× ×ž×¨××™× ×ת
+מספר השורה שבה × ×ž×¦× ×”×¡×ž×Ÿ.
+
+הכוכביות ליד הקצה השמ×לי משמעותן ×›×™ ×©×™× ×™×ª× ×ת הטקסט. מיד ×חרי פתיחת
+הקובץ ×ו ×חרי שמירתו החלק ×”×–×” של שורת הסטטוס ×ינו מציג כוכביות, ××œ× ×¨×§
+מקפי×.
+
+החלק שבתוך ×”×¡×•×’×¨×™×™× ×ומר ×œ×›× ×ž×”o ×ופני העריכה (editing modes) הפעילי×
+כעת. ברירת המחדל ×”×™× Fundamental, ×”×ופן הבסיס, שבו ××ª× ×ž×©×ª×ž×©×™× ×›×¢×ª.
+זוהי ×“×•×’×ž× ×©×œ "×ופן עריכה ר×שי" (major mode).
+
+ל-Emacs ×ופני עריכה ר××©×™×™× ×¨×‘×™× ×•×ž×’×•×•× ×™×. חלק ×ž×”× × ×•×¢×“×• לעריכה של שפת
+תכנות מסוימת ו/×ו סוג ×ž×¡×•×™× ×©×œ טקסט, כגון Lisp mode, Text mode וכד'.
+בכל רגע נתון רק ×ופן עיקרי ×חד יכול להיות פעיל ושמו תמיד מצויין בשורת
+הסטטוס ב×ותו ×ž×§×•× ×‘×• כרגע ××ª× ×¨×•××™× "Fundamental".
+
+כל ×ופן עיקרי ×’×•×¨× ×œ×›×ž×” פקודות לפעול בצורה מיוחדת. למשל, ישנן פקודות
+ליצירת הערות בתוך תוכנית, והיות וכל שפת תכנות מגדירה ×ת הפורמט של
+הערות בצורה ×חרת, כל ×ופן עיקרי חייב להכניס הערות בצורה שמת×ימה לשפה.
+כל ×ופן עיקרי הינו למעשה ×©× ×”×¤×§×•×“×” שבעזרתה ×פשר להפעיל ×ת ×ותו ×”×ופן.
+למשל הפקודה להפעיל ×ת ×”×ופן Fundamental ×”×™× ×” M-x fundamental-mode.
+
+×× ×‘×›×•×•× ×ª×›× ×œ×¢×¨×•×š טקסט בשפה ×נושית כלשהי, כמו הקובץ ×”×–×”, כד××™ לכ×
+להשתמש ב-Text mode.
+
+>> הקישו M-x text-mode <Return>‎.
+
+×ל ד××’×”: ××£ ×חת מפקודות Emacs ×©×œ×ž×“×ª× ×¢×“ ×›×” משנה ×ת התנהגותה ב×ופן
+מהותי. ×¢× ×–×ת, שימו לב ש-M-f ו-M-b ×ž×ª×™×™×—×¡×™× ×¢×›×©×™×• ל-'גרש' כחלק מהמילה.
+לפני-כן, ב-Fundamental mode, â€M-f ו-M-b התנהגו ×¢× ×”×’×¨×© כמפריד בין
+מילי×.
+
+××•×¤× ×™× ×¨××©×™×™× ×‘×“×¨×š-כלל ×ž×©× ×™× ×§×œ×•×ª ×ת התנהגות הפקודות: רוב הפקודות
+עדיין "עושות ×ותה עבודה" בכל ×”××•×¤× ×™× ×”×¨×שיי×, ×בל עושות ×ותה קצת ×חרת.
+
+לצפיה בתיעוד של ×”×ופן הר×שי הנוכחי יש להקיש C-h m.
+
+>> השתמשו ב-C-u C-v ×¤×¢× ×חת ×ו יותר כדי ×œ×”×‘×™× ×©×•×¨×” זו לר×שית התצוגה.
+>> עתה הקישו C-h m כדי לר×ות במה Text mode שונה מה-Fundamental mode.
+>> לבסוף, הקישו C-x 1 כדי לסלק ×ת התיעוד מהתצוגה.
+
+××•×¤× ×™× ×¨××©×™×™× × ×§×¨××™× ×›×š ×ž×©×•× ×©×§×™×™×ž×™× ×’× ×ופני-משנה (minor modes).
+×ופני משנה ××™× × ×ž×”×•×•×™× ×—×œ×•×¤×” ל××•×¤× ×™× ×”×¨×שיי×, ×”× ×¨×§ ×ž×©× ×™× ××•×ª× ×‘×ž×§×¦×ª.
+כל ×ופן-משנה ניתן להפעלה ×ו ביטול ×œ×œ× ×ª×œ×•×ª בכל ש×ר ×ופני המשנה ולל×
+תלות ב×ופן הר×שי הנוכחי. לכן תוכלו להפעיל ×ופן-משנה ×חד ×ו יותר, ×ו ××£
+×ופן-משנה.
+
+×חד מ×ופני-המשנה ×”×©×™×ž×•×©×™×™× ×‘×™×•×ª×¨, במיוחד ×œ×©× ×¢×¨×™×›×ª טקס בשפת-×נוש, הו×
+Auto Fill mode. ×›×שר ×ופן ×–×” מופעל, Emacs ×וטומטית פותח שורה חדשה
+×‘×¡×™×•× ×ž×™×œ×” ×× ×”×˜×§×¡×˜ ×©×”×§×©×ª× ×רוך מדי בשביל שורה ×חת.
+
+להפעלת Auto Fill mode יש להקיש M-x auto-fill-mode <Return>‎. ×›×שר ×ופן
+×–×” מופעל, ניתן לבטלו ×¢"×™ M-x auto-fill-mode <Return>‎. ×–×ת ×ומרת, פקודה
+זו מפעילה ×ת ×”×ופן כש×ינו פעיל ומבטלת ×ותו ×›×©×”×•× ×¤×¢×™×œ. לפעולה זו
+קור××™× "מיתוג" -- הפקודה "ממתגת" ×ת ×”×ופן.
+
+>> הקישו עתה M-x auto-fill-mode <Return>‎. ×חר-כך הקישו "שדגכ " (×¢×
+   הרווח בסוף) שוב ושוב עד שתיפתח שורה חדשה. ×”×¨×•×•×—×™× ×—×©×•×‘×™× ×ž×©×•×
+   ש-Auto Fill mode שובר שורות ×ך ורק ברווח שבין המלי×.
+
+×”×©×•×œ×™×™× (margin) ש-Emacs שומר בדרך-כלל ×ž×ª×—×™×œ×™× ×חרי 70 תווי×, ×בל ניתן
+לשנות הגדרה זו בעזרת הפקודה C-x f. פקודה זו מקבלת ×ת ההגדרה החדשה של
+×”×©×•×œ×™×™× ×›×רגומנט נומרי.
+
+>> הקישו C-x f ×¢× ×רגומנט של 20. (C-u 2 0 C-x f). ×חר-כך הקישו טקסט
+   כלשהו ושימו לב ש-Emacs פותח שורות חדשות ×חרי 20 ×ª×•×•×™× ×œ×›×œ היותר.
+   לבסוף, החזירו ×ת הגדרת ×”×©×•×œ×™×™× ×œ-70 ×¢"×™ שימוש חוזר ב-C-x f.
+
+×× ×¢×¨×›×ª× ×©×™× ×•×™×™× ×‘×מצע פסקה, Auto Fill mode ×œ× ×™×ž×œ× ×©×•×¨×•×ª מחדש ב×ופן
+×וטומטי.
+כדי ×œ×ž×œ× ×ž×—×“×© ×ת כל הפסקה הקישו M-q â€(META-q) כשהסמן × ×ž×¦× ×‘×ª×•×š
+הפסקה.
+
+>> הניעו ×ת הסמן לתוך הפסקה הקודמת והקישו M-q.
+
+
+* חיפוש
+-------
+
+â€Emacs יכול לחפש מחרוזות (רצף של ×ª×•×•×™× ×ו מילי×) קדימה ×ו ×חורה בתוך
+הטקסט. חיפוש של מחרוזת ×”×•× ×¡×•×’ של פקודה להנעת הסמן: ×”×•× ×ž×ž×§× ×ת הסמן
+היכן שנמצ××” המחרוזת הב××”.
+
+החיפוש של Emacs הינו "מצטבר" ("incremental"). פירוש הדבר ×”×•× ×©×”×—×™×¤×•×©
+מתבצע במקביל ×œ×”×§×©×ª×›× ×ת המחרוזת ×ותה ×‘×¨×¦×•× ×›× ×œ×ž×¦×•×.
+
+הפקודה להתחיל בחיפוש ×”×™× C-s לחיפוש קדימה ו-C-r לחיפוש ×חורה. חכו! ×ל
+תפעילו ×ותן עדיין.
+
+כשתקישו C-s, תר×ו שב×זור תצוגת ההד יופיע הטקסט "I-search". ×–×” ×ומר
+ש-Emacs × ×ž×¦× ×‘×ž×¦×‘ "חיפוש מצטבר" ("incremental search") ×•×”×•× ×ž×ž×ª×™×Ÿ
+×œ×”×§×©×ª×›× ×ת המחרוזת ×ותה ×‘×¨×¦×•× ×›× ×œ×ž×¦×•×. הקשה על <Return> מסיימת ×ת
+החיפוש.
+
+>> הקישו עתה C-s כדי להתחיל בחיפוש. ל×ט-ל×ט, ×ות-×ות, הקישו ×ת המילה
+   "סמן", ×¢× ×”×¤×¡×§×” ×חרי כל ×ות, ושימו לב להתנהגות הסמן.
+   ×–×” עתה מצ××ª× ×ת המילה "סמן" ×¤×¢× ×חת.
+>> הקישו C-s שוב, כדי ×œ×ž×¦×•× ×ת "סמן" במקומות × ×•×¡×¤×™× ×‘×˜×§×¡×˜.
+>> הקישו <Delback> שלוש ×¤×¢×ž×™× ×•×©×™×ž×• לב לתנועת הסמן בכל הקשה.
+>> הקישו <Return> ×œ×¡×™×•× ×”×—×™×¤×•×©.
+
+×”×× ×©×ž×ª× ×œ×‘ למה שקרה? במהלך "חיפוש מצטבר" Emacs מנסה ×œ×ž×¦×•× ×ת המקו×
+×”×‘× ×‘×• מופיעה המחרוזת שהקשת×. כדי ×œ×ž×¦×•× ×ת המחרוזת ×‘×ž×§×•× ×”×‘×, פשוט
+הקישו C-s ×¤×¢× × ×•×¡×¤×ª. ×× ×”×ž×—×¨×•×–×ª ××™× ×” נמצ×ת בהמשך הטקסט, Emacs מצפצף
+ומודיע שהחיפוש נכנס למצב של "כשלון" ("failing"). הקשה על C-g ×’× ×”×™×
+מסיימת ×ת החיפוש.
+
+(הערה: במערכות ×חדות הקשה על C-s מקפיעה ×ת תצוגת המסך, כך ×©×œ× ×ª×¨×ו
+יותר ×©×•× ×¤×œ×˜ של Emacs. משמעות הדבר שתכונת מערכת ההפעלה ששמה "flow
+control" מופעלת ×¢"×™ C-s ו××™× ×” מעבירה ×ת C-s ל-Emacs. לביטול הקפ×ת
+התצוגה במערכות ×לו יש להקיש C-q.)
+
+×× ×‘×ž×”×œ×š החיפוש תקישו על <Delback>, תר×ו שהתו ×”×חרון של המחרוזת
+המבוקשת נמחק והחיפוש חוזר ×œ×ž×§×•× ×”×§×•×“× ×‘×• נמצ××” המחרוזת ×œ×œ× ×”×ª×• ×”×חרון.
+למשל, × × ×™×— ×©×”×§×©×ª× "ס" על-מנת ×œ×ž×¦×•× ×ת ×”×ž×§×•× ×”×‘× ×‘×• מופיעה ×”×ות "ס". ××
+עכשיו תקישו "מ", הסמן יזוז ×œ×ž×§×•× ×‘×• × ×ž×¦× "סמ". עתה הקישו <Delback>.
+×”-"מ" נמחק מהמחרוזת והסמן חוזר ×œ×ž×§×•× ×‘×• ×”×•× ×ž×¦× ×ת "ס" לר×שונה.
+
+×× ×‘×ž×”×œ×š החיפוש תפעילו פקודה כלשהי ×¢"×™ הקשה על מקש תוך לחיצה על
+CONTROL ×ו META, החיפוש יסתיי×. (כמה ×ª×•×•×™× ×™×•×¦××™× ×ž×›×œ×œ ×–×” -- ×לו תווי×
+×ž×™×•×—×“×™× ×‘×¢×ª חיפוש, כדוגמת C-s ו-C-r.)
+
+הקשה על C-s מתחילה חיפוש שמנסה ×œ×ž×¦×•× ×ת המחרוזת _×חרי_ הסמן. ××
+×‘×¨×¦×•× ×›× ×œ×ž×¦×•× ×ž×©×”×• בטקסט ×”×§×•×“× ×œ×ž×§×•× ×”× ×•×›×—×™, הקישו C-r ×‘×ž×§×•× C-s. כל
+מה ש×מרנו לגבי C-s תקף ×’× ×œ×’×‘×™ C-r, ××œ× ×©×›×™×•×•×Ÿ החיפוש מתהפך.
+
+
+* חלונות מרובי×
+---------------
+
+×חת התכונות הנוחות של Emacs ×”×™× ×›×™ ניתן להציג יותר מחלון ×חד על המסך
+בו-זמנית. (הערה: Emacs משתמש במונח "frame" -- "תבנית" -- בשביל מה
+שתוכניות ×חרות מכנות "חלון". תבניות מתו×רות בפסקה הב××”. תוכלו ×œ×ž×¦×•× ×ת
+רשימת ×”×ž×•× ×—×™× ×©×œ Emacs בפרק "Glossary" של מדריך משתמש.)
+
+>> הבי×ו סמן לשורה זו והקישו C-u 0 C-l â€(CONTROL-L ×•×œ× CONTROL-1).
+
+>> עתה הקישו C-x 2 וכתוצ××” מכך החלון יתחלק לשניי×. כל ×חד משני החלונות
+   מציג ×ת השיעור ×”×–×”. הסמן נש×ר בחלון העליוןץ
+
+>> הקישו C-M-v כדי לגלול ×ת החלון התחתון.
+   (×× ×‘×ž×§×œ×“×ª ×©×œ×›× ×ין מקש META ×מיתי, הקישו ‎<ESC> C-v כתחליף.)
+
+>> הקישו C-x o â€("o" ×”×•× ×¨×ž×– ל-"other", "×חר") על-מנת להעביר ×ת הסמן
+   לחלון התחתון.
+>> הקישו C-v ו-M-v בחלון התחתון כדי לגלול ×ותו.
+   המשיכו ×œ×§×¨×•× ×”×•×¨×ות ×לו בחלון העליון.
+
+>> הקישו C-x o שוב לחזור לחלון העליון.
+   הסמן בחלון העליון ייש×ר ×‘×ž×§×•× ×‘×• ×”×•× ×”×™×” לפני-כן.
+
+תוכלו להמשיך להשתמש ב-C-x o כדי לדלג בין שני החלונות. לכל חלון מיקו×
+סמן משלו, ×בל רק חלון ×חד מציג ×ת הסמן בכל רגע. כל פקודות העריכה
+הרגילות פועלות על החלון שבו מוצג הסמן. ×נו קור××™× ×œ×—×œ×•×Ÿ ×–×” "החלון
+הנבחר".
+
+הפקודה C-M-v נוחה מ×ד ×›×שר ×”×™× ×›× ×¢×•×¨×›×™× ×˜×§×¡×˜ בחלון ×חד ×•×ž×©×ª×ž×©×™× ×‘×—×œ×•×Ÿ
+×חר לייחוס. תוכלו בכל עת לשמור על הסמן בחלון בו ××ª× ×¢×•×¨×›×™× ×˜×§×¡×˜
+×•×œ×”×ª×§×“× ×‘×—×œ×•×Ÿ השני בעזרת C-M-v.
+
+â€C-M-v ×”×™× ×“×•×’×ž× ×חת של פקודת CONTROL-META. ×× ×‘×ž×§×œ×“×ª ×©×œ×›× ×§×™×™× ×ž×§×©
+META ×מיתי, תוכלו להקיש ×ת הפקודה ×¢"×™ לחיצה והחזקה של מקשי CONTROL
+ו-META ×’× ×™×—×“ ו××– להקיש v. הסדר שבו תלחצו על CONTROL ו-META ×ינו משנה
+×›×™ שני ×”×ž×§×©×™× ×”×œ×œ×• ×¤×•×¢×œ×™× ×¢"×™ שינוי התו המוקש יחד ×ית×.
+
+×× ×ין במקלדת מקש META ×מיתי ו××ª× ×ž×©×ª×ž×©×™× ×‘-<ESC> כתחליף, הסדר כן
+משנה: ×—×™×™×‘×™× ×œ×”×§×™×© <ESC> ורק ל×חר מכן CONTROL-v, וז×ת משו×
+ש-CONTROL-<ESC> v ×œ× ×™×¢×‘×•×“. <ESC> ×”×•× ×ª×• בזכות עצמו, ×©×œ× ×›×ž×• CONTROL
+×ו META.
+
+>> הקישו C-x 1 (בחלון העליון) כדי לסלק ×ת החלון התחתון.
+
+(×ילו ×”×§×©×ª× C-x 1 בחלון התחתון, ×”×™×™×ª× ×ž×¡×œ×§×™× ×ת החלון העליון. תוכלו
+לחשוב על פקודה זו ×›-"הש×ר רק חלון ×חד -- החלון בו ×× ×™ × ×ž×¦× ×¢×ª×”".)
+
+×ין חובה להציג ×ת ×ותו החוצץ בשני החלונות. תוכלו להשתמש ב-C-x C-f
+לפתיחת קובץ ב×חד החלונות -- דבר ×–×” ×ינו משפיע על החלון השני. ×פשר ×’×
+לפתוח ×§×‘×¦×™× ×©×•× ×™× ×‘×›×œ ×חד משני החלונות ב×ופן בלתי-תלוי.
+
+×”× ×” עוד שיטה להשתמש בשני חלונות להצגה של שני ×“×‘×¨×™× ×©×•× ×™×:
+
+>> הקישו C-x 4 C-f ו×חר-כך הקישו ×©× ×©×œ ×חד ×”×§×‘×¦×™× ×©×œ×›×.
+   סיימו ×¢× <Return>. שימו לב שהקובץ המבוקש מוצג בחלון התחתון. הסמן
+   מדלג ×œ×©× ××£ הו×.
+
+>> הקישו C-x o לעבור לחלון העליון ו×חר-כך הקישו C-x 1 כדי לסלק ×ת
+   החלון התחתון.
+
+
+* תבניות מרובות
+---------------
+
+â€Emacs מסוגל לפתוח מספר "תבניות" ("frames") בתנ××™ ש××™× ×›× ×ž×©×ª×ž×©×™× ×‘×¦×’
+שמסוגל להציג רק טקסט. תבנית כוללת קבוצת חלונות, תפריט, פסי גלילה, ×זור
+תצוגת הד וכו'. (תוכניות ×חרות נוהגות ×œ×§×¨×•× ×œ×–×” "חלון".)
+
+>> הקישו M-x make-frame <Return>‎.
+   כתוצ××”, תבנית חדשה תופיע על המסך.
+
+כל מה ×©×¢×©×™×ª× ×‘×ª×‘× ×™×ª המקורית ניתן לעשות ×’× ×‘×ª×‘× ×™×ª החדשה. התבנית הר×שונה
+×ין בה ×©×•× ×“×‘×¨ מיוחד.
+
+>> הקישו M-x delete-frame <Return>‎.
+   התבנית שבה ×”×§×©×ª× ×ת הפקודה תיסגר ×•×ª×™×¢×œ× ×ž×”×ž×¡×š.
+
+כמו-כן, ניתן לסגור תבנית בדרך הרגילה הנתמכת ע"י מנהל החלונות של המערכת
+×©×œ×›× (בדרך-כלל, ×¢"×™ הקלקה על הכפתור המסומן ב-"X" בפינה עליונה של
+התבנית.) ×©×•× ×ž×™×“×¢ ×ינו הולך לעיבוד ×›×שר ×¡×•×’×¨×™× ×ª×‘× ×™×ª (×ו חלון). המידע
+×”×–×” פשוט יורד מהתצוגה, ×בל ניתן ל×חזרו מ×וחר יותר.
+
+
+* רמות עריכה רקורסיביות
+-----------------------
+
+יתכן ותיקלעו למצב שקרוי "רמת עריכה רקורסיבית". Emacs מציין ×–×ת ×¢"×™
+×¡×•×’×¨×™×™× ×ž×¨×•×‘×¢×™× ×‘×©×•×¨×ª הסטטוס מסביב ×œ×©× ×”×ופן הר×שי. למשל, יוצג ש×
+[(Fundamental)] ×‘×ž×§×•× (Fundamental).
+
+כדי להחלץ מרמת עריכה רקורסיבית יש להקיש <ESC> <ESC> <ESC>. זוהי פקודה
+כללית של "הימלטות". ניתן להשתמש בה ×’× ×›×“×™ לסלק חלונות ×ž×™×•×ª×¨×™× ×•×œ×™×¦×™××”
+מתוך מיני-חוצץ.
+
+>> הקישו M-x כדי להיכנס למיני-חוצץ; ×חר-כך הקישו <ESC> <ESC> <ESC> כדי
+   להיחלץ מש×.
+
+הקשה על C-g ×œ× ×ª×—×œ×¥ ××ª×›× ×ž×¨×ž×•×ª עריכה רקורסיביות. ×–×ת, ×ž×©×•× ×©-C-g מבטל
+פקודות ו××¨×’×•×ž× ×˜×™× _במסגרת_ הרמה הרקורסיבית, מבלי לצ×ת ממנה.
+
+
+* לקבלת עזרה נוספת
+------------------
+
+בשיעור הר×שון ×”×–×” השתדלנו לתת ×‘×™×“×™×›× ×ž×™×“×¢ ש×ך יספיק להתחלת השימוש שלכ×
+ב-Emacs. â€Emacs מכיל כל-כך הרבה ש×ין ×©×•× ×פשרות לת×ר ולהסביר ×›×ן ×ת
+הכל. ×ול×, סביר שתרצו ללמוד יותר על Emacs שכן יש בו עוד הרבה תכונות
+שימושיות. Emacs כולל פקודות ×œ×©× ×§×¨×™×ת תיעוד על הפקודות של Emacs.
+הפעלת פקודות "עזרה" ×לו תמיד מתחילה במקש CONTROL-h שעל-כן × ×§×¨× "מקש
+עזרה" ("help").
+
+להפעלת פקודות עזרה יש להקיש ×ת C-h ו×חר-כך עוד תו שמבקש עזרה מסוג
+מסויי×. ×× ××ª× _ב×מת_ ×בודי×, הקישו C-h ?‎ ו-Emacs יציג ×ת סוגי העזרה
+×©×”×•× ×ž×¢×ž×™×“ לרשותכ×. ×× ×”×§×©×ª× C-h ובסופו של דבר ×”×—×œ×˜×ª× ×©×ין צורך בשו×
+עזרה, פשוט הקישו C-g לבטל ×ת הפקודה.
+
+(×× ×”×§×©×ª C-h ××™× ×” מציגה בתחתית התצוגה הודעה בדבר עזרה, נסו להקיש F1 ×ו
+M-x help <Return>‎ כתחליף.)
+
+סוג העזרה הבסיס ביותר ×”×•× C-h c. הקישו C-h, ×חריו ×ת ×”×ות c ו××– הקישו
+סדרת ×ž×§×©×™× ×©×ž×¤×¢×™×œ×” פקודה כלשהי. Emacs יציג תי×ור מ×ד קצר של הפקודה
+×”×”×™×.
+
+>> הקישו C-h c C-p.
+
+התוצ××” שתוצג צריכה להיות משהו כמו ×–×”:
+
+		C-p runs the command previous-line
+
+ההודעה הזו מר××” ×ת "×©× ×”×¤×•× ×§×¦×™×”". היות ושמות הפונקציות × ×‘×—×¨×™× ×›×“×™
+לציין מה הן עושות, השמות ×¢×©×•×™×™× ×œ×©×ž×© כתיעוד מקוצר -- מספיק כדי להזכיר
+×œ×›× ×ת הפקודות ×©×œ×ž×“×ª× ×‘×¢×‘×¨.
+
+ניתן לציין ×חרי C-h c ×’× ×¤×§×•×“×•×ª שמופעלות ×¢"×™ סדרת ×ž×§×©×™× ×‘×ורך גדול
+מ×חד, כגון C-x C-s ×ו (×× ×ין מקש META ×ו EDIT ×ו ALT) â€â€Ž<ESC> v.
+
+לקבלת מידע מפורט יותר על פקודה, השתמשו בפקודה C-h k ×‘×ž×§×•× C-h c.
+
+>> הקישו C-h k C-p.
+
+כתוצ××”, יוצגו ×”×©× ×•×”×ª×™×¢×•×“ של הפונקציה בחלון Emacs נפרד. כשתסיימו לקרו×
+×ת התיעוד, הקישו C-x 1 כדי לסלק ×ת חלון העזרה. ×œ× ×—×™×™×‘×™× ×œ×¢×©×•×ª ×–×ת
+מיד. ×פשר לבצע קצת עריכה תוך שימוש בתיעוד המוצג ורק ×חר-כך להקיש C-x 1.
+
+הנה עוד כמה פקודות עזרה שימושיות:
+
+    â€C-h f	תן הסבר על פונקציה. יש להקיש ×ת ×©× ×”×¤×•× ×§×¦×™×”.
+
+>> נסו להקיש C-h f previous-line <Return>‎.
+   כתוצ××”, יוצג תיעוד ×ž×œ× ×©×œ הפונקציה המממשת ×ת הפקודה C-p כפי שהו×
+   ידוע ל-Emacs.
+
+פקודה דומה C-h v מציגה תיעוד של משתנה, כולל ×לו ש×ת ×”×¢×¨×›×™× ×©×œ×”× × ×™×ª×Ÿ
+לשנות כדי ×œ×§×¡×˜× ×ת Emacs. יש להקיש ×ת ×©× ×”×ž×©×ª× ×” ×›×שר Emacs יבקש ×–×ת.
+
+    â€C-h a	פקודות בנוגע ×œ× ×•×©× ×ž×¡×•×™×™×. הקישו מילת מפתח ו-Emacs
+		יציג ×ת רשימת הפקודות ששמותיהן מכילות ×ת מילת המפתח.
+		כל הפקודות הללו ניתנות להפעלה ע"י META-x. עבור חלק
+		מהפקודות תוצג ×’× ×¡×“×¨×ª ×ž×§×©×™× ×©×ž×¤×¢×™×œ×” ×ת הפקודה.
+
+>> הקישו C-h a file <Return>‎.
+
+כתוצ××” מזה, יוצג חלון ×¢× ×¨×©×™×ž×” של כל הפקודות ששמותיהן מכילות ×ת המילה
+"file". ביניהן תר×ו ×’× ×ž×§×©×™ קיצור כגון C-x C-f לצד שמות הפקודות כגון
+find-file.
+
+>> הקישו C-M-v כדי לגלול ×ת חלון העזרה. עשו ×–×ת ×¤×¢×ž×™× ×חדות.
+
+>> עתה הקישו C-x 1 כדי לסגור ×ת חלון העזרה.
+
+    â€C-h i	הצג ×ž×“×¨×™×›×™× ×œ×ž×©×ª×ž×© ×”×›×œ×•×œ×™× ×‘×—×‘×™×œ×ª Emacs. (פקודה זו
+		ידועה ×’× ×‘×©× "Info".) פקודה ×–×ת פותחת חוצץ מיוחד הקרוי
+		"*info*" שבו תוכלו ×œ×§×¨×•× ×ž×“×¨×™×›×™× ×”×ž×•×ª×§× ×™× ×‘×ž×¢×¨×›×ª שלכ×.
+		הקישו m emacs <Return>‎ כדי ×œ×§×¨×•× ×‘×ž×“×¨×™×š למשתמשי Emacs.
+		×× ××™× ×›× ×ž×›×™×¨×™× ×ת Info, הקישו ? ו-Emacs יקח ×תכ×
+		לשיעור על התכונות של Info mode. כשתסיימו ×¢× ×”×©×™×¢×•×¨
+		×”×–×”, ×נו בהחלט ×ž×ž×œ×™×¦×™× ×œ×”×©×ª×ž×© במדריך Emacs בתור התיעוד
+		העיקרי שלכ×.
+
+
+* עוד תכונות
+------------
+
+תוכלו ללמוד עוד על-×ודות Emacs ×¢"×™ קרי××” במדריך למשתמש שלו, ×× ×›×¡×¤×¨
+מודפס ×ו בגירסה מקוונת בתוך Emacs עצמו. (תוכלו להגיע ×ל המדריך דרך
+תפריט Help ×ו ×¢"×™ הקשה על C-h r.) ××•×œ× ×©×ª×™ תכונות שבווד××™ ימצ×ו חן
+×‘×¢×™× ×™×›× ×”×Ÿ השלמה ×שר חוסכת הקשות, ו-dired שמ×פשרת טיפול נוח בקבצי×.
+
+השלמה ×”×™× ×“×¨×š להימנע מהקשות מיותרות. למשל, ×× ×‘×¨×¦×•× ×›× ×œ×¢×‘×•×¨ לחוצץ
+*Messages*, תוכלו להקיש C-x b *M<Tab>‎ ו-Emacs ×™×©×œ×™× ×ת ש×ר ×”×ותיות של
+×©× ×”×—×•×¦×¥ ככל שניתן להסיק ממה שהקשת×. השלמה פועלת ×’× ×¢×œ שמות הפקודות
+ושמות קבצי×. תכונת ההשלמה מתו×רת במלו××” במדריך למשתמש Emacs בצומת
+(node) ×‘×©× "Completion".
+
+â€Dired מ×פשר להציג רשימת ×§×‘×¦×™× ×‘×ª×™×§×™×” (וכ×פציה ×’× ×‘×ª×ª-תיקיות שלה), לנוע
+בתוך הרשימה הזו, לפתוח קבצי×, לשנות ×ת שמותיה×, למחוק ××•×ª× ×•×œ×‘×¦×¢ עליה×
+עוד פעולות רבות. Dired מתו×ר במלו×ו במדריך למשתמש בצומת ×‘×©× "Dired".
+
+בנוסף, מדריך למשתמש מת×ר עוד הרבה מ×ד תכונות של Emacs.
+
+
+* לסיו×
+-------
+
+כדי לצ×ת מ-Emacs יש להקיש C-x C-c.
+
+שיעור ×–×” נכתב כדי להיות מובן לכל ×”×ž×©×ª×ž×©×™× ×”×—×“×©×™×, לכן ×× ×ž×¦××ª× ×©×ž×©×”×•
+×›×ן ×ינו ברור, ×ל תשבו ות×שימו ×ת ×¢×¦×ž×›× -- תתלוננו!
+
+
+* זכויות שימוש
+--------------
+
+שיעור ×–×” הינו צ××¦× ×©×œ שורה ×רוכה של ×©×™×¢×•×¨×™× ×‘×©×™×ž×•×© ב-Emacs, החל מהגרסה
+הר×שונה שנכתבה ×¢"×™ Stuart Cracraft עבור גירסת ×”-Emacs המקורית.
+
+גירסה זו של השיעור ×”×™× ×” חלק מחבילת GNU Emacs. ×”×™× ×ž×•×’× ×ª בזכויות יוצרי×
+וניתנת להעתקה והפצת ×¢×•×ª×§×™× ×‘×ª× ××™× ×ž×¡×•×™×™×ž×™× ×›×“×œ×§×ž×Ÿ:
+
+                       Copyright (C) 2010 Free Software Foundation, Inc.
+
+â€GNU Emacs הינו תכנה חפשית; ×–×›×•×ª×›× ×œ×”×¤×™×¦×• ו\×ו לשנותו בכפוף לתנ××™
+הרשיון GNU General Public License, כפי ×©×”×•× ×™×•×¦× ×œ×ור ×¢"×™ Free
+Software Foundation, ×× ×‘×’×¨×¡× 3 של הרשיון, ו×× (×›×ופציה השמורה לכ×)
+בכל ×’×¨×¡× ×ž×וחרת יותר.
+
+â€GNU Emacs מופץ מתוך תקווה ×©×”×•× ×™×‘×™× ×ª×•×¢×œ×ª, ××•×œ× ×œ×œ× ×›×œ כתב ×חריות;
+×פילו ×œ× ×חריות-במשתמע של סחירות ×ו הת×מה ל×יזו תכלית מסוימת. לפרטי×,
+×× × ×¢×™×™× ×• ב-GNU General Public License.
+
+â€GNU Emacs ×מור להיות מלווה בעותק של GNU General Public License; ×× ×œ×
+×§×™×‘×œ×ª× ×ותו, תוכלו ×œ×ž×¦×•× ×ותו ב-‭<http://www.gnu.org/licenses/>‬.
+
+×”× ×›× ×ž×•×–×ž× ×™× ×œ×§×¨×•× ×ת הקובץ COPYING ו××– ×כן לחלק ×¢×•×ª×§×™× ×©×œ GNU Emacs
+לחבריכ×. עזרו לנו לחסל ×ת "הבעלות" על תוכנה ש××™× ×” ××œ× ×—×‘×œ×” בתוכנה,
+וז×ת ×¢"×™ שימוש, כתיבה ושיתוף של תוכנה חופשית!
+
+
+
+--- end of TUTORIAL.he ---
+
+;;; Local Variables:
+;;;   coding: utf-8
+;;;   bidi-display-reordering: t
+;;;   sentence-end-double-space: nil
+;;;   bidi-paragraph-direction: nil
+;;; End:
--- a/etc/tutorials/TUTORIAL.translators	Mon Jul 26 13:29:08 2010 +0900
+++ b/etc/tutorials/TUTORIAL.translators	Mon Aug 09 10:51:16 2010 +0900
@@ -31,6 +31,10 @@
 Author:     Éric Jacoboni <jaco@teaser.fr>
 Maintainer: Éric Jacoboni <jaco@teaser.fr>
 
+* TUTORIAL.he
+Author:     Eli Zaretskii <eliz@gnu.org>
+Maintainer: Eli Zaretskii <eliz@gnu.org>
+
 * TUTORIAL.it:
 Author:     Alfredo Finelli <alfredofnl@tiscali.it>
 	    Italian GNU Translation Group <tp@lists.linux.it>
--- a/lib-src/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lib-src/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,20 @@
+2010-08-07  Juanma Barranquero  <lekktu@gmail.com>
+
+	* ebrowse.c (usage, version, mark_virtual):
+	Remove duplicate declarations.
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* emacsclient.c: Move socket related #includes together with the
+	rest of the #includes.  Move a WINDOWSNT includes closer together.
+	(HAVE_CONFIG_H): Remove.
+	(NO_RETURN): Remove, defined in config.h.
+	(main): Convert definition to standard C.
+
+2010-07-29  Juanma Barranquero  <lekktu@gmail.com>
+
+	* make-docfile.c (write_c_args): Warn for old-style empty arglist ().
+
 2010-07-25  Juanma Barranquero  <lekktu@gmail.com>
 
 	* emacsclient.c (getcwd): Fix previous change: make getcwd
@@ -12,7 +29,7 @@
 
 2010-07-24  Dan Nicolaescu  <dann@ics.uci.edu>
 
-	* update-game-score.c (usage):  Add NO_RETURN specifier.
+	* update-game-score.c (usage): Add NO_RETURN specifier.
 	* movemail.c (fatal, pfatal_with_name, pfatal_and_delete):
 	* make-docfile.c (fatal):
 	* hexl.c (usage):
--- a/lib-src/ebrowse.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/lib-src/ebrowse.c	Mon Aug 09 10:51:16 2010 +0900
@@ -492,8 +492,6 @@
 void insert_keyword (char *, int);
 void re_init_scanner (void);
 void init_scanner (void);
-void usage (int);
-void version (void);
 void process_file (char *);
 void add_search_path (char *);
 FILE *open_file (char *);
@@ -504,7 +502,6 @@
 struct member *find_member (struct sym *, char *, int, int, unsigned);
 struct member *add_member (struct sym *, char *, int, int, unsigned);
 void mark_virtual (struct sym *);
-void mark_virtual (struct sym *);
 struct sym *make_namespace (char *, struct sym *);
 char *sym_scope (struct sym *);
 char *sym_scope_1 (struct sym *);
--- a/lib-src/emacsclient.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/lib-src/emacsclient.c	Mon Aug 09 10:51:16 2010 +0900
@@ -18,9 +18,7 @@
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #ifdef WINDOWSNT
 
@@ -32,6 +30,8 @@
 # include <stdlib.h>
 # include <windows.h>
 # include <commctrl.h>
+# include <io.h>
+# include <winsock2.h>
 
 # define NO_SOCKETS_IN_FILE_SYSTEM
 
@@ -45,8 +45,12 @@
 
 # ifdef HAVE_INET_SOCKETS
 #  include <netinet/in.h>
+#  ifdef HAVE_SOCKETS
+#    include <sys/types.h>
+#    include <sys/socket.h>
+#    include <sys/un.h>
+#  endif /* HAVE_SOCKETS */
 # endif
-
 # include <arpa/inet.h>
 
 # define INVALID_SOCKET -1
@@ -67,19 +71,15 @@
 #include <stdio.h>
 #include "getopt.h"
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
 #endif
 
-#ifdef WINDOWSNT
-# include <io.h>
-#else /* not WINDOWSNT */
-# include <pwd.h>
-#endif /* not WINDOWSNT */
+#include <pwd.h>
 #include <sys/stat.h>
-
 #include <signal.h>
 #include <errno.h>
 
+
 
 char *getenv (const char *), *getwd (char *);
 #ifdef HAVE_GETCWD
@@ -114,10 +114,6 @@
 #define TRUE 1
 #endif
 
-#ifndef NO_RETURN
-#define NO_RETURN
-#endif
-
 /* Additional space when allocating buffers for filenames, etc.  */
 #define EXTRA_SPACE 100
 
@@ -702,9 +698,7 @@
 #if !defined (HAVE_SOCKETS) || !defined (HAVE_INET_SOCKETS)
 
 int
-main (argc, argv)
-     int argc;
-     char **argv;
+main (int argc, char **argv)
 {
   main_argv = argv;
   progname = argv[0];
@@ -716,14 +710,6 @@
 
 #else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
 
-#ifdef WINDOWSNT
-# include <winsock2.h>
-#else
-# include <sys/types.h>
-# include <sys/socket.h>
-# include <sys/un.h>
-#endif
-
 #define AUTH_KEY_LENGTH      64
 #define SEND_BUFFER_SIZE   4096
 
--- a/lib-src/make-docfile.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/lib-src/make-docfile.c	Mon Aug 09 10:51:16 2010 +0900
@@ -442,7 +442,7 @@
   register char *p;
   int in_ident = 0;
   char *ident_start;
-  int ident_length;
+  int ident_length = 0;
 
   fprintf (out, "(fn");
 
@@ -476,6 +476,12 @@
 	 identifier.  */
       if (c == ',' || c == ')')
 	{
+	  if (ident_length == 0)
+	    {
+	      error ("empty arg list for `%s' should be (void), not ()", func);
+	      continue;
+	    }
+
 	  if (strncmp (ident_start, "void", ident_length) == 0)
 	    continue;
 
--- a/lisp/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,396 @@
+2010-08-08  Chong Yidong  <cyd@stupidchicken.com>
+
+	* tutorial.el (tutorial--default-keys): C-d is now bound to
+	delete-forward-char (Bug#6826).
+
+	* mouse.el (mouse-drag-track): Remove accidentally-removed check
+	for `double' value of mouse-1-click-follows-link (Bug#6807).
+
+2010-08-08  Johan Bockgård  <bojohan@gnu.org>
+
+	* replace.el (replace-highlight): Bind isearch-forward and
+	isearch-error, ensuring that highlighting is updated if the user
+	switches the search direction (Bug#6808).
+
+	* isearch.el (isearch-lazy-highlight-forward): New var.
+	(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search):
+	(isearch-lazy-highlight-update): Use it.
+
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule.el (define-charset): Store NAME as :base property.
+	(ctext-non-standard-encodings-table): Pay attention to charset aliases.
+	(ctext-pre-write-conversion): Sort ctext-standard-encodings by the
+	current priority.  Force using the designation of the specific
+	charset by adding `charset' text property.  Improve the whole algorithm.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emulation/pc-select.el (pc-selection-mode-hook)
+	(copy-region-as-kill-nomark, beginning-of-buffer-mark)
+	(pc-selection-mode): Fix typos in docstrings.
+
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* language/cyrillic.el: Don't add "microsoft-cp1251" to
+	ctext-non-standard-encodings-alist here.
+
+	* international/mule.el (ctext-non-standard-encodings-alist):
+	Add "koi8-r" and "microsoft-cp1251".
+	(ctext-standard-encodings): New variable.
+	(ctext-non-standard-encodings-table): List only elements for
+	non-standard encodings.
+	(ctext-pre-write-conversion): Adjusted for the above change.
+	Check ctext-standard-encodings.
+
+	* international/mule-conf.el (compound-text): Doc fix.
+	(ctext-no-compositions): Doc fix.
+	(compound-text-with-extensions): Doc fix.
+
+2010-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (exchange-dot-and-mark): Mark obsolete, finally.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* progmodes/which-func.el (which-func-format): Split help-echo text
+	into lines, like other mode-line tooltips.
+
+	* server.el (server-start): When using TCP sockets, force IPv4
+	and use a literal 127.0.0.1 for localhost.  (Related to bug#6781.)
+
+2010-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (complete-symbol): Run completion-at-point as a fallback.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* term.el (term-delimiter-argument-list): Reflow docstring.
+	(term-read-input-ring, term-write-input-ring, term-send-input)
+	(term-bol, term-erase-in-display, serial-supported-or-barf):
+	Fix typos in docstrings.
+
+2010-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (function-key-map): Add a S-tab => backtab fallback.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* dabbrev.el (dabbrev-completion): Fix typo in docstring.
+
+2010-08-08  MON KEY  <monkey@sandpframing.com>  (tiny change)
+
+	* emacs-lisp/syntax.el (syntax-ppss-toplevel-pos):
+	Fix typo in docstring (bug#6747).
+
+2010-08-08  Leo  <sdl.web@gmail.com>
+
+	* eshell/esh-io.el (eshell-get-target): Better detection of
+	read-only file (Bug#6762).
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* align.el (align-default-spacing): Doc fix.
+	(align-region-heuristic, align-regexp): Fix typos in docstrings.
+
+2010-08-08  Ulf Jasper  <ulf.jasper@web.de>
+
+	* calendar/icalendar.el (icalendar-uid-format): Doc fix.
+	(icalendar--split-value): Fixed splitting regexp. (Bug#6766)
+	(icalendar--get-weekday-numbers): New
+	(icalendar--create-uid, icalendar-export-region)
+	(icalendar--parse-summary-and-rest): Code formatting.
+	(icalendar--convert-recurring-to-diary): Handle multiple byday
+	values in weekly rules. (Bug#6766)
+
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc/calc.el (calc-trail-mode,calc-refresh): Use `face' property
+	to italicize headers.
+	(calc-highlight-selections-with-faces): New variable.
+	(calc-selected-face, calc-nonselected-face): New faces.
+
+	* calc/calccomp.el (math-comp-highlight-string): Use
+	`calc-highlight-selections-with-faces' to determine how to highlight
+	sub-formulas.
+
+	* calc/calc-sel.el (calc-show-selections): Change message to when
+	using faces to highlight selections.
+
+2010-08-07  Michael R. Mauger  <mmaug@yahoo.com>
+
+	* progmodes/sql.el (sql-mode-sqlite-font-lock-keywords):
+	Add SQLite 3 keywords, functions and datatypes.
+	(sql-interactive-mode): Remove `comint-process-echoes' set to t
+	(Bug#6686).
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (select-active-regions): Move to keyboard.c.
+	(deactivate-mark): Used saved-region-selection.
+	(select-active-region): Function removed.
+	(activate-mark, set-mark, push-mark-command)
+	(handle-shift-selection): Don't call it.
+	(keyboard-quit): Avoid adding the region to the window selection.
+
+	* mouse.el (mouse-drag-track): Remove hacks to deal with old
+	select-active-regions implementation.
+	(mouse-yank-at-click): Doc fix.
+
+	* cus-start.el: Add custom declaration for select-active-regions.
+
+2010-08-07  Eli Zaretskii  <eliz@gnu.org>
+
+	* simple.el (delete-forward-char): Doc fix.
+
+	* tutorial.el (help-with-tutorial): Hack safe file-local variables
+	after reading the tutorial.
+
+2010-08-06  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-cmds.el (c-mask-paragraph, c-fill-paragraph): Fix
+	for the case that a C style comment has its delimiters alone on
+	their respective lines.
+
+2010-08-06  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-start-file-process): Set connection
+	property "vec".
+	(tramp-process-sentinel): Use it for flushing the cache.  We
+	cannot do it via the process buffer, the buffer could be deleted
+	already when running the sentinel.
+
+2010-08-06  Jürgen Hötzel  <juergen@archlinux.org>  (tiny change)
+
+	* comint.el (comint-mode): Make directory tracking functions
+	functional on remote files.  (Bug#6764)
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc/diff-mode.el (diff-mode-shared-map): Bind g to revert-buffer.
+
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* emacs-lisp/find-gc.el (find-gc-source-files): Rename
+	unexec.c => unexcoff.c.
+
+	* emacs-lisp/authors.el (authors-fixed-entries): Rename
+	unexec.c => unexcoff.c.
+
+2010-08-05  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-dired-uncache): Flush directory
+	cache, not only file cache.
+	(tramp-process-sentinel): New defun.
+	(tramp-handle-start-file-process): Use it, in order to invalidate
+	file caches.
+
+2010-08-03  Leo  <sdl.web@gmail.com>
+
+	* server.el (server-start): Simplify loop.
+
+2010-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* frame.el (screen-height, screen-width, set-screen-width)
+	(set-screen-height): Remove ancient compatibility aliases.
+
+	* textmodes/fill.el (justify-current-line): Don't add 1 to nspaces
+	when justifying.  It seems useless and harmful for ncols=1 (bug#6738).
+
+	* emacs-lisp/timer.el (timer-event-handler): Protect against timers
+	that change current buffer.
+
+2010-08-01  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mouse.el (mouse-fixup-help-message): Match "mouse-2" only at the
+	beginning of the string.  Use `string-match-p'.  (Bug#6765)
+
+2010-08-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* cus-start.el (x-gtk-use-system-tooltips): New variable.
+
+2010-08-01  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el (package--list-packages): Fix column alignment.
+	(package--builtins): Tweak descriptions.
+	(package-print-package): Upcase descriptions if necessary.
+	Show all built-in packages in font-lock-builtin-face.
+	(package-list-packages-internal): Omit "emacs" package.
+	Show status of built-in packages as "built-in".
+
+2010-07-31  Chong Yidong  <cyd@stupidchicken.com>
+
+	* mouse.el (mouse-save-then-kill): Doc fix.  Deactivate mark
+	before killing to preserve the primary selection (Bug#6701).
+
+	* term/x-win.el (x-select-text): Doc fix.
+
+2010-07-31  Nathaniel Flath  <flat0103@gmail.com>
+
+	Enhance Java Mode to handle Java 5.0 (Tiger) and Java 6 (Mustang).
+	The following functions were modified or created:
+
+	* progmodes/cc-vars.el (c-offsets-alist, c-inside-block-syms)
+	(objc-font-lock-extra-types):
+	* progmodes/cc-mode.el (c-basic-common-init):
+	* progmodes/cc-langs.el (c-make-mode-syntax-table)
+	(c++-make-template-syntax-table)
+	(c-identifier-syntax-modifications, c-symbol-start, c-operators)
+	(c-<-op-cont-regexp, c->-op-cont-regexp, c-class-decl-kwds)
+	(c-brace-list-decl-kwds, c-modifier-kwds, c-prefix-spec-kwds-re)
+	(c-type-list-kwds, c-decl-prefix-re, c-opt-type-suffix-key):
+	* progmodes/cc-fonts.el (c-make-inverse-face)
+	(c-basic-matchers-after):
+	* progmodes/cc-engine.el (c-forward-keyword-clause)
+	(c-forward-<>-arglist, c-forward-<>-arglist-recur)
+	(c-forward-name, c-forward-type, c-forward-decl-or-cast-1)
+	(c-guess-continued-construct, c-guess-basic-syntax):
+
+2010-07-31  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* faces.el (face-all-attributes): Improve documentation (Bug#6767).
+
+2010-07-31  Eli Zaretskii  <eliz@gnu.org>
+
+	* files.el (bidi-paragraph-direction): Define safe local values.
+
+	* language/hebrew.el ("Hebrew"): Add TUTORIAL.he to
+	language-info-alist.  Remove outdated FIXME in a comment.
+
+2010-07-31  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-cmds.el (c-mask-paragraph): Fix bug #6688:
+	Auto-fill broken in C/C++ modes.
+
+2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left)
+	(menu-bar-showhide-tool-bar-menu-customize-disable)
+	(menu-bar-showhide-tool-bar-menu-customize-enable-right)
+	(menu-bar-showhide-tool-bar-menu-customize-enable-bottom)
+	(menu-bar-showhide-tool-bar-menu-customize-enable-top): New functions
+	(menu-bar-showhide-tool-bar-menu): If tool bar is moveable,
+	make a menu for Options => toolbar that can move it.
+
+2010-07-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package-x.el (package--make-rss-entry):
+	(package-maint-add-news-item, package--update-news)
+	(package-upload-buffer-internal): New arg ARCHIVE-URL.
+
+	* emacs-lisp/package.el (package-archive-url): Rename from
+	package-archive-id.
+	(package-install): Doc fix.
+	(package-download-single, package-download-tar, package-install)
+	(package-menu-view-commentary): Callers changed.
+
+2010-07-29  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-start-file-process): Check only for
+	`remote-tty' process property.
+	(tramp-open-shell): Don't check for tty.
+	(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
+	process property.
+
+	* progmodes/gdb-mi.el (gdb-init-1): Check also for tty on a remote
+	host.
+
+2010-07-28  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el (package-load-list, package-archives)
+	(package-archive-contents, package-user-dir)
+	(package-directory-list, package--builtins, package-alist)
+	(package-activated-list, package-obsolete-alist): Mark as risky.
+
+2010-07-28  Phil Hagelberg  <phil@evri.com>
+
+	Add support for non-default package repositories.
+	* emacs-lisp/package.el (package-archive-base): Var deleted.
+	(package-archives): New variable.
+	(package-archive-contents): Doc fix.
+	(package-load-descriptor): Do nothing if descriptor file is missing.
+	(package--write-file-no-coding): New function.
+	(package-unpack-single): Use it.
+	(package-archive-id): New function.
+	(package-download-single, package-download-tar)
+	(package-menu-view-commentary): Use it.
+	(package-installed-p): Make second argument optional.
+	(package-read-all-archive-contents): New function.
+	(package-initialize): Use it.
+	(package-read-archive-contents): Add ARCHIVE argument.
+	(package--add-to-archive-contents): New function.
+	(package-install): Don't call package-read-archive-contents.
+	(package--download-one-archive): Store archive file in a
+	subdirectory of package-user-dir.
+	(package-menu-execute): Remove spurious line movement.
+
+2010-07-28  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* cus-start.el (tool-bar-style): Add text-image-horiz.
+
+2010-07-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* progmodes/gud.el (gud-common-init): Check for remoteness of
+	`file', and not of `default-directory'.
+
+2010-07-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-methods): Move hostname to the end in all
+	ssh `tramp-login-args'.
+	(tramp-verbose): Describe verbose level 9.
+	(tramp-open-shell): Check for tty if `tramp-verbose' >= 9.
+	(tramp-open-connection-setup-interactive-shell): Trace stty
+	settings if `tramp-verbose' >= 9.
+	(tramp-handle-start-file-process): Implement tty setting.
+	(Bug#4604, Bug#6360)
+
+	* net/tramp-cmds.el (tramp-bug): Recommend setting of
+	`tramp-verbose' to 9.
+
+2010-07-27  Aaron S. Hawley  <ashawley@burlingtontelecom.net>
+
+	* emacs-lisp/re-builder.el (reb-re-syntax, reb-lisp-mode)
+	(reb-lisp-syntax-p, reb-change-syntax, reb-cook-regexp):
+	Remove references to package `lisp-re' (bug#4369).
+
+2010-07-27  Tom Tromey  <tromey@redhat.com>
+
+	* progmodes/js.el (js-mode):
+	* progmodes/make-mode.el (makefile-mode):
+	* progmodes/simula.el (simula-mode):
+	* progmodes/tcl.el (tcl-mode): Derive from prog-mode.
+
+2010-07-27  Juanma Barranquero  <lekktu@gmail.com>
+
+	* help-fns.el (find-lisp-object-file-name): Doc fix (bug#6494).
+
+	* cedet/semantic/db-file.el (object-write): Fix typo in docstring.
+
+	* time.el (display-time-day-and-date): Remove spurious * in docstring.
+	(display-time-world-buffer-name, display-time-world-mode-map):
+	Fix typos in docstrings.
+
+2010-07-27  Shyam Karanatt  <shyam@swathanthran.in>  (tiny change)
+
+	* image-mode.el (image-display-size): New function.
+	(image-forward-hscroll, image-next-line, image-eol, image-eob)
+	(image-mode-fit-frame): Use it (Bug#6639).
+
+2010-07-27  Chong Yidong  <cyd@stupidchicken.com>
+
+	* dired.el (dired-buffers-for-dir): Handle list values of
+	dired-directory (Bug#6636).
+
+2010-07-26  Sam Steingold  <sds@gnu.org>
+
+	* mouse.el (mouse-yank-primary, mouse-yank-secondary):
+	Do not call `x-get-selection' the second time, reuse the value.
+
+2010-07-26  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa-mail.el (epa-mail-mode-map): Add alternative key bindings
+	which consist of control chars only.  Suggested by Richard Stallman.
+
 2010-07-25  Daiki Ueno  <ueno@unixuser.org>
 
 	* epa-file.el (epa-file-insert-file-contents): Check if LOCAL-FILE
--- a/lisp/ChangeLog.1	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog.1	Mon Aug 09 10:51:16 2010 +0900
@@ -173,7 +173,7 @@
 
 1986-03-15  Bill Rozas  (jinx@prep)
 
-	* scheme.el: (scheme-zap-name) Uses expand-file-name to obtain an
+	* scheme.el (scheme-zap-name): Uses expand-file-name to obtain an
 	absolute pathname.
 
 1986-03-15  Richard M. Stallman  (rms@prep)
@@ -184,7 +184,7 @@
 
 1986-03-13  Bill Rozas  (jinx@prep)
 
-	* scheme.el: (scheme-zap-name) change it back to fromedit.zap
+	* scheme.el (scheme-zap-name): Change it back to fromedit.zap
 	since that is where scheme expects it and it is too much work to
 	change scheme right now.  This interface is obsolete anyway, but
 	some people (athena) still use it.
@@ -384,7 +384,7 @@
 	* info.el (Info-find-node):
 	Fix braino.
 	Also, allow abbreviations for node names.
-	Info-tagify:  insert tags in forward order so that
+	(Info-tagify): Insert tags in forward order so that
 	an abbrev finds the textually first possibility rather than the
 	last.
 
@@ -570,7 +570,7 @@
 
 1986-01-18  Richard M. Stallman  (rms@prep)
 
-	* doctor.el:  Fix typo "symtoms".
+	* doctor.el: Fix typo "symtoms".
 
 1986-01-10  Richard Mlynarik  (mly@prep)
 
@@ -660,7 +660,7 @@
 1985-12-27  Richard Mlynarik  (mly@prep)
 
 	* view.el:
-	Various:  Fix cases of "view" => "View" which were missed.  Damn.
+	Various: Fix cases of "view" => "View" which were missed.  Damn.
 
 1985-12-27  Richard M. Stallman  (rms@prep)
 
@@ -917,7 +917,7 @@
 	* files.el (normal-mode):
 	New command to choose major mode automatically.
 
-	* inc-vers.el:  Renamed from inc-version.el
+	* inc-vers.el: Renamed from inc-version.el
 	for file name length reasons.
 
 	* term/*.el: terminal-specific files found here now.
@@ -1137,7 +1137,7 @@
 
 1985-11-27  Richard Mlynarik  (mly@prep)
 
-	* rnews.el: (news-mode, news-set-mode-line):
+	* rnews.el (news-mode, news-set-mode-line):
 	Get rid of news-mode-group-string.
 
 	* rnews.el (news-unsubscribe-internal):
@@ -1614,7 +1614,7 @@
 
 1985-10-17  Richard Mlynarik  (mly@mit-prep)
 
-	* rnews.el: (news-save-item-in-file)
+	* rnews.el (news-save-item-in-file):
 	Append to file, rather than overwriting.
 
 	* isearch.el
@@ -2521,10 +2521,10 @@
 	No, this directory is added automatically to the path
 	used by call-process.  It should have worked before. - RMS
 
-	* loaddefs.el:  C-z -> C-c in documentation for mail.
+	* loaddefs.el: C-z -> C-c in documentation for mail.
 	autoload report-emacs-bug from emacsbug.el.
 
-	* emacsbug.el:  New file.  Reports bugs with version info.
+	* emacsbug.el: New file.  Reports bugs with version info.
 
 	* helper.el (Helper-describe-bindings):
 	Make it describe local bindings faster by binding global map to
@@ -2532,7 +2532,7 @@
 
 	* lisp-mode.el: First form of prog1 is distinguished.
 
-	* loaddefs.el: autoload functions from chistory.el and echistory.el.
+	* loaddefs.el: Autoload functions from chistory.el and echistory.el.
 
 	* chistory.el:
 	New file containing two alternatives to `repeat-complex-command'
@@ -2585,10 +2585,10 @@
 
 1985-06-11  K. Shane Hartman  (shane@mit-prep)
 
-	* ebuff-menu.el:  Make M-C-v scroll-other-window instead of
+	* ebuff-menu.el: Make M-C-v scroll-other-window instead of
 	scroll-down.  Make M-v scroll-down.
 
-	* ebuff-menu.el, echistory.el:	Made them use electric.
+	* ebuff-menu.el, echistory.el: Made them use electric.
 
 	* electric.el:
 	New module for packages that retain control until some event
@@ -2600,7 +2600,7 @@
 	Made it use helper.el.  Remove kill-ring-save stuff pending use of
 	new winning prin1-to-string for minibuffer hacking.
 
-	* view.el:  Made it use helper.el.
+	* view.el: Made it use helper.el.
 
 	* helper.el:
 	New module for packages which want to do help without giving up
@@ -2802,7 +2802,7 @@
 
 1985-06-01  K. Shane Hartman  (shane@mit-prep)
 
-	* loaddefs.el:  Update documentation for rmail.
+	* loaddefs.el: Update documentation for rmail.
 
 	* lisp-mode.el (calculate-lisp-indent):
 	Asked (fboundp 'lisp-indent-hook).  Right question is boundp.
@@ -2856,7 +2856,7 @@
 	Skip strings, comments, char constants.
 	Find symbols even if they have no letters in them.
 
-	* mlsupport.el:  Insert symbol-value call in use-local-map.
+	* mlsupport.el: Insert symbol-value call in use-local-map.
 	Handle key codes > 127 in local-bind-to-key.
 	Write ml-modify-syntax-entry.
 
@@ -3165,7 +3165,7 @@
 1985-05-16  K. Shane Hartman  (shane@mit-prep)
 
 	* dired.el: Put dired-rename-file, dired-copy file-on keys.  Make
-	them change buffer if appropriate.  Put	dired-mark-backup-files,
+	them change buffer if appropriate.  Put dired-mark-backup-files,
 	dired-mark-temp-files on keys.  Eliminate possibility of looping
 	at last line in dired-repeat-over-filenames.
 
@@ -3194,53 +3194,56 @@
 	replace loop so that replacing continues after moving back to
 	previous.
 
-	* add-log.el: add prefix arg to add-change-log-entry so will
+	* add-log.el: Add prefix arg to add-change-log-entry so will
 	prompt for information if desired.  If there is an entry for today,
 	make sure login-name is same before using it, else make new entry.
 	Use auto-fill-mode.
 
 1985-05-12  Richard M. Stallman  (rms@mit-prep)
 
-	* lisp-mode.el: defined lisp-mode-commands, lisp-mode-variables.
+	* lisp-mode.el: Defined lisp-mode-commands, lisp-mode-variables.
 	Added external-lisp-mode.
 	Made doc strings mention mode hook variables.
 
-	* shell.el: defined functions `lisp' and `inferior-lisp-mode'.
+	* shell.el: Defined functions `lisp' and `inferior-lisp-mode'.
 	Renamed shell-send-defun... to lisp-send-defun...
 	and made them use process "lisp", buffer *lisp*.
 
-	* text-mode.el: made indented-text-mode not call text-mode.
+	* text-mode.el: Made indented-text-mode not call text-mode.
 	Made doc strings mention mode hook variables.
 
 	* c-mode.el: Made doc strings mention mode hook variables.
 
-	* add-log.el
+	* add-log.el:
 	Change format used for change log entries.
 	Select indented-text-mode for the change log file.
 
 1985-05-12  K. Shane Hartman  (shane@mit-ajax)
-	simple.el: suppress matching close paren if preceded
+
+	* simple.el: Suppress matching close paren if preceded
 		by char syntax \.
-	mim-mode.el: flush private paren blinker in favor of default.
-	add-log.el: change mode-string to mode-name so reflected in
+	* mim-mode.el: Flush private paren blinker in favor of default.
+	* add-log.el: Change mode-string to mode-name so reflected in
 		mode-line.  change \\W to \\sW when looking for place to add.
 
 1985-05-12  Richard M. Stallman  (rms@mit-prep)
-	simple.el: modified open-line to insert newlines before
+
+	* simple.el: Modified open-line to insert newlines before
 		an existing one before dot.  This makes better redisplay.
-	dired.el: Installed Shane's changes that allow user to choose
+	* dired.el: Installed Shane's changes that allow user to choose
 		switches to use.
 
 1985-05-11  Richard M. Stallman  (rms@mit-prep)
-	rmail.el: if given file name as argument,
+
+	* rmail.el: If given file name as argument,
 		correctly displays one message of that file
 		but does not try to get new mail.
-	simple.el: Fix what-line bug: line # too high by 1 if not at bol.
+	* simple.el: Fix what-line bug: line # too high by 1 if not at bol.
 		Put in blink-matching-paren-distance,
 		and check for wrong kinds of parens matching.
-	time.el: Put in display-time-day-and-date flag,
+	* time.el: Put in display-time-day-and-date flag,
 		to display day and date in addition to the time.
-	startup.el: Call lisp-interaction-mode-hook if defined.
+	* startup.el: Call lisp-interaction-mode-hook if defined.
 		Set current buffer variables from defaults
 		in case user's init file has changed them.
 
--- a/lisp/ChangeLog.14	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog.14	Mon Aug 09 10:51:16 2010 +0900
@@ -640,7 +640,7 @@
 
 2009-04-11  Chong Yidong  <cyd@stupidchicken.com>
 
-	* files.el (dir-locals-directory-cache):  Rename from
+	* files.el (dir-locals-directory-cache): Rename from
 	dir-locals-directory-alist.  Change format to include
 	the mtime of the directory-local variables file (Bug#2833).
 	(dir-locals-set-directory-class): New arg mtime.  Store it in
--- a/lisp/ChangeLog.7	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog.7	Mon Aug 09 10:51:16 2010 +0900
@@ -7738,7 +7738,7 @@
 1997-12-09  Kenichi HANDA  <handa@nora.etl.go.jp>
 
 	* language/korea-util.el (setup-korean-environment):
-	Bind C-f9 (intead of C-f10) to quail-hangul-switch-symbol-ksc.
+	Bind C-f9 (instead of C-f10) to quail-hangul-switch-symbol-ksc.
 
 	* language/korean.el: Documentation for "Korean" language
 	environment adjusted for the above change.
--- a/lisp/ChangeLog.8	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog.8	Mon Aug 09 10:51:16 2010 +0900
@@ -8808,14 +8808,14 @@
 	enable-kinsoku.
 
 	* simple.el (do-auto-fill): Don't check kinsoku-enable here.
-	Don't call kinsoku directly, intead call fill-find-break-point.
+	Don't call kinsoku directly, instead call fill-find-break-point.
 
 	* textmodes/fill.el: Setup `fill-find-break-point-function'
 	property to character sets which require `kinsoku' processing for
 	filling.
 	(fill-find-break-point): New function.
 	(fill-region-as-paragraph): Don't check kinsoku-enable here.
-	Don't call kinsoku directly, intead call fill-find-break-point.
+	Don't call kinsoku directly, instead call fill-find-break-point.
 
 1998-10-18  Richard Stallman  <rms@psilocin.ai.mit.edu>
 
--- a/lisp/ChangeLog.9	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/ChangeLog.9	Mon Aug 09 10:51:16 2010 +0900
@@ -1667,7 +1667,7 @@
 	* Makefile.in (finder_setwins): Renamed from nonobsolete_setwins.
 	Don't include term/.
 
-	* mail/sc.el:  Moved to obsolete/.
+	* mail/sc.el: Moved to obsolete/.
 
 2001-08-14  Vinicius Jose Latorre  <vinicius@cpqd.com.br>
 
@@ -5547,7 +5547,7 @@
 
 2001-02-12  Dave Love  <d.love@dl.ac.uk>
 
-	* international/latin1-disp.el:  Doc fixes.
+	* international/latin1-disp.el: Doc fixes.
 	(latin1-display) <defgroup>: Add :link.
 	(latin1-display) <function>: Set variable latin1-display.
 
@@ -5978,7 +5978,7 @@
 
 	* shell.el (shell-write-history-on-exit): Make sure that we are in
 	the shell buffer (M-x tex-file RET inserted the error message into
-	the TeX	buffer).
+	the TeX buffer).
 
 2001-01-27  Eli Zaretskii  <eliz@is.elta.co.il>
 
@@ -8747,7 +8747,7 @@
 2000-11-13  Miles Bader  <miles@gnu.org>
 
 	* textmodes/fill.el (skip-line-prefix): New function.
-	(fill-region-as-paragraph, fill-region):  Return the fill-prefix.
+	(fill-region-as-paragraph, fill-region): Return the fill-prefix.
 	(fill-paragraph): Don't leave point inside the fill-prefix.
 	* textmodes/refill.el (refill-fill-paragraph-at): Don't leave
 	point inside the fill-prefix.
@@ -10795,7 +10795,7 @@
 2000-10-06  Dave Love  <fx@gnu.org>
 
 	* textmodes/fill.el (sentence-end-double-space)
-	(sentence-end-without-period):  Doc fix.
+	(sentence-end-without-period): Doc fix.
 	(adaptive-fill-regexp): Purecopy.
 	(unjustify-current-line): Use line-end-position.
 	(fill-individual-paragraphs-prefix): Use line-beginning-position.
@@ -11871,7 +11871,7 @@
 
 	* strokes.el: Sync with maintainer's current version with changes
 	for Emacs, but avoid runtime cl and levents.
-	(toplevel):  Change autoloads and compilation requires.
+	(toplevel): Change autoloads and compilation requires.
 	(strokes-version, strokes-bug-address, strokes-lift): Values
 	changed.
 	(strokes-xpm-header, strokes-insinuated): New variable.
@@ -11934,12 +11934,12 @@
 2000-09-14  Dave Love  <fx@gnu.org>
 
 	* toolbar/cancel.xpm, toolbar/close.xpm, toolbar/copy.xpm,
-	toolbar/cut.xpm, toolbar/exit.xpm, toolbar/fld_open.xpm,
-	toolbar/help.xpm, toolbar/info.xpm, toolbar/mail.xpm,
-	toolbar/mail_compose.xpm, toolbar/new.xpm, toolbar/open.xpm,
-	toolbar/paste.xpm, toolbar/preferences.xpm, toolbar/print.xpm,
-	toolbar/save.xpm, toolbar/saveas.xpm, toolbar/search-replace.xpm,
-	toolbar/search.xpm, toolbar/spell.xpm, toolbar/undo.xpm:  New.
+	* toolbar/cut.xpm, toolbar/exit.xpm, toolbar/fld_open.xpm,
+	* toolbar/help.xpm, toolbar/info.xpm, toolbar/mail.xpm,
+	* toolbar/mail_compose.xpm, toolbar/new.xpm, toolbar/open.xpm,
+	* toolbar/paste.xpm, toolbar/preferences.xpm, toolbar/print.xpm,
+	* toolbar/save.xpm, toolbar/saveas.xpm, toolbar/search-replace.xpm,
+	* toolbar/search.xpm, toolbar/spell.xpm, toolbar/undo.xpm: New.
 	From Tuomas Kuosmanen <tigert@gimp.org>.  (Gnome icons fetched
 	from <URL:http://tigert.gimp.org/gnome/gnome-stock/>.)
 
@@ -14832,7 +14832,7 @@
 	(comint-replace-by-expanded-history)
 	(comint-get-old-input-default, comint-show-output)
 	(comint-backward-matching-input, comint-forward-matching-input)
-	(comint-next-prompt, comint-previous-prompt):  Use field
+	(comint-next-prompt, comint-previous-prompt): Use field
 	properties if comint-use-prompt-regexp-instead-of-fields is nil.
 	(comint-line-beginning-position): New function.
 	(comint-bol): Use comint-line-beginning-position.  Make ARG optional.
@@ -18040,7 +18040,7 @@
 	(help-xref-interned): Maybe insert face doc too.  Separate
 	sections with a line of hyphens.
 
-	* faces.el:  Some doc fixes.  Declare some functions obsolete.
+	* faces.el: Some doc fixes.  Declare some functions obsolete.
 	(describe-face): Add customize button.  Return the help
 	text.  Fix prompt.
 
@@ -20406,7 +20406,7 @@
 
 2000-01-10  Ken Stevens  <k.stevens@ieee.org>
 
-	* ispell.el:  Only define dictionaries in menus when they exist.
+	* ispell.el: Only define dictionaries in menus when they exist.
 	(version18p): New variable.
 	(version20p): New variable.
 	(xemacsp): New variable.
--- a/lisp/align.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/align.el	Mon Aug 09 10:51:16 2010 +0900
@@ -140,8 +140,8 @@
   "An integer that represents the default amount of padding to use.
 If `align-to-tab-stop' is non-nil, this will represent the number of
 tab stops to use for alignment, rather than the number of spaces.
-Each alignment rule can optionally override both this variable.  See
-`align-mode-alist'."
+Each alignment rule can optionally override both this variable and
+`align-to-tab-stop'.  See `align-rules-list'."
   :type 'integer
   :group 'align)
 
@@ -157,8 +157,8 @@
 sections (whenever `align-region-separate' is non-nil, and not a
 string), this heuristic is used to determine how far before and after
 point we should search in looking for a region separator.  Larger
-values can mean slower perform in large files, although smaller values
-may cause unexpected behavior at times."
+values can mean slower performance in large files, although smaller
+values may cause unexpected behavior at times."
   :type 'integer
   :group 'align)
 
@@ -926,7 +926,7 @@
     Joe (123) 456-7890
 
 There is no predefined rule to handle this, but you could easily do it
-using a REGEXP like \"(\". All you would have to do is to mark the
+using a REGEXP like \"(\".  All you would have to do is to mark the
 region, call `align-regexp' and type in that regular expression."
   (interactive
    (append
--- a/lisp/bindings.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/bindings.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1054,6 +1054,9 @@
 ;; so we can't distinguish those two keys, but usually we consider C-SPC
 ;; (rather than C-@) as the "canonical" binding.
 (define-key function-key-map [?\C-@] [?\C-\s])
+;; Many keyboards don't have a `backtab' key, so by convention the user
+;; can use S-tab instead to access that binding.
+(define-key function-key-map [S-tab] [backtab])
 
 (define-key global-map [mouse-movement] 'ignore)
 
--- a/lisp/calc/calc-sel.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/calc/calc-sel.el	Mon Aug 09 10:51:16 2010 +0900
@@ -309,6 +309,8 @@
        (setq n (1+ n))))
    (calc-clear-command-flag 'position-point)))
 
+(defvar calc-highlight-selections-with-faces)
+
 (defun calc-show-selections (arg)
   (interactive "P")
   (calc-wrapper
@@ -330,8 +332,12 @@
 		(setcar (nthcdr 2 calc-selection-cache-entry) nil)
 		(calc-change-current-selection sel)))))
    (message (if calc-show-selections
-		"Displaying only selected part of formulas"
-	      "Displaying all but selected part of formulas"))))
+                (if calc-highlight-selections-with-faces
+                    "De-emphasizing all but selected part of formulas"
+                  "Displaying only selected part of formulas")
+              (if calc-highlight-selections-with-faces
+                  "Emphasizing selected part of formulas"
+                "Displaying all but selected part of formulas")))))
 
 ;; The variables calc-final-point-line and calc-final-point-column
 ;; are declared in calc.el, and are used throughout.
--- a/lisp/calc/calc.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/calc/calc.el	Mon Aug 09 10:51:16 2010 +0900
@@ -425,6 +425,27 @@
   :group 'calc
   :type 'integer)
 
+(defcustom calc-highlight-selections-with-faces
+  nil
+  "If non-nil, use a separate face to indicate selected sub-formulas.
+If `calc-show-selections' is non-nil, then selected sub-formulas are shown
+by displaying the rest of the formula in `calc-nonselected-face'.  
+If `calc-show-selections' is nil, then selected sub-formulas are shown
+by displaying the sub-formula in `calc-selected-face'."
+  :group 'calc
+  :type 'boolean)
+
+(defface calc-nonselected-face
+  '((t :inherit shadow       
+       :slant italic))
+  "Face used to show the non-selected portion of a formula."
+  :group 'calc)
+
+(defface calc-selected-face
+  '((t :weight bold))
+  "Face used to show the selected portion of a formula."
+  :group 'calc)
+
 (defvar calc-bug-address "jay.p.belanger@gmail.com"
   "Address of the maintainer of Calc, for use by `report-calc-bug'.")
 
@@ -1385,8 +1406,7 @@
     (set (make-local-variable 'calc-main-buffer) buf))
   (when (= (buffer-size) 0)
     (let ((buffer-read-only nil))
-      (insert (propertize (concat "Emacs Calculator Trail\n")
-			  'font-lock-face 'italic))))
+      (insert (propertize "Emacs Calculator Trail\n" 'face 'italic))))
   (run-mode-hooks 'calc-trail-mode-hook))
 
 (defun calc-create-buffer ()
@@ -1976,7 +1996,7 @@
 	 (erase-buffer)
 	 (when calc-show-banner
 	   (insert (propertize "--- Emacs Calculator Mode ---\n"
-			       'font-lock-face 'italic)))
+			       'face 'italic)))
 	 (while thing
 	   (goto-char (point-min))
 	   (when calc-show-banner
--- a/lisp/calc/calccomp.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/calc/calccomp.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1339,12 +1339,15 @@
 
 (defun math-comp-highlight-string (s)
   (setq s (copy-sequence s))
-  (let ((i (length s)))
-    (while (>= (setq i (1- i)) 0)
-      (or (memq (aref s i) '(32 ?\n))
-	  (aset s i (if calc-show-selections ?\. ?\#)))))
-  s)
-
+  (if calc-highlight-selections-with-faces
+      (if (not calc-show-selections)
+          (propertize s 'face 'calc-selected-face)
+        (propertize s 'face 'calc-nonselected-face))
+    (let ((i (length s)))
+      (while (>= (setq i (1- i)) 0)
+        (or (memq (aref s i) '(32 ?\n))
+            (aset s i (if calc-show-selections ?\. ?\#)))))
+    s))
 
 ;; The variable math-comp-sel-tag is local to calc-find-selected-part
 ;; in calc-sel.el, but is used by math-comp-sel-flat-term and
--- a/lisp/calendar/icalendar.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/calendar/icalendar.el	Mon Aug 09 10:51:16 2010 +0900
@@ -212,15 +212,15 @@
 
 (defcustom icalendar-uid-format
   "emacs%t%c"
-  "Format of unique ID code (UID) for each iCalendar object.  
-The following specifiers are available: 
+  "Format of unique ID code (UID) for each iCalendar object.
+The following specifiers are available:
 %c COUNTER, an integer value that is increased each time a uid is
-   generated. This may be necessary for systems which do not
+   generated.  This may be necessary for systems which do not
    provide time-resolution finer than a second.
 %h HASH, a hash value of the diary entry,
 %s DTSTART, the start date (excluding time) of the diary entry,
 %t TIMESTAMP, a unique creation timestamp,
-%u USERNAME, the user-login-name.
+%u USERNAME, the variable `user-login-name'.
 
 For example, a value of \"%s_%h@mydomain.com\" will generate a
 UID code for each entry composed of the time of the event, a hash
@@ -427,7 +427,7 @@
         (goto-char (point-min))
         (while
             (re-search-forward
-             "\\([A-Za-z0-9-]+\\)=\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\);?"
+             "\\([A-Za-z0-9-]+\\)=\\(\\([^;:]+\\)\\|\"\\([^\"]+\\)\"\\);?"
              nil t)
           (setq param-name (intern (match-string 1)))
           (setq param-value (match-string 2))
@@ -744,6 +744,20 @@
     ;; Error:
     -1))
 
+(defun icalendar--get-weekday-numbers (abbrevweekdays)
+  "Return the list of numbers for the comma-separated ABBREVWEEKDAYS."
+  (when abbrevweekdays
+    (let* ((num -1)
+           (weekday-alist (mapcar (lambda (day)
+                                    (progn
+                                      (setq num (1+ num))
+                                      (cons (downcase day) num)))
+                                  icalendar--weekday-array)))
+      (delq nil
+            (mapcar (lambda (abbrevday)
+                      (cdr (assoc abbrevday weekday-alist)))
+                    (split-string (downcase abbrevweekdays) ","))))))
+
 (defun icalendar--get-weekday-abbrev (weekday)
   "Return the abbreviated WEEKDAY."
   (catch 'found
@@ -912,21 +926,21 @@
 `icalendar--uid-count'.  Returns the UID string."
   (let ((uid icalendar-uid-format))
     
-    (setq uid (replace-regexp-in-string 
-	       "%c" 
+    (setq uid (replace-regexp-in-string
+	       "%c"
 	       (format "%d" icalendar--uid-count)
                uid t t))
     (setq icalendar--uid-count (1+ icalendar--uid-count))
-    (setq uid (replace-regexp-in-string 
+    (setq uid (replace-regexp-in-string
 	       "%t"
 	       (format "%d%d%d" (car (current-time))
 		       (cadr (current-time))
-		       (car (cddr (current-time)))) 
+		       (car (cddr (current-time))))
 	       uid t t))
-    (setq uid (replace-regexp-in-string 
-	       "%h" 
+    (setq uid (replace-regexp-in-string
+	       "%h"
 	       (format "%d" (abs (sxhash entry-full))) uid t t))
-    (setq uid (replace-regexp-in-string 
+    (setq uid (replace-regexp-in-string
 	       "%u" (or user-login-name "UNKNOWN_USER") uid t t))
     (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents)
                        (substring contents (match-beginning 1) (match-end 1))
@@ -1008,7 +1022,7 @@
                 (if url
                     (setq contents (concat contents "\nURL:" url))))
 
-	      (setq header (concat "\nBEGIN:VEVENT\nUID:" 
+	      (setq header (concat "\nBEGIN:VEVENT\nUID:"
 				   (icalendar--create-uid entry-full contents)))
               (setq result (concat result header contents "\nEND:VEVENT")))
           ;; handle errors
@@ -1126,7 +1140,7 @@
                (list "%u"
                      (concat "\\(" icalendar-import-format-url "\\)??"))))
 	;; Need the \' regexp in order to detect multi-line items
-        (setq s (concat "\\`" 
+        (setq s (concat "\\`"
 			   (icalendar--rris "%s" "\\(.*?\\)" s nil t)
                         "\\'"))
         (if (string-match s summary-and-rest)
@@ -2057,39 +2071,47 @@
           ))
       )
     (cond ((string-equal frequency "WEEKLY")
-           (if (not start-t)
-               (progn
-                 ;; weekly and all-day
-                 (icalendar--dmsg "weekly all-day")
-                 (if until
-                     (setq result
-                           (format
-                            (concat "%%%%(and "
-                                    "(diary-cyclic %d %s) "
-                                    "(diary-block %s %s))")
-                            (* interval 7)
-                            dtstart-conv
-                            dtstart-conv
-                            (if count until-1-conv until-conv)
-                            ))
-                   (setq result
-                         (format "%%%%(and (diary-cyclic %d %s))"
-                                 (* interval 7)
-                                 dtstart-conv))))
-             ;; weekly and not all-day
-             (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
-                    (weekday
-                     (icalendar--get-weekday-number byday)))
+	   (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
+		  (weekdays
+		   (icalendar--get-weekday-numbers byday))
+		  (weekday-clause
+		   (when (> (length weekdays) 1)
+		     (format "(memq (calendar-day-of-week date) '%s) "
+			     weekdays))))
+	     (if (not start-t)
+		 (progn
+		   ;; weekly and all-day
+		   (icalendar--dmsg "weekly all-day")
+		   (if until
+		       (setq result
+			     (format
+			      (concat "%%%%(and "
+				      "%s"
+				      "(diary-block %s %s))")
+			      (or weekday-clause
+				  (format "(diary-cyclic %d %s) "
+					  (* interval 7)
+					  dtstart-conv))
+			      (if count until-1-conv until-conv)
+			      ))
+		       (setq result
+			     (format "%%%%(and %s(diary-cyclic %d %s))"
+				     (or weekday-clause "")
+				     (if weekday-clause 1 (* interval 7))
+				     dtstart-conv))))
+               ;; weekly and not all-day
                (icalendar--dmsg "weekly not-all-day")
                (if until
                    (setq result
                          (format
                           (concat "%%%%(and "
-                                  "(diary-cyclic %d %s) "
+                                  "%s"
                                   "(diary-block %s %s)) "
                                   "%s%s%s")
-                          (* interval 7)
-                          dtstart-conv
+			  (or weekday-clause
+			      (format "(diary-cyclic %d %s) "
+				      (* interval 7)
+				      dtstart-conv))
                           dtstart-conv
                           until-conv
                           (or start-t "")
@@ -2100,10 +2122,11 @@
                  ;; DTEND;VALUE=DATE-TIME:20030919T113000
                  (setq result
                        (format
-                        "%%%%(and (diary-cyclic %s %s)) %s%s%s"
-                        (* interval 7)
-                        dtstart-conv
-                        (or start-t "")
+                        "%%%%(and %s(diary-cyclic %d %s)) %s%s%s"
+			(or weekday-clause "")
+			(if weekday-clause 1 (* interval 7))
+			dtstart-conv
+			(or start-t "")
                         (if end-t "-" "") (or end-t "")))))))
           ;; yearly
           ((string-equal frequency "YEARLY")
--- a/lisp/cedet/semantic/db-file.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/cedet/semantic/db-file.el	Mon Aug 09 10:51:16 2010 +0900
@@ -277,7 +277,7 @@
 
 (defmethod object-write ((obj semanticdb-table))
   "When writing a table, we have to make sure we deoverlay it first.
-Restore the overlays after writting.
+Restore the overlays after writing.
 Argument OBJ is the object to write."
   (when (semanticdb-live-p obj)
     (when (semanticdb-in-buffer-p obj)
--- a/lisp/comint.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/comint.el	Mon Aug 09 10:51:16 2010 +0900
@@ -674,6 +674,9 @@
   (make-local-variable 'comint-process-echoes)
   (make-local-variable 'comint-file-name-chars)
   (make-local-variable 'comint-file-name-quote-list)
+  ;; dir tracking on remote files
+  (set (make-local-variable 'comint-file-name-prefix)
+       (or (file-remote-p default-directory) ""))
   (make-local-variable 'comint-accum-marker)
   (setq comint-accum-marker (make-marker))
   (make-local-variable 'font-lock-defaults)
--- a/lisp/cus-start.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/cus-start.el	Mon Aug 09 10:51:16 2010 +0900
@@ -197,6 +197,11 @@
 	     (help-char keyboard character)
 	     (help-event-list keyboard (repeat (sexp :format "%v")))
 	     (menu-prompting menu boolean)
+	     (select-active-regions killing
+				    (choice (const :tag "lazy" lazy)
+					    (const :tag "always" t)
+					    (const :tag "off" nil))
+				    "24.1")
 	     (suggest-key-bindings keyboard (choice (const :tag "off" nil)
 						    (integer :tag "time" 2)
 						    (other :tag "on")))
@@ -345,6 +350,7 @@
 		      (const :tag "Text" :value text)
 		      (const :tag "Both" :value both)
 		      (const :tag "Both-horiz" :value both-horiz)
+		      (const :tag "Text-image-horiz" :value text-image-horiz)
 		      (const :tag "System default" :value nil)) "23.3")
              (tool-bar-max-label-size frames integer "23.3")
 
@@ -357,6 +363,7 @@
 	     (x-gtk-show-hidden-files menu boolean "22.1")
 	     (x-gtk-file-dialog-help-text menu boolean "22.1")
 	     (x-gtk-whole-detached-tool-bar x boolean "22.1")
+	     (x-gtk-use-system-tooltips tooltip boolean "23.3")
 	     ;; xterm.c
 	     (x-use-underline-position-properties display boolean "22.1")
 	     (x-underline-at-descent-line display boolean "22.1")
--- a/lisp/dabbrev.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/dabbrev.el	Mon Aug 09 10:51:16 2010 +0900
@@ -377,7 +377,7 @@
 function pointed out by `dabbrev-friend-buffer-function' to find the
 completions.
 
-If the prefix argument is 16 (which comes from \\[prefix-argument] \\[prefix-argument]),
+If the prefix argument is 16 (which comes from \\[universal-argument] \\[universal-argument]),
 then it searches *all* buffers."
   (interactive "*P")
   (dabbrev--reset-global-variables)
--- a/lisp/dired.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/dired.el	Mon Aug 09 10:51:16 2010 +0900
@@ -2225,31 +2225,33 @@
 ;; Keeping Dired buffers in sync with the filesystem and with each other
 
 (defun dired-buffers-for-dir (dir &optional file)
-;; Return a list of buffers that dired DIR (top level or in-situ subdir).
+;; Return a list of buffers for DIR (top level or in-situ subdir).
 ;; If FILE is non-nil, include only those whose wildcard pattern (if any)
 ;; matches FILE.
 ;; The list is in reverse order of buffer creation, most recent last.
 ;; As a side effect, killed dired buffers for DIR are removed from
 ;; dired-buffers.
   (setq dir (file-name-as-directory dir))
-  (let ((alist dired-buffers) result elt buf)
-    (while alist
-      (setq elt (car alist)
-	    buf (cdr elt))
-      (if (buffer-name buf)
-	  (if (dired-in-this-tree dir (car elt))
-	      (with-current-buffer buf
-		(and (assoc dir dired-subdir-alist)
-		     (or (null file)
-			 (let ((wildcards
-				(file-name-nondirectory dired-directory)))
-			   (or (= 0 (length wildcards))
-			       (string-match (dired-glob-regexp wildcards)
-					     file))))
-		     (setq result (cons buf result)))))
-	;; else buffer is killed - clean up:
+  (let (result buf)
+    (dolist (elt dired-buffers)
+      (setq buf (cdr elt))
+      (cond
+       ((null (buffer-name buf))
+	;; Buffer is killed - clean up:
 	(setq dired-buffers (delq elt dired-buffers)))
-      (setq alist (cdr alist)))
+       ((dired-in-this-tree dir (car elt))
+	(with-current-buffer buf
+	  (and (assoc dir dired-subdir-alist)
+	       (or (null file)
+		   (if (stringp dired-directory)
+		       (let ((wildcards (file-name-nondirectory
+					 dired-directory)))
+			 (or (= 0 (length wildcards))
+			     (string-match (dired-glob-regexp wildcards)
+					   file)))
+		     (member (expand-file-name file dir)
+			     (cdr dired-directory))))
+	       (setq result (cons buf result)))))))
     result))
 
 (defun dired-glob-regexp (pattern)
--- a/lisp/emacs-lisp/authors.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/authors.el	Mon Aug 09 10:51:16 2010 +0900
@@ -354,7 +354,7 @@
     ;; No longer distributed.
 ;;;    ("Viktor Dukhovni" :wrote "unexsunos4.c")
     ("Paul Eggert" :wrote "rcs2log" "vcdiff")
-    ("Fred Fish" :changed "unexec.c")
+    ("Fred Fish" :changed "unexcoff.c")
     ;; No longer distributed.
 ;;;    ("Tim Fleehart" :wrote "makefile.nt")
     ("Keith Gabryelski" :wrote "hexl.c")
@@ -377,13 +377,13 @@
      "indent.c" "search.c" "xdisp.c" "region-cache.c" "region-cache.h")
     ;; ibmrt.h, ibmrt-aix.h no longer distributed.
     ("International Business Machines" :changed "emacs.c" "fileio.c"
-     "process.c" "sysdep.c" "unexec.c")
+     "process.c" "sysdep.c" "unexcoff.c")
     ;; No longer distributed.
 ;;;    ("Ishikawa Chiaki" :changed "aviion.h" "dgux.h")
     ;; ymakefile no longer distributed.
     ("Michael K. Johnson" :changed "configure.in" "emacs.c" "intel386.h"
      "mem-limits.h" "process.c" "template.h" "sysdep.c" "syssignal.h"
-     "systty.h" "unexec.c" "linux.h")
+     "systty.h" "unexcoff.c" "linux.h")
     ;; No longer distributed.
 ;;;    ("Kyle Jones" :wrote "mldrag.el")
     ("Henry Kautz" :wrote "bib-mode.el")
@@ -408,7 +408,7 @@
      "rmail.el" "rmailedit.el" "rmailkwd.el"
      "rmailmsc.el" "rmailout.el" "rmailsum.el" "scribe.el"
      ;; It was :wrote for xmenu.c, but it has been rewritten since.
-     "server.el" "lisp.h" "sysdep.c" "unexec.c" "xmenu.c")
+     "server.el" "lisp.h" "sysdep.c" "unexcoff.c" "xmenu.c")
     ("Niall Mansfield" :changed "etags.c")
     ("Brian Marick" :cowrote "hideif.el")
     ("Marko Kohtala" :changed "info.el")
@@ -463,9 +463,9 @@
     ("Kayvan Sylvan" :changed "supercite.el")
     ;; No longer distributed: emacsserver.c, tcp.c.
     ("Spencer Thomas" :changed "emacsclient.c" "server.el"
-     "dabbrev.el" "unexec.c" "gnus.texi")
+     "dabbrev.el" "unexcoff.c" "gnus.texi")
     ("Jonathan Vail" :changed "vc.el")
-    ("James Van Artsdalen" :changed "usg5-4.h" "unexec.c")
+    ("James Van Artsdalen" :changed "usg5-4.h" "unexcoff.c")
     ;; No longer distributed: src/makefile.nt, lisp/makefile.nt
     ;; winnt.el renamed to w32-fns.el; nt.[ch] to w32.[ch];
     ;; ntheap.[ch] to w32heap.[ch]; ntinevt.c to w32inevt.c;
--- a/lisp/emacs-lisp/find-gc.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/find-gc.el	Mon Aug 09 10:51:16 2010 +0900
@@ -60,7 +60,7 @@
     "indent.c" "search.c" "regex.c" "undo.c"
     "alloc.c" "data.c" "doc.c" "editfns.c"
     "callint.c" "eval.c" "fns.c" "print.c" "lread.c"
-    "abbrev.c" "syntax.c" "unexec.c"
+    "abbrev.c" "syntax.c" "unexcoff.c"
     "bytecode.c" "process.c" "callproc.c" "doprnt.c"
     "x11term.c" "x11fns.c"))
 
--- a/lisp/emacs-lisp/package-x.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/package-x.el	Mon Aug 09 10:51:16 2010 +0900
@@ -56,12 +56,12 @@
     (setq string (replace-match "&quot;" t nil string)))
   string)
 
-(defun package--make-rss-entry (title text)
+(defun package--make-rss-entry (title text archive-url)
   (let ((date-string (format-time-string "%a, %d %B %Y %T %z")))
     (concat "<item>\n"
 	    "<title>" (package--encode title) "</title>\n"
 	    ;; FIXME: should have a link in the web page.
-	    "<link>" package-archive-base "news.html</link>\n"
+	    "<link>" archive-url "news.html</link>\n"
 	    "<description>" (package--encode text) "</description>\n"
 	    "<pubDate>" date-string "</pubDate>\n"
 	    "</item>\n")))
@@ -85,7 +85,7 @@
 	(unless old-buffer
 	  (kill-buffer (current-buffer)))))))
 
-(defun package-maint-add-news-item (title description)
+(defun package-maint-add-news-item (title description archive-url)
   "Add a news item to the ELPA web pages.
 TITLE is the title of the news item.
 DESCRIPTION is the text of the news item.
@@ -93,21 +93,28 @@
   (interactive "sTitle: \nsText: ")
   (package--update-file (concat package-archive-upload-base "elpa.rss")
 			"<description>"
-			(package--make-rss-entry title description))
+			(package--make-rss-entry title description archive-url))
   (package--update-file (concat package-archive-upload-base "news.html")
 			"New entries go here"
 			(package--make-html-entry title description)))
 
-(defun package--update-news (package version description)
+(defun package--update-news (package version description archive-url)
   "Update the ELPA web pages when a package is uploaded."
   (package-maint-add-news-item (concat package " version " version)
-			       description))
+			       description
+			       archive-url))
 
-(defun package-upload-buffer-internal (pkg-info extension)
+(defun package-upload-buffer-internal (pkg-info extension &optional archive-url)
   "Upload a package whose contents are in the current buffer.
 PKG-INFO is the package info, see `package-buffer-info'.
 EXTENSION is the file extension, a string.  It can be either
-\"el\" or \"tar\"."
+\"el\" or \"tar\".
+
+Optional arg ARCHIVE-URL is the URL of the destination archive.
+If nil, the \"gnu\" archive is used."
+  (unless archive-url
+    (or (setq archive-url (cdr (assoc "gnu" package-archives)))
+	(error "No destination URL")))
   (save-excursion
     (save-restriction
       (let* ((file-type (cond
@@ -127,7 +134,7 @@
 
 	     ;; Download latest archive-contents.
 	     (buffer (url-retrieve-synchronously
-		      (concat package-archive-base "archive-contents"))))
+		      (concat archive-url "archive-contents"))))
 
 	;; Parse archive-contents.
 	(set-buffer buffer)
@@ -178,7 +185,7 @@
 
 	  ;; Write a news entry.
 	  (package--update-news (concat file-name "." extension)
-				pkg-version desc)
+				pkg-version desc archive-url)
 
 	  ;; special-case "package": write a second copy so that the
 	  ;; installer can easily find the latest version.
--- a/lisp/emacs-lisp/package.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/package.el	Mon Aug 09 10:51:16 2010 +0900
@@ -43,9 +43,6 @@
 ;; currently register any of these, so this feature does not actually
 ;; work.)
 
-;; This code supports a single package repository, ELPA.  All packages
-;; must be registered there.
-
 ;; A package is described by its name and version.  The distribution
 ;; format is either  a tar file or a single .el file.
 
@@ -55,11 +52,13 @@
 ;; which consists of a call to define-package.  It may also contain a
 ;; "dir" file and the info files it references.
 
-;; A .el file will be named "NAME-VERSION.el" in ELPA, but will be
+;; A .el file is named "NAME-VERSION.el" in the remote archive, but is
 ;; installed as simply "NAME.el" in a directory named "NAME-VERSION".
 
-;; The downloader will download all dependent packages.  It will also
-;; byte-compile the package's lisp at install time.
+;; The downloader downloads all dependent packages.  By default,
+;; packages come from the official GNU sources, but others may be
+;; added by customizing the `package-archives' alist.  Packages get
+;; byte-compiled at install time.
 
 ;; At activation time we will set up the load-path and the info path,
 ;; and we will load the package's autoloads.  If a package's
@@ -207,6 +206,7 @@
  Hence, the package is \"held\" at that version.
 If VERSION is nil, the package is not loaded (it is \"disabled\")."
   :type '(repeat symbol)
+  :risky t
   :group 'package
   :version "24.1")
 
@@ -217,10 +217,16 @@
 (declare-function lm-commentary "lisp-mnt" (&optional file))
 (declare-function dired-delete-file "dired" (file &optional recursive trash))
 
-(defconst package-archive-base "http://elpa.gnu.org/packages/"
-  "Base URL for the Emacs Lisp Package Archive (ELPA).
-Ordinarily you should not need to change this.
-Note that some code in package.el assumes that this is an http: URL.")
+(defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/"))
+  "An alist of archives from which to fetch.
+The default value points to the GNU Emacs package repository.
+Each element has the form (ID . URL), where ID is an identifier
+string for an archive and URL is a http: URL (a string)."
+  :type '(alist :key-type (string :tag "Archive name")
+                :value-type (string :tag "Archive URL"))
+  :risky t
+  :group 'package
+  :version "24.1")
 
 (defconst package-archive-version 1
   "Version number of the package archive understood by this file.
@@ -234,8 +240,10 @@
   "Cache of the contents of the Emacs Lisp Package Archive.
 This is an alist mapping package names (symbols) to package
 descriptor vectors.  These are like the vectors for `package-alist'
-but have an extra entry which is 'tar for tar packages and
-'single for single-file packages.")
+but have extra entries: one which is 'tar for tar packages and
+'single for single-file packages, and one which is the name of
+the archive from which it came.")
+(put 'package-archive-contents 'risky-local-variable t)
 
 (defcustom package-user-dir (locate-user-emacs-file "elpa")
   "Directory containing the user's Emacs Lisp packages.
@@ -243,6 +251,7 @@
 Apart from this directory, Emacs also looks for system-wide
 packages in `package-directory-list'."
   :type 'directory
+  :risky t
   :group 'package
   :version "24.1")
 
@@ -259,6 +268,7 @@
 These directories contain packages intended for system-wide; in
 contrast, `package-user-dir' contains packages for personal use."
   :type '(repeat directory)
+  :risky t
   :group 'package
   :version "24.1")
 
@@ -282,17 +292,18 @@
 	 (if (>= emacs-major-version 22)
 	     ;; FIXME: emacs 22 includes tramp, rcirc, maybe
 	     ;; other things...
-	     '((erc . [(5 2) nil "An Emacs Internet Relay Chat client"])
+	     '((erc . [(5 2) nil "Internet Relay Chat client"])
 	       ;; The external URL is version 1.15, so make sure the
 	       ;; built-in one looks newer.
 	       (url . [(1 16) nil "URL handling libary"])))
 	 (if (>= emacs-major-version 23)
 	     '(;; Strangely, nxml-version is missing in Emacs 23.
 	       ;; We pick the merge date as the version.
-	       (nxml . [(20071123) nil "Major mode for editing XML documents."])
-	       (bubbles . [(0 5) nil "Puzzle game for Emacs."])))))
+	       (nxml . [(20071123) nil "Major mode for XML documents"])
+	       (bubbles . [(0 5) nil "A puzzle game"])))))
   "Alist of all built-in packages.
 Maps the package name to a vector [VERSION REQS DOCSTRING].")
+(put 'package--builtins 'risky-local-variable t)
 
 (defvar package-alist package--builtins
   "Alist of all packages available for activation.
@@ -301,15 +312,18 @@
 The value is generated by `package-load-descriptor', usually
 called via `package-initialize'.  For user customizations of
 which packages to load/activate, see `package-load-list'.")
+(put 'package-archive-contents 'risky-local-variable t)
 
 (defvar package-activated-list
   (mapcar #'car package-alist)
   "List of the names of currently activated packages.")
+(put 'package-activated-list 'risky-local-variable t)
 
 (defvar package-obsolete-alist nil
   "Representation of obsolete packages.
 Like `package-alist', but maps package name to a second alist.
 The inner alist is keyed by version.")
+(put 'package-obsolete-alist 'risky-local-variable t)
 
 (defconst package-subdirectory-regexp
   "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
@@ -344,16 +358,6 @@
       ;; Both null.
       (funcall fun 0 0))))
 
-(defun package--test-version-compare ()
-  "Test suite for `package-version-compare'."
-  (unless (and (package-version-compare '(0) '(0) '=)
-	       (not (package-version-compare '(1) '(0) '=))
-	       (package-version-compare '(1 0 1) '(1) '>=)
-	       (package-version-compare '(1 0 1) '(1) '>)
-	       (not (package-version-compare '(0 9 1) '(1 0 2) '>=)))
-    (error "Failed"))
-  t)
-
 (defun package-strip-version (dirname)
   "Strip the version from a combined package name and version.
 E.g., if given \"quux-23.0\", will return \"quux\""
@@ -361,16 +365,14 @@
       (match-string 1 dirname)))
 
 (defun package-load-descriptor (dir package)
-  "Load the description file for a package.
-DIR is the directory in which to find the package subdirectory,
-and PACKAGE is the name of the package subdirectory.
-Return nil if the package could not be found."
-  (let ((pkg-dir (expand-file-name package dir)))
-    (if (file-directory-p pkg-dir)
-	(load (expand-file-name (concat (package-strip-version package)
-					"-pkg")
-				pkg-dir)
-	      nil t))))
+  "Load the description file in directory DIR for package PACKAGE."
+  (let* ((pkg-dir (expand-file-name package dir))
+	 (pkg-file (expand-file-name
+		    (concat (package-strip-version package) "-pkg")
+		    pkg-dir)))
+    (when (and (file-directory-p pkg-dir)
+	       (file-exists-p (concat pkg-file ".el")))
+      (load pkg-file nil t))))
 
 (defun package-load-all-descriptors ()
   "Load descriptors for installed Emacs Lisp packages.
@@ -613,20 +615,23 @@
       (let ((load-path (cons pkg-dir load-path)))
 	(byte-recompile-directory pkg-dir 0 t)))))
 
+(defun package--write-file-no-coding (file-name excl)
+  (let ((buffer-file-coding-system 'no-conversion))
+    (write-region (point-min) (point-max) file-name nil nil nil excl)))
+
 (defun package-unpack-single (file-name version desc requires)
   "Install the contents of the current buffer as a package."
   ;; Special case "package".
   (if (string= file-name "package")
-      (write-region (point-min) (point-max)
-		    (expand-file-name (concat file-name ".el")
-				      package-user-dir)
-		    nil nil nil nil)
+      (package--write-file-no-coding
+       (expand-file-name (concat file-name ".el") package-user-dir)
+       nil)
     (let* ((pkg-dir  (expand-file-name (concat file-name "-" version)
 				       package-user-dir))
 	   (el-file  (expand-file-name (concat file-name ".el") pkg-dir))
 	   (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir)))
       (make-directory pkg-dir t)
-      (write-region (point-min) (point-max) el-file nil nil nil 'excl)
+      (package--write-file-no-coding el-file 'excl)
       (let ((print-level nil)
 	    (print-length nil))
 	(write-region
@@ -670,7 +675,7 @@
 (defun package-download-single (name version desc requires)
   "Download and install a single-file package."
   (let ((buffer (url-retrieve-synchronously
-		 (concat package-archive-base
+		 (concat (package-archive-url name)
 			 (symbol-name name) "-" version ".el"))))
     (with-current-buffer buffer
       (package-handle-response)
@@ -683,7 +688,7 @@
 (defun package-download-tar (name version)
   "Download and install a tar package."
   (let ((tar-buffer (url-retrieve-synchronously
-		     (concat package-archive-base
+		     (concat (package-archive-url name)
 			     (symbol-name name) "-" version ".tar"))))
     (with-current-buffer tar-buffer
       (package-handle-response)
@@ -692,12 +697,12 @@
       (package-unpack name version)
       (kill-buffer tar-buffer))))
 
-(defun package-installed-p (package version)
+(defun package-installed-p (package &optional min-version)
   (let ((pkg-desc (assq package package-alist)))
     (and pkg-desc
-	 (package-version-compare version
+	 (package-version-compare min-version
 				  (package-desc-vers (cdr pkg-desc))
-				  '>=))))
+				  '<=))))
 
 (defun package-compute-transaction (result requirements)
   (dolist (elt requirements)
@@ -772,16 +777,13 @@
 		       (car contents) package-archive-version))
 	    (cdr contents))))))
 
-(defun package-read-archive-contents ()
+(defun package-read-all-archive-contents ()
   "Re-read `archive-contents' and `builtin-packages', if they exist.
 Set `package-archive-contents' and `package--builtins' if successful.
 Throw an error if the archive version is too new."
-  (let ((archive-contents (package--read-archive-file "archive-contents"))
-	(builtins (package--read-archive-file "builtin-packages")))
-    (if archive-contents
-	;; Version 1 of 'archive-contents' is identical to our
-	;; internal representation.
-	(setq package-archive-contents archive-contents))
+  (dolist (archive package-archives)
+    (package-read-archive-contents (car archive)))
+  (let ((builtins (package--read-archive-file "builtin-packages")))
     (if builtins
 	;; Version 1 of 'builtin-packages' is a list where the car is
 	;; a split emacs version and the cdr is an alist suitable for
@@ -793,6 +795,33 @@
 		  (if (package-version-compare our-version (car elt) '>=)
 		      (setq result (append (cdr elt) result)))))))))
 
+(defun package-read-archive-contents (archive)
+  "Re-read `archive-contents' and `builtin-packages' for ARCHIVE.
+If successful, set `package-archive-contents' and `package--builtins'.
+If the archive version is too new, signal an error."
+  (let ((archive-contents (package--read-archive-file
+                           (concat "archives/" archive
+                                   "/archive-contents"))))
+    (if archive-contents
+        ;; Version 1 of 'archive-contents' is identical to our
+        ;; internal representation.
+        ;; TODO: merge archive lists
+        (dolist (package archive-contents)
+          (package--add-to-archive-contents package archive)))))
+
+(defun package--add-to-archive-contents (package archive)
+  "Add the PACKAGE from the given ARCHIVE if necessary.
+Also, add the originating archive to the end of the package vector."
+  (let* ((name    (car package))
+         (version (aref (cdr package) 0))
+         (entry   (cons (car package)
+			(vconcat (cdr package) (vector archive))))
+         (existing-package (cdr (assq name package-archive-contents))))
+    (when (or (not existing-package)
+              (package-version-compare version
+                                       (aref existing-package 0) '>))
+      (add-to-list 'package-archive-contents entry))))
+
 (defun package-download-transaction (transaction)
   "Download and install all the packages in the given transaction."
   (dolist (elt transaction)
@@ -817,26 +846,21 @@
 (defun package-install (name)
   "Install the package named NAME.
 Interactively, prompt for the package name.
-The package is found on the archive site, see `package-archive-base'."
+The package is found on one of the archives in `package-archives'."
   (interactive
-   (list (progn
-	   ;; Make sure we're using the most recent download of the
-	   ;; archive.  Maybe we should be updating the archive first?
-	   (package-read-archive-contents)
-	   (intern (completing-read "Install package: "
-				    (mapcar (lambda (elt)
-					      (cons (symbol-name (car elt))
-						    nil))
-					    package-archive-contents)
-				    nil t)))))
+   (list (intern (completing-read "Install package: "
+				  (mapcar (lambda (elt)
+					    (cons (symbol-name (car elt))
+						  nil))
+					  package-archive-contents)
+				  nil t))))
   (let ((pkg-desc (assq name package-archive-contents)))
     (unless pkg-desc
-      (error "Package '%s' not available for installation"
+      (error "Package '%s' is not available for installation"
 	     (symbol-name name)))
-    (let ((transaction
-	   (package-compute-transaction (list name)
-					(package-desc-reqs (cdr pkg-desc)))))
-      (package-download-transaction transaction)))
+    (package-download-transaction
+     (package-compute-transaction (list name)
+				  (package-desc-reqs (cdr pkg-desc)))))
   ;; Try to activate it.
   (package-initialize))
 
@@ -996,20 +1020,28 @@
 		     ;; FIXME: query user?
 		     'always))
 
-(defun package--download-one-archive (file)
-  "Download a single archive file and cache it locally."
-  (let ((buffer (url-retrieve-synchronously
-		 (concat package-archive-base file))))
+(defun package-archive-url (name)
+  "Return the archive containing the package NAME."
+  (let ((desc (cdr (assq (intern-soft name) package-archive-contents))))
+    (cdr (assoc (aref desc (- (length desc) 1)) package-archives))))
+
+(defun package--download-one-archive (archive file)
+  "Download an archive file FILE from ARCHIVE, and cache it locally."
+  (let* ((archive-name (car archive))
+         (archive-url  (cdr archive))
+	 (dir (expand-file-name "archives" package-user-dir))
+	 (dir (expand-file-name archive-name dir))
+         (buffer (url-retrieve-synchronously (concat archive-url file))))
     (with-current-buffer buffer
       (package-handle-response)
       (re-search-forward "^$" nil 'move)
       (forward-char)
       (delete-region (point-min) (point))
-      (setq buffer-file-name (concat (file-name-as-directory package-user-dir)
-				     file))
+      (make-directory dir t)
+      (setq buffer-file-name (expand-file-name file dir))
       (let ((version-control 'never))
-	(save-buffer))
-      (kill-buffer buffer))))
+	(save-buffer)))
+    (kill-buffer buffer)))
 
 (defun package-refresh-contents ()
   "Download the ELPA archive description if needed.
@@ -1019,9 +1051,9 @@
   (interactive)
   (unless (file-exists-p package-user-dir)
     (make-directory package-user-dir t))
-  (package--download-one-archive "archive-contents")
-  (package--download-one-archive "builtin-packages")
-  (package-read-archive-contents))
+  (dolist (archive package-archives)
+    (package--download-one-archive archive "archive-contents"))
+  (package-read-all-archive-contents))
 
 ;;;###autoload
 (defun package-initialize ()
@@ -1030,7 +1062,7 @@
   (interactive)
   (setq package-obsolete-alist nil)
   (package-load-all-descriptors)
-  (package-read-archive-contents)
+  (package-read-all-archive-contents)
   ;; Try to activate all our packages.
   (mapc (lambda (elt)
 	  (package-activate (car elt) (package-desc-vers (cdr elt))))
@@ -1306,11 +1338,12 @@
 For single-file packages, shows the commentary section from the header.
 For larger packages, shows the README file."
   (interactive)
-  (let* (start-point ok
-	 (pkg-name (package-menu-get-package))
-	 (buffer (url-retrieve-synchronously (concat package-archive-base
-						     pkg-name
-						     "-readme.txt"))))
+  (let* ((pkg-name (package-menu-get-package))
+	 (buffer (url-retrieve-synchronously
+		  (concat (package-archive-url pkg-name)
+			  pkg-name
+			  "-readme.txt")))
+	 start-point ok)
     (with-current-buffer buffer
       ;; FIXME: it would be nice to work with any URL type.
       (setq start-point url-http-end-of-headers)
@@ -1322,7 +1355,7 @@
 	  (insert "Package information for " pkg-name "\n\n")
 	  (if ok
 	      (insert-buffer-substring buffer start-point)
-	    (insert "This package does not have a README file or commentary comment.\n"))
+	    (insert "This package lacks a README file or commentary.\n"))
 	  (goto-char (point-min))
 	  (view-mode)))
       (display-buffer new-buffer t))))
@@ -1355,7 +1388,6 @@
 Emacs."
   (interactive)
   (goto-char (point-min))
-  (forward-line 2)
   (while (not (eobp))
     (let ((cmd (char-after))
 	  (pkg-name (package-menu-get-package))
@@ -1380,7 +1412,7 @@
 
 (defun package-print-package (package version key desc)
   (let ((face
-	 (cond ((eq package 'emacs) 'font-lock-builtin-face)
+	 (cond ((string= key "built-in") 'font-lock-builtin-face)
 	       ((string= key "available") 'default)
 	       ((string= key "held") 'font-lock-constant-face)
 	       ((string= key "disabled") 'font-lock-warning-face)
@@ -1402,7 +1434,9 @@
     ;; FIXME: this 'when' is bogus...
     (when desc
       (indent-to 43 1)
-      (insert (propertize desc 'font-lock-face face)))
+      (let ((opoint (point)))
+	(insert (propertize desc 'font-lock-face face))
+	(upcase-region opoint (min (point) (1+ opoint)))))
     (insert "\n")))
 
 (defun package-list-maybe-add (package version status description result)
@@ -1420,22 +1454,31 @@
     (setq buffer-read-only nil)
     (erase-buffer)
     (let ((info-list)
-	  name desc hold)
+	  name desc hold
+	  builtin)
       ;; List installed packages
       (dolist (elt package-alist)
+	;; Ignore the Emacs package.
 	(setq name (car elt)
 	      desc (cdr elt)
 	      hold (assq name package-load-list))
-	(setq info-list
-	      (package-list-maybe-add name (package-desc-vers desc)
-				      ;; FIXME: it turns out to be
-				      ;; tricky to see if this package
-				      ;; is presently activated.
-				      (if (stringp (cadr hold))
-					  "held"
-					"installed")
-				      (package-desc-doc desc)
-				      info-list)))
+	(unless (eq name 'emacs)
+	  (setq info-list
+		(package-list-maybe-add
+		 name (package-desc-vers desc)
+		 ;; FIXME: it turns out to be tricky to see if this
+		 ;; package is presently activated.
+		 (cond ((stringp (cadr hold))
+			"held")
+		       ((and (setq builtin (assq name package--builtins))
+			     (package-version-compare
+			      (package-desc-vers (cdr builtin))
+			      (package-desc-vers desc)
+			      '=))
+			"built-in")
+		       (t "installed"))
+		 (package-desc-doc desc)
+		 info-list))))
       ;; List available packages
       (dolist (elt package-archive-contents)
 	(setq name (car elt)
@@ -1532,8 +1575,8 @@
 	   '((0 . "")
 	     (2 . "Package")
 	     (20 . "Version")
-	     (30 . "Status")
-	     (41 . "Description"))
+	     (32 . "Status")
+	     (43 . "Description"))
 	   ""))
 
     ;; It's okay to use pop-to-buffer here.  The package menu buffer
--- a/lisp/emacs-lisp/re-builder.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/re-builder.el	Mon Aug 09 10:51:16 2010 +0900
@@ -61,14 +61,12 @@
 ;; this limit allowing an easy way to see all matches.
 
 ;; Currently `re-builder' understands five different forms of input,
-;; namely `read', `string', `rx', `sregex' and `lisp-re' syntax.  Read
+;; namely `read', `string', `rx', and `sregex' syntax.  Read
 ;; syntax and string syntax are both delimited by `"'s and behave
 ;; according to their name.  With the `string' syntax there's no need
 ;; to escape the backslashes and double quotes simplifying the editing
 ;; somewhat.  The other three allow editing of symbolic regular
-;; expressions supported by the packages of the same name.  (`lisp-re'
-;; is a package by me and its support may go away as it is nearly the
-;; same as the `sregex' package in Emacs)
+;; expressions supported by the packages of the same name.
 
 ;; Editing symbolic expressions is done through a major mode derived
 ;; from `emacs-lisp-mode' so you'll get all the good stuff like
@@ -128,12 +126,11 @@
 
 (defcustom reb-re-syntax 'read
   "Syntax for the REs in the RE Builder.
-Can either be `read', `string', `sregex', `lisp-re', `rx'."
+Can either be `read', `string', `sregex', or `rx'."
   :group 're-builder
   :type '(choice (const :tag "Read syntax" read)
 		 (const :tag "String syntax" string)
 		 (const :tag "`sregex' syntax" sregex)
-		 (const :tag "`lisp-re' syntax" lisp-re)
 		 (const :tag "`rx' syntax" rx)))
 
 (defcustom reb-auto-match-limit 200
@@ -281,9 +278,8 @@
 (define-derived-mode reb-lisp-mode
   emacs-lisp-mode "RE Builder Lisp"
   "Major mode for interactively building symbolic Regular Expressions."
-  (cond ((eq reb-re-syntax 'lisp-re)	; Pull in packages
-	 (require 'lisp-re))		; as needed
-	((eq reb-re-syntax 'sregex)	; sregex is not autoloaded
+  ;; Pull in packages as needed
+  (cond	((eq reb-re-syntax 'sregex)	; sregex is not autoloaded
 	 (require 'sregex))		; right now..
 	((eq reb-re-syntax 'rx)		; rx-to-string is autoloaded
 	 (require 'rx)))		; require rx anyway
@@ -329,7 +325,7 @@
 
 (defsubst reb-lisp-syntax-p ()
   "Return non-nil if RE Builder uses a Lisp syntax."
-  (memq reb-re-syntax '(lisp-re sregex rx)))
+  (memq reb-re-syntax '(sregex rx)))
 
 (defmacro reb-target-binding (symbol)
   "Return binding for SYMBOL in the RE Builder target buffer."
@@ -489,10 +485,10 @@
    (list (intern
 	  (completing-read "Select syntax: "
 			   (mapcar (lambda (el) (cons (symbol-name el) 1))
-				   '(read string lisp-re sregex rx))
+				   '(read string sregex rx))
 			   nil t (symbol-name reb-re-syntax)))))
 
-  (if (memq syntax '(read string lisp-re sregex rx))
+  (if (memq syntax '(read string sregex rx))
       (let ((buffer (get-buffer reb-buffer)))
 	(setq reb-re-syntax syntax)
 	(when buffer
@@ -616,10 +612,7 @@
 
 (defun reb-cook-regexp (re)
   "Return RE after processing it according to `reb-re-syntax'."
-  (cond ((eq reb-re-syntax 'lisp-re)
-	 (when (fboundp 'lre-compile-string)
-	   (lre-compile-string (eval (car (read-from-string re))))))
-	((eq reb-re-syntax 'sregex)
+  (cond ((eq reb-re-syntax 'sregex)
 	 (apply 'sregex (eval (car (read-from-string re)))))
 	((eq reb-re-syntax 'rx)
 	 (rx-to-string (eval (car (read-from-string re)))))
--- a/lisp/emacs-lisp/syntax.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/syntax.el	Mon Aug 09 10:51:16 2010 +0900
@@ -52,7 +52,7 @@
 
 (defun syntax-ppss-toplevel-pos (ppss)
   "Get the latest syntactically outermost position found in a syntactic scan.
-PPSS is a scan state, as returned by `partial-parse-sexp' or `syntax-ppss'.
+PPSS is a scan state, as returned by `parse-partial-sexp' or `syntax-ppss'.
 An \"outermost position\" means one that it is outside of any syntactic entity:
 outside of any parentheses, comments, or strings encountered in the scan.
 If no such position is recorded in PPSS (because the end of the scan was
--- a/lisp/emacs-lisp/timer.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emacs-lisp/timer.el	Mon Aug 09 10:51:16 2010 +0900
@@ -321,7 +321,11 @@
 	  ;; We do this after rescheduling so that the handler function
 	  ;; can cancel its own timer successfully with cancel-timer.
 	  (condition-case nil
-	      (apply (timer--function timer) (timer--args timer))
+              ;; Timer functions should not change the current buffer.
+              ;; If they do, all kinds of nasty surprises can happen,
+              ;; and it can be hellish to track down their source.
+              (save-current-buffer
+                (apply (timer--function timer) (timer--args timer)))
 	    (error nil))
 	  (if retrigger
 	      (setf (timer--triggered timer) nil)))
--- a/lisp/emulation/pc-select.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/emulation/pc-select.el	Mon Aug 09 10:51:16 2010 +0900
@@ -110,7 +110,7 @@
   :group 'pc-select)
 
 (defcustom pc-selection-mode-hook nil
-  "The hook to run when pc-selection-mode is toggled."
+  "The hook to run when PC Selection mode is toggled."
   :type 'hook
   :group 'pc-select)
 
@@ -261,7 +261,7 @@
 (provide 'pc-select)
 
 (defun copy-region-as-kill-nomark (beg end)
-  "Save the region as if killed; but don't kill it; deactivate mark.
+  "Save the region as if killed, but don't kill it; deactivate mark.
 If `interprogram-cut-function' is non-nil, also save the text for a window
 system cut and paste.
 
@@ -569,7 +569,7 @@
 ;;;;;;;;;;;;;;;;;;;;
 
 (defun backward-char-mark (&optional arg)
-"Ensure mark is active; move point left ARG characters (right if ARG negative).
+  "Ensure mark is active; move point left ARG characters (right if ARG negative).
 On attempt to pass beginning or end of buffer, stop and signal error."
   (interactive "p")
   (pc-select-ensure-mark)
@@ -633,7 +633,7 @@
 
 
 (defun scroll-up-mark (&optional arg)
-"Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
+  "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
 A near full screen is `next-screen-context-lines' less than a full screen.
 Negative ARG means scroll downward.
 When calling from a program, supply a number as argument or nil.
@@ -654,7 +654,7 @@
 of the accessible part of the buffer.
 
 Don't use this command in Lisp programs!
-\(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
+\(goto-char (point-min)) is faster and avoids clobbering the mark."
   (interactive "P")
   (pc-select-ensure-mark)
   (let ((size (- (point-max) (point-min))))
@@ -841,7 +841,7 @@
 
 ;;;###autoload
 (define-minor-mode pc-selection-mode
-  "Change mark behavior to emulate Motif, MAC or MS-Windows cut and paste style.
+  "Change mark behavior to emulate Motif, Mac or MS-Windows cut and paste style.
 
 This mode enables Delete Selection mode and Transient Mark mode.
 
--- a/lisp/epa-mail.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/epa-mail.el	Mon Aug 09 10:51:16 2010 +0900
@@ -32,6 +32,12 @@
     (define-key keymap "\C-c\C-ee" 'epa-mail-encrypt)
     (define-key keymap "\C-c\C-ei" 'epa-mail-import-keys)
     (define-key keymap "\C-c\C-eo" 'epa-insert-keys)
+    (define-key keymap "\C-c\C-e\C-d" 'epa-mail-decrypt)
+    (define-key keymap "\C-c\C-e\C-v" 'epa-mail-verify)
+    (define-key keymap "\C-c\C-e\C-s" 'epa-mail-sign)
+    (define-key keymap "\C-c\C-e\C-e" 'epa-mail-encrypt)
+    (define-key keymap "\C-c\C-e\C-i" 'epa-mail-import-keys)
+    (define-key keymap "\C-c\C-e\C-o" 'epa-insert-keys)
     keymap))
 
 (defvar epa-mail-mode-hook nil)
--- a/lisp/erc/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/erc/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,11 @@
+2010-08-08  Fran Litterio  <flitterio@gmail.com>
+
+	* erc-backend.el (erc-server-filter-function): Call
+	erc-log-irc-protocol.
+
+	* erc.el (erc-toggle-debug-irc-protocol): Bind
+	erc-toggle-debug-irc-protocol to t.
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/lisp/erc/erc-backend.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/erc/erc-backend.el	Mon Aug 09 10:51:16 2010 +0900
@@ -574,6 +574,7 @@
                       nil
                     (substring erc-server-filter-data
                                (match-end 0))))
+            (erc-log-irc-protocol line nil)
             (erc-parse-server-response process line)))))))
 
 (defsubst erc-server-reconnect-p (event)
--- a/lisp/erc/erc.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/erc/erc.el	Mon Aug 09 10:51:16 2010 +0900
@@ -2306,14 +2306,14 @@
 	  (insert (erc-make-notice "This buffer displays all IRC protocol traffic exchanged with each server.\n"))
 	  (insert (erc-make-notice "Kill this buffer to terminate protocol logging.\n\n")))
 	(use-local-map (make-sparse-keymap))
-	(local-set-key (kbd "RET") 'erc-toggle-debug-irc-protocol))
+	(local-set-key (kbd "t") 'erc-toggle-debug-irc-protocol))
       (add-hook 'kill-buffer-hook
 		#'(lambda () (setq erc-debug-irc-protocol nil))
 		nil 'local)
       (goto-char (point-max))
       (let ((inhibit-read-only t))
 	(insert (erc-make-notice
-		 (format "IRC protocol logging %s at %s -- Press ENTER to toggle logging.\n"
+		 (format "IRC protocol logging %s at %s -- Press `t' to toggle logging.\n"
 			 (if erc-debug-irc-protocol "disabled" "enabled")
 			 (current-time-string))))))
     (setq erc-debug-irc-protocol (not erc-debug-irc-protocol))
--- a/lisp/eshell/esh-io.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/eshell/esh-io.el	Mon Aug 09 10:51:16 2010 +0900
@@ -343,8 +343,9 @@
 	(let* ((exists (get-file-buffer target))
 	       (buf (find-file-noselect target t)))
 	  (with-current-buffer buf
-	    (if buffer-read-only
+	    (if buffer-file-read-only
 		(error "Cannot write to read-only file `%s'" target))
+	    (setq buffer-read-only nil)
 	    (set (make-local-variable 'eshell-output-file-buffer)
 		 (if (eq exists buf) 0 t))
 	    (cond ((eq mode 'overwrite)
--- a/lisp/faces.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/faces.el	Mon Aug 09 10:51:16 2010 +0900
@@ -376,7 +376,7 @@
 (defun face-all-attributes (face &optional frame)
   "Return an alist stating the attributes of FACE.
 Each element of the result has the form (ATTR-NAME . ATTR-VALUE).
-Normally the value describes the default attributes,
+If FRAME is omitted or nil the value describes the default attributes,
 but if you specify FRAME, the value describes the attributes
 of FACE on FRAME."
   (mapcar (lambda (pair)
--- a/lisp/files.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/files.el	Mon Aug 09 10:51:16 2010 +0900
@@ -2784,6 +2784,9 @@
 	(truncate-lines          . booleanp)   ;; C source code
 	(bidi-display-reordering . booleanp))) ;; C source code
 
+(put 'bidi-paragraph-direction 'safe-local-variable
+     (lambda (v) (memq v '(nil right-to-left left-to-right))))
+
 (put 'c-set-style 'safe-local-eval-function t)
 
 (defvar file-local-variables-alist nil
--- a/lisp/frame.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/frame.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1431,23 +1431,6 @@
 the opposite frame edge from the edge indicated in the input spec."
   (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec))))
 
-;;;; Aliases for backward compatibility with Emacs 18.
-(define-obsolete-function-alias 'screen-height 'frame-height "19.7")
-(define-obsolete-function-alias 'screen-width 'frame-width "19.7")
-
-(defun set-screen-width (cols &optional pretend)
-  "Change the size of the screen to COLS columns.
-Optional second arg non-nil means that redisplay should use COLS columns
-but that the idea of the actual width of the frame should not be changed.
-This function is provided only for compatibility with Emacs 18."
-  (set-frame-width (selected-frame) cols pretend))
-
-(defun set-screen-height (lines &optional pretend)
-  "Change the height of the screen to LINES lines.
-Optional second arg non-nil means that redisplay should use LINES lines
-but that the idea of the actual height of the screen should not be changed.
-This function is provided only for compatibility with Emacs 18."
-  (set-frame-height (selected-frame) lines pretend))
 
 (defun delete-other-frames (&optional frame)
   "Delete all frames except FRAME.
@@ -1473,9 +1456,6 @@
       (when (eq (frame-parameter frame 'minibuffer) 'only)
 	(delete-frame frame)))))
 
-(make-obsolete 'set-screen-width 'set-frame-width "19.7")
-(make-obsolete 'set-screen-height 'set-frame-height "19.7")
-
 ;; miscellaneous obsolescence declarations
 (define-obsolete-variable-alias 'delete-frame-hook
     'delete-frame-functions "22.1")
--- a/lisp/gnus/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/gnus/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,20 @@
+2010-08-06  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* rfc2047.el (rfc2047-encode): Use utf-8 as a last resort if
+	determining charset of text fails.
+
+2010-08-01  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* nnmail.el (nnmail-get-new-mail-1): Revert.
+
+	* nnml.el (nnml-active-number): Make sure names of newly created groups
+	in nnml-group-alist are encoded.
+
+2010-07-30  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* nnmail.el (nnmail-get-new-mail-1): Encode group names possibly
+	containing non-ASCII characters in active file for nnml back end.
+
 2010-07-24  David Engster  <dengste@eml.cc>
 
 	* mml-smime.el (mml-smime-epg-verify): Also accept the older
--- a/lisp/gnus/ChangeLog.2	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/gnus/ChangeLog.2	Mon Aug 09 10:51:16 2010 +0900
@@ -2603,7 +2603,7 @@
 
 	* message.el (message-use-idna): Use mm-coding-system-p.
 	(message-tokenize-header, message-make-organization)
-	(message-make-from):  Use with-temp-buffer.
+	(message-make-from): Use with-temp-buffer.
 	(message-set-work-buffer): Deleted.
 	(message-fill-paragraph): Use `if' not `and' for compiler warning.
 	(message-check-news-header-syntax): Remove useless lambda.
@@ -5643,7 +5643,7 @@
 
 2003-01-12  Raymond Scholz  <ray-2003@zonix.de>
 
-	* gnus-msg.el (gnus-confirm-mail-reply-to-news):  May be a
+	* gnus-msg.el (gnus-confirm-mail-reply-to-news): May be a
 	regexp or a function too.
 	(gnus-confirm-treat-mail-like-news): New variable.  Ask for
 	confirmation even if the original article is mail.
@@ -16855,7 +16855,7 @@
 
 	* gnus-msg.el (gnus-summary-mail-forward): ???
 
-	* message.el (message-forward):  Move mime-to-mml here.
+	* message.el (message-forward): Move mime-to-mml here.
 
 2000-12-20 02:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
@@ -17157,7 +17157,7 @@
 
 	* nnheader.el: Wrap subst-char-in-string def in eval-and-compile.
 	Put some defvars in eval-when-compile.
-	(gnus-intersection, gnus-sorted-complement):  Autoload.
+	(gnus-intersection, gnus-sorted-complement): Autoload.
 
 	* imap.el (imap-point-at-eol): New, replacing gnus-point-at-eol.
 
@@ -17329,7 +17329,7 @@
 
 	* qp.el (mm-decode-coding-region, mm-encode-coding-region):
 	Autoload.
-	(quoted-printable-decode-region):  Rename arg which confused
+	(quoted-printable-decode-region): Rename arg which confused
 	charset with coding-system.  Don't use nonascii-insert-offset.
 	Coding-system encode the region initially.  Don't recognize `=='
 	as valid QP.  Coding-system decode the region finally.
@@ -17384,7 +17384,7 @@
 
 2000-09-29  Gerd Moellmann  <gerd@gnu.org>
 
-	* smiley-ems.el (smiley-update-cache):  Use `:ascent center'.
+	* smiley-ems.el (smiley-update-cache): Use `:ascent center'.
 
 2000-09-21  Dave Love  <fx@gnu.org>
 
@@ -18036,7 +18036,7 @@
 	* gnus-art.el (gnus-mime-display-part): Show MIME security button.
 	(gnus-insert-mime-security-button): New function.
 	* mm-decode.el (mm-possibly-verify-or-decrypt): Add security info.
-	* mml2015.el:  Add security info when verify or decrypt.
+	* mml2015.el: Add security info when verify or decrypt.
 	* mm-uu.el (mm-uu-pgp-signed-extract): Use multipart.
 	(mm-uu-pgp-encrypted-extract): Ditto.
 
@@ -18433,7 +18433,7 @@
 	(mm-dissect-multipart): Use it.
 	* mml2015.el (mml2015-fix-micalg): New function.
 	(mml2015-decrypt): Use new interface.
-	(mml2015-verify):  Use new interface.
+	(mml2015-verify): Use new interface.
 	(mml2015-setup): Make it bogus.
 
 2000-10-28 16:54:45  ShengHuo ZHU  <zsh@cs.rochester.edu>
--- a/lisp/gnus/nnml.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/gnus/nnml.el	Mon Aug 09 10:51:16 2010 +0900
@@ -751,10 +751,9 @@
 
 (defun nnml-active-number (group &optional server)
   "Compute the next article number in GROUP on SERVER."
-  (let ((active (cadr (assoc (if nnmail-group-names-not-encoded-p
-				 (nnml-encoded-group-name group server)
-			       group)
-			     nnml-group-alist))))
+  (let* ((encoded (if nnmail-group-names-not-encoded-p
+		      (nnml-encoded-group-name group server)))
+	 (active (cadr (assoc (or encoded group) nnml-group-alist))))
     ;; The group wasn't known to nnml, so we just create an active
     ;; entry for it.
     (unless active
@@ -772,7 +771,7 @@
 		(cons (caar nnml-article-file-alist)
 		      (caar (last nnml-article-file-alist)))
 	      (cons 1 0)))
-      (push (list group active) nnml-group-alist))
+      (push (list (or encoded group) active) nnml-group-alist))
     (setcdr active (1+ (cdr active)))
     (while (file-exists-p
 	    (nnml-group-pathname group (int-to-string (cdr active)) server))
--- a/lisp/gnus/rfc2047.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/gnus/rfc2047.el	Mon Aug 09 10:51:16 2010 +0900
@@ -655,6 +655,9 @@
 Point moves to the end of the region."
   (let ((mime-charset (or (mm-find-mime-charset-region b e) (list 'us-ascii)))
 	cs encoding tail crest eword)
+    ;; Use utf-8 as a last resort if determining charset of text fails.
+    (if (memq nil mime-charset)
+	(setq mime-charset (list 'utf-8)))
     (cond ((> (length mime-charset) 1)
 	   (error "Can't rfc2047-encode `%s'"
 		  (buffer-substring-no-properties b e)))
--- a/lisp/help-fns.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/help-fns.el	Mon Aug 09 10:51:16 2010 +0900
@@ -231,8 +231,8 @@
   "Guess the file that defined the Lisp object OBJECT, of type TYPE.
 OBJECT should be a symbol associated with a function, variable, or face;
   alternatively, it can be a function definition.
-If TYPE is `variable', search for a variable definition.
-If TYPE is `face', search for a face definition.
+If TYPE is `defvar', search for a variable definition.
+If TYPE is `defface', search for a face definition.
 If TYPE is the value returned by `symbol-function' for a function symbol,
  search for a function definition.
 
--- a/lisp/image-mode.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/image-mode.el	Mon Aug 09 10:51:16 2010 +0900
@@ -128,6 +128,28 @@
 
 (declare-function image-size "image.c" (spec &optional pixels frame))
 
+(defun image-display-size (spec &optional pixels frame)
+  "Wrapper around `image-size', to handle slice display properties.
+If SPEC is an image display property, call `image-size' with the
+given arguments.
+If SPEC is a list of properties containing `image' and `slice'
+properties, calculate the display size from the slice property.
+If SPEC contains `image' but not `slice', call `image-size' with
+the specified image."
+  (if (eq (car spec) 'image)
+      (image-size spec pixels frame)
+    (let ((image (assoc 'image spec))
+	  (slice (assoc 'slice spec)))
+      (cond ((and image slice)
+	     (if pixels
+		 (cons (nth 3 slice) (nth 4 slice))
+	       (cons (/ (float (nth 3 slice)) (frame-char-width frame))
+		     (/ (float (nth 4 slice)) (frame-char-height frame)))))
+	    (image
+	     (image-size image pixels frame))
+	    (t
+	     (error "Invalid image specification: %s" spec))))))
+
 (defun image-forward-hscroll (&optional n)
   "Scroll image in current window to the left by N character widths.
 Stop if the right edge of the image is reached."
@@ -139,7 +161,7 @@
 	 (let* ((image (image-get-display-property))
 		(edges (window-inside-edges))
 		(win-width (- (nth 2 edges) (nth 0 edges)))
-		(img-width (ceiling (car (image-size image)))))
+		(img-width (ceiling (car (image-display-size image)))))
 	   (image-set-window-hscroll (min (max 0 (- img-width win-width))
 					  (+ n (window-hscroll))))))))
 
@@ -160,7 +182,7 @@
 	 (let* ((image (image-get-display-property))
 		(edges (window-inside-edges))
 		(win-height (- (nth 3 edges) (nth 1 edges)))
-		(img-height (ceiling (cdr (image-size image)))))
+		(img-height (ceiling (cdr (image-display-size image)))))
 	   (image-set-window-vscroll (min (max 0 (- img-height win-height))
 					  (+ n (window-vscroll))))))))
 
@@ -233,7 +255,7 @@
   (let* ((image (image-get-display-property))
 	 (edges (window-inside-edges))
 	 (win-width (- (nth 2 edges) (nth 0 edges)))
-	 (img-width (ceiling (car (image-size image)))))
+	 (img-width (ceiling (car (image-display-size image)))))
     (image-set-window-hscroll (max 0 (- img-width win-width)))))
 
 (defun image-bob ()
@@ -248,9 +270,9 @@
   (let* ((image (image-get-display-property))
 	 (edges (window-inside-edges))
 	 (win-width (- (nth 2 edges) (nth 0 edges)))
-	 (img-width (ceiling (car (image-size image))))
+	 (img-width (ceiling (car (image-display-size image))))
 	 (win-height (- (nth 3 edges) (nth 1 edges)))
-	 (img-height (ceiling (cdr (image-size image)))))
+	 (img-height (ceiling (cdr (image-display-size image)))))
     (image-set-window-hscroll (max 0 (- img-width win-width)))
     (image-set-window-vscroll (max 0 (- img-height win-height)))))
 
@@ -264,7 +286,7 @@
   (interactive)
   (let* ((saved (frame-parameter nil 'image-mode-saved-size))
          (display (image-get-display-property))
-         (size (image-size display)))
+         (size (image-display-size display)))
     (if (and saved
              (eq (caar saved) (frame-width))
              (eq (cdar saved) (frame-height)))
--- a/lisp/international/mule-conf.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/international/mule-conf.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1410,9 +1410,10 @@
   :flags '(ascii-at-eol ascii-at-cntl designation single-shift composition))
 
 (define-coding-system 'compound-text
-  "Compound text based generic encoding for decoding unknown messages.
-
-This coding system does not support extended segments of CTEXT."
+  "Compound text based generic encoding.
+This coding system is an extension of X's \"Compound Text Encoding\".
+It encodes many characters using the normal ISO-2022 designation sequences,
+but it doesn't support extended segments of CTEXT."
   :coding-type 'iso-2022
   :mnemonic ?x
   :charset-list 'iso-2022
@@ -1432,7 +1433,7 @@
 ;; not have a mime-charset property, to prevent it from showing up
 ;; close to the beginning of coding systems ordered by priority.
 (define-coding-system 'ctext-no-compositions
- "Compound text based generic encoding for decoding unknown messages.
+ "Compound text based generic encoding.
 
 Like `compound-text', but does not produce escape sequences for compositions."
   :coding-type 'iso-2022
@@ -1445,8 +1446,9 @@
 (define-coding-system 'compound-text-with-extensions
  "Compound text encoding with ICCCM Extended Segment extensions.
 
-See the variable `ctext-non-standard-encodings-alist' for the
-detail about how extended segments are handled.
+See the variables `ctext-standard-encodings' and
+`ctext-non-standard-encodings-alist' for the detail about how
+extended segments are handled.
 
 This coding system should be used only for X selections.  It is inappropriate
 for decoding and encoding files, process I/O, etc."
--- a/lisp/international/mule.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/international/mule.el	Mon Aug 09 10:51:16 2010 +0900
@@ -282,6 +282,7 @@
 	(plist-put props :short-name (symbol-name name)))
     (or (plist-get props :long-name)
 	(plist-put props :long-name (plist-get props :short-name)))
+    (plist-put props :base name)
     ;; We can probably get a worthwhile amount in purespace.
     (setq props
 	  (mapcar (lambda (elt)
@@ -1465,7 +1466,9 @@
   '(("big5-0" big5 2 big5)
     ("ISO8859-14" iso-8859-14 1 latin-iso8859-14)
     ("ISO8859-15" iso-8859-15 1 latin-iso8859-15)
-    ("gbk-0" gbk 2 chinese-gbk)))
+    ("gbk-0" gbk 2 chinese-gbk)
+    ("koi8-r" koi8-r 1 koi8-r)
+    ("microsoft-cp1251" windows-1251 1 windows-1251)))
   "Alist of non-standard encoding names vs the corresponding usages in CTEXT.
 
 It controls how extended segments of a compound text are handled
@@ -1554,6 +1557,20 @@
       (goto-char (point-min))
       (- (point-max) (point)))))
 
+(defvar ctext-standard-encodings
+  '(ascii latin-jisx0201 katakana-jisx0201
+	  latin-iso8859-1 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
+	  greek-iso8859-7 arabic-iso8859-6 hebrew-iso8859-8 cyrillic-iso8859-5
+	  latin-iso8859-9
+	  chinese-gb2312 japanese-jisx0208 korean-ksc5601)
+  "List of approved standard encodings (i.e. charsets) of X's Compound Text.
+Coding-system `compound-text-with-extensions' encodes a character
+belonging to any of those charsets using the normal ISO2022
+designation sequence unless the current language environment or
+the variable `ctext-non-standard-encodings' decide to use an extended
+segment of CTEXT for that character.  See also the documentation
+of `ctext-non-standard-encodings-alist'.")
+
 ;; Return an alist of CHARSET vs CTEXT-USAGE-INFO generated from
 ;; `ctext-non-standard-encodings' and a list specified by the key
 ;; `ctext-non-standard-encodings' for the currrent language
@@ -1565,115 +1582,94 @@
 ;; is encoded using UTF-8 encoding extention.
 
 (defun ctext-non-standard-encodings-table ()
-  (let (table)
-    ;; Setup charsets specified by the key
-    ;; `ctext-non-standard-encodings' for the current language
-    ;; environment and in `ctext-non-standard-encodings'.
-    (dolist (encoding (append
-			(get-language-info current-language-environment
-					   'ctext-non-standard-encodings)
-			ctext-non-standard-encodings))
-      (let* ((slot (assoc encoding ctext-non-standard-encodings-alist))
+  (let* ((table (append ctext-non-standard-encodings
+			(copy-sequence
+			 (get-language-info current-language-environment
+					    'ctext-non-standard-encodings))))
+	 (tail table)
+	 elt)
+    (while tail
+      (setq elt (car tail))
+      (let* ((slot (assoc elt ctext-non-standard-encodings-alist))
 	     (charset (nth 3 slot)))
 	(if (charsetp charset)
-	    (push (cons charset slot) table)
-	  (dolist (cs charset)
-	    (push (cons cs slot) table)))))
-
-    ;; Next prepend charsets for ISO2022 designation sequence.
-    (dolist (charset charset-list)
-      (let ((final (plist-get (charset-plist charset) :iso-final-char)))
-	(if (and (integerp final)
-		 (>= final #x40) (<= final #x7e)
-		 ;; Exclude ascii and chinese-cns11643-X.
-		 (not (eq charset 'ascii))
-		 (not (string-match "cns11643" (symbol-name charset))))
-	    (push (cons charset nil) table))))
-
-    ;; Returned reversed list so that the charsets specified by the
-    ;; key `ctext-non-standard-encodings' for the current language
-    ;; have the highest priority.
-    (nreverse table)))
+	    (setcar tail
+		    (cons (plist-get (charset-plist charset) :base) slot))
+	  (setcar tail (cons (car charset) slot))
+	  (dolist (cs (cdr charset))
+	    (setcdr tail
+		    (cons (cons (plist-get (charset-plist (car cs)) :base) slot)
+			  (cdr tail)))
+	    (setq tail (cdr tail))))
+	(setq tail (cdr tail))))
+    table))
 
 (defun ctext-pre-write-conversion (from to)
   "Encode characters between FROM and TO as Compound Text w/Extended Segments.
 
-If FROM is a string, or if the current buffer is not the one set up for us
-by `encode-coding-string', generate a new temp buffer, insert the text,
-and convert it in the temporary buffer.  Otherwise, convert in-place."
+If FROM is a string, generate a new temp buffer, insert the text,
+and convert it in the temporary buffer.  Otherwise, convert
+in-place."
   (save-match-data
     ;; Setup a working buffer if necessary.
     (when (stringp from)
       (set-buffer (generate-new-buffer " *temp"))
       (set-buffer-multibyte (multibyte-string-p from))
-      (insert from))
-
-    ;; Now we can encode the whole buffer.
-    (let ((encoding-table (ctext-non-standard-encodings-table))
-	  last-coding-system-used
-	  last-pos last-encoding-info
-	  encoding-info end-pos ch)
-      (goto-char (setq last-pos (point-min)))
-      (setq end-pos (point-marker))
-      (while (re-search-forward "[^\000-\177]+" nil t)
-	;; Found a sequence of non-ASCII characters.
-	(setq last-pos (match-beginning 0)
-	      ch (char-after last-pos)
-	      last-encoding-info (catch 'tag
-				   (dolist (elt encoding-table)
-				     (if (encode-char ch (car elt))
-					 (throw 'tag (cdr elt))))
-				   'utf-8))
-	(set-marker end-pos (match-end 0))
-	(goto-char (1+ last-pos))
-	(catch 'tag
-	  (while t
-	    (setq encoding-info
-		  (if (< (point) end-pos)
-		      (catch 'tag
-			(setq ch (following-char))
-			(dolist (elt encoding-table)
-			  (if (encode-char ch (car elt))
-			      (throw 'tag (cdr elt))))
-			'utf-8)))
-	    (unless (eq last-encoding-info encoding-info)
-	      (cond ((consp last-encoding-info)
-		     ;; Encode the previous range using an extended
-		     ;; segment.
-		     (let ((encoding-name (car last-encoding-info))
-			   (coding-system (nth 1 last-encoding-info))
-			   (noctets (nth 2 last-encoding-info))
-			   len)
-		       (encode-coding-region last-pos (point) coding-system)
-		       (setq len (+ (length encoding-name) 1
-				    (- (point) last-pos)))
-		       ;; According to the spec of CTEXT, it is not
-		       ;; necessary to produce this extra designation
-		       ;; sequence, but some buggy application
-		       ;; (e.g. crxvt-gb) requires it.
-		       (insert "\e(B")
-		       (save-excursion
-			 (goto-char last-pos)
-			 (insert (format "\e%%/%d" noctets))
-			 (insert-byte (+ (/ len 128) 128) 1)
-			 (insert-byte (+ (% len 128) 128) 1)
-			 (insert encoding-name)
-			 (insert 2))))
-		    ((eq last-encoding-info 'utf-8)
-		     ;; Encode the previous range using UTF-8 encoding
-		     ;; extention.
-		     (encode-coding-region last-pos (point) 'mule-utf-8)
-		     (save-excursion
-		       (goto-char last-pos)
-		       (insert "\e%G"))
-		     (insert "\e%@")))
-	      (setq last-pos (point)
-		    last-encoding-info encoding-info))
-	    (if (< (point) end-pos)
-		(forward-char 1)
-	      (throw 'tag nil)))))
-      (set-marker end-pos nil)
-      (goto-char (point-min))))
+      (insert from)
+      (setq from 1 to (point-max)))
+    (save-restriction
+      (narrow-to-region from to)
+      (goto-char from)
+      (let ((encoding-table (ctext-non-standard-encodings-table))
+	    (charset-list (sort-charsets
+			   (copy-sequence ctext-standard-encodings)))
+	    (end-pos (make-marker))
+	    last-coding-system-used
+	    last-pos charset encoding-info)
+	(dolist (elt encoding-table)
+	  (push (car elt) charset-list))
+	(setq end-pos (point-marker))
+	(while (re-search-forward "[^\0-\177]+" nil t)
+	  ;; Found a sequence of non-ASCII characters.
+	  (set-marker end-pos (match-end 0))
+	  (goto-char (match-beginning 0))
+	  (setq last-pos (point)
+		charset (char-charset (following-char) charset-list))
+	  (forward-char 1)
+	  (while (and (< (point) end-pos)
+		      (eq charset (char-charset (following-char) charset-list)))
+	    (forward-char 1))
+	  (if charset
+	      (if (setq encoding-info (cdr (assq charset encoding-table)))
+		  ;; Encode this range using an extended segment.
+		  (let ((encoding-name (car encoding-info))
+			(coding-system (nth 1 encoding-info))
+			(noctets (nth 2 encoding-info))
+			len)
+		    (encode-coding-region last-pos (point) coding-system)
+		    (setq len (+ (length encoding-name) 1
+				 (- (point) last-pos)))
+		    ;; According to the spec of CTEXT, it is not
+		    ;; necessary to produce this extra designation
+		    ;; sequence, but some buggy application
+		    ;; (e.g. crxvt-gb) requires it.
+		    (insert "\e(B")
+		    (save-excursion
+		      (goto-char last-pos)
+		      (insert (format "\e%%/%d" noctets))
+		      (insert-byte (+ (/ len 128) 128) 1)
+		      (insert-byte (+ (% len 128) 128) 1)
+		      (insert encoding-name)
+		      (insert 2)))
+		;; Encode this range as characters in CHARSET.
+		(put-text-property last-pos (point) 'charset charset))
+	    ;; Encode this range using UTF-8 encoding extention.
+	    (encode-coding-region last-pos (point) 'mule-utf-8)
+	    (save-excursion
+	      (goto-char last-pos)
+	      (insert "\e%G"))
+	    (insert "\e%@")))
+	(goto-char (point-min)))))
   ;; Must return nil, as build_annotations_2 expects that.
   nil)
 
--- a/lisp/isearch.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/isearch.el	Mon Aug 09 10:51:16 2010 +0900
@@ -2581,6 +2581,7 @@
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
 (defvar isearch-lazy-highlight-space-regexp nil)
+(defvar isearch-lazy-highlight-forward nil)
 
 (defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -2620,7 +2621,9 @@
                  (not (= (window-start)
                          isearch-lazy-highlight-window-start))
                  (not (= (window-end)   ; Window may have been split/joined.
-                         isearch-lazy-highlight-window-end))))
+			 isearch-lazy-highlight-window-end))
+		 (not (eq isearch-forward
+			  isearch-lazy-highlight-forward))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t) ;kill old loop & remove overlays
     (when (not isearch-error)
@@ -2635,7 +2638,8 @@
 	    isearch-lazy-highlight-case-fold-search isearch-case-fold-search
 	    isearch-lazy-highlight-regexp	isearch-regexp
             isearch-lazy-highlight-wrapped      nil
-	    isearch-lazy-highlight-space-regexp search-whitespace-regexp)
+	    isearch-lazy-highlight-space-regexp search-whitespace-regexp
+	    isearch-lazy-highlight-forward      isearch-forward)
       (unless (equal isearch-string "")
 	(setq isearch-lazy-highlight-timer
 	      (run-with-idle-timer lazy-highlight-initial-delay nil
@@ -2651,7 +2655,8 @@
 	    (search-invisible nil)	; don't match invisible text
 	    (retry t)
 	    (success nil)
-	    (bound (if isearch-forward
+	    (isearch-forward isearch-lazy-highlight-forward)
+	    (bound (if isearch-lazy-highlight-forward
 		       (min (or isearch-lazy-highlight-end-limit (point-max))
 			    (if isearch-lazy-highlight-wrapped
 				isearch-lazy-highlight-start
@@ -2687,7 +2692,7 @@
 	    (select-window isearch-lazy-highlight-window))
 	(save-excursion
 	  (save-match-data
-	    (goto-char (if isearch-forward
+	    (goto-char (if isearch-lazy-highlight-forward
 			   isearch-lazy-highlight-end
 			 isearch-lazy-highlight-start))
 	    (while looping
@@ -2700,7 +2705,7 @@
 		    (let ((mb (match-beginning 0))
 			  (me (match-end 0)))
 		      (if (= mb me)	;zero-length match
-			  (if isearch-forward
+			  (if isearch-lazy-highlight-forward
 			      (if (= mb (if isearch-lazy-highlight-wrapped
 					    isearch-lazy-highlight-start
 					  (window-end)))
@@ -2720,7 +2725,7 @@
 			  (overlay-put ov 'priority 1000)
 			  (overlay-put ov 'face lazy-highlight-face)
 			  (overlay-put ov 'window (selected-window))))
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (setq isearch-lazy-highlight-end (point))
 			(setq isearch-lazy-highlight-start (point)))))
 
@@ -2730,7 +2735,7 @@
 			(setq looping nil
 			      nomore  t)
 		      (setq isearch-lazy-highlight-wrapped t)
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (progn
 			    (setq isearch-lazy-highlight-end (window-start))
 			    (goto-char (max (or isearch-lazy-highlight-start-limit (point-min))
--- a/lisp/language/cyrillic.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/language/cyrillic.el	Mon Aug 09 10:51:16 2010 +0900
@@ -239,13 +239,6 @@
 	   (documentation . "Support for Tajik using KOI8-T."))
  '("Cyrillic"))
 
-(let ((elt `("microsoft-cp1251" windows-1251 1
-	     ,(get 'encode-windows-1251 'translation-table)))
-      (slot (assoc "microsoft-cp1251" ctext-non-standard-encodings-alist)))
-  (if slot
-      (setcdr slot (cdr elt))
-    (push elt ctext-non-standard-encodings-alist)))
-
 (set-language-info-alist
  "Bulgarian" `((coding-system windows-1251)
 	       (coding-priority windows-1251)
--- a/lisp/language/hebrew.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/language/hebrew.el	Mon Aug 09 10:51:16 2010 +0900
@@ -46,14 +46,13 @@
 (define-coding-system-alias 'iso-8859-8 'hebrew-iso-8bit)
 
 ;; These are for Explicit and Implicit directionality information, as
-;; defined in RFC 1556.  We don't yet support directional information
-;; in bidi languages, so these aliases are a lie, especially as far as
-;; iso-8859-8-e is concerned.  FIXME.
+;; defined in RFC 1556.
 (define-coding-system-alias 'iso-8859-8-e 'hebrew-iso-8bit)
 (define-coding-system-alias 'iso-8859-8-i 'hebrew-iso-8bit)
 
 (set-language-info-alist
- "Hebrew" '((charset iso-8859-8)
+ "Hebrew" '((tutorial . "TUTORIAL.he")
+	    (charset iso-8859-8)
 	    (coding-priority hebrew-iso-8bit)
 	    (coding-system hebrew-iso-8bit windows-1255 cp862)
 	    (nonascii-translation . iso-8859-8)
--- a/lisp/menu-bar.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/menu-bar.el	Mon Aug 09 10:51:16 2010 +0900
@@ -968,11 +968,95 @@
 	      :help ,(purecopy "Turn menu-bar on/off")
 	      :button (:toggle . (> (frame-parameter nil 'menu-bar-lines) 0))))
 
-(define-key menu-bar-showhide-menu [showhide-tool-bar]
-  `(menu-item ,(purecopy "Tool-bar") toggle-tool-bar-mode-from-frame
-	      :help ,(purecopy "Turn tool-bar on/off")
-	      :visible (display-graphic-p)
-	      :button (:toggle . (> (frame-parameter nil 'tool-bar-lines) 0))))
+(defun menu-bar-showhide-tool-bar-menu-customize-disable ()
+  "Do not display tool bars."
+  (interactive)
+  (customize-set-variable 'tool-bar-mode nil))
+(defun menu-bar-showhide-tool-bar-menu-customize-enable-left ()
+  "Display tool bars on the left side."
+  (interactive)
+  (customize-set-variable 'tool-bar-mode t)
+  (set-frame-parameter nil 'tool-bar-position 'left))
+
+(defun menu-bar-showhide-tool-bar-menu-customize-enable-right ()
+  "Display tool bars on the right side."
+  (interactive)
+  (customize-set-variable 'tool-bar-mode t)
+  (set-frame-parameter nil 'tool-bar-position 'right))
+(defun menu-bar-showhide-tool-bar-menu-customize-enable-top ()
+  "Display tool bars on the top side."
+  (interactive)
+  (customize-set-variable 'tool-bar-mode t)
+  (set-frame-parameter nil 'tool-bar-position 'top))
+(defun menu-bar-showhide-tool-bar-menu-customize-enable-bottom ()
+  "Display tool bars on the bottom side."
+  (interactive)
+  (customize-set-variable 'tool-bar-mode t)
+  (set-frame-parameter nil 'tool-bar-position 'bottom))
+
+(if (featurep 'move-toolbar)
+    (progn
+      (defvar menu-bar-showhide-tool-bar-menu (make-sparse-keymap "Tool-bar"))
+
+      (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-left]
+	`(menu-item ,(purecopy "On the left") 
+		    menu-bar-showhide-tool-bar-menu-customize-enable-left
+		    :help ,(purecopy "Tool-bar at the left side")
+		    :visible (display-graphic-p)
+		    :button 
+		    (:radio . (and tool-bar-mode 
+				   (eq (frame-parameter nil 'tool-bar-position)
+				       'left)))))
+
+      (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-right]
+	`(menu-item ,(purecopy "On the right") 
+		    menu-bar-showhide-tool-bar-menu-customize-enable-right
+		    :help ,(purecopy "Tool-bar at the right side")
+		    :visible (display-graphic-p)
+		    :button
+		    (:radio . (and tool-bar-mode 
+				   (eq (frame-parameter nil 'tool-bar-position)
+				       'right)))))
+
+      (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-bottom]
+	`(menu-item ,(purecopy "On the bottom") 
+		    menu-bar-showhide-tool-bar-menu-customize-enable-bottom
+		    :help ,(purecopy "Tool-bar at the bottom")
+		    :visible (display-graphic-p)
+		    :button
+		    (:radio . (and tool-bar-mode 
+				   (eq (frame-parameter nil 'tool-bar-position)
+				       'bottom)))))
+
+      (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-top]
+	`(menu-item ,(purecopy "On the top") 
+		    menu-bar-showhide-tool-bar-menu-customize-enable-top
+		    :help ,(purecopy "Tool-bar at the top")
+		    :visible (display-graphic-p)
+		    :button
+		    (:radio . (and tool-bar-mode 
+				   (eq (frame-parameter nil 'tool-bar-position)
+				       'top)))))
+
+      (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-none]
+	`(menu-item ,(purecopy "None") 
+		    menu-bar-showhide-tool-bar-menu-customize-disable
+		    :help ,(purecopy "Turn tool-bar off")
+		    :visible (display-graphic-p)
+		    :button (:radio . (eq tool-bar-mode nil))))
+
+      (define-key menu-bar-showhide-menu [showhide-tool-bar]
+	`(menu-item ,(purecopy "Tool-bar") ,menu-bar-showhide-tool-bar-menu
+		    :visible (display-graphic-p)))
+
+      )
+  ;; else not tool bar that can move.
+  (define-key menu-bar-showhide-menu [showhide-tool-bar]
+    `(menu-item ,(purecopy "Tool-bar") toggle-tool-bar-mode-from-frame
+		:help ,(purecopy "Turn tool-bar on/off")
+		:visible (display-graphic-p)
+		:button (:toggle . (> (frame-parameter nil 'tool-bar-lines) 0))))
+)
 
 (define-key menu-bar-options-menu [showhide]
   `(menu-item ,(purecopy "Show/Hide") ,menu-bar-showhide-menu))
--- a/lisp/mh-e/ChangeLog.1	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/mh-e/ChangeLog.1	Mon Aug 09 10:51:16 2010 +0900
@@ -333,9 +333,9 @@
 	Synced with manual.
 	(mh-junk-program): Use double-quotes on non-symbols.
 
-	* mh-pick.el: (mh-search-folder): Synced docstrings with manual.
-
-	* mh-index.el: (mh-index-search, mh-pick-execute-search)
+	* mh-pick.el (mh-search-folder): Synced docstrings with manual.
+
+	* mh-index.el (mh-index-search, mh-pick-execute-search)
 	(mh-grep-execute-search, mh-mairix-execute-search)
 	(mh-swish-execute-search, mh-swish++-execute-search)
 	(mh-namazu-execute-search): Synced docstrings with manual. Note
@@ -659,13 +659,13 @@
 
 	* mh-mime.el (mh-display-with-external-viewer): Checkdoc fixes.
 
-	* mh-identity.el: (mh-identity-attribution-verb-end): Stripped
+	* mh-identity.el (mh-identity-attribution-verb-end): Stripped
 	trailing space; checkdoc fixes.
 
 	* mh-e.el (mh-restore-desktop-buffer): Checkdoc fixes.
 
-	* mh-customize.el: (mh-inc-spool-list,
-	mh-compose-forward-as-mime-flag, defcustom): Stripped trailing
+	* mh-customize.el (mh-inc-spool-list)
+	(mh-compose-forward-as-mime-flag, defcustom): Stripped trailing
 	space; checkdoc fixes.
 
 	* mh-comp.el (mh-reply): Stripped trailing space.
@@ -794,7 +794,7 @@
 
 	Merged in 7.4.4 changes, described below.
 
-	* mh-e.el (Version, mh-version):  Set to 7.4.4+cvs.
+	* mh-e.el (Version, mh-version): Set to 7.4.4+cvs.
 
 2004-07-10  Bill Wohler  <wohler@newt.com>
 
@@ -1214,7 +1214,7 @@
 	* mh-loaddefs.el: Regenerated.
 
 	* mh-index.el (mh-indexer-choices): Remove option for the non-free
-	glimpse indexer	(closes SF #831276).
+	glimpse indexer (closes SF #831276).
 	(mh-glimpse-binary, mh-glimpse-directory)
 	(mh-glimpse-execute-search, mh-glimpse-next-result): Functions
 	and variables to implement glimpse support are removed.
@@ -1819,7 +1819,7 @@
 
 2003-08-19  Bill Wohler  <wohler@newt.com>
 
-	* mh-seq.el: (mh-edit-pick-expr): Renamed from mh-read-pick-regexp
+	* mh-seq.el (mh-edit-pick-expr): Renamed from mh-read-pick-regexp
 	since the new name is more indicative of what the function does.
 	Prompt now says "Pick expression" instead of "Pick regexp".
 	(mh-narrow-to-subject): Rewrote function to behave like other
@@ -1980,7 +1980,7 @@
 	* mh-comp.el (mh-send-letter): Go to the top of the draft so that
 	the user can see which header fields have been inserted. I think
 	this is more important than leaving point alone or going to the
-	end to see the signature since Mail-Followup-To	or Bcc or cc could
+	end to see the signature since Mail-Followup-To or Bcc or cc could
 	have some deleterious effects.
 
 	* mh-customize.el (mh-auto-fields-prompt-flag): New variable.
@@ -2197,7 +2197,7 @@
 	* mh-comp.el (mh-extract-rejected-mail, mh-letter-mode-message):
 	Ditto.
 
-	* mh-e.el (mh-refile-a-msg):  Ditto.
+	* mh-e.el (mh-refile-a-msg): Ditto.
 
 	* mh-funcs.el (mh-undo-folder): Ditto.
 
@@ -2509,7 +2509,7 @@
 
 2003-07-28  Peter S Galbraith  <psg@debian.org>
 
-	* mh-comp.el (mh-insert-letter):  Remove `mh-visible-headers'
+	* mh-comp.el (mh-insert-letter): Remove `mh-visible-headers'
 	operation.
 
 	* mh-mime.el (mh-mm-inline-message): Same.
@@ -2697,7 +2697,7 @@
 
 2003-06-24  Bill Wohler  <wohler@newt.com>
 
-	* mh-e.el (Version, mh-version):  Set to 7.4.1+cvs.
+	* mh-e.el (Version, mh-version): Set to 7.4.1+cvs.
 
 2003-06-25  Bill Wohler  <wohler@newt.com>
 
@@ -2719,7 +2719,7 @@
 
 2003-06-24  Bill Wohler  <wohler@newt.com>
 
-	* mh-e.el (Version, mh-version):  Set to 7.4+cvs.
+	* mh-e.el (Version, mh-version): Set to 7.4+cvs.
 
 2003-06-24  Bill Wohler  <wohler@newt.com>
 
@@ -2763,7 +2763,7 @@
 	replacement text.
 	(mh-index-parse-search-regexp): Preserve case of search terms.
 	This is needed to take advantage of the acronym indexing in
-	swish++	(closes SF #755718).
+	swish++ (closes SF #755718).
 
 2003-06-13  Satyaki Das  <satyakid@stanford.edu>
 
@@ -4106,7 +4106,7 @@
 
 2003-04-06  Bill Wohler  <wohler@newt.com>
 
-	* mh-comp.el (mh-forward):  Updated docstrings to indicate that a
+	* mh-comp.el (mh-forward): Updated docstrings to indicate that a
 	list of messages is acceptable as well.
 
 	* mh-e.el (mh-delete-msg, mh-delete-msg-no-motion, mh-refile-msg)
@@ -4198,7 +4198,7 @@
 
 2003-04-04  Peter S Galbraith  <psg@debian.org>
 
-	* mh-e.el (mh-folder-from-address):  Minor Fix.  Wrong ending of
+	* mh-e.el (mh-folder-from-address): Minor Fix.  Wrong ending of
 	`when' block.
 
 2003-04-04  Satyaki Das  <satyaki@theforce.stanford.edu>
@@ -5383,7 +5383,7 @@
 
 	* import-emacs: MH-E now has its own directory in Emacs.
 
-	* mh-e.el: (mh-version): Set to 7.2+cvs.
+	* mh-e.el (mh-version): Set to 7.2+cvs.
 
 2003-02-03  Bill Wohler  <wohler@newt.com>
 
@@ -6883,7 +6883,7 @@
 	* mh-e.el (mh-add-cur-notation): New function to mark the
 	current message with the mh-note-cur character.
 	(mh-get-new-mail): Use mh-add-cur-notation to undo the work of
-	mh-remove-cur-notation if there was no new mail	(closes SF #647681).
+	mh-remove-cur-notation if there was no new mail (closes SF #647681).
 
 	* mh-e.el (mh-set-cmd-note): Do not update the default mh-cmd-note
 	value (closes SF #643701).
@@ -7247,7 +7247,7 @@
 
 2002-11-13  Mark D. Baushke  <mdb@gnu.org>
 
-	* mh-identity.el (mh-insert-identity):  A value of either nil or
+	* mh-identity.el (mh-insert-identity): A value of either nil or
 	"" should cause the field to be removed.
 	(mh-identity-list): Update the docstring.
 
@@ -7911,7 +7911,7 @@
 	(mh-folder-font-lock-subject): Adapt to new mh-scan-subject-regexp.
 	* mh-seq.el (mh-subject-to-sequence): Ditto.
 
-	* mh-e.el (mh-folder-sequence-menu):  Remove "Toggle Subject
+	* mh-e.el (mh-folder-sequence-menu): Remove "Toggle Subject
 	Thread" from menu.   mh-toggle-threads is in the Folder menu.
 
 	* mh-e.el (mh-folder-sequence-menu): Minor menu text edits.
@@ -8250,7 +8250,7 @@
 	(mh-thread-generate-scan-lines): Renamed dupl-p as dupl-flag.
 	This addresses part of SF #627015.
 
-	* mh-index.el (mh-index-advance):  Renamed backward-p
+	* mh-index.el (mh-index-advance): Renamed backward-p
 	local variable as backward-flag.
 	(mh-index-next-button): Renamed backward-p
 	argument as backward-flag.
@@ -9217,7 +9217,7 @@
 	decide how many buttons to use for replying.
 
 	* mh-mime.el (mh-file-mime-type-substitutions)
-	(mh-file-mime-type-substitute):  Fix typos and doc strings.
+	(mh-file-mime-type-substitute): Fix typos and doc strings.
 
 2002-09-30  Peter S Galbraith  <psg@debian.org>
 
@@ -9321,7 +9321,7 @@
 2002-08-19  Peter S Galbraith  <psg@debian.org>
 
 	* reply-to.xpm, reply-to.pbm, reply-from.xpm, reply-from.pbm,
-	* reply-all.xpm, reply-all.pbm:  New icons for various reply methods.
+	* reply-all.xpm, reply-all.pbm: New icons for various reply methods.
 	* mh-e.el (mh-folder-tool-bar-map): Split reply button into three
 	that won't prompt for "from", "to" and "all".
 	* mh-comp.el (mh-reply): Put variable reply-to in the interactive
@@ -9760,13 +9760,13 @@
 	to `mh-mml-to-mime' in `mh-send-letter'.
 	(mh-mml-secure-message-sign-pgpmime): New function.
 	Front end to mml-secure-message-sign-pgpmime.
-	(mh-mml-secure-message-encrypt-pgpmime):  New function.
+	(mh-mml-secure-message-encrypt-pgpmime): New function.
 	Front end to mml-secure-message-encrypt-pgpmime.
 
 	* mh-comp.el (mh-send-letter): automatic call to `mh-mml-to-mime'
 	if mh-mml-compose-insert-p is set.
 	(mh-letter-mode-map): Add keys for new mh-mime functions above.
-	* mh-comp.el:  Added autoloads for new mh-mime functions above.
+	* mh-comp.el: Added autoloads for new mh-mime functions above.
 
 2002-06-17  Peter S Galbraith  <psg@debian.org>
 
@@ -10501,7 +10501,7 @@
 	* mh-comp.el: Require mh-e and easymenu, moved autoloads to top of
 	file.
 
-	* Makefile: (EMACS): New constant to hold emacs calling sequence.
+	* Makefile (EMACS): New constant to hold emacs calling sequence.
 	(install): Renamed to install-emacs.
 	(compile): New target to compile all files.
 	(dist): Make dependent on compile.
@@ -10738,7 +10738,7 @@
 
 2001-11-29  Jeffrey C Honig  <jch@honig.net>
 
-	* mh-utils.el: (mh-find-progs): Change mh-find-progs to rely on
+	* mh-utils.el (mh-find-progs): Change mh-find-progs to rely on
 	the existence of mhparam.  The location of mhparam is used to find
 	`mh-progs'.  It uses the libdir and etcdir to find the
 	`mh-lib-progs' and `mh-lib' directories.  If etcdir doesn't return
@@ -10795,7 +10795,7 @@
 	set mh-page-to-next-msg-p to t. The second time the end of page is
 	hit, go to the next message.
 
-	* mh-utils.el: (mh-show-msg): Initialize mh-page-to-next-msg-p to
+	* mh-utils.el (mh-show-msg): Initialize mh-page-to-next-msg-p to
 	nil.
 
 2001-11-27  Bill Wohler  <wohler@newt.com>
@@ -11004,8 +11004,8 @@
 2001-11-20  Peter S Galbraith  <psg@debian.org>
 
 	* mh-comp.el (mh-letter-mode): Make font-lock-defaults a local variable
-	* mh-e.el (mh-folder-mode):  Same.
-	* mh-utils.el (mh-show-mode):  Same.
+	* mh-e.el (mh-folder-mode): Same.
+	* mh-utils.el (mh-show-mode): Same.
 
 	* mh-e.el (mh-scan-msg-num-regexp): Delete variable and replace
 	with mh-good-msg-regexp.
@@ -11279,7 +11279,7 @@
 	* mh-e.el (mh-refile-msg): Mark messages in region for refiling if
 	mark is active and in transient-mark-mode.
 	* mh-e.el (mh-undo): Undo message marks for refile or deletion if
-	region if mark is active and in	transient-mark-mode.
+	region if mark is active and in transient-mark-mode.
 
 2001-11-06  Peter S Galbraith  <psg@debian.org>
 
--- a/lisp/mouse.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/mouse.el	Mon Aug 09 10:51:16 2010 +0900
@@ -697,9 +697,6 @@
 	(window-system)
 	(sit-for 1))
     (push-mark)
-    ;; If `select-active-regions' is non-nil, `set-mark' sets the
-    ;; primary selection to the buffer's region, overriding the role
-    ;; of `copy-region-as-kill'; that's why we did the copy first.
     (set-mark (point))
     (if (numberp end) (goto-char end))
     (mouse-set-region-1)))
@@ -879,8 +876,7 @@
   (let (mp pos)
     (if (and mouse-1-click-follows-link
 	     (stringp msg)
-	     (save-match-data
-	       (string-match "^mouse-2" msg))
+	     (string-match-p "\\`mouse-2" msg)
 	     (setq mp (mouse-pixel-position))
 	     (consp (setq pos (cdr mp)))
 	     (car pos) (>= (car pos) 0)
@@ -906,10 +902,6 @@
 `mouse-drag-region'."
   (mouse-minibuffer-check start-event)
   (setq mouse-selection-click-count-buffer (current-buffer))
-  ;; We must call deactivate-mark before repositioning point.
-  ;; Otherwise, for `select-active-regions' non-nil, we get the wrong
-  ;; selection if the user drags a region, clicks elsewhere to
-  ;; reposition point, then middle-clicks to paste the selection.
   (deactivate-mark)
   (let* ((original-window (selected-window))
          ;; We've recorded what we needed from the current buffer and
@@ -937,6 +929,9 @@
                        ;; intangible text.
                        (mouse-on-link-p start-posn)))
 	 (click-count (1- (event-click-count start-event)))
+	 (remap-double-click (and on-link
+				  (eq mouse-1-click-follows-link 'double)
+				  (= click-count 1)))
 	 ;; Suppress automatic hscrolling, because that is a nuisance
 	 ;; when setting point near the right fringe (but see below).
 	 (automatic-hscrolling-saved automatic-hscrolling)
@@ -949,6 +944,8 @@
     (if (< (point) start-point)
 	(goto-char start-point))
     (setq start-point (point))
+    (if remap-double-click
+	(setq click-count 0))
 
     ;; Activate the region, using `mouse-start-end' to determine where
     ;; to put point and mark (e.g., double-click will select a word).
@@ -956,10 +953,7 @@
 	  (if (eq transient-mark-mode 'lambda)
 	      '(only)
 	    (cons 'only transient-mark-mode)))
-    (let ((range (mouse-start-end start-point start-point click-count))
-	  ;; Prevent `push-mark' from clobbering the primary selection
-	  ;; if the user clicks without dragging.
-	  (select-active-regions nil))
+    (let ((range (mouse-start-end start-point start-point click-count)))
       (goto-char (nth 0 range))
       (push-mark nil t t)
       (goto-char (nth 1 range)))
@@ -1018,23 +1012,16 @@
 
 	    ;; If point has moved, finish the drag.
 	    (let* (last-command this-command)
-	      ;; Copy the region so that `select-active-regions' can
-	      ;; override `copy-region-as-kill'.
 	      (and mouse-drag-copy-region
 		   do-mouse-drag-region-post-process
 		   (let (deactivate-mark)
-		     (copy-region-as-kill (mark) (point))))
-	      ;; For `select-active-regions' non-nil, ensure that
-	      ;; further alterations of the region (e.g. via
-	      ;; shift-selection) continue to update PRIMARY.
-	      (select-active-region))
+		     (copy-region-as-kill (mark) (point)))))
 
 	  ;; If point hasn't moved, run the binding of the
 	  ;; terminating up-event.
 	  (if do-multi-click
 	      (goto-char start-point)
-	    (let (select-active-regions)
-	      (deactivate-mark)))
+	    (deactivate-mark))
 	  (when (and (functionp fun)
 		     (= start-hscroll (window-hscroll start-window))
 		     ;; Don't run the up-event handler if the window
@@ -1252,9 +1239,7 @@
 and set mark at the beginning.
 Prefix arguments are interpreted as with \\[yank].
 If `mouse-yank-at-point' is non-nil, insert at point
-regardless of where you click.
-If `select-active-regions' is non-nil, the mark is deactivated
-before inserting the text."
+regardless of where you click."
   (interactive "e\nP")
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
@@ -1282,7 +1267,7 @@
   (or mouse-yank-at-point (mouse-set-point click))
   (let ((primary (x-get-selection 'PRIMARY)))
     (if primary
-        (insert (x-get-selection 'PRIMARY))
+        (insert primary)
       (error "No primary selection"))))
 
 (defun mouse-kill-ring-save (click)
@@ -1336,16 +1321,23 @@
   (undo-boundary))
 
 (defun mouse-save-then-kill (click)
-  "Save text to point in kill ring; the second time, kill the text.
-If the text between point and the mouse is the same as what's
-at the front of the kill ring, this deletes the text.
-Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
-which prepares for a second click to delete the text.
+  "Set the region according to CLICK; the second time, kill the region.
+Assuming this command is bound to a mouse button, CLICK is the
+corresponding input event.
 
-If you have selected words or lines, this command extends the
-selection through the word or line clicked on.  If you do this
-again in a different position, it extends the selection again.
-If you do this twice in the same position, the selection is killed."
+If the region is already active, adjust it.  Normally, this
+happens by moving either point or mark, whichever is closer, to
+the position of CLICK.  But if you have selected words or lines,
+the region is adjusted by moving point or mark to the word or
+line boundary closest to CLICK.
+
+If the region is inactive, activate it temporarily; set mark at
+the original point, and move click to the position of CLICK.
+
+However, if this command is being called a second time (i.e. the
+value of `last-command' is `mouse-save-then-kill'), kill the
+region instead.  If the text in the region is the same as the
+text in the front of the kill ring, just delete it."
   (interactive "e")
   (let ((before-scroll
 	 (with-current-buffer (window-buffer (posn-window (event-start click)))
@@ -1357,44 +1349,50 @@
 	  (this-command this-command))
       (if (and (with-current-buffer
                    (window-buffer (posn-window (event-start click)))
-		 (and (mark t) (> (mod mouse-selection-click-count 3) 0)
+		 (and (mark t)
+		      (> (mod mouse-selection-click-count 3) 0)
 		      ;; Don't be fooled by a recent click in some other buffer.
 		      (eq mouse-selection-click-count-buffer
 			  (current-buffer)))))
-	  (if (not (and (eq last-command 'mouse-save-then-kill)
-			(equal click-posn
-			       (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
-	      ;; Find both ends of the object selected by this click.
-	      (let* ((range
-		      (mouse-start-end click-posn click-posn
-				       mouse-selection-click-count)))
-		;; Move whichever end is closer to the click.
-		;; That's what xterm does, and it seems reasonable.
-		(if (< (abs (- click-posn (mark t)))
-		       (abs (- click-posn (point))))
-		    (set-mark (car range))
-		  (goto-char (nth 1 range)))
-		;; We have already put the old region in the kill ring.
-		;; Replace it with the extended region.
-		;; (It would be annoying to make a separate entry.)
-		(kill-new (buffer-substring (point) (mark t)) t)
-		(mouse-set-region-1)
-		;; Arrange for a repeated mouse-3 to kill this region.
-		(setq mouse-save-then-kill-posn
-		      (list (car kill-ring) (point) click-posn)))
-	    ;; If we click this button again without moving it,
-	    ;; that time kill.
-	    (mouse-save-then-kill-delete-region (mark) (point))
-	    (setq mouse-selection-click-count 0)
-	    (setq mouse-save-then-kill-posn nil))
+	  (if (and (eq last-command 'mouse-save-then-kill)
+		   (equal click-posn (nth 2 mouse-save-then-kill-posn)))
+	      ;; If we click this button again without moving it, kill.
+	      (progn
+		;; Call `deactivate-mark' to save the primary selection.
+		(deactivate-mark)
+		(mouse-save-then-kill-delete-region (mark) (point))
+		(setq mouse-selection-click-count 0)
+		(setq mouse-save-then-kill-posn nil))
+	    ;; Find both ends of the object selected by this click.
+	    (let* ((range
+		    (mouse-start-end click-posn click-posn
+				     mouse-selection-click-count)))
+	      ;; Move whichever end is closer to the click.
+	      ;; That's what xterm does, and it seems reasonable.
+	      (if (< (abs (- click-posn (mark t)))
+		     (abs (- click-posn (point))))
+		  (set-mark (car range))
+		(goto-char (nth 1 range)))
+	      ;; We have already put the old region in the kill ring.
+	      ;; Replace it with the extended region.
+	      ;; (It would be annoying to make a separate entry.)
+	      (kill-new (buffer-substring (point) (mark t)) t)
+	      (mouse-set-region-1)
+	      ;; Arrange for a repeated mouse-3 to kill this region.
+	      (setq mouse-save-then-kill-posn
+		    (list (car kill-ring) (point) click-posn))))
+
 	(if (and (eq last-command 'mouse-save-then-kill)
 		 mouse-save-then-kill-posn
 		 (eq (car mouse-save-then-kill-posn) (car kill-ring))
-		 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
+		 (equal (cdr mouse-save-then-kill-posn)
+			(list (point) click-posn)))
 	    ;; If this is the second time we've called
 	    ;; mouse-save-then-kill, delete the text from the buffer.
 	    (progn
-	      (mouse-save-then-kill-delete-region (point) (mark))
+	      ;; Call `deactivate-mark' to save the primary selection.
+	      (deactivate-mark)
+	      (mouse-save-then-kill-delete-region (point) (mark t))
 	      ;; After we kill, another click counts as "the first time".
 	      (setq mouse-save-then-kill-posn nil))
 	  ;; This is not a repetition.
@@ -1577,7 +1575,7 @@
   (or mouse-yank-at-point (mouse-set-point click))
   (let ((secondary (x-get-selection 'SECONDARY)))
     (if secondary
-        (insert (x-get-selection 'SECONDARY))
+        (insert secondary)
       (error "No secondary selection"))))
 
 (defun mouse-kill-secondary ()
--- a/lisp/net/tramp-cmds.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/net/tramp-cmds.el	Mon Aug 09 10:51:16 2010 +0900
@@ -225,7 +225,7 @@
 This allows to investigate from a clean environment.  Another
 useful thing to do is to put
 
-  (setq tramp-verbose 8)
+  (setq tramp-verbose 9)
 
 in the ~/.emacs file and to repeat the bug.  Then, include the
 contents of the *tramp/foo* buffer and the *debug tramp/foo*
--- a/lisp/net/tramp.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/net/tramp.el	Mon Aug 09 10:51:16 2010 +0900
@@ -200,6 +200,7 @@
  6  sent and received strings
  7  file caching
  8  connection properties
+ 9  test commands
 10  traces (huge)."
   :group 'tramp
   :type 'integer)
@@ -332,8 +333,8 @@
 	     (tramp-copy-recursive       t)
 	     (tramp-password-end-of-line nil))
     ("scp"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -348,8 +349,8 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-1" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-1") ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -364,8 +365,8 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-2" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-2") ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -400,8 +401,8 @@
 	     (tramp-copy-recursive       t)
 	     (tramp-password-end-of-line nil))
     ("sftp"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "sftp")
@@ -409,8 +410,8 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("rsync" (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
@@ -421,10 +422,10 @@
 	     (tramp-password-end-of-line nil))
     ("rsyncc"
              (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
-					  ("-e" "none")))
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
@@ -453,8 +454,8 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("ssh"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -467,8 +468,8 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-1" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-1") ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -481,8 +482,8 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-2" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-2") ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -545,10 +546,10 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("scpc"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
-					  ("-e" "none")))
+					  ("-e" "none") ("%h")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -563,8 +564,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scpx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none" "-t" "-t" "/bin/sh")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("-t" "-t")
+					  ("%h") ("/bin/sh")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -577,8 +579,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("sshx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none" "-t" "-t" "/bin/sh")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("-t" "-t")
+					  ("%h") ("/bin/sh")))
 	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -4231,7 +4234,7 @@
   ;; DIR-P is valid for XEmacs only.
   (with-parsed-tramp-file-name
       (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
-    (tramp-flush-file-property v localname)))
+    (tramp-flush-directory-property v localname)))
 
 ;; Pacify byte-compiler.  The function is needed on XEmacs only.  I'm
 ;; not sure at all that this is the right way to do it, but let's hope
@@ -4500,20 +4503,30 @@
   (with-parsed-tramp-file-name default-directory nil
     (tramp-find-executable v command (tramp-get-remote-path v) t)))
 
+(defun tramp-process-sentinel (proc event)
+  "Flush file caches."
+  (unless (memq (process-status proc) '(run open))
+    (let ((vec (tramp-get-connection-property proc "vector" nil)))
+      (when vec
+	(tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event)
+        (tramp-flush-directory-property vec "")))))
+
 ;; We use BUFFER also as connection buffer during setup. Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files."
   (with-parsed-tramp-file-name default-directory nil
-    (unless (stringp program)
-      (tramp-error
-       v 'file-error "pty association is not supported for `%s'" name))
     (unwind-protect
-	(let ((command (format "cd %s; exec %s"
-			       (tramp-shell-quote-argument localname)
-			       (mapconcat 'tramp-shell-quote-argument
-					  (cons program args) " ")))
+	;; When PROGRAM is nil, we just provide a tty.
+	(let ((command
+	       (when (stringp program)
+		 (format "cd %s; exec %s"
+			 (tramp-shell-quote-argument localname)
+			 (mapconcat 'tramp-shell-quote-argument
+				    (cons program args) " "))))
+	      (tramp-process-connection-type
+	       (or (null program) tramp-process-connection-type))
 	      (name1 name)
 	      (i 0))
 	  (unless buffer
@@ -4533,14 +4546,21 @@
 	  (with-current-buffer (tramp-get-connection-buffer v)
 	    (clear-visited-file-modtime)
 	    (narrow-to-region (point-max) (point-max)))
-	  ;; Send the command.  `tramp-send-command' opens a new
-	  ;; connection.
-	  (tramp-send-command v command nil t) ; nooutput
-	  ;; Set query flag for this process.
-	  (tramp-set-process-query-on-exit-flag
-	   (tramp-get-connection-process v) t)
-	  ;; Return process.
-	  (tramp-get-connection-process v))
+	  (if command
+	      ;; Send the command.
+	      (tramp-send-command v command nil t) ; nooutput
+	    ;; Check, whether a pty is associated.
+	    (tramp-maybe-open-connection v)
+	    (unless (process-get (tramp-get-connection-process v) 'remote-tty)
+	      (tramp-error
+	       v 'file-error "pty association is not supported for `%s'" name)))
+	  (let ((p (tramp-get-connection-process v)))
+	    ;; Set sentinel and query flag for this process.
+	    (tramp-set-connection-property p "vector" v)
+	    (set-process-sentinel p 'tramp-process-sentinel)
+	    (tramp-set-process-query-on-exit-flag p t)
+	    ;; Return process.
+	    p))
       ;; Save exit.
       (with-current-buffer (tramp-get-connection-buffer v)
 	(if (string-match tramp-temp-buffer-name (buffer-name))
@@ -6984,7 +7004,7 @@
 	;; stty, instead.
 	(tramp-send-command vec "stty -onlcr" t))))
   ;; Dump stty settings in the traces.
-  (when (>= tramp-verbose 10)
+  (when (>= tramp-verbose 9)
     (tramp-send-command vec "stty -a" t))
   (tramp-send-command vec "set +o vi +o emacs" t)
 
@@ -7056,6 +7076,11 @@
   (when (string-match "^IRIX64" (tramp-get-connection-property vec "uname" ""))
     (tramp-send-command vec "set +H" t))
 
+  ;; Set `remote-tty' process property.
+  (ignore-errors
+    (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"")))
+      (unless (zerop (length tty)) (process-put proc 'remote-tty tty))))
+
   ;; Set the environment.
   (tramp-message vec 5 "Setting default environment")
 
@@ -8950,7 +8975,6 @@
 ;;   rsync).
 ;; * Keep a second connection open for out-of-band methods like scp or
 ;;   rsync.
-;; * Support ptys in `tramp-handle-start-file-process'.  (Bug#4604, Bug#6360)
 ;; * IMHO, it's a drawback that currently Tramp doesn't support
 ;;   Unicode in Dired file names by default.  Is it possible to
 ;;   improve Tramp to set LC_ALL to "C" only for commands where Tramp
--- a/lisp/progmodes/cc-cmds.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-cmds.el	Mon Aug 09 10:51:16 2010 +0900
@@ -3974,16 +3974,17 @@
 		    ;; "Invalid search bound (wrong side of point)"
 		    ;; error in the subsequent re-search.  Maybe
 		    ;; another fix would be needed (2007-12-08).
-		    (and (> (- (cdr c-lit-limits) 2) (point))
+		    (or (<= (- (cdr c-lit-limits) 2) (point))
+			(and 
 			 (search-forward-regexp
 			  (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
 			  (- (cdr c-lit-limits) 2) t)
 			 (not (search-forward-regexp
 			       "\\(\\s \\|\\sw\\)"
 			       (- (cdr c-lit-limits) 2) 'limit))
-			     ;; The comment ender IS on its own line.  Exclude
-			     ;; this line from the filling.
-			 (set-marker end (c-point 'bol))))
+			 ;; The comment ender IS on its own line.  Exclude
+			 ;; this line from the filling.
+			 (set-marker end (c-point 'bol)))))
 
 		;; The comment ender is hanging.  Replace all space between it
 		;; and the last word either by one or two 'x's (when
@@ -4000,6 +4001,14 @@
 				       (goto-char ender-start)
 				       (current-column)))
 		       (point-rel (- ender-start here))
+		       (sentence-ends-comment
+			(save-excursion
+			  (goto-char ender-start)
+			  (and (search-backward-regexp
+				(c-sentence-end) (c-point 'bol) t)
+			       (goto-char (match-end 0))
+			  (looking-at "[ \t]*")
+			  (= (match-end 0) ender-start))))
 		       spaces)
 
 		  (save-excursion
@@ -4042,7 +4051,9 @@
 			      (setq spaces
 				    (max
 				     (min spaces
-					  (if sentence-end-double-space 2 1))
+					  (if (and sentence-ends-comment
+						   sentence-end-double-space)
+					      2 1))
 				     1)))
 			  ;; Insert the filler first to keep marks right.
 			  (insert-char ?x spaces t)
@@ -4252,8 +4263,11 @@
   (let ((fill-paragraph-function
 	 ;; Avoid infinite recursion.
 	 (if (not (eq fill-paragraph-function 'c-fill-paragraph))
-	     fill-paragraph-function)))
-    (c-mask-paragraph t nil 'fill-paragraph arg))
+	     fill-paragraph-function))
+	(start-point (point-marker)))
+    (c-mask-paragraph
+     t nil (lambda () (fill-region-as-paragraph (point-min) (point-max) arg)))
+    (goto-char start-point))
   ;; Always return t.  This has the effect that if filling isn't done
   ;; above, it isn't done at all, and it's therefore effectively
   ;; disabled in normal code.
--- a/lisp/progmodes/cc-engine.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-engine.el	Mon Aug 09 10:51:16 2010 +0900
@@ -5401,6 +5401,7 @@
 		  ;; `nconc' doesn't mind that the tail of
 		  ;; `c-record-found-types' is t.
 		  (nconc c-record-found-types c-record-type-identifiers)))
+	    (if (c-major-mode-is 'java-mode) (c-fontify-recorded-types-and-refs))
 	  t)
 
       (goto-char start)
@@ -5420,7 +5421,6 @@
 	;; List that collects the positions after the argument
 	;; separating ',' in the arglist.
 	arg-start-pos)
-
     ;; If the '<' has paren open syntax then we've marked it as an angle
     ;; bracket arglist before, so skip to the end.
     (if (and (not c-parse-and-markup-<>-arglists)
@@ -5431,7 +5431,6 @@
 	  (if (and (c-go-up-list-forward)
 		   (eq (char-before) ?>))
 	      t
-
 	    ;; Got unmatched paren angle brackets.  We don't clear the paren
 	    ;; syntax properties and retry, on the basis that it's very
 	    ;; unlikely that paren angle brackets become operators by code
@@ -5441,70 +5440,51 @@
 	    nil))
 
       (forward-char)
+
       (unless (looking-at c-<-op-cont-regexp)
-	(while (and
+		(while (and
 		(progn
-
-		  (when c-record-type-identifiers
-		    (if all-types
-
-			;; All encountered identifiers are types, so set the
-			;; promote flag and parse the type.
-			(progn
-			  (c-forward-syntactic-ws)
-			  (when (looking-at c-identifier-start)
-			    (let ((c-promote-possible-types t))
-			      (c-forward-type))))
-
-		      ;; Check if this arglist argument is a sole type.  If
-		      ;; it's known then it's recorded in
-		      ;; `c-record-type-identifiers'.  If it only is found
-		      ;; then it's recorded in `c-record-found-types' which we
-		      ;; might roll back if it turns out that this isn't an
-		      ;; angle bracket arglist afterall.
-		      (when (memq (char-before) '(?, ?<))
-			(let ((orig-record-found-types c-record-found-types))
-			  (c-forward-syntactic-ws)
-			  (and (memq (c-forward-type) '(known found))
-			       (not (looking-at "[,>]"))
-			       ;; A found type was recorded but it's not the
-			       ;; only thing in the arglist argument, so reset
-			       ;; `c-record-found-types'.
-			       (setq c-record-found-types
-				     orig-record-found-types))))))
-
-		  (setq pos (point))
-		  (or (when (eq (char-after) ?>)
-			;; Must check for '>' at the very start separately,
-			;; since the regexp below has to avoid ">>" without
-			;; using \\=.
-			(forward-char)
-			t)
-
-		      ;; Note: These regexps exploit the match order in \| so
-		      ;; that "<>" is matched by "<" rather than "[^>:-]>".
-		      (c-syntactic-re-search-forward
-		       (if c-restricted-<>-arglists
-			   ;; Stop on ',', '|', '&', '+' and '-' to catch
-			   ;; common binary operators that could be between
-			   ;; two comparison expressions "a<b" and "c>d".
-			   "[<;{},|&+-]\\|\\([^>:-]>\\)"
-			 ;; Otherwise we still stop on ',' to find the
-			 ;; argument start positions.
-			 "[<;{},]\\|\\([^>:-]>\\)")
-		       nil 'move t t 1)
-
-		      ;; If the arglist starter has lost its open paren
-		      ;; syntax but not the closer, we won't find the
-		      ;; closer above since we only search in the
-		      ;; balanced sexp.  In that case we stop just short
-		      ;; of it so check if the following char is the closer.
-		      (when (eq (char-after) ?>)
-			(forward-char)
-			t)))
-
-		(cond
-		 ((eq (char-before) ?>)
+		      (c-forward-syntactic-ws)
+		 (let ((orig-record-found-types c-record-found-types))
+		   (when (or (and c-record-type-identifiers all-types)
+			     (c-major-mode-is 'java-mode))
+		     ;; All encountered identifiers are types, so set the
+		     ;; promote flag and parse the type.
+		     (progn
+		       (c-forward-syntactic-ws)
+		       (if (looking-at "\\?")
+			   (forward-char)
+			 (when (looking-at c-identifier-start)
+			   (let ((c-promote-possible-types t)
+				 (c-record-found-types t))
+			     (c-forward-type))))
+
+		     (c-forward-syntactic-ws)
+
+		     (when (or (looking-at "extends")
+			       (looking-at "super"))
+		       (forward-word)
+		       (c-forward-syntactic-ws)
+		       (let ((c-promote-possible-types t)
+			    (c-record-found-types t))
+			 (c-forward-type)
+			 (c-forward-syntactic-ws))))))
+
+		      (setq pos (point))
+
+		      (or
+		       ;; Note: These regexps exploit the match order in \| so
+		       ;; that "<>" is matched by "<" rather than "[^>:-]>".
+		       (c-syntactic-re-search-forward
+			;; Stop on ',', '|', '&', '+' and '-' to catch
+			;; common binary operators that could be between
+			;; two comparison expressions "a<b" and "c>d".
+			"[<;{},|+&-]\\|[>)]"
+			nil t t)
+		       t))
+
+		    (cond
+		     ((eq (char-before) ?>)
 		  ;; Either an operator starting with '>' or the end of
 		  ;; the angle bracket arglist.
 
@@ -5526,7 +5506,6 @@
 
 		 ((eq (char-before) ?<)
 		  ;; Either an operator starting with '<' or a nested arglist.
-
 		  (setq pos (point))
 		  (let (id-start id-end subres keyword-match)
 		    (if (if (looking-at c-<-op-cont-regexp)
@@ -5546,14 +5525,14 @@
 			      (when (or (setq keyword-match
 					      (looking-at c-opt-<>-sexp-key))
 					(not (looking-at c-keywords-regexp)))
-				(setq id-start (point))))
-
-			    (setq subres
-				  (let ((c-record-type-identifiers nil)
-					(c-record-found-types nil))
-				    (c-forward-<>-arglist-recur
-				     (and keyword-match
-					  (c-keyword-member
+				    (setq id-start (point))))
+
+				(setq subres
+				      (let ((c-promote-possible-types t)
+					    (c-record-found-types t))
+					(c-forward-<>-arglist-recur
+					 (and keyword-match
+					      (c-keyword-member
 					   (c-keyword-sym (match-string 1))
 					   'c-<>-type-kwds)))))
 			    )))
@@ -5574,14 +5553,16 @@
 				   (c-forward-syntactic-ws)
 				   (looking-at c-opt-identifier-concat-key)))
 			    (c-record-ref-id (cons id-start id-end))
-			  (c-record-type-id (cons id-start id-end))))))
-		  t)
-
-		 ((and (eq (char-before) ?,)
-		       (not c-restricted-<>-arglists))
-		  ;; Just another argument.  Record the position.  The
-		  ;; type check stuff that made us stop at it is at
-		  ;; the top of the loop.
+			      (c-record-type-id (cons id-start id-end))))))
+		      t)
+
+		((and (not c-restricted-<>-arglists)
+		      (or (and (eq (char-before) ?&)
+			       (not (eq (char-after) ?&)))
+			  (eq (char-before) ?,)))
+		      ;; Just another argument.	 Record the position.  The
+		      ;; type check stuff that made us stop at it is at
+		      ;; the top of the loop.
 		  (setq arg-start-pos (cons (point) arg-start-pos)))
 
 		 (t
@@ -5590,7 +5571,6 @@
 		  ;; it's useless to try to find a surrounding arglist
 		  ;; if we're nested.
 		  (throw 'angle-bracket-arglist-escape nil))))))
-
       (if res
 	  (or c-record-found-types t)))))
 
@@ -5793,9 +5773,8 @@
 	      ((and c-recognize-<>-arglists
 		    (eq (char-after) ?<))
 	       ;; Maybe an angle bracket arglist.
-
-	       (when (let (c-record-type-identifiers
-			   c-record-found-types)
+	       (when (let ((c-record-type-identifiers t)
+			   (c-record-found-types t))
 		       (c-forward-<>-arglist nil))
 
 		 (c-add-type start (1+ pos))
@@ -5844,6 +5823,9 @@
   ;; `c-record-type-identifiers' is non-nil.
   ;;
   ;; This function might do hidden buffer changes.
+  (when (looking-at "<")
+    (c-forward-<>-arglist t)
+    (c-forward-syntactic-ws))
 
   (let ((start (point)) pos res name-res id-start id-end id-range)
 
@@ -6043,6 +6025,18 @@
 
     res))
 
+(defun c-forward-annotation ()
+  ;; Used for Java code only at the moment.  Assumes point is on the
+  ;; @, moves forward an annotation.  returns nil if there is no
+  ;; annotation at point.
+  (and (looking-at "@")
+       (progn (forward-char) t)
+       (c-forward-type)
+       (progn (c-forward-syntactic-ws) t)
+       (if (looking-at "(")
+	   (c-go-list-forward)
+         t)))
+
 
 ;; Handling of large scale constructs like statements and declarations.
 
@@ -6212,6 +6206,9 @@
 	(save-rec-type-ids c-record-type-identifiers)
 	(save-rec-ref-ids c-record-ref-identifiers))
 
+    (while (c-forward-annotation)
+      (c-forward-syntactic-ws))
+
     ;; Check for a type.  Unknown symbols are treated as possible
     ;; types, but they could also be specifiers disguised through
     ;; macros like __INLINE__, so we recognize both types and known
@@ -6545,13 +6542,14 @@
 		;; CASE 3
 		(when (= (point) start)
 		  ;; Got a plain list of identifiers.  If a colon follows it's
-		  ;; a valid label.  Otherwise the last one probably is the
-		  ;; declared identifier and we should back up to the previous
-		  ;; type, providing it isn't a cast.
-		  (if (eq (char-after) ?:)
-		      ;; If we've found a specifier keyword then it's a
-		      ;; declaration regardless.
-		      (throw 'at-decl-or-cast (eq at-decl-or-cast t))
+		   ;; a valid label.  Otherwise the last one probably is the
+		   ;; declared identifier and we should back up to the previous
+		   ;; type, providing it isn't a cast.
+		   (if (and (eq (char-after) ?:)
+			    (not (c-major-mode-is 'java-mode)))
+		       ;; If we've found a specifier keyword then it's a
+		       ;; declaration regardless.
+		       (throw 'at-decl-or-cast (eq at-decl-or-cast t))
 		    (setq backup-if-not-cast t)
 		    (throw 'at-decl-or-cast t)))
 
@@ -8512,7 +8510,7 @@
   ;;
   ;; This function might do hidden buffer changes.
 
-  (let (special-brace-list)
+  (let (special-brace-list placeholder)
     (goto-char indent-point)
     (skip-chars-forward " \t")
 
@@ -8619,6 +8617,22 @@
       (c-add-stmt-syntax 'func-decl-cont nil t
 			 containing-sexp paren-state))
 
+     ;;CASE F: continued statement and the only preceding items are
+     ;;annotations.
+     ((and (c-major-mode-is 'java-mode)
+	   (setq placeholder (point))
+            (c-beginning-of-statement-1)
+            (progn
+              (while (and (c-forward-annotation)
+                          (< (point) placeholder))
+                (c-forward-syntactic-ws))
+              t)
+            (prog1
+                (>= (point) placeholder)
+              (goto-char placeholder)))
+       (c-beginning-of-statement-1 containing-sexp)
+       (c-add-syntax 'annotation-var-cont (point)))
+
      ;; CASE D: continued statement.
      (t
       (c-beginning-of-statement-1 containing-sexp)
@@ -8718,7 +8732,6 @@
 	(when (and containing-sexp
 		   (eq (char-after containing-sexp) ?\())
 	  (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
-
 	;; cache char before and after indent point, and move point to
 	;; the most likely position to perform the majority of tests
 	(goto-char indent-point)
@@ -9468,23 +9481,36 @@
 	    (c-add-syntax 'objc-method-args-cont placeholder))
 
 	   ;; CASE 5L: we are at the first argument of a template
-	   ;; arglist that begins on the previous line.
-	   ((and c-recognize-<>-arglists
-		 (eq (char-before) ?<)
-		 (setq placeholder (1- (point)))
-		 (not (and c-overloadable-operators-regexp
-			   (c-after-special-operator-id lim))))
-	    (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
-	    (c-add-syntax 'template-args-cont (c-point 'boi) placeholder))
-
-	   ;; CASE 5Q: we are at a statement within a macro.
-	   (macro-start
-	    (c-beginning-of-statement-1 containing-sexp)
-	    (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
-
-	   ;; CASE 5M: we are at a topmost continuation line
-	   (t
-	    (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
+	 ;; arglist that begins on the previous line.
+	 ((and c-recognize-<>-arglists
+	       (eq (char-before) ?<)
+	       (not (and c-overloadable-operators-regexp
+			 (c-after-special-operator-id lim))))
+	  (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
+	  (c-add-syntax 'template-args-cont (c-point 'boi)))
+
+	 ;; CASE 5Q: we are at a statement within a macro.
+	 (macro-start
+	  (c-beginning-of-statement-1 containing-sexp)
+	  (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
+
+     ;;CASE 5N: We are at a tompmost continuation line and the only
+     ;;preceding items are annotations.
+	 ((and (c-major-mode-is 'java-mode)
+	       (setq placeholder (point))
+           (c-beginning-of-statement-1)
+           (progn
+		 (while (and (c-forward-annotation))
+	       (c-forward-syntactic-ws))
+	     t)
+	   (prog1
+             (>= (point) placeholder)
+             (goto-char placeholder)))
+      (c-add-syntax 'annotation-top-cont (c-point 'boi)))
+
+	 ;; CASE 5M: we are at a topmost continuation line
+	 (t
+	  (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
 	    (when (c-major-mode-is 'objc-mode)
 	      (setq placeholder (point))
 	      (while (and (c-forward-objc-directive)
@@ -9495,43 +9521,20 @@
 	    (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
 	   ))
 
-	 ;; (CASE 6 has been removed.)
-
-	 ;; CASE 19: line is an expression, not a statement, and is directly
-	 ;; contained by a template delimiter.  Most likely, we are in a
-	 ;; template arglist within a statement.  This case is based on CASE
-	 ;; 7.  At some point in the future, we may wish to create more
-	 ;; syntactic symbols such as `template-intro',
-	 ;; `template-cont-nonempty', etc., and distinguish between them as we
-	 ;; do for `arglist-intro' etc. (2009-12-07).
-	 ((and c-recognize-<>-arglists
-	       (setq containing-< (c-up-list-backward indent-point containing-sexp))
-	       (eq (char-after containing-<) ?\<))
-	  (setq placeholder (c-point 'boi containing-<))
-	  (goto-char containing-sexp)	; Most nested Lbrace/Lparen (but not
-					; '<') before indent-point.
-	  (if (>= (point) placeholder)
-	      (progn
-		(forward-char)
-		(skip-chars-forward " \t"))
-	    (goto-char placeholder))
-	  (c-add-stmt-syntax 'template-args-cont (list containing-<) t
-			     (c-most-enclosing-brace c-state-cache (point))
-			     paren-state))
-			     
-
-	 ;; CASE 7: line is an expression, not a statement.  Most
-	 ;; likely we are either in a function prototype or a function
-	 ;; call argument list, or a template argument list.
-	 ((not (or (and c-special-brace-lists
-			(save-excursion
-			  (goto-char containing-sexp)
-			  (c-looking-at-special-brace-list)))
-		   (eq (char-after containing-sexp) ?{)
-		   (eq (char-after containing-sexp) ?<)))
-	  (cond
-
-	   ;; CASE 7A: we are looking at the arglist closing paren.
+
+       ;; (CASE 6 has been removed.)
+
+       ;; CASE 7: line is an expression, not a statement.  Most
+       ;; likely we are either in a function prototype or a function
+       ;; call argument list
+       ((not (or (and c-special-brace-lists
+		      (save-excursion
+			(goto-char containing-sexp)
+			(c-looking-at-special-brace-list)))
+		 (eq (char-after containing-sexp) ?{)))
+	(cond
+
+	 ;; CASE 7A: we are looking at the arglist closing paren.
 	   ;; C.f. case 7F.
 	   ((memq char-after-ip '(?\) ?\]))
 	    (goto-char containing-sexp)
@@ -9543,12 +9546,34 @@
 		  (skip-chars-forward " \t"))
 	      (goto-char placeholder))
 	    (c-add-stmt-syntax 'arglist-close (list containing-sexp) t
-			       (c-most-enclosing-brace paren-state (point))
-			       paren-state))
-
-	   ;; CASE 7B: Looking at the opening brace of an
-	   ;; in-expression block or brace list.  C.f. cases 4, 16A
-	   ;; and 17E.
+			     (c-most-enclosing-brace paren-state (point))
+			     paren-state))
+
+        ;; CASE 19: line is an expression, not a statement, and is directly
+        ;; contained by a template delimiter.	Most likely, we are in a
+        ;; template arglist within a statement.  This case is based on CASE
+        ;; 7.	At some point in the future, we may wish to create more
+        ;; syntactic symbols such as `template-intro',
+        ;; `template-cont-nonempty', etc., and distinguish between them as we
+        ;; do for `arglist-intro' etc. (2009-12-07).
+        ((and c-recognize-<>-arglists
+ 	     (setq containing-< (c-up-list-backward indent-point containing-sexp))
+ 	     (eq (char-after containing-<) ?\<))
+ 	(setq placeholder (c-point 'boi containing-<))
+ 	(goto-char containing-sexp)	; Most nested Lbrace/Lparen (but not
+ 					; '<') before indent-point.
+ 	(if (>= (point) placeholder)
+ 	    (progn
+ 	      (forward-char)
+ 	      (skip-chars-forward " \t"))
+ 	  (goto-char placeholder))
+ 	(c-add-stmt-syntax 'template-args-cont (list containing-<) t
+ 			   (c-most-enclosing-brace c-state-cache (point))
+ 			   paren-state))
+
+	 ;; CASE 7B: Looking at the opening brace of an
+	 ;; in-expression block or brace list.	C.f. cases 4, 16A
+	 ;; and 17E.
 	   ((and (eq char-after-ip ?{)
 		 (progn
 		   (setq placeholder (c-inside-bracelist-p (point)
--- a/lisp/progmodes/cc-fonts.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-fonts.el	Mon Aug 09 10:51:16 2010 +0900
@@ -194,6 +194,10 @@
 	 (unless (face-property-instance oldface 'reverse)
 	   (invert-face newface)))))
 
+(defvar c-annotation-face (make-face 'c-annotation-face)
+  "Face used to highlight annotations in java-mode and other modes that may wish to use it.")
+(set-face-foreground 'c-annotation-face "blue")
+
 (eval-and-compile
   ;; We need the following functions during compilation since they're
   ;; called when the `c-lang-defconst' initializers are evaluated.
@@ -1538,6 +1542,9 @@
 	       '((c-fontify-types-and-refs ((c-promote-possible-types t))
 		   (c-forward-keyword-clause 1)
 		   (if (> (point) limit) (goto-char limit))))))))
+
+      ,@(when (c-major-mode-is 'java-mode)
+	  `((eval . (list "\\<\\(@[a-zA-Z0-9]+\\)\\>" 1 c-annotation-face))))
       ))
 
 (c-lang-defconst c-matchers-1
--- a/lisp/progmodes/cc-langs.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-langs.el	Mon Aug 09 10:51:16 2010 +0900
@@ -359,7 +359,7 @@
        (let ((table (make-syntax-table)))
 	 (c-populate-syntax-table table)
 	 ;; Mode specific syntaxes.
-	 ,(cond ((c-major-mode-is 'objc-mode)
+	 ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode))
 		 ;; Let '@' be part of symbols in ObjC to cope with
 		 ;; its compiler directives as single keyword tokens.
 		 ;; This is then necessary since it's assumed that
@@ -382,7 +382,7 @@
   ;; '<' and '>' characters.  Therefore this syntax table might go
   ;; away when CC Mode handles templates correctly everywhere.
   t   nil
-  c++ `(lambda ()
+  (java c++) `(lambda ()
 	 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
 	   (modify-syntax-entry ?< "(>" table)
 	   (modify-syntax-entry ?> ")<" table)
@@ -425,7 +425,7 @@
   ;; it as an indentifier character since it's often used in various
   ;; machine generated identifiers.
   t    '((?_ . "w") (?$ . "w"))
-  objc (append '((?@ . "w"))
+  (objc java) (append '((?@ . "w"))
 	       (c-lang-const c-identifier-syntax-modifications))
   awk  '((?_ . "w")))
 (c-lang-defvar c-identifier-syntax-modifications
@@ -502,9 +502,10 @@
 
 (c-lang-defconst c-symbol-start
   "Regexp that matches the start of a symbol, i.e. any identifier or
-keyword.  It's unspecified how far it matches.  Does not contain a \\|
+keyword.  It's unspecified how far it matches.	Does not contain a \\|
 operator at the top level."
   t    (concat "[" c-alpha "_]")
+  java (concat "[" c-alpha "_@]")
   objc (concat "[" c-alpha "@]")
   pike (concat "[" c-alpha "_`]"))
 (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))
@@ -859,7 +860,7 @@
 
       ;; Primary.
       ,@(c-lang-const c-identifier-ops)
-      ,@(cond ((c-major-mode-is 'c++-mode)
+      ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode))
 	       `((postfix-if-paren "<" ">"))) ; Templates.
 	      ((c-major-mode-is 'pike-mode)
 	       `((prefix "global" "predef")))
@@ -1118,6 +1119,7 @@
 		    t
 		    "\\`<."
 		    (lambda (op) (substring op 1)))))
+
 (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
 
 (c-lang-defconst c->-op-cont-regexp
@@ -1127,7 +1129,13 @@
       (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
 		    t
 		    "\\`>."
-		    (lambda (op) (substring op 1)))))
+		    (lambda (op) (substring op 1))))
+  java (c-make-keywords-re nil
+	 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+		       t
+		       "\\`>[^>]\\|\\`>>[^>]"
+		       (lambda (op) (substring op 1)))))
+
 (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
 
 (c-lang-defconst c-stmt-delim-chars
@@ -1628,7 +1636,7 @@
   c++  '("class" "struct" "union")
   objc '("struct" "union"
 	 "@interface" "@implementation" "@protocol")
-  java '("class" "interface")
+  java '("class" "@interface" "interface")
   idl  '("component" "eventtype" "exception" "home" "interface" "struct"
 	 "union" "valuetype"
 	 ;; In CORBA PSDL:
@@ -1651,7 +1659,7 @@
 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
 will be handled."
   t    '("enum")
-  (java awk) nil)
+  (awk) nil)
 
 (c-lang-defconst c-brace-list-key
   ;; Regexp matching the start of declarations where the following
@@ -1772,7 +1780,7 @@
 	 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
   ;; Note: "const" is not used in Java, but it's still a reserved keyword.
   java '("abstract" "const" "final" "native" "private" "protected" "public"
-	 "static" "strictfp" "synchronized" "transient" "volatile")
+	 "static" "strictfp" "synchronized" "transient" "volatile" "@[A-Za-z0-9]+")
   pike '("final" "inline" "local" "nomask" "optional" "private" "protected"
 	 "public" "static" "variant"))
 
@@ -1858,7 +1866,11 @@
 
 (c-lang-defconst c-prefix-spec-kwds-re
   ;; Adorned regexp of `c-prefix-spec-kwds'.
-  t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))
+  t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))
+  java (replace-regexp-in-string
+     "\\\\\\[" "["
+     (replace-regexp-in-string "\\\\\\+" "+" (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))))
+
 (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
 
 (c-lang-defconst c-specifier-key
@@ -1950,7 +1962,7 @@
   t    nil
   c++  '("operator")
   objc '("@class")
-  java '("import" "new" "extends" "implements" "throws")
+  java '("import" "new" "extends" "super" "implements" "throws")
   idl  '("manages" "native" "primarykey" "supports"
 	 ;; In CORBA PSDL:
 	 "as" "implements" "of" "scope")
@@ -2499,7 +2511,7 @@
   ;; in all languages except Java for when a cpp macro definition
   ;; begins with a declaration.
   t "\\([\{\}\(\);,]+\\)"
-  java "\\([\{\}\(;,]+\\)"
+  java "\\([\{\}\(;,<]+\\)"
   ;; Match "<" in C++ to get the first argument in a template arglist.
   ;; In that case there's an additional check in `c-find-decl-spots'
   ;; that it got open paren syntax.
@@ -2759,7 +2771,7 @@
 is in effect or not."
   t nil
   (c c++ objc pike) "\\(\\.\\.\\.\\)"
-  java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)"))
+  java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)"))
 (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))
 
 (c-lang-defvar c-known-type-key
--- a/lisp/progmodes/cc-mode.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-mode.el	Mon Aug 09 10:51:16 2010 +0900
@@ -522,7 +522,7 @@
 
   (when (or c-recognize-<>-arglists
 	    (c-major-mode-is 'awk-mode)
-	    (c-major-mode-is '(c-mode c++-mode objc-mode)))
+	    (c-major-mode-is '(java-mode c-mode c++-mode objc-mode)))
     ;; We'll use the syntax-table text property to change the syntax
     ;; of some chars for this language, so do the necessary setup for
     ;; that.
--- a/lisp/progmodes/cc-vars.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/cc-vars.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1056,9 +1056,13 @@
        ;; Anchor pos: Boi at the topmost intro line.
        (knr-argdecl           . 0)
        ;; Anchor pos: At the beginning of the first K&R argdecl.
-       (topmost-intro         . 0)
+       (topmost-intro	      . 0)
        ;; Anchor pos: Bol at the last line of previous construct.
        (topmost-intro-cont    . c-lineup-topmost-intro-cont)
+       ;;Anchor pos: Bol at the topmost annotation line
+       (annotation-top-cont   .   0)
+       ;;Anchor pos: Bol at the topmost annotation line
+       (annotation-var-cont   .   +)
        ;; Anchor pos: Boi at the topmost intro line.
        (member-init-intro     . +)
        ;; Anchor pos: Boi at the func decl arglist open.
@@ -1285,12 +1289,16 @@
                            between them; in C++ and Java, throws declarations
                            and other things can appear in this context.
  knr-argdecl-intro      -- First line of a K&R C argument declaration.
- knr-argdecl            -- Subsequent lines in a K&R C argument declaration.
- topmost-intro          -- The first line in a topmost construct definition.
- topmost-intro-cont     -- Topmost definition continuation lines.
- member-init-intro      -- First line in a member initialization list.
- member-init-cont       -- Subsequent member initialization list lines.
- inher-intro            -- First line of a multiple inheritance list.
+ knr-argdecl		-- Subsequent lines in a K&R C argument declaration.
+ topmost-intro		-- The first line in a topmost construct definition.
+ topmost-intro-cont	-- Topmost definition continuation lines.
+ annotation-top-cont    -- Topmost definition continuation line where only
+ 			   annotations are on previous lines.
+ annotation-var-cont    -- A continuation of a C (or like) statement where
+ 			   only annotations are on previous lines.
+ member-init-intro	-- First line in a member initialization list.
+ member-init-cont	-- Subsequent member initialization list lines.
+ inher-intro		-- First line of a multiple inheritance list.
  inher-cont             -- Subsequent multiple inheritance lines.
  block-open             -- Statement block open brace.
  block-close            -- Statement block close brace.
@@ -1376,7 +1384,7 @@
   '(defun-block-intro block-open block-close statement statement-cont
     statement-block-intro statement-case-intro statement-case-open
     substatement substatement-open substatement-label case-label label
-    do-while-closure else-clause catch-clause inlambda))
+    do-while-closure else-clause catch-clause inlambda annotation-var-cont))
 
 (defcustom c-style-variables-are-local-p t
   "*Whether style variables should be buffer local by default.
@@ -1577,7 +1585,7 @@
   :group 'c)
 
 (defcustom java-font-lock-extra-types
-  (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
+  (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw"))
   (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat
 "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
 capitalized words are treated as type names (the requirement for a
--- a/lisp/progmodes/compile.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/compile.el	Mon Aug 09 10:51:16 2010 +0900
@@ -47,7 +47,7 @@
 ;; using the same *compilation* buffer. this necessitates re-parsing markers.
 
 ;;   FILE-STRUCTURE is a list of
-;;   ((FILENAME . DIRECTORY) FORMATS (LINE LOC ...) ...)
+;;   ((FILENAME DIRECTORY) FORMATS (LINE LOC ...) ...)
 
 ;; FILENAME is a string parsed from an error message.  DIRECTORY is a string
 ;; obtained by following directory change messages.  DIRECTORY will be nil for
--- a/lisp/progmodes/gdb-mi.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/gdb-mi.el	Mon Aug 09 10:51:16 2010 +0900
@@ -795,7 +795,10 @@
   (gdb-input
    ;; Needs GDB 6.4 onwards
    (list (concat "-inferior-tty-set "
-		 (process-tty-name (get-process "gdb-inferior")))
+		 (or
+		  ;; The process can run on a remote host.
+		  (process-get (get-process "gdb-inferior") 'remote-tty)
+		  (process-tty-name (get-process "gdb-inferior"))))
 	 'ignore))
   (if (eq window-system 'w32)
       (gdb-input (list "-gdb-set new-console off" 'ignore)))
--- a/lisp/progmodes/gud.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/gud.el	Mon Aug 09 10:51:16 2010 +0900
@@ -145,7 +145,7 @@
            (gud-call "suspend"))
           ((eq gud-minor-mode 'gdbmi)
            (gud-call (gdb-gud-context-command "-exec-interrupt")))
-          (t 
+          (t
            (comint-interrupt-subjob)))))
 
 (easy-mmode-defmap gud-menu-map
@@ -2513,7 +2513,7 @@
 	(setq w (cdr w)))
       (if w
  	  (setcar w
- 		  (if (file-remote-p default-directory)
+ 		  (if (file-remote-p file)
 		      ;; Tramp has already been loaded if we are here.
 		      (setq file (tramp-file-name-localname
 				  (tramp-dissect-file-name file)))
--- a/lisp/progmodes/js.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/js.el	Mon Aug 09 10:51:16 2010 +0900
@@ -3268,7 +3268,7 @@
 ;;; Main Function
 
 ;;;###autoload
-(define-derived-mode js-mode nil "js"
+(define-derived-mode js-mode prog-mode "js"
   "Major mode for editing JavaScript.
 
 Key bindings:
--- a/lisp/progmodes/make-mode.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/make-mode.el	Mon Aug 09 10:51:16 2010 +0900
@@ -768,7 +768,7 @@
 ;;; ------------------------------------------------------------
 
 ;;;###autoload
-(define-derived-mode makefile-mode nil "Makefile"
+(define-derived-mode makefile-mode prog-mode "Makefile"
   "Major mode for editing standard Makefiles.
 
 If you are editing a file for a different make, try one of the
--- a/lisp/progmodes/simula.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/simula.el	Mon Aug 09 10:51:16 2010 +0900
@@ -330,7 +330,7 @@
   (popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu)))
 
 ;;;###autoload
-(define-derived-mode simula-mode nil "Simula"
+(define-derived-mode simula-mode prog-mode "Simula"
   "Major mode for editing SIMULA code.
 \\{simula-mode-map}
 Variables controlling indentation style:
--- a/lisp/progmodes/sql.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/sql.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1961,7 +1961,51 @@
 function `regexp-opt'.  Therefore, take a look at the source before
 you define your own `sql-mode-mysql-font-lock-keywords'.")
 
-(defvar sql-mode-sqlite-font-lock-keywords nil
+(defvar sql-mode-sqlite-font-lock-keywords
+  (eval-when-compile
+    (list
+     ;; SQLite Keyword
+     (sql-font-lock-keywords-builder 'font-lock-keyword-face nil
+"abort" "action" "add" "after" "all" "alter" "analyze" "and" "as"
+"asc" "attach" "autoincrement" "before" "begin" "between" "by"
+"cascade" "case" "cast" "check" "collate" "column" "commit" "conflict"
+"constraint" "create" "cross" "current_date" "current_time"
+"current_timestamp" "database" "default" "deferrable" "deferred"
+"delete" "desc" "detach" "distinct" "drop" "each" "else" "end"
+"escape" "except" "exclusive" "exists" "explain" "fail" "for"
+"foreign" "from" "full" "glob" "group" "having" "if" "ignore"
+"immediate" "in" "index" "indexed" "initially" "inner" "insert"
+"instead" "intersect" "into" "is" "isnull" "join" "key" "left" "like"
+"limit" "match" "natural" "no" "not" "notnull" "null" "of" "offset"
+"on" "or" "order" "outer" "plan" "pragma" "primary" "query" "raise"
+"references" "regexp" "reindex" "release" "rename" "replace"
+"restrict" "right" "rollback" "row" "savepoint" "select" "set" "table"
+"temp" "temporary" "then" "to" "transaction" "trigger" "union"
+"unique" "update" "using" "vacuum" "values" "view" "virtual" "when"
+"where"
+)
+     ;; SQLite Data types
+     (sql-font-lock-keywords-builder 'font-lock-type-face nil
+"int" "integer" "tinyint" "smallint" "mediumint" "bigint" "unsigned"
+"big" "int2" "int8" "character" "varchar" "varying" "nchar" "native "
+"nvarchar" "text" "clob" "blob" "real" "double" "precision" "float"
+"numeric" "decimal" "boolean" "date" "datetime"
+)
+     ;; SQLite Functions
+     (sql-font-lock-keywords-builder 'font-lock-builtin-face nil
+;; Core functions
+"abs" "changes" "coalesce" "glob" "ifnull" "hex" "last_insert_rowid"
+"length" "like" "load_extension" "lower" "ltrim" "max" "min" "nullif"
+"quote" "random" "randomblob" "replace" "round" "rtrim" "soundex"
+"sqlite_compileoption_get" "sqlite_compileoption_used"
+"sqlite_source_id" "sqlite_version" "substr" "total_changes" "trim"
+"typeof" "upper" "zeroblob"
+;; Date/time functions
+"time" "julianday" "strftime"
+;; Aggregate functions
+"avg" "count" "group_concat" "max" "min" "sum" "total"
+)))
+
   "SQLite SQL keywords used by font-lock.
 
 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
@@ -2951,7 +2995,6 @@
        (sql-get-product-feature sql-product :prompt-length))
   (make-local-variable 'sql-input-ring-separator)
   (make-local-variable 'sql-input-ring-file-name)
-  (setq comint-process-echoes t)
   ;; Run the mode hook (along with comint's hooks).
   (run-mode-hooks 'sql-interactive-mode-hook)
   ;; Set comint based on user overrides.
--- a/lisp/progmodes/tcl.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/tcl.el	Mon Aug 09 10:51:16 2010 +0900
@@ -545,7 +545,7 @@
 ;;
 
 ;;;###autoload
-(define-derived-mode tcl-mode nil "Tcl"
+(define-derived-mode tcl-mode prog-mode "Tcl"
   "Major mode for editing Tcl code.
 Expression and list commands understand all Tcl brackets.
 Tab indents for Tcl code.
--- a/lisp/progmodes/which-func.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/progmodes/which-func.el	Mon Aug 09 10:51:16 2010 +0900
@@ -145,7 +145,9 @@
 		 local-map ,which-func-keymap
 		 face which-func
 		 ;;mouse-face highlight	; currently not evaluated :-(
-		 help-echo "mouse-1: go to beginning, mouse-2: toggle rest visibility, mouse-3: go to end")
+		 help-echo "mouse-1: go to beginning\n\
+mouse-2: toggle rest visibility\n\
+mouse-3: go to end")
     "]")
   "Format for displaying the function in the mode line."
   :group 'which-func
--- a/lisp/replace.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/replace.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1979,7 +1979,9 @@
       (let ((isearch-string string)
 	    (isearch-regexp regexp)
 	    (search-whitespace-regexp nil)
-	    (isearch-case-fold-search case-fold))
+	    (isearch-case-fold-search case-fold)
+	    (isearch-forward t)
+	    (isearch-error nil))
 	;; Set isearch-word to nil because word-replace is regexp-based,
 	;; so `isearch-search-fun' should not use `word-search-forward'.
 	(if (and isearch-word isearch-regexp) (setq isearch-word nil))
--- a/lisp/server.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/server.el	Mon Aug 09 10:51:16 2010 +0900
@@ -563,9 +563,9 @@
 		       :coding 'raw-text-unix
 		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
-			   (list :family nil
+			   (list :family 'ipv4  ;; We're not ready for IPv6 yet
 				 :service t
-				 :host (or server-host 'local)
+				 :host (or server-host "127.0.0.1") ;; See bug#6781
 				 :plist '(:authenticated nil))
 			 (list :family 'local
 			       :service server-file
@@ -577,7 +577,7 @@
 		   (loop
 		      ;; The auth key is a 64-byte string of random chars in the
 		      ;; range `!'..`~'.
-		      for i below 64
+		      repeat 64
 		      collect (+ 33 (random 94)) into auth
 		      finally return (concat auth))))
 	      (process-put server-process :auth-key auth-key)
--- a/lisp/simple.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/simple.el	Mon Aug 09 10:51:16 2010 +0900
@@ -895,7 +895,7 @@
 	(t (delete-char (- n) killflag))))
 
 (defun delete-forward-char (n &optional killflag)
-  "Delete the previous N characters (following if N is negative).
+  "Delete the following N characters (previous if N is negative).
 If Transient Mark mode is enabled, the mark is active, and N is 1,
 delete the text in the region and deactivate the mark instead.
 To disable this, set `delete-active-region' to nil.
@@ -3666,29 +3666,28 @@
       (marker-position (mark-marker))
     (signal 'mark-inactive nil)))
 
-(defcustom select-active-regions t
-  "If non-nil, an active region automatically becomes the window selection."
-  :type 'boolean
-  :group 'killing
-  :version "24.1")
-
 (declare-function x-selection-owner-p "xselect.c" (&optional selection))
 
-;; Many places set mark-active directly, and several of them failed to also
-;; run deactivate-mark-hook.  This shorthand should simplify.
 (defsubst deactivate-mark (&optional force)
   "Deactivate the mark by setting `mark-active' to nil.
 Unless FORCE is non-nil, this function does nothing if Transient
 Mark mode is disabled.
 This function also runs `deactivate-mark-hook'."
   (when (or transient-mark-mode force)
-    ;; Copy the latest region into the primary selection, if desired.
-    (and select-active-regions
-	 mark-active
-	 (display-selections-p)
-	 (x-selection-owner-p 'PRIMARY)
-	 (x-set-selection 'PRIMARY (buffer-substring-no-properties
-				    (region-beginning) (region-end))))
+    (when (and select-active-regions
+	       (region-active-p)
+	       (display-selections-p))
+      ;; The var `saved-region-selection', if non-nil, is the text in
+      ;; the region prior to the last command modifying the buffer.
+      ;; Set the selection to that, or to the current region.
+      (cond (saved-region-selection
+	     (x-set-selection 'PRIMARY saved-region-selection)
+	     (setq saved-region-selection nil))
+	    ((/= (region-beginning) (region-end))
+	     (x-set-selection 'PRIMARY
+			      (buffer-substring-no-properties
+			       (region-beginning)
+			       (region-end))))))
     (if (and (null force)
 	     (or (eq transient-mark-mode 'lambda)
 		 (and (eq (car-safe transient-mark-mode) 'only)
@@ -3706,14 +3705,7 @@
   (when (mark t)
     (setq mark-active t)
     (unless transient-mark-mode
-      (setq transient-mark-mode 'lambda))
-    (select-active-region)))
-
-(defsubst select-active-region ()
-  "Set the PRIMARY X selection if `select-active-regions' is non-nil."
-  (and select-active-regions
-       (display-selections-p)
-       (x-set-selection 'PRIMARY (current-buffer))))
+      (setq transient-mark-mode 'lambda))))
 
 (defun set-mark (pos)
   "Set this buffer's mark to POS.  Don't use this function!
@@ -3736,7 +3728,6 @@
       (progn
 	(setq mark-active t)
 	(run-hooks 'activate-mark-hook)
-	(select-active-region)
 	(set-marker (mark-marker) pos (current-buffer)))
     ;; Normally we never clear mark-active except in Transient Mark mode.
     ;; But when we actually clear out the mark value too, we must
@@ -3820,7 +3811,6 @@
 	(push-mark nil nomsg t)
       (setq mark-active t)
       (run-hooks 'activate-mark-hook)
-      (select-active-region)
       (unless nomsg
 	(message "Mark activated")))))
 
@@ -3951,7 +3941,8 @@
     (setq mark-ring (cdr mark-ring)))
   (deactivate-mark))
 
-(defalias 'exchange-dot-and-mark 'exchange-point-and-mark)
+(define-obsolete-function-alias
+  'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
 (defun exchange-point-and-mark (&optional arg)
   "Put the mark where point is now, and point where the mark is now.
 This command works even when the mark is not active,
@@ -4008,11 +3999,8 @@
 deactivate it, and restore the variable `transient-mark-mode' to
 its earlier value."
   (cond ((and shift-select-mode this-command-keys-shift-translated)
-         (if (and mark-active
-		  (eq (car-safe transient-mark-mode) 'only))
-	     ;; Another program may have grabbed the selection; make
-	     ;; sure we get it back now.
-	     (select-active-region)
+         (unless (and mark-active
+		      (eq (car-safe transient-mark-mode) 'only))
 	   (setq transient-mark-mode
                  (cons 'only
                        (unless (eq transient-mark-mode 'lambda)
@@ -5576,7 +5564,10 @@
 During execution of Lisp code, this character causes a quit directly.
 At top-level, as an editor command, this simply beeps."
   (interactive)
-  (deactivate-mark)
+  ;; Avoid adding the region to the window selection.
+  (setq saved-region-selection nil)
+  (let (select-active-regions)
+    (deactivate-mark))
   (if (fboundp 'kmacro-keyboard-quit)
       (kmacro-keyboard-quit))
   (setq defining-kbd-macro nil)
--- a/lisp/term.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/term.el	Mon Aug 09 10:51:16 2010 +0900
@@ -502,8 +502,8 @@
 (defvar term-delimiter-argument-list ()
   "List of characters to recognize as separate arguments in input.
 Strings comprising a character in this list will separate the arguments
-surrounding them, and also be regarded as arguments in their own right (unlike
-whitespace).  See `term-arguments'.
+surrounding them, and also be regarded as arguments in their own right
+\(unlike whitespace).  See `term-arguments'.
 Defaults to the empty list.
 
 For shells, a good value is (?\\| ?& ?< ?> ?\\( ?\\) ?\\;).
@@ -1516,7 +1516,7 @@
 ;; term-replace-by-expanded-history-before-point Workhorse function.
 
 (defun term-read-input-ring (&optional silent)
-  "Sets the buffer's `term-input-ring' from a history file.
+  "Set the buffer's `term-input-ring' from a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The history ring is of size `term-input-ring-size', regardless of file size.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1564,7 +1564,7 @@
 		 term-input-ring-index nil)))))
 
 (defun term-write-input-ring ()
-  "Writes the buffer's `term-input-ring' to a history file.
+  "Write the buffer's `term-input-ring' to a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The original contents of the file are lost if `term-input-ring' is not empty.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1996,12 +1996,12 @@
   "Send input to process.
 After the process output mark, sends all text from the process mark to
 point as input to the process.  Before the process output mark, calls value
-of variable term-get-old-input to retrieve old input, copies it to the
+of variable `term-get-old-input' to retrieve old input, copies it to the
 process mark, and sends it.  A terminal newline is also inserted into the
 buffer and sent to the process.  The list of function names contained in the
 value of `term-input-filter-functions' is called on the input before sending
 it.  The input is entered into the input history ring, if the value of variable
-term-input-filter returns non-nil when called on the input.
+`term-input-filter' returns non-nil when called on the input.
 
 Any history reference may be expanded depending on the value of the variable
 `term-input-autoexpand'.  The list of function names contained in the value
@@ -2137,7 +2137,7 @@
   (term-send-string proc "\n"))
 
 (defun term-bol (arg)
-  "Goes to the beginning of line, then skips past the prompt, if any.
+  "Go to the beginning of line, then skip past the prompt, if any.
 If a prefix argument is given (\\[universal-argument]), then no prompt skip
 -- go straight to column 0.
 
@@ -3760,7 +3760,7 @@
       (goto-char saved-point))))
 
 (defun term-erase-in-display (kind)
-  "Erases (that is blanks out) part of the window.
+  "Erase (that is blank out) part of the window.
 If KIND is 0, erase from (point) to (point-max);
 if KIND is 1, erase from home to point; else erase from home to point-max."
   (term-handle-deferred-scroll)
@@ -4166,7 +4166,7 @@
 
 ;; I need a make-term that doesn't surround with *s -mm
 (defun term-ansi-make-term (name program &optional startfile &rest switches)
-"Make a term process NAME in a buffer, running PROGRAM.
+  "Make a term process NAME in a buffer, running PROGRAM.
 The name of the buffer is NAME.
 If there is already a running process in that buffer, it is not restarted.
 Optional third arg STARTFILE is the name of a file to send the contents of to
@@ -4267,7 +4267,7 @@
 for special serial ports that cannot be configured.")
 
 (defun serial-supported-or-barf ()
-  "Signal an error if serial processes are not supported"
+  "Signal an error if serial processes are not supported."
   (unless (fboundp 'make-serial-process)
     (error "Serial processes are not supported on this system")))
 
--- a/lisp/term/x-win.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/term/x-win.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1234,18 +1234,12 @@
 
 (defun x-select-text (text &optional push)
   "Select TEXT, a string, according to the window system.
-
-On X, put TEXT in the primary X selection.  For backward
-compatibility with older X applications, set the value of X cut
-buffer 0 as well, and if the optional argument PUSH is non-nil,
-rotate the cut buffers.  If `x-select-enable-clipboard' is
-non-nil, copy the text to the X clipboard as well.
-
-On Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.  The argument PUSH is ignored.
-
-On Nextstep, put TEXT in the pasteboard; PUSH is ignored."
+If `x-select-enable-clipboard' is non-nil, copy TEXT to the
+clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
+the primary selection.  For backward compatibility with older X
+applications, this function also sets the value of X cut buffer
+0, and, if the optional argument PUSH is non-nil, rotates the cut
+buffers."
   ;; With multi-tty, this function may be called from a tty frame.
   (when (eq (framep (selected-frame)) 'x)
     ;; Don't send the cut buffer too much text.
--- a/lisp/textmodes/fill.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/textmodes/fill.el	Mon Aug 09 10:51:16 2010 +0900
@@ -1289,18 +1289,16 @@
 		     (skip-chars-backward " "))
 		   (setq ncols (- fc endcol))
 		   ;; Ncols is number of additional space chars needed
-		   (if (and (> ncols 0) (> nspaces 0) (not eop))
-		       (progn
-			 (setq curr-fracspace (+ ncols (/ (1+ nspaces) 2))
-			       count nspaces)
-			 (while (> count 0)
-			   (skip-chars-forward " ")
-			   (insert-and-inherit
-			    (make-string (/ curr-fracspace nspaces) ?\s))
-			   (search-forward " " nil t)
-			   (setq count (1- count)
-				 curr-fracspace
-				   (+ (% curr-fracspace nspaces) ncols)))))))
+		   (when (and (> ncols 0) (> nspaces 0) (not eop))
+                     (setq curr-fracspace (+ ncols (/ nspaces 2))
+                           count nspaces)
+                     (while (> count 0)
+                       (skip-chars-forward " ")
+                       (insert-char ?\s (/ curr-fracspace nspaces) t)
+                       (search-forward " " nil t)
+                       (setq count (1- count)
+                             curr-fracspace
+                             (+ (% curr-fracspace nspaces) ncols))))))
 		(t (error "Unknown justification value"))))
 	(goto-char pos)
 	(move-marker pos nil)))
--- a/lisp/time.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/time.el	Mon Aug 09 10:51:16 2010 +0900
@@ -87,7 +87,7 @@
 
 ;;;###autoload
 (defcustom display-time-day-and-date nil "\
-*Non-nil means \\[display-time] should display day and date as well as time."
+Non-nil means \\[display-time] should display day and date as well as time."
   :type 'boolean
   :group 'display-time)
 
@@ -182,7 +182,7 @@
   :version "23.1")
 
 (defcustom display-time-world-buffer-name "*wclock*"
-  "Name of the wclock buffer."
+  "Name of the world clock buffer."
   :group 'display-time
   :type 'string
   :version "23.1")
@@ -203,7 +203,7 @@
   (let ((map (make-sparse-keymap)))
     (define-key map "q" 'kill-this-buffer)
     map)
-  "Keymap of Display Time World mode")
+  "Keymap of Display Time World mode.")
 
 ;;;###autoload
 (defun display-time ()
--- a/lisp/tutorial.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/tutorial.el	Mon Aug 09 10:51:16 2010 +0900
@@ -252,7 +252,7 @@
              ;; * INSERTING AND DELETING
              ;; C-u 8 * to insert ********.
              (delete-backward-char "\d")
-             (delete-char [?\C-d])
+             (delete-forward-char [?\C-d])
              (backward-kill-word [?\M-\d])
              (kill-word [?\M-d])
              (kill-line [?\C-k])
@@ -829,6 +829,8 @@
         (if old-tut-file
             (progn
               (insert-file-contents (tutorial--saved-file))
+	      (let ((enable-local-variables :safe))
+		(hack-local-variables))
               (goto-char (point-min))
               (setq old-tut-point
                     (string-to-number
@@ -844,6 +846,8 @@
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
           (insert-file-contents (expand-file-name filename tutorial-directory))
+	  (let ((enable-local-variables :safe))
+	    (hack-local-variables))
           (forward-line)
           (setq tutorial--point-before-chkeys (point-marker)))
 
--- a/lisp/url/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/url/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,12 @@
+2010-07-27  Michael Albinus  <michael.albinus@gmx.de>
+
+	* url-http (url-http-parse-headers): Disable file name handlers at
+	all (not only Tramp).  (Bug#6717)
+
+2010-07-27  Michael Albinus  <michael.albinus@gmx.de>
+
+	* url-http (url-http-parse-headers): Disable Tramp.  (Bug#6717)
+
 2010-07-01  Mark A. Hershberger  <mah@everybody.org>
 
 	* url-http.el (url-http-create-request): Add a CRLF on the end so
--- a/lisp/url/url-http.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/url/url-http.el	Mon Aug 09 10:51:16 2010 +0900
@@ -486,7 +486,11 @@
 	(class nil)
 	(success nil)
 	;; other status symbols: jewelry and luxury cars
-	(status-symbol (cadr (assq url-http-response-status url-http-codes))))
+	(status-symbol (cadr (assq url-http-response-status url-http-codes)))
+	;; The filename part of a URL could be in remote file syntax,
+	;; see Bug#6717 for an example.  We disable file name
+	;; handlers, therefore.
+	(file-name-handler-alist nil))
     (setq class (/ url-http-response-status 100))
     (url-http-debug "Parsed HTTP headers: class=%d status=%d" class url-http-response-status)
     (url-http-handle-cookies)
--- a/lisp/vc/diff-mode.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/lisp/vc/diff-mode.el	Mon Aug 09 10:51:16 2010 +0900
@@ -141,6 +141,7 @@
     ;; Standard M-r is useful, so don't change M-r or M-R.
     ;;("r" . diff-restrict-view)
     ;;("R" . diff-reverse-direction)
+    ("g" . revert-buffer)
     ("q" . quit-window))
   "Basic keymap for `diff-mode', bound to various prefix keys.")
 
--- a/lwlib/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/lwlib/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,11 @@
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* xlwmenu.c (abort_gracefully): Mark as NO_RETURN.
+
+2010-07-26  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* xlwmenu.h (xlwmenu_window_p, xlwmenu_redisplay): Add declarations.
+
 2010-07-12  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* Makefile.in (C_WARNINGS_SWITCH, PROFILING_CFLAGS): Set from
--- a/lwlib/xlwmenu.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/lwlib/xlwmenu.c	Mon Aug 09 10:51:16 2010 +0900
@@ -204,7 +204,7 @@
 static void Nothing(Widget w, XEvent *ev, String *params, Cardinal *num_params);
 static int separator_height (enum menu_separator);
 static void pop_up_menu (XlwMenuWidget, XButtonPressedEvent *);
-
+static void abort_gracefully (Widget w) NO_RETURN;
 
 static XtActionsRec
 xlwMenuActionsList [] =
--- a/lwlib/xlwmenu.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/lwlib/xlwmenu.h	Mon Aug 09 10:51:16 2010 +0900
@@ -81,6 +81,9 @@
 
 extern WidgetClass xlwMenuWidgetClass;
 
+extern int xlwmenu_window_p (Widget w, Window window);
+extern void xlwmenu_redisplay (Widget);
+
 #endif /* _XlwMenu_h */
 
 /* arch-tag: 0c019735-d61b-4080-be85-4fdd6e50ae07
--- a/msdos/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/msdos/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,12 @@
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* sed1v2.inp (UNEXEC_OBJ): Edit to unexcoff.o, due to renaming of
+	unexec.c => unexcoff.c.
+
+2010-07-29  Chad Brown  <yandros@mit.edu>
+
+	* sed2v2.inp (HAVE_DIRENT_H): Edit to 1.
+
 2010-07-12  Eli Zaretskii  <eliz@gnu.org>
 
 	* sed1v2.inp (C_WARNINGS_SWITCH, PROFILING_CFLAGS, PROFILING_LDFLAGS):
--- a/msdos/sed1v2.inp	Mon Jul 26 13:29:08 2010 +0900
+++ b/msdos/sed1v2.inp	Mon Aug 09 10:51:16 2010 +0900
@@ -118,7 +118,7 @@
 /^RALLOC_OBJ *=/s/@RALLOC_OBJ@/ralloc.o/
 /^PRE_ALLOC_OBJ *=/s/@PRE_ALLOC_OBJ@/lastfile.o/
 /^POST_ALLOC_OBJ *=/s/@POST_ALLOC_OBJ@/$(vmlimitobj)/
-/^UNEXEC_OBJ *=/s/@UNEXEC_OBJ@/unexec.o/
+/^UNEXEC_OBJ *=/s/@UNEXEC_OBJ@/unexcoff.o/
 /^CANNOT_DUMP *=/s/@CANNOT_DUMP@/no/
 /^DEPFLAGS *=/s/@DEPFLAGS@//
 /^MKDEPDIR *=/s/@MKDEPDIR@//
--- a/msdos/sed2v2.inp	Mon Jul 26 13:29:08 2010 +0900
+++ b/msdos/sed2v2.inp	Mon Aug 09 10:51:16 2010 +0900
@@ -57,6 +57,7 @@
 /^#undef PACKAGE_TARNAME/s/^.*$/#define PACKAGE_TARNAME ""/
 /^#undef PACKAGE_VERSION/s/^.*$/#define PACKAGE_VERSION ""/
 /^#undef SYS_SIGLIST_DECLARED/s/^.*$/#define SYS_SIGLIST_DECLARED 1/
+/^#undef HAVE_DIRENT_H/s/^.*$/#define HAVE_DIRENT_H 1/
 
 /^#undef GNU_MALLOC *$/s/^.*$/#define GNU_MALLOC 1/
 /^#undef REL_ALLOC *$/s/^.*$/#define REL_ALLOC 1/
--- a/nt/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/nt/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,17 @@
+2010-08-08  Óscar Fuentes  <ofv@wanadoo.es>
+
+	* cmdproxy.c (main): Use _snprintf instead of wsprintf,
+	which has a 1024 char limit on Windows (bug#6647).
+
+2010-08-02  Juanma Barranquero  <lekktu@gmail.com>
+
+	* config.nt (TIME_WITH_SYS_TIME): Remove #undef, unused (bug#6754).
+	Suggested by Dan Nicolaescu <dann@ics.uci.edu>.
+
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* config.nt: Remove code referring to NO_REMAP, unused.
+
 2010-07-25  Christoph Scholtes  <cschol2112@gmail.com>
 
 	Build binary distros on Windows using emacs-VERSION as root dir name.
--- a/nt/cmdproxy.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/nt/cmdproxy.c	Mon Aug 09 10:51:16 2010 +0900
@@ -35,6 +35,9 @@
 #include <stdlib.h>  /* getenv */
 #include <string.h>  /* strlen */
 
+/* We don't want to include stdio.h because we are already duplicating
+   lots of it here */
+extern int _snprintf (char *buffer, size_t count, const char *format, ...);
 
 /*******  Mock C library routines  *********************************/
 
@@ -604,6 +607,7 @@
     {
       char * p;
       int    extra_arg_space = 0;
+      int    maxlen, remlen;
       int    run_command_dot_com;
 
       progname = getenv ("COMSPEC");
@@ -635,21 +639,27 @@
 	     case path contains spaces (fortunately it can't contain
 	     quotes, since they are illegal in path names).  */
 
-	  buf = p = alloca (strlen (progname) + extra_arg_space +
-			    strlen (cmdline) + 16);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (cmdline) + 16;
+	  buf = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\"", progname);
+	  p += _snprintf (p, remlen, "\"%s\"", progname);
+	  remlen = maxlen - (p - buf);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - buf);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf(p, " /e:%d /c %s", envsize, cmdline);
+	    _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline);
 	  else
-	    wsprintf(p, " /c %s", cmdline);
+	    _snprintf (p, remlen, " /c %s", cmdline);
+	  remlen = maxlen - (p - buf);
 	  cmdline = buf;
 	}
       else
@@ -669,19 +679,27 @@
 	  else
 	    path[0] = '\0';
 
-	  cmdline = p = alloca (strlen (progname) + extra_arg_space +
-				strlen (path) + 13);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (path) + 13;
+	  cmdline = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\" %s", progname, path);
+	  p += _snprintf (p, remlen, "\"%s\" %s", progname, path);
+	  remlen = maxlen - (p - cmdline);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - cmdline);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf (p, " /e:%d", envsize);
+	    {
+	      _snprintf (p, remlen, " /e:%d", envsize);
+	      remlen = maxlen - (p - cmdline);
+	    }
 	}
     }
 
--- a/nt/config.nt	Mon Jul 26 13:29:08 2010 +0900
+++ b/nt/config.nt	Mon Aug 09 10:51:16 2010 +0900
@@ -138,7 +138,6 @@
 #undef HAVE_STDLIB_H
 #undef HAVE_PWD_H
 #undef STDC_HEADERS
-#undef TIME_WITH_SYS_TIME
 
 #undef HAVE_LIBDNET
 #undef HAVE_LIBPTHREADS
@@ -308,12 +307,6 @@
 #undef config_machfile
 #include "m/intel386.h"
 
-/* If no remapping takes place, static variables cannot be dumped as
-   pure, so don't worry about the `static' keyword. */
-#ifdef NO_REMAP
-#undef static
-#endif
-
 /* Define `subprocesses' should be defined if you want to
    have code for asynchronous subprocesses
    (as used in M-x compile and M-x shell).
--- a/src/.gdbinit	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/.gdbinit	Mon Aug 09 10:51:16 2010 +0900
@@ -535,6 +535,9 @@
   if ($g->overlaps_vertically_p)
     printf " OVL"
   end
+  if ($g->avoid_cursor_p)
+    printf " AVOID"
+  end
   if ($g->left_box_line_p)
     printf " ["
   end
--- a/src/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,7 +1,735 @@
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* charset.c: Include <stdlib.h>
+	(struct charset_sort_data): New struct.
+	(charset_compare): New function.
+	(Fsort_charsets): New funciton.
+	(syms_of_charset): Declare Fsort_charsets as a Lisp function.
+
+	* coding.c (decode_coding_iso_2022): Fix checking of dimension
+	number in CTEXT extended segment.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* w32fns.c (syms_of_w32fns) <x-max-tooltip-size>: Fix typo in docstring.
+	* xfns.c (syms_of_xfns) <x-max-tooltip-size>: Reflow docstring.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* fns.c (Fsubstring_no_properties, Fnthcdr, Ffeaturep)
+	(Fhash_table_size): Fix typos in docstrings.
+	(Fmake_hash_table): Doc fix.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.c (syms_of_minibuf) <read-buffer-function>:
+	Doc fix (bug#5625).
+
+2010-08-08  Ken Brown  <kbrown@cornell.edu>
+
+	* dired.c (DIRENTRY_NONEMPTY) [cygwin]: Use d_ino instead of
+	the MSDOS definition.
+
+2010-08-08  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Use const char* instead of char*.
+	* xterm.c (x_create_toolkit_scroll_bar):
+	* xfont.c (xfont_list_pattern):
+	* xfns.c (x_default_scroll_bar_color_parameter)
+	(xic_create_fontsetname, x_default_font_parameter)
+	(x_screen_planes):
+	* xdisp.c (c_string_pos, number_of_chars, reseat_to_string)
+	(store_mode_line_string, decode_mode_spec, display_string):
+	* menu.c (digest_single_submenu):
+	* keymap.h (initial_define_key, initial_define_lispy_key):
+	* keymap.c (initial_define_key, initial_define_lispy_key):
+	* image.c (image_error, image_keyword):
+	* gtkutil.h (xg_create_widget, xg_create_scroll_bar):
+	* gtkutil.c (xg_create_widget, xg_create_scroll_bar):
+	* ftfont.c (struct fc_charset_table, ftfont_spec_pattern)
+	(ftfont_list, ftfont_match):
+	* frame.c (frame_parm_table):
+	* font.h (font_intern_prop, font_parse_xlfd, font_parse_fcname)
+	(font_unparse_fcname, font_unparse_fcname, font_open_by_name)
+	(font_add_log, font_deferred_log):
+	* font.c (font_intern_prop, font_parse_xlfd, font_parse_fcname)
+	(font_unparse_fcname, font_unparse_fcname, font_open_by_name)
+	(font_add_log, font_deferred_log):
+	* emacs.c (argmatch):
+	* dispextern.h (struct it):
+	* coding.c (ENCODE_DESIGNATION):
+	* charset.c (define_charset_internal): Use const.
+
+	* s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused.
+
+	* xrdb.c: Remove include guard.  Remove
+	DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
+	Remove #if 0 code.  Replace malloc->xmalloc, free->xfree,
+	realloc->xrealloc instead of using #defines.
+
+2010-08-08  Eli Zaretskii  <eliz@gnu.org>
+
+	* cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line):
+	* editfns.c (Fline_beginning_position, Fline_end_position): State
+	in the doc strings that start and end of line are in the logical
+	order.
+
+	* xdisp.c (display_line): Move the handling of overlay arrow after
+	the call to find_row_edges.  (Bug#6699)
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* keyboard.c (command_loop_1):
+	* insdel.c (prepare_to_modify_buffer): Don't call validate_region.
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* insdel.c (prepare_to_modify_buffer): Save active region text to
+	Vsaved_region_selection.
+
+	* xselect.c (QPRIMARY): Move to keyboard.c.
+
+	* keyboard.c (Vselect_active_regions): Move from simple.el.
+	(Vsaved_region_selection, Qx_set_selection, QPRIMARY, Qlazy): New vars.
+	(command_loop_1): Set window selection prior to deactivating the mark.
+
+2010-08-07  Juanma Barranquero  <lekktu@gmail.com>
+
+	* alloc.c (lisp_malloc):
+	* buffer.c (set_buffer_internal, set_buffer_internal_1):
+	* charset.h (emacs_mule_charset):
+	* dispextern.h (inhibit_free_realized_faces, redraw_frame)
+	(redraw_garbaged_frames, scroll_cost, update_frame, scrolling)
+	(bitch_at_user):
+	* lisp.h (Fcheck_coding_system, Fget_text_property)
+	(Qfunction, Qcompletion_ignore_case, QCwidth, QCsize):
+	Remove duplicate declarations.
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* process.c: Simplify include logic.
+
+	* keyboard.h (quit_char): Add declaration.
+	* process.h (QCport, QCspeed, QCprocess, QCbytesize, QCstopbits)
+	(QCparity, Qodd, Qeven, QCflowcontrol, Qhw, Qsw, QCsummary):
+	Add declarations.
+	* sysdep.c:
+	* w32.c: Remove the above declarations.
+
+	Remove extern declarations in .c files, .h files have them.
+	* xterm.c:
+	* xdisp.c:
+	* msdos.c:
+	* image.c:
+	* gtkutil.c:
+	* fileio.c:
+	* eval.c: Remove declarations.
+
+	* frame.c (frame_params): Make const.
+
+	* lisp.h (fatal_error_signal, emacs_root_dir): Add declaration.
+
+	* emacs.c (emacs_copyright, emacs_version): Make static.
+	(Vinitial_window_system, Vauto_save_list_file_name)
+	(Vinhibit_redisplay): Remove declarations.
+	(main): Remove HAVE_SHM code, unused.  Remove _I386 conditional
+	for AIX.
+
+	Use const for some arrays and functions.
+	* xterm.h (xg_set_icon_from_xpm_data):
+	* xfns.c (xg_set_icon_from_xpm_data):
+	* term.c (fkeys):
+	* keyboard.c (lispy_accent_keys, lispy_function_keys)
+	(lispy_multimedia_keys, lispy_kana_keys, iso_lispy_function_keys)
+	(lispy_drag_n_drop_names, scroll_bar_parts, modify_event_symbol)
+	(frame.c frame_parms):
+	* emacs-icon.h (gnu_xpm_bits):
+	* callint.c (callint_argfuns): Use const.
+
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* sysdep.c: Move include term.h last of includes (Bug#6812).
+
+2010-08-06  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispnew.c (realloc_glyph_pool): Zero out newly allocated glyphs.
+
+	* msdos.c (IT_display_cursor): Log cursor position on termscript.
+
+	* .gdbinit (pgx): Display the avoid_cursor_p flag.
+
+2010-08-06  Juanma Barranquero  <lekktu@gmail.com>
+
+	* makefile.w32-in ($(BLD)/xdisp.$(O)): Update dependencies.
+
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xterm.h (x_get_focus_frame): Declare.
+
+	* keyboard.h (poll_for_input_1): Unconditionally declare.
+
+	* nsterm.h (x_set_menu_bar_lines): Declare.
+
+	* window.c: Don't include menu.h, it depends on lots of other .h-files.
+
+	* xfaces.c (x_create_gc, x_free_gc): Convert to ANSI C prototypes.
+
+	* window.c: Include menu.h.
+
+	* unexmacosx.c (print_region_list, print_regions)
+	(build_region_list, find_emacs_zone_regions)
+	(unexec_regions_merge, read_load_commands, dump_it)
+	(unexec_init_emacs_zone): Convert to ANSI C prototypes.
+
+	* term.c: Check HAVE_SYS_IOCTL_H.
+
+	* sysdep.c: Check HAVE_TERM_H.
+
+	* process.c: Check HAVE_UTIL_H.  Include nsterm.h if HAVE_NS.
+
+	* nsterm.m (ns_init_paths, ns_alloc_autorelease_pool)
+	(ns_ring_bell, ns_defined_color, hide_hourglass)
+	(x_display_pixel_height, x_display_pixel_width, syms_of_nsterm):
+	Convert to ANSI C prototypes.
+	(x_set_window_size, ns_draw_fringe_bitmap, judge): Move declarations
+	before code.
+
+	* nsterm.h : Include sysselect.h.
+	(x_sync, x_get_focus_frame, x_set_mouse_position)
+	(x_set_mouse_pixel_position, x_make_frame_visible)
+	(x_make_frame_invisible, x_iconify_frame, x_char_width, x_char_height)
+	(x_pixel_width, x_pixel_height, x_set_frame_alpha, x_set_tool_bar_lines)
+	(x_activate_menubar, free_frame_menubar, ns_init_paths, ns_select)
+	(syms_of_nsterm, syms_of_nsfns, syms_of_nsmenu, syms_of_nsselect):
+	Declare.
+
+	* nsmenu.m (popup_activated, name_is_separator)
+	(syms_of_nsmenu): Convert to ANSI C prototypes.
+	(runMenuAt): Prototypes and move declarations before code.
+
+	* nsimage.m (ns_load_image): Move NSTRACE after declarations.
+
+	* nsfont.m (ns_fallback_entity, syms_of_nsfont): Convert to ANSI C
+	prototypes.
+
+	* nsfns.m (have_menus_p, ns_display_info_for_name)
+	(x_set_cursor_type, ns_appkit_version_str)
+	(ns_appkit_version_int, ns_do_applescript)
+	(x_set_scroll_bar_default_width, x_sync, compute_tip_xy)
+	(syms_of_nsfns): Convert to ANSI C prototypes.
+
+	* menu.h (x_set_menu_bar_line): Declare.
+	(free_menubar_widget_value_tree et.al): Add HAVE_NS for these functions.
+
+	* lisp.h (fmod_float): Declare.
+
+	* image.c (xpm_scan, xpm_make_color_table_v)
+	(xpm_put_color_table_v, xpm_get_color_table_v)
+	(xpm_make_color_table_h, xpm_put_color_table_h)
+	(xpm_get_color_table_h, xpm_str_to_color_key, xpm_load_image)
+	(xpm_load): Convert to ANSI C prototypes.
+
+	* emacs.c: Include nsterm.h if HAVE_NS.
+
+	* bidi.c (bidi_dump_cached_states): Fix fprintf warning.
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* process.c: Remove HAVE_SOCKETS #ifdefs inside #ifdef
+	subprocesses, only MSDOS does not define HAVE_SOCKETS.
+	(socket_options): Use const char* for name.
+
+2010-08-06  Juanma Barranquero  <lekktu@gmail.com>
+
+	Fix changes in revnos 100982..100984 for Windows build.
+
+	* xmenu.c [USE_X_TOOLKIT || USE_GTK]:
+	Don't declare xmalloc_widget_value and digest_single_submenu.
+
+	* w32font.c (Qlatin): Remove declaration.
+
+	* menu.h (xmalloc_widget_value, digest_single_submenu): Declare.
+
+	* dired.c (compile_pattern): Restore declaration.
+
+2010-08-05  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Remove extern declarations in .c files, .h files have them.
+	* data.c:
+	* dired.c:
+	* editfns.c:
+	* filelock.c:
+	* fns.c:
+	* font.c:
+	* fontset.c:
+	* frame.c:
+	* fringe.c:
+	* ftfont.c:
+	* gtkutil.c:
+	* indent.c:
+	* keyboard.c:
+	* keymap.c:
+	* lread.c:
+	* menu.c:
+	* print.c:
+	* search.c:
+	* sound.c:
+	* window.c:
+	* xdisp.c:
+	* xfaces.c:
+	* xfns.c:
+	* xfont.c:
+	* xftfont.c:
+	* xmenu.c:
+	* xterm.c: Remove declarations.
+
+	Cleanup syssignal.h.
+	* syssignal.h (sighold, sigrelse, RETSIGTYPE): Remove, unused.
+	(main_thread): Move down to remove #ifdef.
+	(SIGMASKTYPE, SIGEMPTYMASK, SIGFULLMASK, sigmask, sigunblock):
+	Remove conditional definition following unconditional ones.
+
+	* lisp.h: Remove HAVE_SHM code, unused.
+	(QCmap, QCrehash_size, QCrehash_threshold, QCsize, QCtest)
+	(QCweakness, Qabove_handle, Qbackquote, Qbar, Qbelow_handle)
+	(Qborder, Qbottom, Qbox, Qcircular_list, Qcomma, Qcomma_at)
+	(Qcomma_dot, Qcursor, Qdefault, Qdown, Qend_scroll, Qeq, Qeql)
+	(Qequal, Qfile_exists_p, Qfont_param, Qfringe, Qfunction)
+	(Qfunction_documentation, Qhandle, Qhbar, Qheader_line, Qhollow)
+	(Qidentity, Qleft_margin, Qmenu, Qmenu_bar_update_hook)
+	(Qmode_line_inactive, Qmouse, Qoverriding_local_map)
+	(Qoverriding_terminal_local_map, Qratio, Qregion, Qright_margin)
+	(Qscroll_bar, Qtool_bar, Qtop, Qup, Qvertical_border, Qwhen)
+	(Qwindow_scroll_functions, Vafter_load_alist)
+	(Vauto_save_list_file_name, Vface_alternative_font_family_alist)
+	(Vface_alternative_font_registry_alist, Vface_font_rescale_alist)
+	(Vface_ignored_fonts, Vinhibit_redisplay, Vminibuffer_list)
+	(Vprint_length, Vprint_level, Vscalable_fonts_allowed)
+	(Vshell_file_name, Vsystem_name, Vwindow_scroll_functions)
+	(Vwindow_system_version, Vx_no_window_manager, initial_argc)
+	(initial_argv, last_nonmenu_event, load_in_progress)
+	(noninteractive_need_newline, scroll_margin): Add declarations.
+
+	* keyboard.h (xmalloc_widget_value, digest_single_submenu): Remove
+	declarations, menu.h has them.
+	(QCbutton, QCtoggle, QCradio, QClabel, extra_keyboard_modifiers)
+	(Vinput_method_function, Qinput_method_function)
+	(Qevent_symbol_element_mask, last_event_timestamp):
+	* dispextern.h (Voverflow_newline_into_fringe):
+	* font.h (QCantialias, Qp, syms_of_ftfont, syms_of_xfns)
+	(syms_of_ftxfont, syms_of_xftfont, syms_of_bdffont)
+	(syms_of_w32font, syms_of_nsfont):
+	* fontset.h (find_font_encoding, Qlatin):
+	* frame.h (Qtooltip, Qrun_hook_with_args, Vmenu_bar_mode)
+	(Vtool_bar_mode, set_frame_menubar):
+	* ftfont.h (ftfont_font_format, ftfont_get_fc_charset):
+	* xterm.h (Qx_gtk_map_stock):
+	* keymap.h (meta_prefix_char): Add declarations.
+
+	* term.c: Remove dead code.
+
+	Fix emacs -Q -f server-start & emacsclient -t on GNU/Linux.
+	* term.c (dissociate_if_controlling_tty): Use USG5 instead of
+	USG.  This is equivalent to defined (USG) && !defined (BSD_PGRPS),
+	which is what was there before BSD_PGRPS was removed.
+
+2010-08-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* deps.mk (unexcoff.o): Rename unexec.[co] => unexcoff.[co].
+
+	* unexcoff.c: Renamed from unexec.c.
+
+2010-08-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* sysdep.c (child_setup_tty): Comment-out left-over non-ICANON code.
+
+2010-08-03  Johan Bockgård  <bojohan@gnu.org>
+
+	* data.c (Flocal_variable_p): Handle variable aliases correctly.
+	(Bug#6744)
+
+2010-08-02  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xterm.c (x_create_toolkit_scroll_bar): Only set XtNbeNiceToColormap
+	to TRUE if depth of screen is < 16.
+
+	* gtkutil.c (hierarchy_ch_cb, qttip_cb): Do not define unless
+	USE_GTK_TOOLTIP.
+	(xg_prepare_tooltip): Return 0 unless USE_GTK_TOOLTIP.
+	(xg_show_tooltip, xg_hide_tooltip): Do nothing unless USE_GTK_TOOLTIP.
+	(xg_create_frame_widgets): Surround tooltip-related code with ifdef
+	USE_GTK_TOOLTIP.
+	(xg_free_frame_widgets): Don't delete ttip_* unless USE_GTK_TOOLTIP.
+
+	* xterm.h (USE_GTK_TOOLTIP): New define.
+	(struct x_output): Put ttip_* inside ifdef USE_GTK_TOOLTIP.
+
+	* sysdep.c (child_setup_tty): Enable ICANON in lflags and set VEOF
+	to Control-D (Bug#6771).
+
+2010-08-02  Juanma Barranquero  <lekktu@gmail.com>
+
+	* editfns.c (Fregion_beginning, Fregion_end): Doc fixes (bug#6493).
+	Wording by Drew Adams <drew.adams@oracle.com>.
+
+2010-08-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xterm.h (struct x_output): Add ttip_widget, ttip_window and
+	ttip_lbl.
+
+	* xterm.c (x_clear_frame): Check FRAME_GTK_WIDGET (f) before
+	calling gtk_widget_queue_draw.
+	(x_free_frame_resources): Call xg_free_frame_widgets.
+
+	* xfns.c (x_gtk_use_system_tooltips): New variable.
+	(Fx_show_tip): If USE_GTK and x_gtk_use_system_tooltips, call
+	new gtkutil tooltip functions to show the tooltip.
+	(Fx_hide_tip): Call xg_hide_tooltip.
+	(syms_of_xfns): Defvar x-gtk-use-system-tooltips.
+
+	* gtkutil.h (xg_free_frame_widgets, xg_prepare_tooltip)
+	(xg_show_tooltip, xg_hide_tooltip): Declare.
+
+	* gtkutil.c (hierarchy_ch_cb, qttip_cb, xg_prepare_tooltip)
+	(xg_show_tooltip, xg_hide_tooltip, xg_free_frame_widgets):
+	New functions.
+	(xg_create_frame_widgets): Set ttip_* to 0.  Set a dummy tooltip
+	text so qttip_cb is called.  Connect query-tooltip to qttip_cb.
+	Remove code that is commented out.
+
+2010-08-01  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* keymap.c (Fdefine_key, Flookup_key): Say what event is invalid.
+
+2010-07-31  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xselect.c (x_own_selection): Use list4.
+
+2010-07-30  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* buffer.c (Qwindow): Do not define, already defined in data.c.
+	(syms_of_buffer): Do not intern and staticpro Qwindow.  (Bug#6760)
+
+2010-07-29  Chad Brown  <yandros@mit.edu>
+
+	Replace tests for SYSV_SYSTEM_DIR with HAVE_DIRENT_H, set via autoconf.
+	* dired.c, sysdep.c: Test HAVE_DIRENT_H instead of SYSV_SYSTEM_DIR.
+	* config.in: Undef HAVE_DIRENT_H.
+	* s/aix4-2.h, s/bsd-common.h, s/cygwin.h, s/gnu-linux.h,
+	* s/msdos.h, s/usg5-4.h: Don't define SYSV_SYSTEM_DIR.
+
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Rename s/usg5-4.h -> s/usg5-4-common.h.
+	* s/usg5-4.h: Rename file to ...
+	* s/usg5-4-common.h: ... this for consistency with what we do for BSD.
+	* s/unixware.h:
+	* s/sol2-6.h:
+	* s/irix6-5.h: Update includes accordingly.
+
+2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xfns.c (x_set_tool_bar_position): Remove debug fprintf.
+
+	* xterm.h (struct x_output): Add toolbar_top_height,
+	toolbar_bottom_height, toolbar_left_width, toolbar_right_width.
+	Remove toolbar_height.
+	If USE_GTK: Add hbox_widget and toolbar_in_hbox.
+	(FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT)
+	(FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros.
+	(FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT.
+
+	* xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
+
+	* xfns.c (x_set_tool_bar_position): New function.
+	(xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT.
+	(x_frame_parm_handlers): Add x_set_tool_bar_position.
+	(syms_of_xfns): If USE_GTK, provide move-toolbar.
+
+	* window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT
+	and FRAME_TOOLBAR_LEFT_WIDTH.
+
+	* gtkutil.h (xg_change_toolbar_position): Declare.
+
+	* gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro.
+	(xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
+	(xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH.
+	(xg_create_frame_widgets): Create a hobox for placing widgets
+	vertically.  Use gtk_box_pack_start.
+	(xg_height_or_width_changed): Renamed from xg_height_changed.
+	(x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width.
+	(xg_update_frame_menubar, free_frame_menubar): Change to
+	xg_height_or_width_changed.
+	(xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar
+	size correctly.  Remove hardcoded 4, instead use handlebox size -
+	toolbar size.
+	(xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar
+	size correctly.  Use handlebox size + toolbar size as additional size.
+	(xg_pack_tool_bar): POS is a new parameter.
+	Set orientation of tool bar based on pos.
+	Only make handlebox_widget if NULL.
+	Check if tool bar goes to vbox or hbox depending on pos.
+	(xg_update_tool_bar_sizes): New function.
+	(update_frame_tool_bar): Remove old_req, new_req.  Do not get tool bar
+	height, call xg_update_tool_bar_sizes instead.
+	(free_frame_tool_bar): Remove from hbox or vbox depending on
+	toolbar_in_hbox,  Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
+	(xg_change_toolbar_position): New function.
+
+	* frame.h (struct frame): Add tool_bar_position.
+	(Qbottom): Declare.
+
+	* frame.c (Qtool_bar_position): New variable.
+	(make_frame): Set tool_bar_position to Qtop.
+	(frame_parms): Add tool-bar-position.
+	(x_report_frame_params): Store tool_bar_position.
+	(x_set_fringe_width): Reset wm size hint after fringe changes.
+
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Make lisp_time_argument declaration work on all systems.
+	* lisp.h (lisp_time_argument): Move declaration ...
+	* systime.h (lisp_time_argument): ... here
+	* editfns.c (lisp_time_argument): Remove declaration.  (Bug#6751)
+
+2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* vm-limit.c (POINTER): Add typedef for it.
+	(start_of_data): Change return type from POINTER to char *.
+
+	* frame.h (Qtty_color_mode): Move declaration out of ifdef
+	HAVE_WINDOW_SYSTEM.
+
+2010-07-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vm-limit.c: Do not include sys/resource.h, mem-limits.h does it.
+	Remove reference to __osf__, unused.
+
+	* mem-limits.h: Remove duplicated includes.
+	(NULL): Remove definition, unused.
+	(POINTER): Remove definition.
+	(start_of_data): Use char* in prototype, as the function
+	definition does.
+
+	Remove extern declarations from .c files, and them to .h files.
+	* keyboard.h (Qhelp_echo, waiting_for_input)
+	(input_available_clear_time, ignore_mouse_drag_p)
+	(Vdouble_click_time, real_this_command, Vthis_original_command):
+	* keymap.h (Qremap, Qmenu_item, Voverriding_local_map)
+	(Voverriding_local_map_menu_flag):
+	* lisp.h (Qinteractive_form, use_file_dialog)
+	(Qcursor_in_echo_area, QCascent, QCmargin, QCrelief, Qcount)
+	(Qextension_data, QCconversion, QCcolor_symbols, QCheuristic_mask)
+	(QCindex, QCmatrix, QCcolor_adjustment, QCmask)
+	(Qrisky_local_variable, map_char_table_for_charset, Vprint_level)
+	(Qfunction, debug_on_next_call, Qfield)
+	(Vinhibit_field_text_motion, Vuser_login_name, lisp_time_argument)
+	(Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string)
+	(Qfile_directory_p, Qinsert_file_contents)
+	(Qcompletion_ignore_case, Qcompletion_ignore_case)
+	(Vcompletion_regexp_list, Vhistory_length, completion_ignore_case)
+	(history_delete_duplicates, minibuffer_auto_raise, Qonly)
+	(Qfile_name_handler_alist, Qfront_sticky, Qrear_nonsticky)
+	(Qminibuffer_prompt)
+	(Vtemporary_file_directory,char_ins_del_vector, Qface):
+	* xterm.h (gray_bitmap_width, gray_bitmap_height)
+	(gray_bitmap_bits, xic_create_fontsetname):
+	* coding.h (Vtranslation_table_for_input): Add extern declarations.
+
+	* xsmfns.c (Vuser_login_name):
+	* xrdb.c (Vdouble_click_time):
+	* xfaces.c (xic_create_fontsetname):
+	* w32select.c (waiting_for_input):
+	* print.c (minibuffer_auto_raise):
+	* msdos.c (Qhelp_echo):
+	* macros.c (real_this_command):
+	* keymap.c (Voverriding_local_map):
+	* xterm.c (poll_for_input_1, gray_bitmap_width)
+	(gray_bitmap_height, gray_bitmap_bits;
+	* xmenu.c ( Voverriding_local_map)
+	(Voverriding_local_map_menu_flag; Qmenu_item; use_dialog_box)
+	(use_file_dialog, Xt_app_con):
+	* xdisp.c (minibuffer_auto_raise, Voverriding_local_map)
+	(Voverriding_local_map_menu_flag, Qmenu_item, Qface, Qinvisible)
+	(Qwidth, Qinvisible, Qwindow, Qpriority, Qtool_bar_lines)
+	(Qtool_bar_lines, ignore_mouse_drag_p):
+	* minibuf.c (Voverriding_local_map, Qfield, Qfront_sticky)
+	(Qrear_nonsticky, nconc2):
+	* keyboard.c (current_global_map, minibuf_level, Qmenu_item)
+	(Vhistory_length, Vtranslation_table_for_input, Qcomposition)
+	(Qdisplay, Qafter_string, Qbefore_string, Qundefined):
+	* fileio.c (use_dialog_box, use_file_dialog, Vuser_login_name)
+	(minibuf_level, minibuffer_auto_raise, lisp_time_argument):
+	* eval.c (Qinteractive_form, Qrisky_local_variable, Qfunction)
+	(gc_in_progress):
+	* doc.c (Voverriding_local_map, Qremap):
+	* dired.c (completion_ignore_case, Qcompletion_ignore_case)
+	(Vcompletion_regexp_list):
+	* coding.c (Qmac, Qinsert_file_contents, Qwrite_region)
+	(Qcompletion_ignore_case):
+	* callint.c (Qcursor_in_echo_area, Qfile_directory_p, Qonly)
+	(Vhistory_length, Vthis_original_command, real_this_command)
+	(Qface, Qminibuffer_prompt, history_delete_duplicates):
+	* image.c (Qrisky_local_variable):
+	* fontset.c (QCname):
+	* fns.c (minibuffer_auto_raise, QCname):
+	* dispnew.c (char_ins_del_cost):
+	* composite.c (font_fill_lglyph_metrics):
+	* cmds.c (Qface, Vtranslation_table_for_input):
+	* charset.c (map_char_table_for_charset, Qfile_name_handler_alist):
+	* ccl.c (charset_unicode):
+	* callproc.c (Vtemporary_file_directory):
+	* buffer.c (emacs_strerror): Remove extern declarations.
+
+	* data.c (Qwindow): Make non-static, used from other files too.
+	* frame.c (validate_x_resource_name): Remove shadow definition for i.
+
+	* unexec.c (make_hdr): Remove references to NO_REMAP, COFF,
+	SEGMENT_MASK, SECTION_ALIGNMENT, ADJUST_EXEC_HEADER.
+	* s/usg5-4.h (COFF):
+	* s/template.h:
+	* s/msdos.h (COFF, NO_REMAP):
+	* s/ms-w32.h (NO_REMAP):
+	* s/hpux10-20.h (NO_REMAP):
+	* m/sparc.h (SEGMENT_MASK):
+	* m/m68k.h (NO_REMAP):
+	* m/intel386.h (SEGMENT_MASK):
+	* m/arm.h (NO_REMAP):
+	* m/alpha.h (COFF):
+	* m/template.h: Remove references to unused defines.
+
+2010-07-28  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsettings.c (Ftool_bar_get_system_style): Also check for
+	Qtext_image_horiz.
+
+	* xdisp.c (Qtext_image_horiz): Define.
+	(syms_of_xdisp): Initialize Qtext_image_horiz.  Add text-image-horiz
+	to documentation of tool-bar-style.
+
+	* lisp.h (Qtext_image_horiz): Declare.
+
+	* gtkutil.c (xg_make_tool_item, xg_show_toolbar_item): Handle tool bar
+	style text_image_horiz.
+
+2010-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* emacs.c (Fkill_emacs): Remove return statement.
+
+	* term.c (Qspace, QCalign_to, QCwidth): Remove declarations.
+	(encode_terminal_code, produce_composite_glyph): Remove unused variables.
+	(set_tty_color_mode, term_mouse_highlight, term_get_fkeys): Remove
+	local extern declarations.
+
+	* xmenu.c: Do not included lwlib.h, not needed.
+
+	* m/iris4d.h (XUINT, XSET): Remove, not needed.
+
+	* process.c: Move definitions earlier to minimize #ifdefs.
+
+	* xterm.h (x_get_customization_string, x_load_resources)
+	(x_get_resource, x_text_icon, x_text_icon, x_check_errors)
+	(x_check_errors, x_property_data_to_lisp, defined_color)
+	(xic_set_xfontset, x_defined_color): Use const.
+
+	* xterm.c (xlwmenu_window_p, xlwmenu_redisplay): Remove declarations.
+	(x_text_icon, x_check_errors, x_connection_closed): Use const.
+
+	* xselect.c (selection_data_to_lisp_data)
+	(x_property_data_to_lisp):
+	* xrdb.c (x_get_string_resource, file_p)
+	(x_get_customization_string, magic_file_p, search_magic_path)
+	(get_system_app, get_user_app, x_load_resources, x_get_resource)
+	(x_get_string_resource): Use const.
+
+	* xfns.c: Include xlwmenu.h when USE_LUCID.
+	(x_defined_color, xic_set_xfontset): Use const.
+	(Fx_hide_tip): Remove local extern declaration.
+
+	* xfaces.c (Qmouse_face): Remove declaration.
+	(face_color_gray_p, tty_defined_color, defined_color)
+	(face_color_gray_p, face_color_supported_p): Add const.
+
+	* xdisp.c (do_mouse_tracking): Remove declaration.
+	(add_to_log): Use const.
+
+	* minibuf.c (Qmouse_face): Remove declaration.
+
+	* msdos.c (IT_note_mouse_highlight): Remove local extern declaration.
+
+	* keyboard.h (do_mouse_tracking): Add declaration.
+
+	* image.c (QCwidth, QCheight, QCforeground, QCbackground, QCfile)
+	(QCdata, QCtype, Qcenter): Remove declarations.
+
+	* frame.c (x_get_resource_string, x_get_string_resource)
+	(x_get_arg, x_frame_get_arg, x_frame_get_and_record_arg)
+	(x_default_parameter): Use const.
+
+	* font.c (Qnormal, QCtype, QCfamily, QCweight, QCslant, QCwidth)
+	(QCheight, QCsize, QCname): Remove declarations.
+
+	* emacs.c (main): Remove local extern declaration.
+
+	* editfns.c (region_limit, syms_of_editfns): Remove local extern
+	declarations.
+
+	* dispnew.c: Remove duplicate #include <unistd.h>.
+	(update_window, update_frame_1, init_display): Remove local extern
+	declarations.
+
+	* dispextern.h (add_to_log): Remove declaration.
+	(x_get_arg, x_frame_get_arg, x_frame_get_and_record_arg)
+	(x_frame_get_and_record_arg, x_default_parameter): Add const.
+
+	* dired.c (scmp): Add const.
+	(directory_files_internal): Remove local extern declaration.
+
+	* data.c (Finteractive_form): Use const.
+
+	* composite.c (syms_of_composite): Remove local extern declarations.
+
+	* charset.c (add_to_log): Remove declaration.
+
+	* character.c (strwidth, parse_str_to_multibyte): Add const.
+
+	* character.h (strwidth, parse_str_to_multibyte): Likewise.
+
+	* buffer.c (Fset_buffer_multibyte): Remove local extern declaration.
+
+	* lisp.h (Fkill_emacs): Mark as NO_RETURN.
+	(Lisp_Subr): Make doc and intspec constant.
+	(QCsize, Qspace, Qcenter, QCalign_to, QCdata, QCfile, QCtype)
+	(Qlocal, Qapply, Qnormal, QCfamily, QCweight, QCslant, QCwidth)
+	(QCheight, QCsize, QCname, QCwidth, QCforeground)
+	(QCbackground, add_to_log, stack_base, Vmark_even_if_inactive)
+	(display_arg): Add declarations.
+
+2010-07-27  Christoph Scholtes  <cschol2112@gmail.com>
+
+	* minibuf.c (Fread_buffer): Doc fix (bug#6528).
+
+	* window.c (Fwindow_height): Doc fix (bug#6518).
+
+2010-07-27  Juanma Barranquero  <lekktu@gmail.com>
+
+	* buffer.c (syms_of_buffer) <fringe-indicator-alist>: Doc fix.
+
+2010-07-26  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* keyboard.c (Ftop_level, Fexit_recursive_edit)
+	(Fabort_recursive_edit): Remove return statements in NO_RETURN
+	functions.
+
+	* frame.h (Qtty_color_mode): Add declaration.
+
+	* lisp.h (Ftop_level, Fexit_recursive_edit)
+	(Fabort_recursive_edit): Mark as NO_RETURN.
+
 2010-07-26  Kenichi Handa  <handa@m17n.org>
 
 	* font.c (Ffont_shape_gstring): Terminate GSTRING by nil if the
-	number of glyphs gets smaller than the original length.
+	number of glyphs gets smaller than the original length.  (Bug#6621)
 
 2010-07-26  Juanma Barranquero  <lekktu@gmail.com>
 
@@ -3322,8 +4050,8 @@
 	(syms_of_xsettings): Initialize current_font.
 	defsubr Sfont_get_system_normal_font.
 
-	* xsettings.h (Ffont_get_system_normal_font,
-	xsettings_get_system_normal_font): Declare.
+	* xsettings.h (Ffont_get_system_normal_font)
+	(xsettings_get_system_normal_font): Declare.
 
 	* xfns.c (extern xlwmenu_default_font): Remove.
 	(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
@@ -5125,7 +5853,7 @@
 	(store_symval_forwarding): Take into account the fact that Ints can
 	now have more than one tag.
 	* buffer.c (syms_of_buffer): Use LISP_INT_TAG.
-	buffer_slot_type_mismatch):
+	(buffer_slot_type_mismatch):
 	* xfaces.c (face_attr_equal_p):
 	* print.c (print_object):
 	* alloc.c (mark_maybe_object, mark_object, survives_gc_p):
@@ -20986,7 +21714,7 @@
 	* charset.c (charset_ordered_list_tick): New variable.
 	(Fdefine_charset_internal): Increment charset_ordered_list_tick.
 	(Funify_charset): New optional arg DEUNIFY.  If it is non-nil,
-	deunify intead of unify a charset.
+	deunify instead of unify a charset.
 	(string_xstring_p): Add `const' to local variables.
 	(find_charsets_in_text): Add `const' to arguments and local variables.
 	(encode_char): Adjust for the change of Funify_charset.  Fix
--- a/src/ChangeLog.2	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ChangeLog.2	Mon Aug 09 10:51:16 2010 +0900
@@ -683,7 +683,7 @@
 	(That `select' saw something on channel 0 doesn't mean it is
 	kbd input; it could be an expose event.)
 
-	* keyboard.c (read_avail_input) [FIONREAD]:  Now static.
+	* keyboard.c (read_avail_input) [FIONREAD]: Now static.
 	New arg specifies value of NREAD;
 	if it is nonzero, don't call get_input_pending to get it.
 	Use kbd_buffer_store_char to put chars into kbd_buffer.
@@ -1210,7 +1210,7 @@
 	Remove #ifndef VMS around the sleep when buffer is full.
 	* s-vms.h: Define nonstandard PENDING_OUTPUT_COUNT for VMS use.
 
-	* fileio.c (file_name_as_directory) [VMS]:  Fix 3rd arg to strncmp.
+	* fileio.c (file_name_as_directory) [VMS]: Fix 3rd arg to strncmp.
 
 1987-07-17  Paul Rubin  (phr@prep)
 
@@ -1323,7 +1323,7 @@
 
 1987-06-09  Richard M. Stallman  (rms@prep)
 
-	* syntax.c: (scan_lists): Clear mathexit on 2nd math-char in a pair.
+	* syntax.c (scan_lists): Clear mathexit on 2nd math-char in a pair.
 
 1987-06-08  Richard M. Stallman  (rms@prep)
 
@@ -1442,7 +1442,7 @@
 	Turn on call to vmserrstr.
 	* sysdep.c (vmserrstr) [VMS]: Define this function.
 
-	* process.c (create_process) [IRIS]:  Don't open the pty's tty
+	* process.c (create_process) [IRIS]: Don't open the pty's tty
 	in the parent process.  Open only once, in the child.
 
 	* xdisp.c (redisplay_window): If window-start points nowhere,
@@ -1544,8 +1544,8 @@
 
 1987-05-05  Richard Mlynarik  (mly@prep)
 
-	* m-irist.h:  New version from raible@orville.arpa
-	* s-iris3-5.h:  New file.  (s-usg5-2 with additions)
+	* m-irist.h: New version from raible@orville.arpa
+	* s-iris3-5.h: New file.  (s-usg5-2 with additions)
 
 	* keyboard.c:
 	IRIS, like HPUX, #defines but does not implement FIONREAD.
@@ -1566,7 +1566,7 @@
 	Fcopy_file, Fset_file_modes: Don't use un*x modes if
 	env var USE_DOMAIN_ACLS is set.
 	Fset_file_modes: utimes fix.
-	Finsert_file_contents:  Must do fstat after open for Apollo.
+	Finsert_file_contents: Must do fstat after open for Apollo.
 
 	* emacs.c (main): (APOLLO from lnz):
 	Don't use un*x modes if env var USE_DOMAIN_ACLS set.
@@ -1675,7 +1675,7 @@
 
 1987-03-20  Richard Mlynarik  (mly@prep)
 
-	* filemode.c:  Hacks for set-uid/gid but not executable.
+	* filemode.c: Hacks for set-uid/gid but not executable.
 
 1987-03-20  Richard M. Stallman  (rms@prep)
 
@@ -1966,7 +1966,7 @@
 
 1987-02-22  Richard M. Stallman  (rms@prep)
 
-	* dispnew.c (Fopen_termscript):  Close existing termscript
+	* dispnew.c (Fopen_termscript): Close existing termscript
 	file before trying to open a new one.  Report open failure
 	with report_file_error.
 
@@ -2071,7 +2071,7 @@
 
 1987-02-10  Richard Mlynarik  (mly@prep)
 
-	* xfns.c (Fx_get_default):  Add (unsigned char *) cast.
+	* xfns.c (Fx_get_default): Add (unsigned char *) cast.
 
 	* window.c: typo.
 
@@ -2853,7 +2853,7 @@
 	local variables for more register decls.  Compute
 	and pass `envlen' arg to child_setup.
 
-	* process.c (create_process):  Compute and pass `envlen' arg
+	* process.c (create_process): Compute and pass `envlen' arg
 	to child_setup.
 
 	* xterm.c (x_term_init): Don't call XPopUpWindow at all.
@@ -3998,7 +3998,7 @@
 	* editfns.c (Fuser_uid, Fuser_real_uid):
 	New functions that return values of geteuid and getuid system calls.
 
-	* dired.c (Ffile_attributes):  Value has additional element
+	* dired.c (Ffile_attributes): Value has additional element
 	t iff file gid would change if Emacs deletes it and recreates it.
 
 	* xdisp.c (display_mode_element):
@@ -4078,7 +4078,7 @@
 	being unbound.  struct catchtag has two new fields,
 	gcpro and pdlcount.
 
-	* eval.c (Fthrow, Fsignal):  Use unbind_catch before longjmp.
+	* eval.c (Fthrow, Fsignal): Use unbind_catch before longjmp.
 
 	* eval.c (internal_catch): No need to restore anything
 	from the catchtag after throw, because unbind_catch does it all.
@@ -4657,14 +4657,14 @@
 
 	* fileio.c (Ffile_newer_than_file_p): New Lisp primitive.
 
-	* fileio.c (Ffile_exists_p):  this is now distinct from
+	* fileio.c (Ffile_exists_p): This is now distinct from
 	Ffile_readable_p; it checks only for existence, not for
 	readability.
 
 	* editfns.c (Fgoto_char): Use new interactive code N.
 
-	* callint.c (Fcall_interactively): New code N
-	means use prefix argif have one, else read number from minibuffer.
+	* callint.c (Fcall_interactively): New code N means use
+	prefix arg if have one, else read number from minibuffer.
 
 	* buffer.c (record_buffer):
 	Don't use Frassq, Fmemq or Fdelq since their loops
--- a/src/ChangeLog.5	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ChangeLog.5	Mon Aug 09 10:51:16 2010 +0900
@@ -176,7 +176,7 @@
 1995-06-12  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
 
 	* mem-limits.h [_LIBC] (start_of_data): Define to &__data_start
- 	for GNU libc.
+	for GNU libc.
 
 1995-06-11  Richard Stallman  <rms@gnu.ai.mit.edu>
 
@@ -227,7 +227,7 @@
 	* xterm.c (x_get_keysym_name): New function.
 	* keyboard.c (modify_event_symbol): Mask out high bits here,
 	and only for certain purposes.  table_size now unsigned.
-	(modify_event_symbol) [HAVE_X_WINDOWS]:	Use x_get_keysym_name.
+	(modify_event_symbol) [HAVE_X_WINDOWS]: Use x_get_keysym_name.
 	(make_lispy_event): Don't mask high bits here.
 	Supply -1 as table_size for system-specific keys.
 
@@ -316,9 +316,9 @@
 	(Fexecute_extended_command, init_kboard, syms_of_keyboard):
 	Undo Feb 28 change; prefix arg handling is now in Lisp code again.
 
-	* buffer.c: (syms_of_buffer): Doc fix.
-
-	* buffer.c: (Fbuffer_disable_undo): Make this function interactive.
+	* buffer.c (syms_of_buffer): Doc fix.
+
+	* buffer.c (Fbuffer_disable_undo): Make this function interactive.
 
 1995-06-07  Richard Stallman  <rms@gnu.ai.mit.edu>
 
@@ -335,7 +335,7 @@
 	(ALL_CFLAGS): Insert $(TOOLKIT_DEFINES) here.
 	* xfns.c (syms_of_xfns): Provide motif in Motif version.
 
-	* lisp.h: (Fwaiting_for_user_input_p): Function declared.
+	* lisp.h (Fwaiting_for_user_input_p): Function declared.
 	(Fupcase_initials, Fupcase_initials_region): Likewise.
 	(Fplist_get, get_local_map, Fx_popup_menu, Fx_popup_dialog): Likewise.
 	(Fframe_first_window): Likewise.
@@ -849,7 +849,7 @@
 1995-05-07  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
 	* process.c (wait_reading_process_input): Pass arg in new call to
- 	set_waiting_for_input.
+	set_waiting_for_input.
 
 	* xfns.c (Funfocus_frame): Check for live X frame.
 
@@ -1366,8 +1366,8 @@
 1995-04-11  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
 
 	* process.c (create_process): Set PROCESS's tty_name to Qnil when
- 	!PTY_FLAG, so Fprocess_tty_name returns nil for pipes as its
- 	docstring says.
+	!PTY_FLAG, so Fprocess_tty_name returns nil for pipes as its
+	docstring says.
 
 1995-04-11  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
@@ -1764,12 +1764,12 @@
 	* keyboard.c (kbd_buffer_get_event): Pass 0 for `insist' arg.
 
 	* m/intel386.h (C_SWITCH_SYSTEM): Don't #undef or define it.
- 	[SOLARIS2, SOLARIS2_4, !__GNUC__] (C_SWITCH_MACHINE): Define instead.
+	[SOLARIS2, SOLARIS2_4, !__GNUC__] (C_SWITCH_MACHINE): Define instead.
 
 1995-03-26  Germano Caronni  <caronni@tik.ethz.ch>
 
 	* ralloc.c (r_re_alloc): Correct realloc behavior--allow shrinking
- 	of blocks while reallocating, if shrinking by more than one page.
+	of blocks while reallocating, if shrinking by more than one page.
 	(relocate_blocs, resize_blocs): Added failsafe to protect future
 	calling of these routines when in frozen state.
 	(r_alloc_thaw): Added call to r_alloc_init.
@@ -1820,7 +1820,7 @@
 	* m/sparc.h: Don't include alloca.h if NOT_C_CODE.
 
 	* m/mips-siemens.h (UNEXEC): Override the definition.
-  	(LIBS_DEBUG, ORDINARY_LINK): Add #undefs.
+	(LIBS_DEBUG, ORDINARY_LINK): Add #undefs.
 
 1995-03-22  Karl Heuer  <kwzh@hal.gnu.ai.mit.edu>
 
@@ -2334,7 +2334,7 @@
 
 1995-02-14  Richard Stallman  <rms@geech.gnu.ai.mit.edu>
 
-	* filelock.c: (unlock_buffer, unlock_all_files, Flock_buffer)
+	* filelock.c (unlock_buffer, unlock_all_files, Flock_buffer)
 	(Funlock_buffer): Use buffer's file_truename, not filename.
 
 	* buffer.c (syms_of_buffer): Set up Lisp var buffer-file-truename.
@@ -3107,7 +3107,7 @@
 
 	* lisp.h (enum Lisp_Type): Lisp_Process, Lisp_Window, Lisp_Frame,
 	Lisp_Subr deleted.
-	(PSEUDOVECTORP, GC_PSEUDOVECTORP):  Add paren for proper nesting.
+	(PSEUDOVECTORP, GC_PSEUDOVECTORP): Add paren for proper nesting.
 	(PROCESSP, GC_PROCESSP, XSETPROCESS): Rewrite to use pseudovectors.
 	(WINDOWP, GC_WINDOWP, XSETWINDOW): Likewise.
 	(FRAMEP, GC_FRAMEP): Likewise.
@@ -3461,7 +3461,7 @@
 
 1994-11-19  Francesco Potortì  <pot@cnuce.cnr.it>
 
-	* lisp.h: (running_asynch_code): New global flag.
+	* lisp.h (running_asynch_code): New global flag.
 	* emacs.c (running_asynch_code): New global flag.
 	(main): Initialise it.
 	* process.c (read_process_output, exec_sentinel): Set and
@@ -3493,7 +3493,7 @@
 
 1994-11-17  Karl Heuer  <kwzh@hal.gnu.ai.mit.edu>
 
-	* lisp.h: (enum Lisp_Misc_Type): Rename Lisp_Vector to
+	* lisp.h (enum Lisp_Misc_Type): Rename Lisp_Vector to
 	Lisp_Vectorlike.  Mark Lisp_Window_Configuration as obsolete.
 	(PSEUDOVECTOR_FLAG, PSEUDOVECTOR_SIZE_MASK, PVEC_BUFFER,
 	PVEC_PROCESS, PVEC_FRAME, PVEC_COMPILED, PVEC_WINDOW,
@@ -3645,7 +3645,7 @@
 
 1994-11-14  Karl Heuer  <kwzh@hal.gnu.ai.mit.edu>
 
-	* lisp.h: (enum Lisp_Misc_Type): Add new enumeration Lisp_Misc_Overlay.
+	* lisp.h (enum Lisp_Misc_Type): Add new enumeration Lisp_Misc_Overlay.
 	(enum Lisp_Type): Delete the corresponding enumeration from here.
 	(struct Lisp_Overlay): New structure.
 	(XOVERLAY, OVERLAYP): Access the new structure.
@@ -3711,7 +3711,7 @@
 
 1994-11-11  Karl Heuer  <kwzh@nutrimat.gnu.ai.mit.edu>
 
-	* lisp.h: (enum Lisp_Misc_Type): Add new enumerations
+	* lisp.h (enum Lisp_Misc_Type): Add new enumerations
 	Lisp_Misc_Buffer_Local_Value and Lisp_Misc_Some_Buffer_Local_Value.
 	(enum Lisp_Type): Delete the corresponding enumerations from here.
 	(struct Lisp_Buffer_Local_Value): New structure.
@@ -3798,7 +3798,7 @@
 	* xfns.c (Fx_list_fonts): Don't bother to retrieve font info when
 	there's no size_ref to compare it against.
 
-	* editfns.c: (Fdecode_time): Fix Lisp_Object vs. integer problems.
+	* editfns.c (Fdecode_time): Fix Lisp_Object vs. integer problems.
 	Don't use tm_gmtoff; it's not portable.
 
 	* lisp.h: Leave DEVICE_SEP undefined by default.
@@ -3955,7 +3955,7 @@
 	Use the return value of child_setup to get the child's pid;
 	don't call vfork etc. explicitly.
 
-	* callproc.c [WINDOWSNT]: Add includes.	 Define NOMINMAX, _P_NOWAIT.
+	* callproc.c [WINDOWSNT]: Add includes.  Define NOMINMAX, _P_NOWAIT.
 	(Vbinary_process_input, Vbinary_process_output)
 	(Qbuffer_file_type): Test DOS_NT, not MSDOS.
 	(syms_of_callproc): Test DOS_NT, not MSDOS.
@@ -4367,7 +4367,7 @@
 	(the_x_screen): Variable moved here.
 	(syms_of_xterm): Staticpro parts of the_x_screen.
 	* xfns.c (Fx_open_connection): Get dpyinfo from x_term_init.
-	Don't set up atoms, xrdb here.	Pass name as Lisp_Object.
+	Don't set up atoms, xrdb here.  Pass name as Lisp_Object.
 	(the_x_screen): Variable moved to xterm.c.
 	(syms_of_xfns): Don't staticpro it here.
 
@@ -4511,7 +4511,7 @@
 
 1994-10-19  Karl Heuer  <kwzh@hal.gnu.ai.mit.edu>
 
-	* search.c: (searchbufs): New variable, replaces searchbuf and
+	* search.c (searchbufs): New variable, replaces searchbuf and
 	last_regexp and search_fastmap.
 	(syms_of_search): Initialize it.
 	(searchbuf_head): New variable.
@@ -4597,7 +4597,7 @@
 	* frame.h [!MULTI_FRAME]: We give up having selected_frame be
 	an always-zero integer variable.  From now on it will be a
 	pointer to a `struct frame' just like in the MULTI_FRAME case.
-	(selected_frame, last_nonminibuf_frame): use FRAME_PTR,	not EMACS_INT.
+	(selected_frame, last_nonminibuf_frame): use FRAME_PTR, not EMACS_INT.
 	(XFRAME): Redefine to use the_only_frame.
 	(XSETFRAME): Define to set Lisp value.
 	(WINDOW_FRAME): Redefine to return Lisp value.
@@ -4640,7 +4640,7 @@
 	(the_only_x_display, x_current_display) [!HAVE_X_WINDOWS]: New
 	variables.
 
-	* msdos.h: (XFontStruct, GC, Pixmap, Display, Window) [MSDOS_NO_X]:
+	* msdos.h (XFontStruct, GC, Pixmap, Display, Window) [MSDOS_NO_X]:
 	Dummy types.
 	(struct face, FACE_HAS_GC, FACE_GC, FACE_FOREGROUND, FACE_BACKGROUND,
 	FACE_FONT, FACE_STIPPLE, FACE_UNDERLINE_P) [MSDOS_NO_X]: Define like
@@ -4937,7 +4937,7 @@
 	(struct Lisp_Free): New structure.
 	(Lisp_Misc_Free): Type code for that structure.
 	* buffer.h (OVERLAY_POSITION): Marker assert now tests substructure.
-	* alloc.c: (MARKER_BLOCK_SIZE, marker_block, marker_free_list):
+	* alloc.c (MARKER_BLOCK_SIZE, marker_block, marker_free_list):
 	Now refers to the superset type, not just markers.
 	(allocate_misc): New function, extracted from Fmake_marker.
 	(Fpurecopy): Check the substructure.
@@ -5185,7 +5185,7 @@
 
 1994-10-02  Paul Reilly  <pmr@geech.gnu.ai.mit.edu>
 
-	* xfns.c: (HACK_EDITRES): Declare if using X11R5.
+	* xfns.c (HACK_EDITRES): Declare if using X11R5.
 	(widget_id_tick): New variable.
 	(x_any_window_to_frame): Use lw_window_is_in_menubar for
 	widget set independence.
@@ -7039,7 +7039,7 @@
 
 1994-06-07  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
-	* mips-siemens.h:  Include pyramid.h, not mips.h.
+	* mips-siemens.h: Include pyramid.h, not mips.h.
 	(LOAD_AVE_TYPE, LOAD_AVE_CVT): Definitions deleted.
 	(NO_ARG_ARRAY, HAVE_ALLOCA): Defined.
 	(BROKEN_FIONREAD): Add #undef.
--- a/src/ChangeLog.9	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ChangeLog.9	Mon Aug 09 10:51:16 2010 +0900
@@ -319,7 +319,7 @@
 
 	* lisp.h (Ftop_level): Add prototype.
 
-	* xterm.c: (xlwmenu_window_p, xlwmenu_redisplay): Add prototypes.
+	* xterm.c (xlwmenu_window_p, xlwmenu_redisplay): Add prototypes.
 	(XTread_socket): Improve style of comments to follow other
 	comments.
 
@@ -1496,7 +1496,7 @@
 	* coding.c (setup_coding_system): Don't do any designation based
 	on reg_bits if charset is not yet defined.
 
-  	* lisp.h (XVECTOR): Verify correct object type before returning a
+	* lisp.h (XVECTOR): Verify correct object type before returning a
 	pointer, using eassert.
 
 2001-07-17  Gerd Moellmann  <gerd@gnu.org>
@@ -1752,7 +1752,7 @@
 	creating the directory might signal an error, and leaves
 	Emacs in a strange state.
 
-	* term.c: (tty_cursor_hidden): New variable.
+	* term.c (tty_cursor_hidden): New variable.
 	(update_begin): Don't call tty_hide_cursor.  Clean up.
 	(update_end, set_terminal_window, set_scroll_region): Clean up.
 	(ring_bell, reset_terminal_modes): Clean up.
@@ -3109,7 +3109,7 @@
 
 	* w32term.c (w32_encode_char): Treat eight bit graphic and control
 	characters the same as ASCII and latin-1.
-	(x_display_and_set_cursor): Check for the focus	frame's selected
+	(x_display_and_set_cursor): Check for the focus frame's selected
 	window instead of selected_window.
 	(x_after_update_window_line): Don't clear if frame's internal
 	border width is zero.
@@ -3896,7 +3896,7 @@
 
 2001-01-07  Dave Love  <fx@gnu.org>
 
-	* keyboard.c (Fread_key_sequence_vector):  Avoid newline in
+	* keyboard.c (Fread_key_sequence_vector): Avoid newline in
 	arglist, for documentation's sake.
 
 2001-01-06  Andrew Innes  <andrewi@gnu.org>
@@ -4180,7 +4180,7 @@
 	what's displayed in the window.
 
 	* xdisp.c (try_window_reusing_current_matrix)
-	<new start <= old start>:  Disable rows in the current matrix
+	<new start <= old start>: Disable rows in the current matrix
 	which are below the window after scrolling.
 
 	* xdisp.c (move_it_by_lines): Don't do optimizations if NEED_Y_P
@@ -5004,7 +5004,7 @@
 	the metrics of BDF fonts.
 	(x_estimate_mode_line_height): If `mode-line' face
 	hasn't a font, use that of the frame, as drawing glyphs does.
-	(note_mouse_highlight): Change the cursor shape	on the vertical
+	(note_mouse_highlight): Change the cursor shape on the vertical
 	border between windows [not enabled].
 
 	* w32term.h (struct w32_output): Add member horizontal_drag_cursor.
@@ -5480,7 +5480,7 @@
 	* lisp.h (pos_visible_p): Change prototype.
 
 	* dispextern.h (CURRENT_MODE_LINE_HEIGHT)
-	(CURRENT_HEADER_LINE_HEIGHT):  Look at current_mode_line_height
+	(CURRENT_HEADER_LINE_HEIGHT): Look at current_mode_line_height
 	and current_header_line_height first.
 	(current_mode_line_height, current_header_line_height):
 	Declare extern.
@@ -6683,7 +6683,7 @@
 	(create_offscreen_bitmap): New function.
 	(w32_BDF_TextOut): Use it. Draw glyphs as DIBs.
 
-	* w32term.c (x_produce_glyphs):  If the distance from the current
+	* w32term.c (x_produce_glyphs): If the distance from the current
 	position to the next tab stop is less than a canonical character
 	width, use the tab stop after that.
 	(x_draw_glyphs): Handle case START and END are out of bounds more
@@ -7536,7 +7536,7 @@
 	CYCLE_CHECK arguments.
 	(merge_face_vector_with_property, Finternal_merge_in_global_face)
 	(lookup_named_face, lookup_derived_face, realize_named_face)
-	(face_at_string_position, face_at_buffer_position):  Supply
+	(face_at_string_position, face_at_buffer_position): Supply
 	new F and CYCLE_CHECK arguments to merge_face_vectors.
 	(merge_face_heights): New function.
 	(merge_face_vectors, merge_face_vector_with_property)
@@ -7826,7 +7826,7 @@
 	(x_compute_glyph_string_overhangs): Incomplete body removed, as
 	the X way of doing this will not work for W32.
 	(w32_intersect_rectangles): Removed. Use IntersectRect API call.
-	(x_draw_image_foreground):  Avoid drawing outside of the clip area
+	(x_draw_image_foreground): Avoid drawing outside of the clip area
 	when image doesn't have a mask.
 	(note_mouse_highlight): Process overlays in the right order of
 	priority. Set help_echo_window.
@@ -10156,7 +10156,7 @@
 	(encode_coding_string): Likewise.
 
 	* ccl.c (ccl_driver) <CCL_ReadMultibyteChar2>
-	<CCL_WriteMultibyteChar2>:  Handle charsets eight-bit-control and
+	<CCL_WriteMultibyteChar2>: Handle charsets eight-bit-control and
 	eight-bit-graphic correctly.
 
 2000-05-24  Kenichi HANDA  <handa@etl.go.jp>
@@ -12812,7 +12812,7 @@
 	(xim_destroy_callback, xim_open_dpy, xim_instantiate_callback)
 	(xim_initialize, xim_close)
 	[HAVE_X_I18N && HAVE_X11R6]: New functions.
-	(x_destroy_window) [HAVE_X_I18N]:  Call xic_destroy_frame.
+	(x_destroy_window) [HAVE_X_I18N]: Call xic_destroy_frame.
 	(x_term_init) [HAVE_X_I18N]: Call xim_initialize.
 	(x_delete_display) [HAVE_X_I18N]: Call xim_close.
 
@@ -13029,7 +13029,7 @@
 
 2000-01-19  Dave Love  <fx@gnu.org>
 
-	* lread.c: (syms_of_lread) [user-init-file]: Doc change.
+	* lread.c (syms_of_lread) [user-init-file]: Doc change.
 
 2000-01-18  Kenichi Handa  <handa@etl.go.jp>
 
--- a/src/alloc.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/alloc.c	Mon Aug 09 10:51:16 2010 +0900
@@ -448,7 +448,6 @@
 static struct mem_node mem_z;
 #define MEM_NIL &mem_z
 
-static POINTER_TYPE *lisp_malloc (size_t, enum mem_type);
 static struct Lisp_Vector *allocate_vectorlike (EMACS_INT);
 static void lisp_free (POINTER_TYPE *);
 static void mark_stack (void);
--- a/src/bidi.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/bidi.c	Mon Aug 09 10:51:16 2010 +0900
@@ -1774,6 +1774,6 @@
   fputs ("\n", stderr);
   fputs ("pos ", stderr);
   for (i = 0; i < bidi_cache_idx; i++)
-    fprintf (stderr, "%*d", ndigits, bidi_cache[i].charpos);
+    fprintf (stderr, "%*ld", ndigits, (long)bidi_cache[i].charpos);
   fputs ("\n", stderr);
 }
--- a/src/buffer.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/buffer.c	Mon Aug 09 10:51:16 2010 +0900
@@ -106,8 +106,6 @@
 int last_per_buffer_idx;
 
 EXFUN (Fset_buffer, 1);
-void set_buffer_internal (struct buffer *b);
-void set_buffer_internal_1 (struct buffer *b);
 static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
                                     int after, Lisp_Object arg1,
                                     Lisp_Object arg2, Lisp_Object arg3);
@@ -162,7 +160,7 @@
 
 Lisp_Object Qoverlayp;
 
-Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string;
+Lisp_Object Qpriority, Qevaporate, Qbefore_string, Qafter_string;
 
 Lisp_Object Qmodification_hooks;
 Lisp_Object Qinsert_in_front_hooks;
@@ -174,8 +172,6 @@
 static void modify_overlay (struct buffer *, EMACS_INT, EMACS_INT);
 static Lisp_Object buffer_lisp_local_variables (struct buffer *);
 
-extern char * emacs_strerror (int);
-
 /* For debugging; temporary.  See set_buffer_internal.  */
 /* Lisp_Object Qlisp_mode, Vcheck_symbol; */
 
@@ -2512,7 +2508,6 @@
   if (!EQ (old_undo, Qt))
     {
       /* Represent all the above changes by a special undo entry.  */
-      extern Lisp_Object Qapply;
       current_buffer->undo_list = Fcons (list3 (Qapply,
 						intern ("set-buffer-multibyte"),
 						NILP (flag) ? Qt : Qnil),
@@ -5348,8 +5343,6 @@
   staticpro (&Qget_file_buffer);
   Qpriority = intern_c_string ("priority");
   staticpro (&Qpriority);
-  Qwindow = intern_c_string ("window");
-  staticpro (&Qwindow);
   Qbefore_string = intern_c_string ("before-string");
   staticpro (&Qbefore_string);
   Qafter_string = intern_c_string ("after-string");
@@ -5899,14 +5892,14 @@
 
 INDICATOR specifies the logical indicator type which is one of the
 following symbols: `truncation' , `continuation', `overlay-arrow',
-`top', `bottom', `up', `down', `one-line', `empty-line', or `unknown'.
-
-BITMAPS is list of symbols (LEFT RIGHT [LEFT1 RIGHT1]) which specifies
+`top', `bottom', `top-bottom', `up', `down', empty-line', or `unknown'.
+
+BITMAPS is a list of symbols (LEFT RIGHT [LEFT1 RIGHT1]) which specifies
 the actual bitmap shown in the left or right fringe for the logical
 indicator.  LEFT and RIGHT are the bitmaps shown in the left and/or
 right fringe for the specific indicator.  The LEFT1 or RIGHT1 bitmaps
-are used only for the `bottom' and `one-line' indicators when the last
-\(only) line in has no final newline.  BITMAPS may also be a single
+are used only for the `bottom' and `top-bottom' indicators when the
+last (only) line has no final newline.  BITMAPS may also be a single
 symbol which is used in both left and right fringes.  */);
 
   DEFVAR_PER_BUFFER ("fringe-cursor-alist",
--- a/src/callint.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/callint.c	Mon Aug 09 10:51:16 2010 +0900
@@ -29,21 +29,12 @@
 #include "window.h"
 #include "keymap.h"
 
-extern Lisp_Object Qcursor_in_echo_area;
-extern Lisp_Object Qfile_directory_p;
-extern Lisp_Object Qonly;
-
 Lisp_Object Vcurrent_prefix_arg, Qminus, Qplus;
 Lisp_Object Qcall_interactively;
 Lisp_Object Vcommand_history;
 
-extern Lisp_Object Vhistory_length;
-extern Lisp_Object Vthis_original_command, real_this_command;
-extern int history_delete_duplicates;
-
 Lisp_Object Vcommand_debug_status, Qcommand_debug_status;
 Lisp_Object Qenable_recursive_minibuffers;
-extern Lisp_Object Qface, Qminibuffer_prompt;
 
 /* Non-nil means treat the mark as active
    even if mark_active is 0.  */
@@ -158,7 +149,7 @@
   return exp;
 }
 
-char *callint_argfuns[]
+static const char *callint_argfuns[]
     = {"", "point", "mark", "region-beginning", "region-end"};
 
 static void
--- a/src/callproc.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/callproc.c	Mon Aug 09 10:51:16 2010 +0900
@@ -102,8 +102,6 @@
 /* Pattern used by call-process-region to make temp files.  */
 static Lisp_Object Vtemp_file_name_pattern;
 
-extern Lisp_Object Vtemporary_file_directory;
-
 Lisp_Object Vshell_file_name;
 
 Lisp_Object Vprocess_environment, Vinitial_environment;
--- a/src/ccl.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ccl.c	Mon Aug 09 10:51:16 2010 +0900
@@ -72,8 +72,6 @@
 #define GET_HASH_TABLE(id) \
   (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
 
-extern int charset_unicode;
-
 /* CCL (Code Conversion Language) is a simple language which has
    operations on one input buffer, one output buffer, and 7 registers.
    The syntax of CCL is described in `ccl.el'.  Emacs Lisp function
--- a/src/character.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/character.c	Mon Aug 09 10:51:16 2010 +0900
@@ -430,7 +430,7 @@
    occupies on the screen.  */
 
 int
-strwidth (unsigned char *str, int len)
+strwidth (const unsigned char *str, int len)
 {
   return c_string_width (str, len, -1, NULL, NULL);
 }
@@ -710,9 +710,9 @@
    `str_to_multibyte'.  */
 
 int
-parse_str_to_multibyte (unsigned char *str, int len)
+parse_str_to_multibyte (const unsigned char *str, int len)
 {
-  unsigned char *endp = str + len;
+  const unsigned char *endp = str + len;
   int bytes;
 
   for (bytes = 0; str < endp; str++)
--- a/src/character.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/character.h	Mon Aug 09 10:51:16 2010 +0900
@@ -605,13 +605,13 @@
 extern int char_printable_p (int c);
 extern void parse_str_as_multibyte (const unsigned char *, int, int *,
                                     int *);
-extern int parse_str_to_multibyte (unsigned char *, int);
+extern int parse_str_to_multibyte (const unsigned char *, int);
 extern int str_as_multibyte (unsigned char *, int, int, int *);
 extern int str_to_multibyte (unsigned char *, int, int);
 extern int str_as_unibyte (unsigned char *, int);
 extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *,
                                  EMACS_INT, int);
-extern int strwidth (unsigned char *, int);
+extern int strwidth (const unsigned char *, int);
 extern int c_string_width (const unsigned char *, int, int, int *, int *);
 extern int lisp_string_width (Lisp_Object, int, int *, int *);
 
--- a/src/charset.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/charset.c	Mon Aug 09 10:51:16 2010 +0900
@@ -28,6 +28,7 @@
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
@@ -127,13 +128,6 @@
 
 Lisp_Object Vcurrent_iso639_language;
 
-/* Defined in chartab.c */
-extern void
-map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
-                            Lisp_Object function, Lisp_Object table,
-                            Lisp_Object arg, struct charset *charset,
-                            unsigned from, unsigned to);
-
 #define CODE_POINT_TO_INDEX(charset, code)				\
   ((charset)->code_linear_p						\
    ? (code) - (charset)->min_code					\
@@ -472,8 +466,6 @@
   return n;
 }
 
-extern Lisp_Object Qfile_name_handler_alist;
-
 /* Return a mapping vector for CHARSET loaded from MAPFILE.
    Each line of MAPFILE has this form
 	0xAAAA 0xCCCC
@@ -491,8 +483,6 @@
    Note that this function uses `openp' to open MAPFILE but ignores
    `file-name-handler-alist' to avoid running any Lisp code.  */
 
-extern void add_to_log (char *, Lisp_Object, Lisp_Object);
-
 static void
 load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int control_flag)
 {
@@ -1276,7 +1266,7 @@
 static int
 define_charset_internal (Lisp_Object name,
 			 int dimension,
-			 unsigned char *code_space,
+			 const unsigned char *code_space,
 			 unsigned min_code, unsigned max_code,
 			 int iso_final, int iso_revision, int emacs_mule_id,
 			 int ascii_compatible, int supplementary,
@@ -2082,23 +2072,22 @@
     charset = CHAR_CHARSET (XINT (ch));
   else
     {
-      Lisp_Object charset_list;
-
       if (CONSP (restriction))
 	{
-	  for (charset_list = Qnil; CONSP (restriction);
-	       restriction = XCDR (restriction))
+	  int c = XFASTINT (ch);
+
+	  for (; CONSP (restriction); restriction = XCDR (restriction))
 	    {
-	      int id;
+	      struct charset *charset;
 
-	      CHECK_CHARSET_GET_ID (XCAR (restriction), id);
-	      charset_list = Fcons (make_number (id), charset_list);
+	      CHECK_CHARSET_GET_CHARSET (XCAR (restriction), charset);
+	      if (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset))
+		return XCAR (restriction);
 	    }
-	  charset_list = Fnreverse (charset_list);
+	  return Qnil;
 	}
-      else
-	charset_list = coding_system_charset_list (restriction);
-      charset = char_charset (XINT (ch), charset_list, NULL);
+      restriction = coding_system_charset_list (restriction);
+      charset = char_charset (XINT (ch), restriction, NULL);
       if (! charset)
 	return Qnil;
     }
@@ -2249,6 +2238,69 @@
   return make_number (id);
 }
 
+struct charset_sort_data
+{
+  Lisp_Object charset;
+  int id;
+  int priority;
+};
+
+static int
+charset_compare (const void *d1, const void *d2)
+{
+  const struct charset_sort_data *data1 = d1, *data2 = d2;
+  return (data1->priority - data2->priority);
+}
+
+DEFUN ("sort-charsets", Fsort_charsets, Ssort_charsets, 1, 1, 0,
+       doc: /* Sort charset list CHARSETS by a priority of each charset.
+Return the sorted list.  CHARSETS is modified by side effects.
+See also `charset-priority-list' and `set-charset-priority'.  */)
+     (Lisp_Object charsets)
+{
+  Lisp_Object len = Flength (charsets);
+  int n = XFASTINT (len), i, j, done;
+  Lisp_Object tail, elt, attrs;
+  struct charset_sort_data *sort_data;
+  int id, min_id, max_id;
+  USE_SAFE_ALLOCA;
+
+  if (n == 0)
+    return Qnil;
+  SAFE_ALLOCA (sort_data, struct charset_sort_data *, sizeof (*sort_data) * n);
+  for (tail = charsets, i = 0; CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      CHECK_CHARSET_GET_ATTR (elt, attrs);
+      sort_data[i].charset = elt;
+      sort_data[i].id = id = XINT (CHARSET_ATTR_ID (attrs));
+      if (i == 0)
+	min_id = max_id = id;
+      else if (id < min_id)
+	min_id = id;
+      else if (id > max_id)
+	max_id = id;
+    }
+  for (done = 0, tail = Vcharset_ordered_list, i = 0;
+       done < n && CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      id = XFASTINT (elt);
+      if (id >= min_id && id <= max_id)
+	for (j = 0; j < n; j++)
+	  if (sort_data[j].id == id)
+	    {
+	      sort_data[j].priority = i;
+	      done++;
+	    }
+    }
+  qsort (sort_data, n, sizeof *sort_data, charset_compare);
+  for (i = 0, tail = charsets; CONSP (tail); tail = XCDR (tail), i++)
+    XSETCAR (tail, sort_data[i].charset);
+  SAFE_FREE ();
+  return charsets;
+}
+
 
 void
 init_charset (void)
@@ -2351,6 +2403,7 @@
   defsubr (&Scharset_priority_list);
   defsubr (&Sset_charset_priority);
   defsubr (&Scharset_id_internal);
+  defsubr (&Ssort_charsets);
 
   DEFVAR_LISP ("charset-map-path", &Vcharset_map_path,
 	       doc: /* *List of directories to search for charset map files.  */);
--- a/src/charset.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/charset.h	Mon Aug 09 10:51:16 2010 +0900
@@ -517,8 +517,6 @@
 #define EMACS_MULE_LEADING_CODE_PRIVATE_21	0x9C /* 2/2 */
 #define EMACS_MULE_LEADING_CODE_PRIVATE_22	0x9D /* 2/2 */
 
-extern struct charset *emacs_mule_charset[256];
-
 
 
 extern Lisp_Object Qcharsetp;
--- a/src/cmds.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/cmds.c	Mon Aug 09 10:51:16 2010 +0900
@@ -43,9 +43,6 @@
 /* This is the command that set up Vself_insert_face.  */
 Lisp_Object Vself_insert_face_command;
 
-extern Lisp_Object Qface;
-extern Lisp_Object Vtranslation_table_for_input;
-
 static int internal_self_insert (int, int);
 
 DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
@@ -116,7 +113,8 @@
 
 DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 1, "^p",
        doc: /* Move N lines forward (backward if N is negative).
-Precisely, if point is on line I, move to the start of line I + N.
+Precisely, if point is on line I, move to the start of line I + N
+\("start of line" in the logical order).
 If there isn't room, go as far as possible (no error).
 Returns the count of lines left to move.  If moving forward,
 that is N - number of lines moved; if backward, N + number moved.
@@ -160,7 +158,7 @@
 }
 
 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p",
-       doc: /* Move point to beginning of current line.
+       doc: /* Move point to beginning of current line (in the logical order).
 With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 
@@ -184,7 +182,7 @@
 }
 
 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 0, 1, "^p",
-       doc: /* Move point to end of current line.
+       doc: /* Move point to end of current line (in the logical order).
 With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
--- a/src/coding.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/coding.c	Mon Aug 09 10:51:16 2010 +0900
@@ -303,7 +303,6 @@
 
 Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type;
 Lisp_Object Qunix, Qdos;
-extern Lisp_Object Qmac;	/* frame.c */
 Lisp_Object Qbuffer_file_coding_system;
 Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
 Lisp_Object Qdefault_char;
@@ -317,7 +316,6 @@
 Lisp_Object QCpost_read_conversion, QCpre_write_conversion;
 Lisp_Object QCascii_compatible_p;
 
-extern Lisp_Object Qinsert_file_contents, Qwrite_region;
 Lisp_Object Qcall_process, Qcall_process_region;
 Lisp_Object Qstart_process, Qopen_network_stream;
 Lisp_Object Qtarget_idx;
@@ -325,8 +323,6 @@
 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
 Lisp_Object Qinterrupted, Qinsufficient_memory;
 
-extern Lisp_Object Qcompletion_ignore_case;
-
 /* If a symbol has this property, evaluate the value to define the
    symbol as a coding system.  */
 static Lisp_Object Qcoding_system_define_form;
@@ -3906,7 +3902,7 @@
 		  int size;
 
 		  ONE_MORE_BYTE (dim);
-		  if (dim < 0 || dim > 4)
+		  if (dim < '0' || dim > '4')
 		    goto invalid_code;
 		  ONE_MORE_BYTE (M);
 		  if (M < 128)
@@ -4101,8 +4097,8 @@
 #define ENCODE_DESIGNATION(charset, reg, coding)			\
   do {									\
     unsigned char final_char = CHARSET_ISO_FINAL (charset);		\
-    char *intermediate_char_94 = "()*+";				\
-    char *intermediate_char_96 = ",-./";				\
+    const char *intermediate_char_94 = "()*+";				\
+    const char *intermediate_char_96 = ",-./";				\
     int revision = -1;							\
     int c;								\
 									\
--- a/src/coding.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/coding.h	Mon Aug 09 10:51:16 2010 +0900
@@ -802,6 +802,9 @@
 /* Default coding systems used for process I/O.  */
 extern Lisp_Object Vdefault_process_coding_system;
 
+/* Char table for translating Quail and self-inserting input.  */
+extern Lisp_Object Vtranslation_table_for_input;
+
 /* Function to call to force a user to force select a propert coding
    system.  */
 extern Lisp_Object Vselect_safe_coding_system_function;
--- a/src/composite.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/composite.c	Mon Aug 09 10:51:16 2010 +0900
@@ -848,8 +848,6 @@
   return header;
 }
 
-extern void font_fill_lglyph_metrics (Lisp_Object, Lisp_Object);
-
 static void
 fill_gstring_body (Lisp_Object gstring)
 {
@@ -1939,7 +1937,6 @@
   /* Make a hash table for static composition.  */
   {
     Lisp_Object args[6];
-    extern Lisp_Object QCsize;
 
     args[0] = QCtest;
     args[1] = Qequal;
@@ -1959,8 +1956,6 @@
   /* Make a hash table for glyph-string.  */
   {
     Lisp_Object args[6];
-    extern Lisp_Object QCsize;
-
     args[0] = QCtest;
     args[1] = Qequal;
     args[2] = QCweakness;
--- a/src/config.in	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/config.in	Mon Aug 09 10:51:16 2010 +0900
@@ -150,6 +150,9 @@
 /* Define to 1 if you have the `difftime' function. */
 #undef HAVE_DIFFTIME
 
+/* Define to 1 if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
 /* Define to 1 if you have the `dup2' function. */
 #undef HAVE_DUP2
 
@@ -728,6 +731,9 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the <util.h> header file. */
+#undef HAVE_UTIL_H
+
 /* Define to 1 if you have the `utimes' function. */
 #undef HAVE_UTIMES
 
--- a/src/data.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/data.c	Mon Aug 09 10:51:16 2010 +0900
@@ -82,7 +82,8 @@
 
 Lisp_Object Qinteger;
 static Lisp_Object Qsymbol, Qstring, Qcons, Qmarker, Qoverlay;
-static Lisp_Object Qfloat, Qwindow_configuration, Qwindow;
+Lisp_Object Qwindow;
+static Lisp_Object Qfloat, Qwindow_configuration;
 Lisp_Object Qprocess;
 static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector;
 static Lisp_Object Qchar_table, Qbool_vector, Qhash_table;
@@ -664,8 +665,6 @@
   return definition;
 }
 
-extern Lisp_Object Qfunction_documentation;
-
 DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0,
        doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION.
 Associates the function with the current load file, if any.
@@ -750,7 +749,7 @@
 
   if (SUBRP (fun))
     {
-      char *spec = XSUBR (fun)->intspec;
+      const char *spec = XSUBR (fun)->intspec;
       if (spec)
 	return list2 (Qinteractive,
 		      (*spec != '(') ? build_string (spec) :
@@ -1865,6 +1864,7 @@
 	Lisp_Object tail, elt, tmp;
 	struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
 	XSETBUFFER (tmp, buf);
+	XSETSYMBOL (variable, sym); /* Update in case of aliasing.  */
 
 	for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
 	  {
@@ -2501,8 +2501,6 @@
 
 static Lisp_Object float_arith_driver (double, int, enum arithop,
                                        int, Lisp_Object *);
-extern Lisp_Object fmod_float (Lisp_Object, Lisp_Object);
-
 Lisp_Object
 arith_driver (enum arithop code, int nargs, register Lisp_Object *args)
 {
--- a/src/deps.mk	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/deps.mk	Mon Aug 09 10:51:16 2010 +0900
@@ -190,7 +190,7 @@
 unexaix.o: unexaix.c lisp.h $(config_h)
 unexalpha.o: unexalpha.c $(config_h)
 unexcw.o: unexcw.c lisp.h $(config_h)
-unexec.o: unexec.c lisp.h $(config_h)
+unexcoff.o: unexcoff.c lisp.h $(config_h)
 unexelf.o: unexelf.c $(config_h)
 unexhp9k800.o: unexhp9k800.c $(config_h)
 unexmacosx.o: unexmacosx.c $(config_h)
--- a/src/dired.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/dired.c	Mon Aug 09 10:51:16 2010 +0900
@@ -48,32 +48,24 @@
    Since applying strlen to the name always works, we'll just do that.  */
 #define NAMLEN(p) strlen (p->d_name)
 
-#ifdef SYSV_SYSTEM_DIR
+#ifdef HAVE_DIRENT_H
 
 #include <dirent.h>
 #define DIRENTRY struct dirent
 
-#else /* not SYSV_SYSTEM_DIR */
+#else /* not HAVE_DIRENT_H */
 
-#ifdef MSDOS
-#include <dirent.h>
-#else
 #include <sys/dir.h>
-#endif
-
 #include <sys/stat.h>
 
-#ifndef MSDOS
 #define DIRENTRY struct direct
 
 extern DIR *opendir (char *);
 extern struct direct *readdir (DIR *);
 
-#endif /* not MSDOS */
-#endif /* not SYSV_SYSTEM_DIR */
+#endif /* HAVE_DIRENT_H */
 
-/* Some versions of Cygwin don't have d_ino in `struct dirent'.  */
-#if defined(MSDOS) || defined(__CYGWIN__)
+#ifdef MSDOS
 #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
 #else
 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
@@ -90,7 +82,9 @@
 #include "blockinput.h"
 
 /* Returns a search buffer, with a fastmap allocated and ready to go.  */
-extern struct re_pattern_buffer *compile_pattern (Lisp_Object, struct re_registers *, Lisp_Object, int, int);
+extern struct re_pattern_buffer *compile_pattern (Lisp_Object,
+						  struct re_registers *,
+						  Lisp_Object, int, int);
 
 /* From filemode.c.  Can't go in Lisp.h because of `stat'.  */
 extern void filemodestring (struct stat *, char *);
@@ -102,9 +96,6 @@
 #define lstat stat
 #endif
 
-extern int completion_ignore_case;
-extern Lisp_Object Qcompletion_ignore_case;
-extern Lisp_Object Vcompletion_regexp_list;
 extern Lisp_Object Vw32_get_true_file_attributes;
 
 Lisp_Object Vcompletion_ignored_extensions;
@@ -115,7 +106,7 @@
 Lisp_Object Qfile_attributes;
 Lisp_Object Qfile_attributes_lessp;
 
-static int scmp (unsigned char *, unsigned char *, int);
+static int scmp (const unsigned char *, const unsigned char *, int);
 
 #ifdef WINDOWSNT
 Lisp_Object
@@ -206,7 +197,6 @@
 #ifdef WINDOWSNT
   if (attrs)
     {
-      extern Lisp_Object Qlocal;
       extern int is_slow_fs (const char *);
 
       /* Do this only once to avoid doing it (in w32.c:stat) for each
@@ -813,7 +803,7 @@
    else number of chars that match at the beginning.  */
 
 static int
-scmp (register unsigned char *s1, register unsigned char *s2, int len)
+scmp (const unsigned char *s1, const unsigned char *s2, int len)
 {
   register int l = len;
 
--- a/src/dispextern.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/dispextern.h	Mon Aug 09 10:51:16 2010 +0900
@@ -2050,7 +2050,7 @@
   /* C string to iterate over.  Non-null means get characters from
      this string, otherwise characters are read from current_buffer
      or it->string.  */
-  unsigned char *s;
+  const unsigned char *s;
 
   /* Number of characters in the string (s, or it->string) we iterate
      over.  */
@@ -2430,7 +2430,6 @@
 
 #define PRODUCE_GLYPHS(IT)                              \
   do {                                                  \
-    extern int inhibit_free_realized_faces;             \
     if ((IT)->glyph_row != NULL && (IT)->bidi_p)	\
       {							\
         if ((IT)->bidi_it.paragraph_dir == R2L)		\
@@ -2951,7 +2950,6 @@
 extern Lisp_Object Vshow_trailing_whitespace;
 extern int mode_line_in_non_selected_windows;
 extern int redisplaying_p;
-extern void add_to_log (char *, Lisp_Object, Lisp_Object);
 extern int help_echo_showing_p;
 extern int current_mode_line_height, current_header_line_height;
 extern Lisp_Object help_echo_string, help_echo_window;
@@ -3032,6 +3030,7 @@
 
 /* Defined in fringe.c */
 
+extern Lisp_Object Voverflow_newline_into_fringe;
 int lookup_fringe_bitmap (Lisp_Object);
 void draw_fringe_bitmap (struct window *, struct glyph_row *, int);
 void draw_row_fringe_bitmaps (struct window *, struct glyph_row *);
@@ -3243,15 +3242,9 @@
 void prepare_desired_row (struct glyph_row *);
 int line_hash_code (struct glyph_row *);
 void set_window_update_flags (struct window *, int);
-void redraw_frame (struct frame *);
-void redraw_garbaged_frames (void);
-int scroll_cost (struct frame *, int, int, int);
-int update_frame (struct frame *, int, int);
 void update_single_window (struct window *, int);
-int scrolling (struct frame *);
 void do_pending_window_change (int);
 void change_frame_size (struct frame *, int, int, int, int, int);
-void bitch_at_user (void);
 void init_display (void);
 void syms_of_display (void);
 extern Lisp_Object Qredisplay_dont_pause;
@@ -3322,18 +3315,18 @@
 };
 
 extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
-                              Lisp_Object, char *, char *class,
+                              Lisp_Object, const char *, const char *class,
                               enum resource_types);
 extern Lisp_Object x_frame_get_arg (struct frame *, Lisp_Object,
-                                    Lisp_Object, char *, char *,
+                                    Lisp_Object, const char *, const char *,
                                     enum resource_types);
-extern Lisp_Object x_frame_get_and_record_arg (
-                                               struct frame *, Lisp_Object,
-                                               Lisp_Object, char *, char *,
+extern Lisp_Object x_frame_get_and_record_arg (struct frame *, Lisp_Object,
+                                               Lisp_Object,
+					       const char *, const char *,
                                                enum resource_types);
 extern Lisp_Object x_default_parameter (struct frame *, Lisp_Object,
                                         Lisp_Object, Lisp_Object,
-                                        char *, char *,
+                                        const char *, const char *,
                                         enum resource_types);
 
 #endif /* HAVE_WINDOW_SYSTEM */
--- a/src/dispnew.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/dispnew.c	Mon Aug 09 10:51:16 2010 +0900
@@ -66,12 +66,6 @@
 #include "systime.h"
 #include <errno.h>
 
-/* To get the prototype for `sleep'.  */
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 /* Get number of chars of output now in the buffer of a stdio stream.
    This ought to be built in in stdio, but it isn't.  Some s- files
    override this because their stdio internals differ.  */
@@ -1534,7 +1528,11 @@
       int size = needed * sizeof (struct glyph);
 
       if (pool->glyphs)
-	pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+	{
+	  pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+	  memset (pool->glyphs + pool->nglyphs, 0,
+		  size - pool->nglyphs * sizeof (struct glyph));
+	}
       else
 	{
 	  pool->glyphs = (struct glyph *) xmalloc (size);
@@ -3664,8 +3662,6 @@
 #if !PERIODIC_PREEMPTION_CHECKING
   int preempt_count = baud_rate / 2400 + 1;
 #endif
-  extern int input_pending;
-  extern Lisp_Object do_mouse_tracking;
   struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
 #if GLYPH_DEBUG
   /* Check that W's frame doesn't have glyph matrices.  */
@@ -4710,7 +4706,6 @@
   int i;
   int pause;
   int preempt_count = baud_rate / 2400 + 1;
-  extern int input_pending;
 
   xassert (current_matrix && desired_matrix);
 
@@ -5039,7 +5034,6 @@
 
 /* Char insertion/deletion cost vector, from term.c */
 
-extern int *char_ins_del_vector;
 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_TOTAL_COLS((f))])
 
 
@@ -6235,10 +6229,6 @@
 {
   char *terminal_type;
 
-#ifdef HAVE_X_WINDOWS
-  extern int display_arg;
-#endif
-
   /* Construct the space glyph.  */
   space_glyph.type = CHAR_GLYPH;
   SET_CHAR_GLYPH (space_glyph, ' ', DEFAULT_FACE_ID, 0);
--- a/src/doc.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/doc.c	Mon Aug 09 10:51:16 2010 +0900
@@ -52,10 +52,6 @@
 /* A list of files used to build this Emacs binary.  */
 static Lisp_Object Vbuild_files;
 
-extern Lisp_Object Voverriding_local_map;
-
-extern Lisp_Object Qremap;
-
 /* Buffer used for reading from documentation file.  */
 static char *get_doc_string_buffer;
 static int get_doc_string_buffer_size;
--- a/src/editfns.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/editfns.c	Mon Aug 09 10:51:16 2010 +0900
@@ -97,7 +97,6 @@
 static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *);
 static void update_buffer_properties (int, int);
 static Lisp_Object region_limit (int);
-int lisp_time_argument (Lisp_Object, time_t *, int *);
 static size_t emacs_memftimeu (char *, size_t, const char *,
                                size_t, const struct tm *, int);
 static void general_insert_function (void (*) (const unsigned char *, EMACS_INT),
@@ -320,7 +319,6 @@
 static Lisp_Object
 region_limit (int beginningp)
 {
-  extern Lisp_Object Vmark_even_if_inactive; /* Defined in callint.c. */
   Lisp_Object m;
 
   if (!NILP (Vtransient_mark_mode)
@@ -338,14 +336,14 @@
 }
 
 DEFUN ("region-beginning", Fregion_beginning, Sregion_beginning, 0, 0, 0,
-       doc: /* Return position of beginning of region, as an integer.  */)
+       doc: /* Return the integer value of point or mark, whichever is smaller.  */)
   (void)
 {
   return region_limit (1);
 }
 
 DEFUN ("region-end", Fregion_end, Sregion_end, 0, 0, 0,
-       doc: /* Return position of end of region, as an integer.  */)
+       doc: /* Return the integer value of point or mark, whichever is larger.  */)
   (void)
 {
   return region_limit (0);
@@ -807,6 +805,9 @@
 With argument N not nil or 1, move forward N - 1 lines first.
 If scan reaches end of buffer, return that position.
 
+The returned position is of the first character in the logical order,
+i.e. the one that has the smallest character position.
+
 This function constrains the returned position to the current field
 unless that would be on a different line than the original,
 unconstrained result.  If N is nil or 1, and a front-sticky field
@@ -845,6 +846,9 @@
 With argument N not nil or 1, move forward N - 1 lines first.
 If scan reaches end of buffer, return that position.
 
+The returned position is of the last character in the logical order,
+i.e. the character whose buffer position is the largest one.
+
 This function constrains the returned position to the current field
 unless that would be on a different line than the original,
 unconstrained result.  If N is nil or 1, and a rear-sticky field ends
@@ -3382,9 +3386,6 @@
       return val;
     }
 }
-#ifdef HAVE_MENUS
-extern Lisp_Object last_nonmenu_event;
-#endif
 
 DEFUN ("message-or-box", Fmessage_or_box, Smessage_or_box, 1, MANY, 0,
        doc: /* Display a message in a dialog box or in the echo area.
@@ -4554,7 +4555,6 @@
 
   {
     Lisp_Object obuf;
-    extern Lisp_Object Vprin1_to_string_buffer;
     obuf = Fcurrent_buffer ();
     /* Do this here, because init_buffer_once is too early--it won't work.  */
     Fset_buffer (Vprin1_to_string_buffer);
--- a/src/emacs-icon.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/emacs-icon.h	Mon Aug 09 10:51:16 2010 +0900
@@ -23,7 +23,7 @@
 /* Note that the GTK port uses gdk to display the icon, so Emacs need
    not have XPM support compiled in.  */
 #if (defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)) || defined (USE_GTK)
-static char * gnu_xpm_bits[] = {
+static const char * gnu_xpm_bits[] = {
 /* width height ncolors chars_per_pixel */
 "32 32 255 2",
 /* colors */
--- a/src/emacs.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/emacs.c	Mon Aug 09 10:51:16 2010 +0900
@@ -63,6 +63,10 @@
 #include "keyboard.h"
 #include "keymap.h"
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
 #ifdef HAVE_SETLOCALE
 #include <locale.h>
 #endif
@@ -87,8 +91,8 @@
 #endif
 #endif
 
-const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
-const char emacs_version[] = "24.0.50";
+static const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
+static const char emacs_version[] = "24.0.50";
 
 /* Make these values available in GDB, which doesn't see macros.  */
 
@@ -213,15 +217,6 @@
    output a warning in dump-emacs.  */
 #define MAX_HEAP_BSS_DIFF (1024*1024)
 
-
-#ifdef HAVE_WINDOW_SYSTEM
-extern Lisp_Object Vinitial_window_system;
-#endif /* HAVE_WINDOW_SYSTEM */
-
-extern Lisp_Object Vauto_save_list_file_name;
-
-extern Lisp_Object Vinhibit_redisplay;
-
 /* Nonzero means running Emacs without interactive terminal.  */
 
 int noninteractive;
@@ -634,7 +629,7 @@
    enough information to do it right.  */
 
 static int
-argmatch (char **argv, int argc, char *sstr, char *lstr, int minlen, char **valptr, int *skipptr)
+argmatch (char **argv, int argc, const char *sstr, const char *lstr, int minlen, char **valptr, int *skipptr)
 {
   char *p = NULL;
   int arglen;
@@ -757,7 +752,6 @@
   char *ch_to_dir;
 
 #if GC_MARK_STACK
-  extern Lisp_Object *stack_base;
   stack_base = &dummy;
 #endif
 
@@ -861,23 +855,6 @@
     }
 #endif /* HAVE_PERSONALITY_LINUX32 */
 
-
-/* Map in shared memory, if we are using that.  */
-#ifdef HAVE_SHM
-  if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
-    {
-      map_in_data (0);
-      /* The shared memory was just restored, which clobbered this.  */
-      skip_args = 1;
-    }
-  else
-    {
-      map_in_data (1);
-      /* The shared memory was just restored, which clobbered this.  */
-      skip_args = 0;
-    }
-#endif
-
 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
   /* Extend the stack space available.
      Don't do that if dumping, since some systems (e.g. DJGPP)
@@ -1276,9 +1253,7 @@
 #ifdef AIX
 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU.  */
       signal (SIGXCPU, fatal_error_signal);
-#ifndef _I386
       signal (SIGIOINT, fatal_error_signal);
-#endif
       signal (SIGGRANT, fatal_error_signal);
       signal (SIGRETRACT, fatal_error_signal);
       signal (SIGSOUND, fatal_error_signal);
@@ -2094,8 +2069,6 @@
     unlink (SDATA (Vauto_save_list_file_name));
 
   exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS);
-  /* NOTREACHED */
-  return Qnil;
 }
 
 
--- a/src/eval.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/eval.c	Mon Aug 09 10:51:16 2010 +0900
@@ -63,7 +63,6 @@
 Lisp_Object Qdebug_on_error;
 Lisp_Object Qdeclare;
 Lisp_Object Qdebug;
-extern Lisp_Object Qinteractive_form;
 
 /* This holds either the symbol `run-hooks' or nil.
    It is nil at an early stage of startup, and when Emacs
@@ -166,10 +165,6 @@
 
 Lisp_Object Vmacro_declaration_function;
 
-extern Lisp_Object Qrisky_local_variable;
-
-extern Lisp_Object Qfunction;
-
 static Lisp_Object funcall_lambda (Lisp_Object, int, Lisp_Object*);
 static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN;
 
@@ -1634,8 +1629,6 @@
      That is a special case--don't do this in other situations.  */
   register struct handler *allhandlers = handlerlist;
   Lisp_Object conditions;
-  extern int gc_in_progress;
-  extern int waiting_for_input;
   Lisp_Object string;
   Lisp_Object real_error_symbol;
   struct backtrace *bp;
@@ -3438,7 +3431,6 @@
   register int i;
   Lisp_Object tail;
   Lisp_Object tem;
-  extern Lisp_Object Vprint_level;
   struct gcpro gcpro1;
 
   XSETFASTINT (Vprint_level, 3);
--- a/src/fileio.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/fileio.c	Mon Aug 09 10:51:16 2010 +0900
@@ -104,8 +104,6 @@
 #endif
 
 #include "commands.h"
-extern int use_dialog_box;
-extern int use_file_dialog;
 
 #ifndef O_WRONLY
 #define O_WRONLY 1
@@ -214,16 +212,10 @@
 /* Lisp function for recursively deleting directories.  */
 Lisp_Object Qdelete_directory;
 
-extern Lisp_Object Vuser_login_name;
-
 #ifdef WINDOWSNT
 extern Lisp_Object Vw32_get_true_file_attributes;
 #endif
 
-extern int minibuf_level;
-
-extern int minibuffer_auto_raise;
-
 /* These variables describe handlers that have "already" had a chance
    to handle the current operation.
 
@@ -862,8 +854,6 @@
 
 	 To avoid this, we set default_directory to the root of the
 	 current drive.  */
-      extern char *emacs_root_dir (void);
-
       default_directory = build_string (emacs_root_dir ());
 #else
       default_directory = build_string ("/");
@@ -3049,7 +3039,6 @@
   return value;
 }
 
-extern int lisp_time_argument (Lisp_Object, time_t *, int *);
 
 DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
        doc: /* Set times of file FILENAME to TIME.
--- a/src/filelock.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/filelock.c	Mon Aug 09 10:51:16 2010 +0900
@@ -117,8 +117,6 @@
 static time_t boot_time;
 static int boot_time_initialized;
 
-extern Lisp_Object Vshell_file_name;
-
 #ifdef BOOT_TIME
 static void get_boot_time_1 (char *, int);
 #endif
--- a/src/fns.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/fns.c	Mon Aug 09 10:51:16 2010 +0900
@@ -61,19 +61,12 @@
    questions asked by mouse commands.  */
 int use_file_dialog;
 
-extern int minibuffer_auto_raise;
-extern Lisp_Object minibuf_window;
-extern Lisp_Object Vlocale_coding_system;
-extern int load_in_progress;
-
 Lisp_Object Qstring_lessp, Qprovide, Qrequire;
 Lisp_Object Qyes_or_no_p_history;
 Lisp_Object Qcursor_in_echo_area;
 Lisp_Object Qwidget_type;
 Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
 
-extern Lisp_Object Qinput_method_function;
-
 static int internal_equal (Lisp_Object , Lisp_Object, int, int);
 
 extern long get_random (void);
@@ -232,9 +225,8 @@
   return Qt;
 }
 
-DEFUN ("compare-strings", Fcompare_strings,
-       Scompare_strings, 6, 7, 0,
-doc: /* Compare the contents of two strings, converting to multibyte if needed.
+DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0,
+       doc: /* Compare the contents of two strings, converting to multibyte if needed.
 In string STR1, skip the first START1 characters and stop at END1.
 In string STR2, skip the first START2 characters and stop at END2.
 END1 and END2 default to the full lengths of the respective strings.
@@ -1206,7 +1198,7 @@
 
 DEFUN ("substring-no-properties", Fsubstring_no_properties, Ssubstring_no_properties, 1, 3, 0,
        doc: /* Return a substring of STRING, without text properties.
-It starts at index FROM and ending before TO.
+It starts at index FROM and ends before TO.
 TO may be nil or omitted; then the substring runs to the end of STRING.
 If FROM is nil or omitted, the substring starts at the beginning of STRING.
 If FROM or TO is negative, it counts from the end.
@@ -1298,7 +1290,7 @@
 }
 
 DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
-       doc: /* Take cdr N times on LIST, returns the result.  */)
+       doc: /* Take cdr N times on LIST, return the result.  */)
   (Lisp_Object n, Lisp_Object list)
 {
   register int i, num;
@@ -1335,7 +1327,7 @@
 }
 
 DEFUN ("member", Fmember, Smember, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -1353,7 +1345,7 @@
 }
 
 DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -1379,7 +1371,7 @@
 }
 
 DEFUN ("memql", Fmemql, Smemql, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -2707,10 +2699,9 @@
 }
 
 Lisp_Object Vfeatures, Qsubfeatures;
-extern Lisp_Object Vafter_load_alist;
 
 DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0,
-       doc: /* Returns t if FEATURE is present in this Emacs.
+       doc: /* Return t if FEATURE is present in this Emacs.
 
 Use this to conditionalize execution of lisp code based on the
 presence or absence of Emacs or environment extensions.
@@ -4433,8 +4424,8 @@
 multiplying the old size with that factor.  Default is 1.5.
 
 :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0.
-Resize the hash table when ratio of the number of entries in the
-table.  Default is 0.8.
+Resize the hash table when the ratio (number of entries / table size)
+is greater or equal than THRESHOLD.  Default is 0.8.
 
 :weakness WEAK -- WEAK must be one of nil, t, `key', `value',
 `key-or-value', or `key-and-value'.  If WEAK is not nil, the table
@@ -4557,7 +4548,7 @@
 DEFUN ("hash-table-size", Fhash_table_size, Shash_table_size, 1, 1, 0,
        doc: /* Return the size of TABLE.
 The size can be used as an argument to `make-hash-table' to create
-a hash table than can hold as many elements of TABLE holds
+a hash table than can hold as many elements as TABLE holds
 without need for resizing.  */)
   (Lisp_Object table)
 {
--- a/src/font.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/font.c	Mon Aug 09 10:51:16 2010 +0900
@@ -48,10 +48,6 @@
 #include "nsterm.h"
 #endif /* HAVE_NS */
 
-#ifdef HAVE_NS
-extern Lisp_Object Qfontsize;
-#endif
-
 Lisp_Object Qopentype;
 
 /* Important character set strings.  */
@@ -127,12 +123,6 @@
   { 200, { "ultra-expanded", "ultraexpanded", "wide" }}
 };
 
-extern Lisp_Object Qnormal;
-
-/* Symbols representing keys of normal font properties.  */
-extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth;
-extern Lisp_Object QCheight, QCsize, QCname;
-
 Lisp_Object QCfoundry, QCadstyle, QCregistry;
 /* Symbols representing keys of font extra info.  */
 Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript, QCavgwidth;
@@ -242,7 +232,7 @@
    STR.  */
 
 Lisp_Object
-font_intern_prop (char *str, int len, int force_symbol)
+font_intern_prop (const char *str, int len, int force_symbol)
 {
   int i;
   Lisp_Object tem;
@@ -400,11 +390,6 @@
   return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1));
 }
 
-extern Lisp_Object Vface_alternative_font_family_alist;
-
-extern Lisp_Object find_font_encoding (Lisp_Object);
-
-
 /* Return ENCODING or a cons of ENCODING and REPERTORY of the font
    FONTNAME.  ENCODING is a charset symbol that specifies the encoding
    of the font.  REPERTORY is a charset symbol or nil.  */
@@ -609,7 +594,7 @@
 
 /* Structure of known font property keys and validater of the
    values.  */
-struct
+static const struct
 {
   /* Pointer to the key symbol.  */
   Lisp_Object *key;
@@ -996,7 +981,7 @@
    a fully specified XLFD.  */
 
 int
-font_parse_xlfd (char *name, Lisp_Object font)
+font_parse_xlfd (const char *name, Lisp_Object font)
 {
   int len = strlen (name);
   int i, j, n;
@@ -1321,7 +1306,7 @@
    This function tries to guess which format it is.  */
 
 int
-font_parse_fcname (char *name, Lisp_Object font)
+font_parse_fcname (const char *name, Lisp_Object font)
 {
   char *p, *q;
   char *size_beg = NULL, *size_end = NULL;
@@ -1578,7 +1563,7 @@
    FONT_SIZE_INDEX of FONT is 0, use PIXEL_SIZE instead.  */
 
 int
-font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
+font_unparse_fcname (Lisp_Object font, int pixel_size, const char *name, int nbytes)
 {
   Lisp_Object family, foundry;
   Lisp_Object tail, val;
@@ -1586,7 +1571,7 @@
   int i, len = 1;
   char *p;
   Lisp_Object styles[3];
-  char *style_names[3] = { "weight", "slant", "width" };
+  const char *style_names[3] = { "weight", "slant", "width" };
   char work[256];
 
   family = AREF (font, FONT_FAMILY_INDEX);
@@ -2144,9 +2129,6 @@
 static Lisp_Object font_sort_entities (Lisp_Object, Lisp_Object,
                                        Lisp_Object, int);
 
-/* Return a rescaling ratio of FONT_ENTITY.  */
-extern Lisp_Object Vface_font_rescale_alist;
-
 static double
 font_rescale_ratio (Lisp_Object font_entity)
 {
@@ -2729,8 +2711,6 @@
      (2) doesn't match with any regexps in Vface_ignored_fonts (if non-nil).
 */
 
-extern Lisp_Object Vface_ignored_fonts;
-
 Lisp_Object
 font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size)
 {
@@ -3526,7 +3506,7 @@
    found, return Qnil.  */
 
 Lisp_Object
-font_open_by_name (FRAME_PTR f, char *name)
+font_open_by_name (FRAME_PTR f, const char *name)
 {
   Lisp_Object args[2];
   Lisp_Object spec, ret;
@@ -5080,7 +5060,7 @@
    opening), ARG is the argument for the action, and RESULT is the
    result of the action.  */
 void
-font_add_log (char *action, Lisp_Object arg, Lisp_Object result)
+font_add_log (const char *action, Lisp_Object arg, Lisp_Object result)
 {
   Lisp_Object tail, val;
   int i;
@@ -5166,7 +5146,7 @@
    as font_add_log.  */
 
 void
-font_deferred_log (char *action, Lisp_Object arg, Lisp_Object result)
+font_deferred_log (const char *action, Lisp_Object arg, Lisp_Object result)
 {
   if (EQ (Vfont_log, Qt))
     return;
@@ -5175,15 +5155,6 @@
   ASET (Vfont_log_deferred, 2, result);
 }
 
-extern void syms_of_ftfont (void);
-extern void syms_of_xfont (void);
-extern void syms_of_xftfont (void);
-extern void syms_of_ftxfont (void);
-extern void syms_of_bdffont (void);
-extern void syms_of_w32font (void);
-extern void syms_of_atmfont (void);
-extern void syms_of_nsfont (void);
-
 void
 syms_of_font (void)
 {
--- a/src/font.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/font.h	Mon Aug 09 10:51:16 2010 +0900
@@ -239,7 +239,9 @@
   ASET ((font), prop, make_number (font_style_to_value (prop, val, 1)))
 
 extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript;
-extern Lisp_Object QCavgwidth, QCfont_entity, QCfc_unknown_spec;
+extern Lisp_Object QCavgwidth, QCantialias, QCfont_entity, QCfc_unknown_spec;
+extern Lisp_Object Qp;
+
 
 /* Important character set symbols.  */
 extern Lisp_Object Qascii_0;
@@ -781,10 +783,10 @@
 extern void font_done_for_face (FRAME_PTR f, struct face *face);
 
 extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec);
-extern Lisp_Object font_open_by_name (FRAME_PTR f, char *name);
+extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name);
 extern void font_close_object (FRAME_PTR f, Lisp_Object font_object);
 
-extern Lisp_Object font_intern_prop (char *str, int len, int force_symbol);
+extern Lisp_Object font_intern_prop (const char *str, int len, int force_symbol);
 extern void font_update_sort_order (int *order);
 
 extern void font_parse_family_registry (Lisp_Object family,
@@ -793,12 +795,12 @@
 extern Lisp_Object font_spec_from_family_registry (Lisp_Object family,
                                                    Lisp_Object registry);
 
-extern int font_parse_xlfd (char *name, Lisp_Object font);
+extern int font_parse_xlfd (const char *name, Lisp_Object font);
 extern int font_unparse_xlfd (Lisp_Object font, int pixel_size,
                               char *name, int bytes);
-extern int font_parse_fcname (char *name, Lisp_Object font);
+extern int font_parse_fcname (const char *name, Lisp_Object font);
 extern int font_unparse_fcname (Lisp_Object font, int pixel_size,
-                                char *name, int bytes);
+                                const char *name, int bytes);
 extern int font_unparse_gtkname (Lisp_Object, struct frame *, char *, int);
 extern void register_font_driver (struct font_driver *driver, FRAME_PTR f);
 extern void free_font_driver_list (FRAME_PTR f);
@@ -821,29 +823,41 @@
 
 #ifdef HAVE_FREETYPE
 extern struct font_driver ftfont_driver;
+extern void syms_of_ftfont (void);
 #endif	/* HAVE_FREETYPE */
 #ifdef HAVE_X_WINDOWS
 extern struct font_driver xfont_driver;
 extern struct font_driver ftxfont_driver;
+extern void syms_of_xfont (void);
+extern void syms_of_ftxfont (void);
 #ifdef HAVE_XFT
 extern struct font_driver xftfont_driver;
+extern void syms_of_xftfont (void);
 #endif	/* HAVE_XFT */
+#ifdef HAVE_BDFFONT
+extern void syms_of_bdffont (void);
+#endif	/* HAVE_BDFFONT */
 #endif	/* HAVE_X_WINDOWS */
 #ifdef WINDOWSNT
 extern struct font_driver w32font_driver;
 extern struct font_driver uniscribe_font_driver;
+extern void syms_of_w32font (void);
 #endif	/* WINDOWSNT */
 #ifdef HAVE_NS
+extern Lisp_Object Qfontsize;
 extern struct font_driver nsfont_driver;
+extern void syms_of_nsfont (void);
 #endif	/* HAVE_NS */
 
 #ifndef FONT_DEBUG
 #define FONT_DEBUG
 #endif
 
+extern Lisp_Object QCfoundry, QCadstyle, QCregistry;
+
 extern Lisp_Object Vfont_log;
-extern void font_add_log (char *, Lisp_Object, Lisp_Object);
-extern void font_deferred_log (char *, Lisp_Object, Lisp_Object);
+extern void font_add_log (const char *, Lisp_Object, Lisp_Object);
+extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object);
 
 #define FONT_ADD_LOG(ACTION, ARG, RESULT)	\
   do {						\
--- a/src/fontset.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/fontset.c	Mon Aug 09 10:51:16 2010 +0900
@@ -177,7 +177,6 @@
 
 /********** VARIABLES and FUNCTION PROTOTYPES **********/
 
-extern Lisp_Object Qfont;
 static Lisp_Object Qfontset;
 static Lisp_Object Qfontset_info;
 static Lisp_Object Qprepend, Qappend;
@@ -388,8 +387,6 @@
    If PREFERRED_FAMILY is not nil, that family has the higher priority
    if the encoding charsets or languages in font-specs are the same.  */
 
-extern Lisp_Object Fassoc_string (Lisp_Object, Lisp_Object, Lisp_Object);
-
 static void
 reorder_font_vector (Lisp_Object font_group, struct font *font)
 {
@@ -1395,7 +1392,6 @@
   ASET (arg, 4, script_range_list);
 }
 
-extern Lisp_Object QCfamily, QCregistry;
 static void update_auto_fontset_alist (Lisp_Object, Lisp_Object);
 
 
@@ -1457,7 +1453,6 @@
   else if (STRINGP (font_spec))
     {
       Lisp_Object args[2];
-      extern Lisp_Object QCname;
 
       fontname = font_spec;
       args[0] = QCname;
--- a/src/fontset.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/fontset.h	Mon Aug 09 10:51:16 2010 +0900
@@ -44,7 +44,9 @@
 extern int fs_query_fontset (Lisp_Object, int);
 EXFUN (Fquery_fontset, 2);
 extern Lisp_Object list_fontsets (struct frame *, Lisp_Object, int);
+extern Lisp_Object find_font_encoding (Lisp_Object);
 
+extern Lisp_Object Qlatin;
 extern Lisp_Object Vuse_default_ascent;
 extern Lisp_Object Vignore_relative_composition;
 extern Lisp_Object Valternate_fontname_alist;
--- a/src/frame.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/frame.c	Mon Aug 09 10:51:16 2010 +0900
@@ -119,7 +119,7 @@
 Lisp_Object Qtitle, Qname;
 Lisp_Object Qexplicit_name;
 Lisp_Object Qunsplittable;
-Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
+Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
 Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
@@ -198,13 +198,6 @@
 
 Lisp_Object Vframe_list;
 
-extern Lisp_Object Vminibuffer_list;
-extern Lisp_Object get_minibuffer (int);
-extern Lisp_Object Fhandle_switch_frame (Lisp_Object event);
-extern Lisp_Object Fredirect_frame_focus (Lisp_Object frame, Lisp_Object focus_frame);
-extern Lisp_Object x_get_focus_frame (struct frame *frame);
-extern Lisp_Object QCname, Qfont_param;
-
 
 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
        doc: /* Return non-nil if OBJECT is a frame.
@@ -323,6 +316,7 @@
   f->menu_bar_window = Qnil;
   f->tool_bar_window = Qnil;
   f->tool_bar_items = Qnil;
+  f->tool_bar_position = Qtop;
   f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
   f->n_tool_bar_items = 0;
   f->left_fringe_width = f->right_fringe_width = 0;
@@ -1280,8 +1274,6 @@
   return 1;
 }
 
-extern Lisp_Object Qrun_hook_with_args;
-
 /* Delete FRAME.  When FORCE equals Qnoelisp, delete FRAME
   unconditionally.  x_connection_closed and delete_terminal use
   this.  Any other value of FORCE implements the semantics
@@ -2778,11 +2770,11 @@
    that is an index in this table.  */
 
 struct frame_parm_table {
-  char *name;
+  const char *name;
   Lisp_Object *variable;
 };
 
-static struct frame_parm_table frame_parms[] =
+static const struct frame_parm_table frame_parms[] =
 {
   {"auto-raise",		&Qauto_raise},
   {"auto-lower",		&Qauto_lower},
@@ -2816,13 +2808,11 @@
   {"font-backend",		&Qfont_backend},
   {"alpha",			&Qalpha},
   {"sticky",			&Qsticky},
+  {"tool-bar-position",		&Qtool_bar_position},
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern Lisp_Object Qbox;
-extern Lisp_Object Qtop;
-
 /* Calculate fullscreen size.  Return in *TOP_POS and *LEFT_POS the
    wanted positions of the WM window (not Emacs window).
    Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
@@ -3209,6 +3199,7 @@
     XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc);
   store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
   store_in_alist (alistptr, Qparent_id, tem);
+  store_in_alist (alistptr, Qtool_bar_position, f->tool_bar_position);
 }
 
 
@@ -3441,6 +3432,11 @@
 x_set_fringe_width (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
 {
   compute_fringe_widths (f, 1);
+#ifdef HAVE_X_WINDOWS
+  /* Must adjust this so window managers report correct number of columns.  */
+  if (FRAME_X_WINDOW (f) != 0)
+    x_wm_set_size_hint (f, 0, 0);
+#endif
 }
 
 void
@@ -3670,7 +3666,6 @@
   if (STRINGP (Vx_resource_name))
     {
       unsigned char *p = SDATA (Vx_resource_name);
-      int i;
 
       len = SBYTES (Vx_resource_name);
 
@@ -3721,7 +3716,7 @@
 }
 
 
-extern char *x_get_string_resource (XrmDatabase, char *, char *);
+extern char *x_get_string_resource (XrmDatabase, const char *, const char *);
 extern Display_Info *check_x_display_info (Lisp_Object);
 
 
@@ -3823,7 +3818,7 @@
 /* Used when C code wants a resource value.  */
 /* Called from oldXMenu/Create.c.  */
 char *
-x_get_resource_string (char *attribute, char *class)
+x_get_resource_string (const char *attribute, const char *class)
 {
   char *name_key;
   char *class_key;
@@ -3856,7 +3851,8 @@
    and don't let it get stored in any Lisp-visible variables!  */
 
 Lisp_Object
-x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
+	   const char *attribute, const char *class, enum resource_types type)
 {
   register Lisp_Object tem;
 
@@ -3954,7 +3950,9 @@
 }
 
 Lisp_Object
-x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
+		 const char *attribute, const char *class,
+		 enum resource_types type)
 {
   return x_get_arg (FRAME_X_DISPLAY_INFO (f),
 		    alist, param, attribute, class, type);
@@ -3963,7 +3961,10 @@
 /* Like x_frame_get_arg, but also record the value in f->param_alist.  */
 
 Lisp_Object
-x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
+			    Lisp_Object param,
+			    const char *attribute, const char *class,
+			    enum resource_types type)
 {
   Lisp_Object value;
 
@@ -3983,7 +3984,9 @@
    If that is not found either, use the value DEFLT.  */
 
 Lisp_Object
-x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, Lisp_Object deflt, char *xprop, char *xclass, enum resource_types type)
+x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
+		     Lisp_Object deflt, const char *xprop, const char *xclass,
+		     enum resource_types type)
 {
   Lisp_Object tem;
 
--- a/src/frame.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/frame.h	Mon Aug 09 10:51:16 2010 +0900
@@ -191,6 +191,10 @@
   /* Desired and current tool-bar items.  */
   Lisp_Object tool_bar_items;
 
+  /* Where tool bar is, can be left, right, top or bottom.  The native
+     tool bar only supports top.  */
+  Lisp_Object tool_bar_position;
+
   /* Desired and current contents displayed in tool_bar_window.  */
   Lisp_Object desired_tool_bar_string, current_tool_bar_string;
 
@@ -823,6 +827,7 @@
 
 extern Lisp_Object Qframep, Qframe_live_p;
 extern Lisp_Object Qtty, Qtty_type;
+extern Lisp_Object Qtty_color_mode;
 extern Lisp_Object Qterminal, Qterminal_live_p;
 extern Lisp_Object Qnoelisp;
 
@@ -1044,6 +1049,7 @@
 extern Lisp_Object Qbackground_color, Qforeground_color;
 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
 extern Lisp_Object Qinternal_border_width;
+extern Lisp_Object Qtooltip;
 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
 extern Lisp_Object Qmouse_color;
 extern Lisp_Object Qname, Qtitle;
@@ -1063,7 +1069,6 @@
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
 extern Lisp_Object Qminibuffer, Qmodeline;
-extern Lisp_Object Qonly;
 extern Lisp_Object Qx, Qw32, Qmac, Qpc, Qns;
 extern Lisp_Object Qvisible;
 extern Lisp_Object Qdisplay_type;
@@ -1071,9 +1076,11 @@
 
 extern Lisp_Object Qx_resource_name;
 
-extern Lisp_Object Qleft, Qright, Qtop, Qbox;
+extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom;
 extern Lisp_Object Qdisplay;
 
+extern Lisp_Object Qrun_hook_with_args;
+
 #ifdef HAVE_WINDOW_SYSTEM
 
 /* The class of this X application.  */
@@ -1091,6 +1098,7 @@
 
 extern Lisp_Object Vx_resource_name;
 extern Lisp_Object Vx_resource_class;
+extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
 
 
 extern Lisp_Object Qface_set_after_frame_default;
@@ -1134,6 +1142,9 @@
 					   Lisp_Object component,
 					   Lisp_Object subclass);
 
+/* In xmenu.c */
+extern void set_frame_menubar (FRAME_PTR, int, int);
+
 #endif /* HAVE_WINDOW_SYSTEM */
 
 #endif /* not EMACS_FRAME_H */
--- a/src/fringe.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/fringe.c	Mon Aug 09 10:51:16 2010 +0900
@@ -32,10 +32,6 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern Lisp_Object Qfringe;
-extern Lisp_Object Qtop, Qbottom, Qcenter;
-extern Lisp_Object Qup, Qdown, Qleft, Qright;
-
 /* Non-nil means that newline may flow into the right fringe.  */
 
 Lisp_Object Voverflow_newline_into_fringe;
@@ -83,10 +79,8 @@
    must specify physical bitmap symbols.
 */
 
-extern Lisp_Object Qunknown;
 Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow;
 Lisp_Object Qempty_line, Qtop_bottom;
-extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
 Lisp_Object Qhollow_small;
 
 enum fringe_bitmap_align
--- a/src/ftfont.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ftfont.c	Mon Aug 09 10:51:16 2010 +0900
@@ -96,11 +96,11 @@
 static struct
 {
   /* registry name */
-  char *name;
+  const char *name;
   /* characters to distinguish the charset from the others */
   int uniquifier[6];
   /* additional constraint by language */
-  char *lang;
+  const char *lang;
   /* set on demand */
   FcCharSet *fc_charset;
 } fc_charset_table[] =
@@ -144,8 +144,6 @@
     { NULL }
   };
 
-extern Lisp_Object Qc, Qm, Qp, Qd;
-
 /* Dirty hack for handing ADSTYLE property.
 
    Fontconfig (actually the underlying FreeType) gives such ADSTYLE
@@ -548,8 +546,6 @@
     ftfont_filter_properties, /* filter_properties */
   };
 
-extern Lisp_Object QCname;
-
 static Lisp_Object
 ftfont_get_cache (FRAME_PTR f)
 {
@@ -695,12 +691,8 @@
   return spec;
 }
 
-static FcPattern *ftfont_spec_pattern (Lisp_Object, char *,
-                                       struct OpenTypeSpec **,
-                                       char **langname);
-
 static FcPattern *
-ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **otspec, char **langname)
+ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **otspec, const char **langname)
 {
   Lisp_Object tmp, extra;
   FcPattern *pattern = NULL;
@@ -870,7 +862,7 @@
   char otlayout[15];		/* For "otlayout:XXXX" */
   struct OpenTypeSpec *otspec = NULL;
   int spacing = -1;
-  char *langname = NULL;
+  const char *langname = NULL;
 
   if (! fc_initialized)
     {
@@ -1061,7 +1053,7 @@
   FcResult result;
   char otlayout[15];		/* For "otlayout:XXXX" */
   struct OpenTypeSpec *otspec = NULL;
-  char *langname = NULL;
+  const char *langname = NULL;
 
   if (! fc_initialized)
     {
@@ -2333,8 +2325,6 @@
 
 static int m17n_flt_initialized;
 
-extern Lisp_Object QCfamily;
-
 static Lisp_Object
 ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
 		     FT_Face ft_face, OTF *otf, FT_Matrix *matrix)
@@ -2636,7 +2626,7 @@
 
         if (strcmp (ftfont_booleans[i], keystr) == 0)
           {
-            char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
+            const char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
             if (INTEGERP (val)) str = XINT (val) != 0 ? "true" : "false";
             if (str == NULL) str = "true";
 
--- a/src/ftfont.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/ftfont.h	Mon Aug 09 10:51:16 2010 +0900
@@ -36,6 +36,9 @@
 #endif	/* HAVE_M17N_FLT */
 #endif	/* HAVE_LIBOTF */
 
+extern Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object);
+extern FcCharSet *ftfont_get_fc_charset (Lisp_Object);
+
 #endif	/* EMACS_FTFONT_H */
 
 /* arch-tag: cec13d1c-7156-4997-9ebd-e989040c3d78
--- a/src/gtkutil.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/gtkutil.c	Mon Aug 09 10:51:16 2010 +0900
@@ -44,6 +44,9 @@
 #define FRAME_TOTAL_PIXEL_HEIGHT(f) \
   (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))
 
+#define FRAME_TOTAL_PIXEL_WIDTH(f) \
+  (FRAME_PIXEL_WIDTH (f) + FRAME_TOOLBAR_WIDTH (f))
+
 /* Avoid "differ in sign" warnings */
 #define SSDATA(x)  ((char *) SDATA (x))
 
@@ -288,7 +291,6 @@
 {
   Lisp_Object specified_file = Qnil;
   Lisp_Object tail;
-  extern Lisp_Object QCfile;
 
   for (tail = XCDR (image);
        NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
@@ -505,6 +507,172 @@
 
 
 /***********************************************************************
+                              Tooltips
+ ***********************************************************************/
+/* Gtk+ calls this callback when the parent of our tooltip dummy changes.
+   We use that to pop down the tooltip.  This happens if Gtk+ for some
+   reason wants to change or hide the tooltip.  */
+
+#ifdef USE_GTK_TOOLTIP
+
+static void
+hierarchy_ch_cb (GtkWidget *widget,
+                 GtkWidget *previous_toplevel,
+                 gpointer   user_data)
+{
+  FRAME_PTR f = (FRAME_PTR) user_data;
+  struct x_output *x = f->output_data.x;
+  GtkWidget *top = gtk_widget_get_toplevel (x->ttip_lbl);
+  
+  if (! top || ! GTK_IS_WINDOW (top))
+      gtk_widget_hide (previous_toplevel);
+}
+
+/* Callback called when Gtk+ thinks a tooltip should be displayed.
+   We use it to get the tooltip window and the tooltip widget so
+   we can manipulate the ourselves.
+
+   Return FALSE ensures that the tooltip is not shown.  */
+
+static gboolean
+qttip_cb (GtkWidget  *widget,
+          gint        xpos,
+          gint        ypos,
+          gboolean    keyboard_mode,
+          GtkTooltip *tooltip,
+          gpointer    user_data)
+{
+  FRAME_PTR f = (FRAME_PTR) user_data;
+  struct x_output *x = f->output_data.x;
+  if (x->ttip_widget == NULL) 
+    {
+      g_object_set (G_OBJECT (widget), "has-tooltip", FALSE, NULL);
+      x->ttip_widget = tooltip;
+      g_object_ref (G_OBJECT (tooltip));
+      x->ttip_lbl = gtk_label_new ("");
+      g_object_ref (G_OBJECT (x->ttip_lbl));
+      gtk_tooltip_set_custom (tooltip, x->ttip_lbl);
+      x->ttip_window = GTK_WINDOW (gtk_widget_get_toplevel (x->ttip_lbl));
+      /* Realize so we can safely get screen later on.  */
+      gtk_widget_realize (GTK_WIDGET (x->ttip_window));
+      gtk_widget_realize (x->ttip_lbl);
+
+      g_signal_connect (x->ttip_lbl, "hierarchy-changed",
+                        G_CALLBACK (hierarchy_ch_cb), f);
+    }
+  return FALSE;
+}
+
+#endif /* USE_GTK_TOOLTIP */
+
+/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT.
+   Return zero if no system tooltip available, non-zero otherwise.  */
+
+int
+xg_prepare_tooltip (FRAME_PTR f,
+                      Lisp_Object string,
+                      int *width,
+                    int *height)
+{
+#ifndef USE_GTK_TOOLTIP
+  return 0;
+#else
+  struct x_output *x = f->output_data.x;
+  GtkWidget *widget;
+  GdkWindow *gwin;
+  GdkScreen *screen;
+  GtkSettings *settings;
+  gboolean tt_enabled = TRUE;
+  GtkRequisition req;
+  Lisp_Object encoded_string;
+
+  if (!x->ttip_lbl) return 0;
+
+  BLOCK_INPUT;
+  encoded_string = ENCODE_UTF_8 (string);
+  widget = GTK_WIDGET (x->ttip_lbl);
+  gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window));
+  screen = gdk_drawable_get_screen (gwin);
+  settings = gtk_settings_get_for_screen (screen);
+  g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL);
+  if (tt_enabled) 
+    {
+      g_object_set (settings, "gtk-enable-tooltips", FALSE, NULL);
+      /* Record that we disabled it so it can be enabled again.  */
+      g_object_set_data (G_OBJECT (x->ttip_window), "restore-tt",
+                         (gpointer)f);
+    }
+    
+  /* Prevent Gtk+ from hiding tooltip on mouse move and such.  */
+  g_object_set_data (G_OBJECT
+                     (gtk_widget_get_display (GTK_WIDGET (x->ttip_window))),
+                     "gdk-display-current-tooltip", NULL);
+
+  /* Put out dummy widget in so we can get callbacks for unrealize and
+     hierarchy-changed.  */
+  gtk_tooltip_set_custom (x->ttip_widget, widget);
+
+  gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string));
+  gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req);
+  if (width) *width = req.width;
+  if (height) *height = req.height;
+  
+  UNBLOCK_INPUT;
+
+  return 1;
+#endif /* USE_GTK_TOOLTIP */
+}
+
+/* Show the tooltip at ROOT_X and ROOT_Y.
+   xg_prepare_tooltip must have been called before this function.  */
+
+void
+xg_show_tooltip (FRAME_PTR f, int root_x, int root_y)
+{
+#ifdef USE_GTK_TOOLTIP
+  struct x_output *x = f->output_data.x;
+  if (x->ttip_window)
+    {
+      BLOCK_INPUT;
+      gtk_window_move (x->ttip_window, root_x, root_y);
+      gtk_widget_show_all (GTK_WIDGET (x->ttip_window));
+      UNBLOCK_INPUT;
+    }
+#endif
+}
+
+/* Hide tooltip if shown.  Do nothing if not shown.
+   Return non-zero if tip was hidden, non-ero if not (i.e. not using
+   system tooltips).  */
+
+int
+xg_hide_tooltip (FRAME_PTR f)
+{
+  int ret = 0;
+#ifdef USE_GTK_TOOLTIP
+  if (f->output_data.x->ttip_window)
+    {
+      GtkWindow *win = f->output_data.x->ttip_window;
+      BLOCK_INPUT;
+      gtk_widget_hide (GTK_WIDGET (win));
+
+      if (g_object_get_data (G_OBJECT (win), "restore-tt"))
+        {
+          GdkWindow *gwin = gtk_widget_get_window (GTK_WIDGET (win));
+          GdkScreen *screen = gdk_drawable_get_screen (gwin);
+          GtkSettings *settings = gtk_settings_get_for_screen (screen);
+          g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL);
+        }
+      UNBLOCK_INPUT;
+
+      ret = 1;
+    }
+#endif
+  return ret;
+}
+
+
+/***********************************************************************
     General functions for creating widgets, resizing, events, e.t.c.
  ***********************************************************************/
 
@@ -640,7 +808,8 @@
 
   /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it
      after calculating that value.  */
-  pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
+  pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols)
+    + FRAME_TOOLBAR_WIDTH (f);
 
 
   /* Do this before resize, as we don't know yet if we will be resized.  */
@@ -677,14 +846,15 @@
      }
 }
 
-/* Handle height changes (i.e. add/remove menu/toolbar).
+/* Handle height/width changes (i.e. add/remove/move menu/toolbar).
    The policy is to keep the number of editable lines.  */
 
 static void
-xg_height_changed (FRAME_PTR f)
+xg_height_or_width_changed (FRAME_PTR f)
 {
   gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                     FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f));
+                     FRAME_TOTAL_PIXEL_WIDTH (f),
+                     FRAME_TOTAL_PIXEL_HEIGHT (f));
   f->output_data.x->hint_flags = 0;
   x_wm_set_size_hint (f, 0, 0);
 }
@@ -733,7 +903,7 @@
 xg_create_frame_widgets (FRAME_PTR f)
 {
   GtkWidget *wtop;
-  GtkWidget *wvbox;
+  GtkWidget *wvbox, *whbox;
   GtkWidget *wfixed;
   GdkColor bg;
   GtkRcStyle *style;
@@ -749,12 +919,14 @@
   xg_set_screen (wtop, f);
 
   wvbox = gtk_vbox_new (FALSE, 0);
+  whbox = gtk_hbox_new (FALSE, 0);
   wfixed = gtk_fixed_new ();  /* Must have this to place scroll bars  */
 
-  if (! wtop || ! wvbox || ! wfixed)
+  if (! wtop || ! wvbox || ! whbox || ! wfixed)
     {
       if (wtop) gtk_widget_destroy (wtop);
       if (wvbox) gtk_widget_destroy (wvbox);
+      if (whbox) gtk_widget_destroy (whbox);
       if (wfixed) gtk_widget_destroy (wfixed);
 
       UNBLOCK_INPUT;
@@ -775,11 +947,13 @@
   FRAME_GTK_OUTER_WIDGET (f) = wtop;
   FRAME_GTK_WIDGET (f) = wfixed;
   f->output_data.x->vbox_widget = wvbox;
+  f->output_data.x->hbox_widget = whbox;
 
   gtk_widget_set_has_window (wfixed, TRUE);
 
   gtk_container_add (GTK_CONTAINER (wtop), wvbox);
-  gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (wvbox), whbox, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (whbox), wfixed, TRUE, TRUE, 0);
 
   if (FRAME_EXTERNAL_TOOL_BAR (f))
     update_frame_tool_bar (f);
@@ -838,17 +1012,38 @@
   style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>");
   gtk_widget_modify_style (wfixed, style);
 
-  /* GTK does not set any border, and they look bad with GTK.  */
-  /* That they look bad is no excuse for imposing this here.  --Stef
-     It should be done by providing the proper default in Fx_create_Frame.
-  f->border_width = 0;
-  f->internal_border_width = 0; */
+#ifdef USE_GTK_TOOLTIP
+  /* Steal a tool tip window we can move ourselves.  */
+  f->output_data.x->ttip_widget = 0;
+  f->output_data.x->ttip_lbl = 0;
+  f->output_data.x->ttip_window = 0;
+  gtk_widget_set_tooltip_text (wtop, "Dummy text");  
+  g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f);
+#endif
 
   UNBLOCK_INPUT;
 
   return 1;
 }
 
+void
+xg_free_frame_widgets (FRAME_PTR f)
+{
+  if (FRAME_GTK_OUTER_WIDGET (f))
+    {
+      struct x_output *x = f->output_data.x;
+      gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
+      FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
+      FRAME_GTK_OUTER_WIDGET (f) = 0;
+#ifdef USE_GTK_TOOLTIP
+      if (x->ttip_lbl)
+        gtk_widget_destroy (x->ttip_lbl);
+      if (x->ttip_widget)
+        g_object_unref (G_OBJECT (x->ttip_widget));
+#endif
+    }
+}
+
 /* Set the normal size hints for the window manager, for frame F.
    FLAGS is the flags word to use--or 0 meaning preserve the flags
    that the window now has.
@@ -889,7 +1084,7 @@
   size_hints.height_inc = FRAME_LINE_HEIGHT (f);
 
   hint_flags |= GDK_HINT_BASE_SIZE;
-  base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
+  base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0) + FRAME_TOOLBAR_WIDTH (f);
   base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0)
     + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
 
@@ -2175,7 +2370,7 @@
    Returns the widget created.  */
 
 GtkWidget *
-xg_create_widget (char *type, char *name, FRAME_PTR f, widget_value *val,
+xg_create_widget (const char *type, const char *name, FRAME_PTR f, widget_value *val,
                   GCallback select_cb, GCallback deactivate_cb,
 		  GCallback highlight_cb)
 {
@@ -2828,7 +3023,7 @@
   gtk_widget_show_all (x->menubar_widget);
   gtk_widget_size_request (x->menubar_widget, &req);
   FRAME_MENUBAR_HEIGHT (f) = req.height;
-  xg_height_changed (f);
+  xg_height_or_width_changed (f);
   UNBLOCK_INPUT;
 
   return 1;
@@ -2851,7 +3046,7 @@
           the container.  */
       x->menubar_widget = 0;
       FRAME_MENUBAR_HEIGHT (f) = 0;
-      xg_height_changed (f);
+      xg_height_or_width_changed (f);
       UNBLOCK_INPUT;
     }
 }
@@ -3038,7 +3233,7 @@
                       struct scroll_bar *bar,
                       GCallback scroll_callback,
                       GCallback end_callback,
-                      char *scroll_bar_name)
+                      const char *scroll_bar_name)
 {
   GtkWidget *wscroll;
   GtkWidget *webox;
@@ -3548,13 +3743,21 @@
 
   if (f)
     {
+      GtkRequisition req, req2;
       FRAME_X_OUTPUT (f)->toolbar_detached = 1;
-
-      /* When detaching a tool bar, not everything dissapear.  There are
-         a few pixels left that are used to drop the tool bar back into
-         place.  */
-      FRAME_TOOLBAR_HEIGHT (f) = 4;
-      xg_height_changed (f);
+      gtk_widget_size_request (GTK_WIDGET (wbox), &req);
+      gtk_widget_size_request (w, &req2);
+      req.width -= req2.width;
+      req.height -= req2.height;
+      if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
+        FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height;
+      else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0)
+        FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height;
+      else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0)
+        FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width;
+      else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0)
+        FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width;
+      xg_height_or_width_changed (f);
     }
 }
 
@@ -3575,13 +3778,21 @@
 
   if (f)
     {
-      GtkRequisition req;
-
+      GtkRequisition req, req2;
       FRAME_X_OUTPUT (f)->toolbar_detached = 0;
-
-      gtk_widget_size_request (w, &req);
-      FRAME_TOOLBAR_HEIGHT (f) = req.height;
-      xg_height_changed (f);
+      gtk_widget_size_request (GTK_WIDGET (wbox), &req);
+      gtk_widget_size_request (w, &req2);
+      req.width += req2.width;
+      req.height += req2.height;
+      if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
+        FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height;
+      else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0)
+        FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height;
+      else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0)
+        FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width;
+      else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0)
+        FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width;
+      xg_height_or_width_changed (f);
     }
 }
 
@@ -3656,34 +3867,6 @@
   return FALSE;
 }
 
-/* Attach a tool bar to frame F.  */
-
-static void
-xg_pack_tool_bar (FRAME_PTR f)
-{
-  struct x_output *x = f->output_data.x;
-  int vbox_pos = x->menubar_widget ? 1 : 0;
-
-  x->handlebox_widget = gtk_handle_box_new ();
-  g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached",
-                    G_CALLBACK (xg_tool_bar_detach_callback), f);
-  g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached",
-                    G_CALLBACK (xg_tool_bar_attach_callback), f);
-
-  gtk_container_add (GTK_CONTAINER (x->handlebox_widget),
-                     x->toolbar_widget);
-
-  gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget,
-                      FALSE, FALSE, 0);
-
-  gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget,
-                         vbox_pos);
-
-  gtk_widget_show (x->toolbar_widget);
-  gtk_widget_show (x->handlebox_widget);
-}
-
-/* Create a tool bar for frame F.  */
 #ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION
 #define toolbar_set_orientation(w, o) \
   gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o)
@@ -3692,6 +3875,56 @@
   gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o)
 #endif
 
+/* Attach a tool bar to frame F.  */
+
+static void
+xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
+{
+  struct x_output *x = f->output_data.x;
+  int into_hbox = EQ (pos, Qleft) || EQ (pos, Qright);
+
+  toolbar_set_orientation (x->toolbar_widget,
+                           into_hbox
+                           ? GTK_ORIENTATION_VERTICAL
+                           : GTK_ORIENTATION_HORIZONTAL);
+  if (!x->handlebox_widget)
+    {
+      x->handlebox_widget = gtk_handle_box_new ();
+      g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached",
+                        G_CALLBACK (xg_tool_bar_detach_callback), f);
+      g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached",
+                        G_CALLBACK (xg_tool_bar_attach_callback), f);
+      gtk_container_add (GTK_CONTAINER (x->handlebox_widget),
+                         x->toolbar_widget);
+    }
+
+  if (into_hbox) 
+    {
+      gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget,
+                          FALSE, FALSE, 0);
+
+      if (EQ (pos, Qleft))
+        gtk_box_reorder_child (GTK_BOX (x->hbox_widget),
+                               x->handlebox_widget,
+                               0);
+      x->toolbar_in_hbox = 1;
+    }
+  else
+    {
+      int vbox_pos = x->menubar_widget ? 1 : 0;
+      gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget,
+                          FALSE, FALSE, 0);
+
+      if (EQ (pos, Qtop))
+        gtk_box_reorder_child (GTK_BOX (x->vbox_widget),
+                               x->handlebox_widget,
+                               vbox_pos);
+      x->toolbar_in_hbox = 0;
+    }
+}
+
+/* Create a tool bar for frame F.  */
+
 static void
 xg_create_tool_bar (FRAME_PTR f)
 {
@@ -3703,8 +3936,7 @@
   gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar");
 
   gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
-  toolbar_set_orientation (x->toolbar_widget,
-                               GTK_ORIENTATION_HORIZONTAL);
+  toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
 }
 
 
@@ -3749,15 +3981,23 @@
                    int i)
 {
   GtkToolItem *ti = gtk_tool_item_new ();
-  GtkWidget *vb = EQ (Vtool_bar_style, Qboth_horiz)
+  Lisp_Object style = Ftool_bar_get_system_style ();
+  int both_horiz = EQ (style, Qboth_horiz);
+  int text_image = EQ (style, Qtext_image_horiz);
+  
+  GtkWidget *vb = both_horiz || text_image
     ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
   GtkWidget *wb = gtk_button_new ();
   GtkWidget *weventbox = gtk_event_box_new ();
 
-  if (wimage)
+  if (wimage && ! text_image)
     gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
 
   gtk_box_pack_start (GTK_BOX (vb), gtk_label_new (label), TRUE, TRUE, 0);
+
+  if (wimage && text_image)
+    gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
+
   gtk_button_set_focus_on_click (GTK_BUTTON (wb), FALSE);
   gtk_button_set_relief (GTK_BUTTON (wb), GTK_RELIEF_NONE);
   gtk_container_add (GTK_CONTAINER (wb), vb);
@@ -3819,11 +4059,12 @@
 xg_show_toolbar_item (GtkToolItem *ti)
 {
   Lisp_Object style = Ftool_bar_get_system_style ();
-
-  int show_label = EQ (style, Qboth)
-    || EQ (style, Qboth_horiz) || EQ (style, Qtext);
+  int both_horiz = EQ (style, Qboth_horiz);
+  int text_image = EQ (style, Qtext_image_horiz);
+
+  int horiz = both_horiz || text_image;
+  int show_label = ! EQ (style, Qimage);
   int show_image = ! EQ (style, Qtext);
-  int horiz = EQ (style, Qboth_horiz);
 
   GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti));
   GtkWidget *wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
@@ -3836,15 +4077,21 @@
     new_box = gtk_hbox_new (FALSE, 0);
   else if (GTK_IS_HBOX (vb) && !horiz && show_label && show_image)
     new_box = gtk_vbox_new (FALSE, 0);
-  if (new_box)
+
+  if (!new_box && horiz)
+      gtk_box_reorder_child (GTK_BOX (vb), wlbl, text_image ? 0 : 1);
+  else if (new_box)
     {
       g_object_ref (G_OBJECT (wimage));
       g_object_ref (G_OBJECT (wlbl));
       gtk_container_remove (GTK_CONTAINER (vb), wimage);
       gtk_container_remove (GTK_CONTAINER (vb), wlbl);
       gtk_widget_destroy (GTK_WIDGET (vb));
-      gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
+      if (! text_image)
+        gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
       gtk_box_pack_start (GTK_BOX (new_box), wlbl, TRUE, TRUE, 0);
+      if (text_image)
+        gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
       gtk_container_add (GTK_CONTAINER (wbutton), new_box);
       g_object_unref (G_OBJECT (wimage));
       g_object_unref (G_OBJECT (wlbl));
@@ -3861,16 +4108,57 @@
   gtk_widget_show (GTK_WIDGET (ti));
 }
 
+static int
+xg_update_tool_bar_sizes (FRAME_PTR f)
+{
+  struct x_output *x = f->output_data.x;
+  GtkRequisition req;
+  int nl = 0, nr = 0, nt = 0, nb = 0;
+
+  gtk_widget_size_request (GTK_WIDGET (x->handlebox_widget), &req);
+  if (x->toolbar_in_hbox)
+    {
+      int pos;
+      gtk_container_child_get (GTK_CONTAINER (x->hbox_widget),
+                               x->handlebox_widget,
+                               "position", &pos, NULL);
+      if (pos == 0) nl = req.width;
+      else nr = req.width;
+    }
+  else
+    {
+      int pos;
+      gtk_container_child_get (GTK_CONTAINER (x->vbox_widget),
+                               x->handlebox_widget,
+                               "position", &pos, NULL);
+      if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height;
+      else nb = req.height;
+    }
+  
+  if (nl != FRAME_TOOLBAR_LEFT_WIDTH (f)
+      || nr != FRAME_TOOLBAR_RIGHT_WIDTH (f)
+      || nt != FRAME_TOOLBAR_TOP_HEIGHT (f)
+      || nb != FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
+    {
+      FRAME_TOOLBAR_RIGHT_WIDTH (f) = FRAME_TOOLBAR_LEFT_WIDTH (f)
+        = FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
+      FRAME_TOOLBAR_LEFT_WIDTH (f) = nl;
+      FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr;
+      FRAME_TOOLBAR_TOP_HEIGHT (f) = nt;
+      FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb;
+      return 1;
+    }
+
+  return 0;
+}
+
 
 /* Update the tool bar for frame F.  Add new buttons and remove old.  */
 
-extern Lisp_Object Qx_gtk_map_stock;
-
 void
 update_frame_tool_bar (FRAME_PTR f)
 {
   int i;
-  GtkRequisition old_req, new_req;
   struct x_output *x = f->output_data.x;
   int hmargin = 0, vmargin = 0;
   GtkToolbar *wtoolbar;
@@ -3911,7 +4199,6 @@
     xg_create_tool_bar (f);
 
   wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
-  gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req);
   dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar));
   
   for (i = 0; i < f->n_tool_bar_items; ++i)
@@ -4129,18 +4416,16 @@
       if (ti) gtk_widget_hide_all (GTK_WIDGET (ti));
     } while (ti != NULL);
 
-  new_req.height = 0;
-  if (pack_tool_bar && f->n_tool_bar_items != 0)
-    xg_pack_tool_bar (f);
-  
-
-  gtk_widget_size_request (GTK_WIDGET (wtoolbar), &new_req);
-  if (old_req.height != new_req.height
-      && ! FRAME_X_OUTPUT (f)->toolbar_detached)
+  if (f->n_tool_bar_items != 0)
     {
-      FRAME_TOOLBAR_HEIGHT (f) = new_req.height;
-      xg_height_changed (f);
+      if (pack_tool_bar)
+        xg_pack_tool_bar (f, f->tool_bar_position);
+      gtk_widget_show (x->toolbar_widget);
+      gtk_widget_show (x->handlebox_widget);
+      if (xg_update_tool_bar_sizes (f))
+        xg_height_or_width_changed (f);
     }
+
   UNBLOCK_INPUT;
 }
 
@@ -4158,21 +4443,54 @@
       BLOCK_INPUT;
       /* We may have created the toolbar_widget in xg_create_tool_bar, but
          not the x->handlebox_widget which is created in xg_pack_tool_bar.  */
-      if (is_packed)
-        gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
-                              x->handlebox_widget);
+      if (is_packed) 
+        {
+          if (x->toolbar_in_hbox)
+            gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
+                                  x->handlebox_widget);
+          else
+            gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
+                                  x->handlebox_widget);
+        }
       else
         gtk_widget_destroy (x->toolbar_widget);
 
       x->toolbar_widget = 0;
       x->handlebox_widget = 0;
-      FRAME_TOOLBAR_HEIGHT (f) = 0;
-      xg_height_changed (f);
+      FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
+      FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0;
+
+      xg_height_or_width_changed (f);
 
       UNBLOCK_INPUT;
     }
 }
 
+int
+xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos)
+{
+  struct x_output *x = f->output_data.x;
+
+  if (! x->toolbar_widget || ! x->handlebox_widget)
+    return 1;
+
+  BLOCK_INPUT;
+  g_object_ref (x->handlebox_widget);
+  if (x->toolbar_in_hbox)
+    gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
+                          x->handlebox_widget);
+  else
+    gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
+                          x->handlebox_widget);
+  xg_pack_tool_bar (f, pos);
+  g_object_unref (x->handlebox_widget);
+  if (xg_update_tool_bar_sizes (f))
+    xg_height_or_width_changed (f);
+
+  UNBLOCK_INPUT;
+  return 1;
+}
+
 
 
 /***********************************************************************
--- a/src/gtkutil.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/gtkutil.h	Mon Aug 09 10:51:16 2010 +0900
@@ -135,8 +135,8 @@
 
 extern char *xg_get_font_name (FRAME_PTR f, char *);
 
-extern GtkWidget *xg_create_widget (char *type,
-                                    char *name,
+extern GtkWidget *xg_create_widget (const char *type,
+                                    const char *name,
                                     FRAME_PTR f,
                                     widget_value *val,
                                     GCallback select_cb,
@@ -163,7 +163,7 @@
                                   struct scroll_bar *bar,
                                   GCallback scroll_callback,
                                   GCallback end_callback,
-                                  char *scroll_bar_name);
+                                  const char *scroll_bar_name);
 extern void xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id);
 
 extern void xg_update_scrollbar_pos (FRAME_PTR f,
@@ -181,6 +181,7 @@
 
 extern void update_frame_tool_bar (FRAME_PTR f);
 extern void free_frame_tool_bar (FRAME_PTR f);
+extern int xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos);
 
 extern void xg_frame_resized (FRAME_PTR f,
                               int pixelwidth,
@@ -193,6 +194,7 @@
 extern GdkCursor * xg_create_default_cursor (Display *dpy);
 
 extern int xg_create_frame_widgets (FRAME_PTR f);
+extern void xg_free_frame_widgets (FRAME_PTR f);
 extern void x_wm_set_size_hint (FRAME_PTR f,
                                 long flags,
                                 int user_position);
@@ -202,6 +204,14 @@
                                Pixmap icon_pixmap,
                                Pixmap icon_mask);
 
+extern int xg_prepare_tooltip (FRAME_PTR f,
+                               Lisp_Object string,
+                               int *width,
+                               int *height);
+extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y);
+extern int xg_hide_tooltip (FRAME_PTR f);
+
+
 /* Mark all callback data that are Lisp_object:s during GC.  */
 extern void xg_mark_data (void);
 
--- a/src/image.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/image.c	Mon Aug 09 10:51:16 2010 +0900
@@ -126,6 +126,9 @@
 
 Lisp_Object Vx_bitmap_file_path;
 
+/* The symbol `postscript' identifying images of this type.  */
+
+Lisp_Object Qpostscript;
 
 static void x_disable_image (struct frame *, struct image *);
 static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
@@ -578,9 +581,6 @@
 
 /* Keywords.  */
 
-extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
-extern Lisp_Object QCdata, QCtype;
-extern Lisp_Object Qcenter;
 Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data;
 Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
 Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask;
@@ -598,7 +598,7 @@
 
 static Lisp_Object define_image_type (struct image_type *type, int loaded);
 static struct image_type *lookup_image_type (Lisp_Object symbol);
-static void image_error (char *format, Lisp_Object, Lisp_Object);
+static void image_error (const char *format, Lisp_Object, Lisp_Object);
 static void x_laplace (struct frame *, struct image *);
 static void x_emboss (struct frame *, struct image *);
 static int x_build_heuristic_mask (struct frame *, struct image *,
@@ -699,7 +699,7 @@
    therefore simply displays a message.  */
 
 static void
-image_error (char *format, Lisp_Object arg1, Lisp_Object arg2)
+image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
 {
   add_to_log (format, arg1, arg2);
 }
@@ -731,7 +731,7 @@
 struct image_keyword
 {
   /* Name of keyword.  */
-  char *name;
+  const char *name;
 
   /* The type of value allowed.  */
   enum image_value_type type;
@@ -1759,8 +1759,6 @@
   /* If not found, create a new image and cache it.  */
   if (img == NULL)
     {
-      extern Lisp_Object Qpostscript;
-
       BLOCK_INPUT;
       img = make_image (spec, hash);
       cache_image (f, img);
@@ -3661,9 +3659,10 @@
    length of the corresponding token, respectively.  */
 
 static int
-xpm_scan (s, end, beg, len)
-     const unsigned char **s, *end, **beg;
-     int *len;
+xpm_scan (const unsigned char **s,
+          const unsigned char *end,
+          const unsigned char **beg,
+          int *len)
 {
   int c;
 
@@ -3727,9 +3726,13 @@
    hash table is used.  */
 
 static Lisp_Object
-xpm_make_color_table_v (put_func, get_func)
-     void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
-     Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
+xpm_make_color_table_v (void (**put_func) (Lisp_Object,
+                                           const unsigned char *,
+                                           int,
+                                           Lisp_Object),
+                        Lisp_Object (**get_func) (Lisp_Object,
+                                                  const unsigned char *,
+                                                  int))
 {
   *put_func = xpm_put_color_table_v;
   *get_func = xpm_get_color_table_v;
@@ -3737,28 +3740,30 @@
 }
 
 static void
-xpm_put_color_table_v (color_table, chars_start, chars_len, color)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
-     Lisp_Object color;
+xpm_put_color_table_v (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len,
+                       Lisp_Object color)
 {
   XVECTOR (color_table)->contents[*chars_start] = color;
 }
 
 static Lisp_Object
-xpm_get_color_table_v (color_table, chars_start, chars_len)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
+xpm_get_color_table_v (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len)
 {
   return XVECTOR (color_table)->contents[*chars_start];
 }
 
 static Lisp_Object
-xpm_make_color_table_h (put_func, get_func)
-     void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
-     Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
+xpm_make_color_table_h (void (**put_func) (Lisp_Object,
+                                           const unsigned char *,
+                                           int,
+                                           Lisp_Object),
+                        Lisp_Object (**get_func) (Lisp_Object,
+                                                  const unsigned char *,
+                                                  int))
 {
   *put_func = xpm_put_color_table_h;
   *get_func = xpm_get_color_table_h;
@@ -3769,11 +3774,10 @@
 }
 
 static void
-xpm_put_color_table_h (color_table, chars_start, chars_len, color)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
-     Lisp_Object color;
+xpm_put_color_table_h (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len,
+                       Lisp_Object color)
 {
   struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
   unsigned hash_code;
@@ -3784,10 +3788,9 @@
 }
 
 static Lisp_Object
-xpm_get_color_table_h (color_table, chars_start, chars_len)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
+xpm_get_color_table_h (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len)
 {
   struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
   int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
@@ -3807,8 +3810,7 @@
 static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
 
 static int
-xpm_str_to_color_key (s)
-     const char *s;
+xpm_str_to_color_key (const char *s)
 {
   int i;
 
@@ -3821,10 +3823,10 @@
 }
 
 static int
-xpm_load_image (f, img, contents, end)
-     struct frame *f;
-     struct image *img;
-     const unsigned char *contents, *end;
+xpm_load_image (struct frame *f,
+                struct image *img,
+                const unsigned char *contents,
+                const unsigned char *end)
 {
   const unsigned char *s = contents, *beg, *str;
   unsigned char buffer[BUFSIZ];
@@ -4056,9 +4058,8 @@
 }
 
 static int
-xpm_load (f, img)
-     struct frame *f;
-     struct image *img;
+xpm_load (struct frame *f,
+          struct image *img)
 {
   int success_p = 0;
   Lisp_Object file_name;
@@ -7742,10 +7743,6 @@
 #define HAVE_GHOSTSCRIPT 1
 #endif /* HAVE_X_WINDOWS */
 
-/* The symbol `postscript' identifying images of this type.  */
-
-Lisp_Object Qpostscript;
-
 #ifdef HAVE_GHOSTSCRIPT
 
 static int gs_image_p (Lisp_Object object);
@@ -8133,8 +8130,6 @@
 void
 syms_of_image (void)
 {
-  extern Lisp_Object Qrisky_local_variable;   /* Syms_of_xdisp has already run.  */
-
   /* Initialize this only once, since that's what we do with Vimage_types
      and they are supposed to be in sync.  Initializing here gives correct
      operation on GNU/Linux of calling dump-emacs after loading some images.  */
--- a/src/indent.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/indent.c	Mon Aug 09 10:51:16 2010 +0900
@@ -469,7 +469,6 @@
   return col;
 }
 
-extern Lisp_Object Qspace, QCwidth, QCalign_to;
 
 /* Check the presence of a display property and compute its width.
    If a property was found and its width was found as well, return
--- a/src/insdel.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/insdel.c	Mon Aug 09 10:51:16 2010 +0900
@@ -74,6 +74,8 @@
 
 Lisp_Object Qinhibit_modification_hooks;
 
+extern Lisp_Object Vselect_active_regions, Vsaved_region_selection;
+
 
 /* Check all markers in the current buffer, looking for something invalid.  */
 
@@ -2047,6 +2049,20 @@
 	   base_buffer->filename);
 #endif /* not CLASH_DETECTION */
 
+  /* If `select-active-regions' is non-nil, save the region text.  */
+  if (!NILP (Vselect_active_regions)
+      && !NILP (current_buffer->mark_active)
+      && !NILP (Vtransient_mark_mode)
+      && NILP (Vsaved_region_selection))
+    {
+      int b = XINT (Fmarker_position (current_buffer->mark));
+      int e = XINT (make_number (PT));
+      if (b < e)
+	Vsaved_region_selection = make_buffer_string (b, e, 0);
+      else if (b > e)
+	Vsaved_region_selection = make_buffer_string (e, b, 0);
+    }
+
   signal_before_change (start, end, preserve_ptr);
 
   if (current_buffer->newline_cache)
--- a/src/keyboard.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/keyboard.c	Mon Aug 09 10:51:16 2010 +0900
@@ -246,9 +246,6 @@
    ASCII character.  */
 int quit_char;
 
-extern Lisp_Object current_global_map;
-extern int minibuf_level;
-
 /* If non-nil, this is a map that overrides all other local maps.  */
 Lisp_Object Voverriding_local_map;
 
@@ -364,6 +361,15 @@
    X Windows wants this for selection ownership.  */
 unsigned long last_event_timestamp;
 
+/* If non-nil, active regions automatically become the window selection.  */
+Lisp_Object Vselect_active_regions;
+
+/* The text in the active region prior to modifying the buffer.
+   Used by the `select-active-regions' feature.  */
+Lisp_Object Vsaved_region_selection;
+
+Lisp_Object Qx_set_selection, QPRIMARY, Qlazy;
+
 Lisp_Object Qself_insert_command;
 Lisp_Object Qforward_char;
 Lisp_Object Qbackward_char;
@@ -468,8 +474,6 @@
 Lisp_Object Qselect_window;
 Lisp_Object Qhelp_echo;
 
-extern Lisp_Object Qremap;
-
 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 Lisp_Object Qmouse_fixup_help_message;
 #endif
@@ -497,7 +501,6 @@
 Lisp_Object Qmenu_enable;
 Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence;
 Lisp_Object QCbutton, QCtoggle, QCradio, QClabel;
-extern Lisp_Object Qmenu_item;
 
 /* An event header symbol HEAD may have a property named
    Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
@@ -517,17 +520,12 @@
 Lisp_Object Qvertical_line;
 Lisp_Object Qvertical_scroll_bar;
 Lisp_Object Qmenu_bar;
-extern Lisp_Object Qleft_margin, Qright_margin;
-extern Lisp_Object Qleft_fringe, Qright_fringe;
-extern Lisp_Object QCmap;
 
 Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void);
 Lisp_Object Fthis_command_keys (void);
 Lisp_Object Qextended_command_history;
 EMACS_TIME timer_check (int do_it_now);
 
-extern Lisp_Object Vhistory_length, Vtranslation_table_for_input;
-
 static void record_menu_key (Lisp_Object c);
 static int echo_length (void);
 
@@ -542,8 +540,6 @@
 /* Incremented whenever a timer is run.  */
 int timers_run;
 
-extern Lisp_Object Vprint_level, Vprint_length;
-
 /* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
    happens.  */
 EMACS_TIME *input_available_clear_time;
@@ -626,7 +622,7 @@
                                         unsigned long);
 #endif
 static Lisp_Object modify_event_symbol (int, unsigned, Lisp_Object,
-                                        Lisp_Object, char **,
+                                        Lisp_Object, const char **,
                                         Lisp_Object *, unsigned);
 static Lisp_Object make_lispy_switch_frame (Lisp_Object);
 static void save_getcjmp (jmp_buf);
@@ -650,7 +646,6 @@
    to support it.  */
 static int cannot_suspend;
 
-extern Lisp_Object Qidentity, Qonly;
 
 /* Install the string STR as the beginning of the string of echoing,
    so that it serves as a prompt for the next character.
@@ -1380,7 +1375,7 @@
   while (INPUT_BLOCKED_P)
     UNBLOCK_INPUT;
 
-  return Fthrow (Qtop_level, Qnil);
+  Fthrow (Qtop_level, Qnil);
 }
 
 DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "",
@@ -1391,7 +1386,6 @@
     Fthrow (Qexit, Qnil);
 
   error ("No recursive edit is in progress");
-  return Qnil;
 }
 
 DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, 0, "",
@@ -1402,7 +1396,6 @@
     Fthrow (Qexit, Qt);
 
   error ("No recursive edit is in progress");
-  return Qnil;
 }
 
 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -1797,11 +1790,29 @@
 	    Vtransient_mark_mode = Qnil;
 	  else if (EQ (Vtransient_mark_mode, Qonly))
 	    Vtransient_mark_mode = Qidentity;
+	  else if (EQ (Vselect_active_regions, Qlazy)
+		   ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+		   : (!NILP (Vselect_active_regions)
+		      && !NILP (Vtransient_mark_mode)))
+	    {
+	      /* Set window selection.  If `select-active-regions' is
+		 `lazy', only do it for temporarily active regions. */
+	      int beg = XINT (Fmarker_position (current_buffer->mark));
+	      int end = XINT (make_number (PT));
+	      if (beg < end)
+		call2 (Qx_set_selection, QPRIMARY,
+		       make_buffer_string (beg, end, 0));
+	      else if (beg > end)
+		call2 (Qx_set_selection, QPRIMARY,
+		       make_buffer_string (end, beg, 0));
+	    }
 
 	  if (!NILP (Vdeactivate_mark))
 	    call0 (Qdeactivate_mark);
 	  else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
 	    call1 (Vrun_hooks, intern ("activate-mark-hook"));
+
+	  Vsaved_region_selection = Qnil;
 	}
 
     finalize:
@@ -1838,16 +1849,11 @@
     }
 }
 
-extern Lisp_Object Qcomposition, Qdisplay;
-
 /* Adjust point to a boundary of a region that has such a property
    that should be treated intangible.  For the moment, we check
    `composition', `display' and `invisible' properties.
    LAST_PT is the last position of point.  */
 
-extern Lisp_Object Qafter_string, Qbefore_string;
-extern Lisp_Object get_pos_property (Lisp_Object, Lisp_Object, Lisp_Object);
-
 static void
 adjust_point_for_property (int last_pt, int modified)
 {
@@ -4374,8 +4380,6 @@
    ...).  Each element has the form (FUN . ARGS).  */
 Lisp_Object pending_funcalls;
 
-extern Lisp_Object Qapply;
-
 /* Check whether a timer has fired.  To prevent larger problems we simply
    disregard elements that are not proper timers.  Do not make a circular
    timer list for the time being.
@@ -4747,7 +4751,7 @@
 /* This is a list of Lisp names for special "accent" characters.
    It parallels lispy_accent_codes.  */
 
-static char *lispy_accent_keys[] =
+static const char *lispy_accent_keys[] =
 {
   "dead-circumflex",
   "dead-grave",
@@ -4774,7 +4778,7 @@
 #ifdef HAVE_NTGUI
 #define FUNCTION_KEY_OFFSET 0x0
 
-char *lispy_function_keys[] =
+char const *lispy_function_keys[] =
   {
     0,                /* 0                      */
 
@@ -4968,7 +4972,7 @@
 
 /* Some of these duplicate the "Media keys" on newer keyboards,
    but they are delivered to the application in a different way.  */
-static char *lispy_multimedia_keys[] =
+static const char *lispy_multimedia_keys[] =
   {
     0,
     "browser-back",
@@ -5032,7 +5036,7 @@
    the XK_kana_A case below.  */
 #if 0
 #ifdef XK_kana_A
-static char *lispy_kana_keys[] =
+static const char *lispy_kana_keys[] =
   {
     /* X Keysym value */
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/* 0x400 .. 0x40f */
@@ -5071,7 +5075,7 @@
 
 /* You'll notice that this table is arranged to be conveniently
    indexed by X Windows keysym values.  */
-static char *lispy_function_keys[] =
+static const char *lispy_function_keys[] =
   {
     /* X Keysym value */
 
@@ -5157,7 +5161,7 @@
 /* ISO 9995 Function and Modifier Keys; the first byte is 0xFE.  */
 #define ISO_FUNCTION_KEY_OFFSET 0xfe00
 
-static char *iso_lispy_function_keys[] =
+static const char *iso_lispy_function_keys[] =
   {
     0, 0, 0, 0, 0, 0, 0, 0,	/* 0xfe00 */
     0, 0, 0, 0, 0, 0, 0, 0,	/* 0xfe08 */
@@ -5180,14 +5184,14 @@
 
 Lisp_Object Vlispy_mouse_stem;
 
-static char *lispy_wheel_names[] =
+static const char *lispy_wheel_names[] =
 {
   "wheel-up", "wheel-down", "wheel-left", "wheel-right"
 };
 
 /* drag-n-drop events are generated when a set of selected files are
    dragged from another application and dropped onto an Emacs window.  */
-static char *lispy_drag_n_drop_names[] =
+static const char *lispy_drag_n_drop_names[] =
 {
   "drag-n-drop"
 };
@@ -5198,7 +5202,7 @@
 Lisp_Object Qtop, Qratio;
 
 /* An array of scroll bar parts, indexed by an enum scroll_bar_part value.  */
-Lisp_Object *scroll_bar_parts[] = {
+const Lisp_Object *scroll_bar_parts[] = {
   &Qabove_handle, &Qhandle, &Qbelow_handle,
   &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio
 };
@@ -6565,7 +6569,7 @@
 
 static Lisp_Object
 modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
-		     Lisp_Object name_alist_or_stem, char **name_table,
+		     Lisp_Object name_alist_or_stem, const char **name_table,
 		     Lisp_Object *symbol_table, unsigned int table_size)
 {
   Lisp_Object value;
@@ -8018,9 +8022,8 @@
 
 static int ntool_bar_items;
 
-/* The symbols `tool-bar', `:image' and `:rtl'.  */
-
-extern Lisp_Object Qtool_bar;
+/* The symbols `:image' and `:rtl'.  */
+
 Lisp_Object QCimage;
 Lisp_Object Qrtl;
 
@@ -8118,7 +8121,6 @@
 process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void *args)
 {
   int i;
-  extern Lisp_Object Qundefined;
   struct gcpro gcpro1, gcpro2;
 
   /* Protect KEY and DEF from GC because parse_tool_bar_item may call
@@ -10245,7 +10247,6 @@
   register Lisp_Object final;
   register Lisp_Object tem;
   Lisp_Object prefixarg;
-  extern int debug_on_next_call;
 
   debug_on_next_call = 0;
 
@@ -11708,6 +11709,13 @@
   Qinput_method_function = intern_c_string ("input-method-function");
   staticpro (&Qinput_method_function);
 
+  Qx_set_selection = intern_c_string ("x-set-selection");
+  staticpro (&Qx_set_selection);
+  QPRIMARY = intern_c_string ("PRIMARY");
+  staticpro (&QPRIMARY);
+  Qlazy = intern_c_string ("lazy");
+  staticpro (&Qlazy);
+
   Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
   staticpro (&Qinput_method_exit_on_first_char);
   Qinput_method_use_echo_area = intern_c_string ("input-method-use-echo-area");
@@ -12315,6 +12323,28 @@
 and tool-bar buttons.  */);
   Venable_disabled_menus_and_buttons = Qnil;
 
+  DEFVAR_LISP ("select-active-regions",
+	       &Vselect_active_regions,
+	       doc: /* If non-nil, an active region automatically becomes the window selection.
+This takes effect only when Transient Mark mode is enabled.
+
+If the value is `lazy', Emacs only sets the window selection during
+`deactivate-mark'; unless the region is temporarily active
+(e.g. mouse-drags or shift-selection), in which case it sets the
+window selection after each command.
+
+For other non-nil value, Emacs sets the window selection after every
+command.  */);
+  Vselect_active_regions = Qlazy;
+
+  DEFVAR_LISP ("saved-region-selection",
+	       &Vsaved_region_selection,
+	       doc: /* Contents of active region prior to buffer modification.
+If `select-active-regions' is non-nil, Emacs sets this to the
+text in the region before modifying the buffer.  The next
+`deactivate-mark' call uses this to set the window selection.  */);
+  Vsaved_region_selection = Qnil;
+
   /* Create the initial keyboard. */
   initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
   init_kboard (initial_kboard);
--- a/src/keyboard.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/keyboard.h	Mon Aug 09 10:51:16 2010 +0900
@@ -366,8 +366,6 @@
   struct _widget_value*	next;
 } widget_value;
 
-extern widget_value *xmalloc_widget_value (void);
-extern widget_value *digest_single_submenu (int, int, int);
 #endif /* HAVE_NS || HAVE_NTGUI */
 
 
@@ -406,6 +404,8 @@
 #define POSN_INBUFFER_P(posn) (NILP (POSN_STRING (posn)))
 #define POSN_BUFFER_POSN(posn) (Fnth (make_number (5), (posn)))
 
+extern Lisp_Object do_mouse_tracking;
+
 /* Some of the event heads.  */
 extern Lisp_Object Qswitch_frame;
 
@@ -420,6 +420,8 @@
 extern Lisp_Object Qfunction_key, Qmouse_click, Qmouse_movement;
 extern Lisp_Object Qscroll_bar_movement;
 
+extern Lisp_Object Qhelp_echo;
+
 /* Getting the kind of an event head.  */
 #define EVENT_HEAD_KIND(event_head) \
   (Fget ((event_head), Qevent_kind))
@@ -427,6 +429,17 @@
 /* Symbols to use for non-text mouse positions.  */
 extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line;
 
+/* True while doing kbd input.  */
+extern int waiting_for_input;
+
+/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
+   happens.  */
+extern EMACS_TIME *input_available_clear_time;
+
+extern int ignore_mouse_drag_p;
+
+extern Lisp_Object Vdouble_click_time;
+
 /* Forward declaration for prototypes.  */
 struct input_event;
 
@@ -443,6 +456,37 @@
 /* Keymap of key translations that can override keymaps.  */
 extern Lisp_Object Vkey_translation_map;
 
+/* This is like Vthis_command, except that commands never set it.  */
+extern Lisp_Object real_this_command;
+
+/* If the lookup of the command returns a binding, the original
+   command is stored in this-original-command.  It is nil otherwise.  */
+extern Lisp_Object Vthis_original_command;
+
+/* Non-nil disable property on a command means
+   do not execute it; call disabled-command-function's value instead.  */
+extern Lisp_Object QCbutton, QCtoggle, QCradio, QClabel;
+
+/* A mask of extra modifier bits to put into every keyboard char.  */
+extern EMACS_INT extra_keyboard_modifiers;
+
+/* If non-nil, this implements the current input method.  */
+extern Lisp_Object Vinput_method_function;
+extern Lisp_Object Qinput_method_function;
+
+/* An event header symbol HEAD may have a property named
+   Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
+   BASE is the base, unmodified version of HEAD, and MODIFIERS is the
+   mask of modifiers applied to it.  If present, this is used to help
+   speed up parse_modifiers.  */
+extern Lisp_Object Qevent_symbol_element_mask;
+
+/* The timestamp of the last input event we received from the X server.
+   X Windows wants this for selection ownership.  */
+extern unsigned long last_event_timestamp;
+
+extern int quit_char;
+
 extern int parse_menu_item (Lisp_Object, int);
 
 extern void echo_now (void);
@@ -473,9 +517,7 @@
 extern void kbd_buffer_store_event_hold (struct input_event *,
                                          struct input_event *);
 extern void kbd_buffer_unget_event (struct input_event *);
-#ifdef POLL_FOR_INPUT
 extern void poll_for_input_1 (void);
-#endif
 extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
                             Lisp_Object, int);
 extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object,
--- a/src/keymap.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/keymap.c	Mon Aug 09 10:51:16 2010 +0900
@@ -103,13 +103,6 @@
 /* Pre-allocated 2-element vector for Fcommand_remapping to use.  */
 static Lisp_Object command_remapping_vector;
 
-/* A char with the CHAR_META bit set in a vector or the 0200 bit set
-   in a string key sequence is equivalent to prefixing with this
-   character.  */
-extern Lisp_Object meta_prefix_char;
-
-extern Lisp_Object Voverriding_local_map;
-
 /* Hash table used to cache a reverse-map to speed up calls to where-is.  */
 static Lisp_Object where_is_cache;
 /* Which keymaps are reverse-stored in the cache.  */
@@ -181,13 +174,13 @@
    initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark");  */
 
 void
-initial_define_key (Lisp_Object keymap, int key, char *defname)
+initial_define_key (Lisp_Object keymap, int key, const char *defname)
 {
   store_in_keymap (keymap, make_number (key), intern_c_string (defname));
 }
 
 void
-initial_define_lispy_key (Lisp_Object keymap, char *keyname, char *defname)
+initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname)
 {
   store_in_keymap (keymap, intern_c_string (keyname), intern_c_string (defname));
 }
@@ -1228,7 +1221,7 @@
 	  && (!CONSP (c)
 	      /* If C is a range, it must be a leaf.  */
 	      || (INTEGERP (XCAR (c)) && idx != length)))
-	error ("Key sequence contains invalid event");
+	message_with_string ("Key sequence contains invalid event %s", c, 1);
 
       if (idx == length)
 	RETURN_UNGCPRO (store_in_keymap (keymap, c, def));
@@ -1342,7 +1335,7 @@
       /* Allow string since binding for `menu-bar-select-buffer'
 	 includes the buffer name in the key sequence.  */
       if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c) && !STRINGP (c))
-	error ("Key sequence contains invalid event");
+	message_with_string ("Key sequence contains invalid event %s", c, 1);
 
       cmd = access_keymap (keymap, c, t_ok, 0, 1);
       if (idx == length)
--- a/src/keymap.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/keymap.h	Mon Aug 09 10:51:16 2010 +0900
@@ -22,6 +22,11 @@
 
 #define KEYMAPP(m) (!NILP (get_keymap (m, 0, 0)))
 extern Lisp_Object Qkeymap, Qmenu_bar;
+extern Lisp_Object Qremap;
+extern Lisp_Object Qmenu_item;
+extern Lisp_Object meta_prefix_char;
+extern Lisp_Object Voverriding_local_map;
+extern Lisp_Object Voverriding_local_map_menu_flag;
 extern Lisp_Object current_global_map;
 EXFUN (Fmake_sparse_keymap, 1);
 EXFUN (Fkeymap_prompt, 1);
@@ -40,8 +45,8 @@
 extern void describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object,
                                char *, int, int, int, int);
 extern int current_minor_maps (Lisp_Object **, Lisp_Object **);
-extern void initial_define_key (Lisp_Object, int, char *);
-extern void initial_define_lispy_key (Lisp_Object, char *, char *);
+extern void initial_define_key (Lisp_Object, int, const char *);
+extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
 extern void syms_of_keymap (void);
 extern void keys_of_keymap (void);
 
--- a/src/lisp.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/lisp.h	Mon Aug 09 10:51:16 2010 +0900
@@ -508,12 +508,6 @@
 #define EQ(x, y) (XHASH (x) == XHASH (y))
 
 #ifndef XPNTR
-#ifdef HAVE_SHM
-/* In this representation, data is found in two widely separated segments.  */
-extern size_t pure_size;
-#define XPNTR(a) \
-  (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
-#else /* not HAVE_SHM */
 #ifdef DATA_SEG_BITS
 /* This case is used for the rt-pc.
    In the diffs I was given, it checked for ptr = 0
@@ -528,7 +522,6 @@
    size.  */
 #define XPNTR(a) ((EMACS_INT) XUINT (a))
 #endif
-#endif /* not HAVE_SHM */
 #endif /* no XPNTR */
 
 /* Largest and smallest representable fixnum values.  These are the C
@@ -976,8 +969,8 @@
     } function;
     short min_args, max_args;
     const char *symbol_name;
-    char *intspec;
-    char *doc;
+    const char *intspec;
+    const char *doc;
   };
 
 
@@ -2269,7 +2262,8 @@
 extern Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive;
 extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
 extern Lisp_Object Qtext_read_only;
-
+extern Lisp_Object Qinteractive_form;
+extern Lisp_Object Qcircular_list;
 extern Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp;
 extern Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp;
 extern Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
@@ -2401,7 +2395,6 @@
 EXFUN (Fcoding_system_base, 1);
 EXFUN (Fcoding_system_eol_type, 1);
 EXFUN (Fcheck_coding_system, 1);
-EXFUN (Fcheck_coding_system, 1);
 EXFUN (Fread_coding_system, 2);
 EXFUN (Fread_non_nil_coding_system, 1);
 EXFUN (Ffind_operation_coding_system, MANY);
@@ -2448,13 +2441,16 @@
 extern void syms_of_syntax (void);
 
 /* Defined in fns.c */
+extern Lisp_Object QCrehash_size, QCrehash_threshold;
 extern int use_dialog_box;
+extern int use_file_dialog;
 extern int next_almost_prime (int);
 extern Lisp_Object larger_vector (Lisp_Object, int, Lisp_Object);
 extern void sweep_weak_hash_tables (void);
+extern Lisp_Object Qcursor_in_echo_area;
 extern Lisp_Object Qstring_lessp;
 extern Lisp_Object Vfeatures;
-extern Lisp_Object QCtest, QCweakness, Qequal, Qeq;
+extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql;
 unsigned sxhash (Lisp_Object, int);
 Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object,
                              Lisp_Object, Lisp_Object, Lisp_Object,
@@ -2551,6 +2547,7 @@
 EXFUN (Ftruncate, 2);
 extern void init_floatfns (void);
 extern void syms_of_floatfns (void);
+extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y);
 
 /* Defined in fringe.c */
 extern void syms_of_fringe (void);
@@ -2558,6 +2555,9 @@
 extern void init_fringe_once (void);
 
 /* Defined in image.c */
+extern Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data;
+extern Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
+extern Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask;
 EXFUN (Finit_image_library, 2);
 extern void syms_of_image (void);
 extern void init_image (void);
@@ -2616,6 +2616,7 @@
 
 /* Defined in dispnew.c */
 extern Lisp_Object selected_frame;
+extern Lisp_Object Vwindow_system_version;
 extern EMACS_INT baud_rate;
 EXFUN (Fding, 1);
 EXFUN (Fredraw_frame, 1);
@@ -2631,10 +2632,23 @@
 extern Lisp_Object Qinhibit_redisplay, Qdisplay;
 extern Lisp_Object Qinhibit_eval_during_redisplay;
 extern Lisp_Object Qmessage_truncate_lines;
-extern Lisp_Object Qimage, Qtext, Qboth, Qboth_horiz;
+extern Lisp_Object Qmenu_bar_update_hook;
+extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
+extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
+extern Lisp_Object Qimage, Qtext, Qboth, Qboth_horiz, Qtext_image_horiz;
+extern Lisp_Object Qspace, Qcenter, QCalign_to;
+extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
+extern Lisp_Object Qleft_margin, Qright_margin;
 extern Lisp_Object Vmessage_log_max;
+extern Lisp_Object QCdata, QCfile;
+extern Lisp_Object QCmap;
+extern Lisp_Object Qrisky_local_variable;
+extern Lisp_Object Vinhibit_redisplay;
 extern int message_enable_multibyte;
+extern int noninteractive_need_newline;
+extern EMACS_INT scroll_margin;
 extern Lisp_Object echo_area_buffer[2];
+extern void add_to_log (const char *, Lisp_Object, Lisp_Object);
 extern void check_message_stack (void);
 extern void setup_echo_area_for_printing (int);
 extern int push_message (void);
@@ -2689,6 +2703,7 @@
 extern void mark_object (Lisp_Object);
 extern Lisp_Object Vpurify_flag;
 extern Lisp_Object Vmemory_full;
+extern Lisp_Object *stack_base;
 EXFUN (Fcons, 2);
 EXFUN (list1, 1);
 EXFUN (list2, 2);
@@ -2770,10 +2785,15 @@
 extern void map_char_table (void (*) (Lisp_Object, Lisp_Object,
                             Lisp_Object),
                             Lisp_Object, Lisp_Object, Lisp_Object);
+extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
+					Lisp_Object, Lisp_Object,
+					Lisp_Object, struct charset *,
+					unsigned, unsigned);
 extern void syms_of_chartab (void);
 
 /* Defined in print.c */
 extern Lisp_Object Vprin1_to_string_buffer;
+extern Lisp_Object Vprint_level, Vprint_length;
 extern void debug_print (Lisp_Object);
 EXFUN (Fprin1, 2);
 EXFUN (Fprin1_to_string, 2);
@@ -2799,8 +2819,11 @@
 extern int doprnt (char *, int, const char *, const char *, va_list);
 
 /* Defined in lread.c */
+extern Lisp_Object Vafter_load_alist;
 extern Lisp_Object Qvariable_documentation, Qstandard_input;
+extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
 extern Lisp_Object Vobarray, initial_obarray, Vstandard_input;
+extern int load_in_progress;
 EXFUN (Fread, 1);
 EXFUN (Fread_from_string, 3);
 EXFUN (Fintern, 2);
@@ -2841,6 +2864,7 @@
 extern Lisp_Object Vdebug_on_error;
 extern Lisp_Object Vsignaling_function;
 extern int handling_signal;
+extern int debug_on_next_call;
 extern int interactive_p (int);
 
 /* To run a normal hook, use the appropriate function from the list below.
@@ -2921,6 +2945,11 @@
 extern void syms_of_eval (void);
 
 /* Defined in editfns.c */
+extern Lisp_Object last_nonmenu_event;
+extern Lisp_Object Qfield;
+extern Lisp_Object Vinhibit_field_text_motion;
+extern Lisp_Object Vsystem_name;
+extern Lisp_Object Vuser_login_name;
 EXFUN (Fpropertize, MANY);
 EXFUN (Fcurrent_message, 0);
 EXFUN (Fgoto_char, 1);
@@ -2967,7 +2996,6 @@
 extern Lisp_Object make_buffer_string_both (int, int, int, int, int);
 extern void init_editfns (void);
 extern void syms_of_editfns (void);
-extern Lisp_Object Vinhibit_field_text_motion;
 EXFUN (Fconstrain_to_field, 5);
 EXFUN (Ffield_string, 1);
 EXFUN (Fdelete_field, 1);
@@ -3009,7 +3037,7 @@
 EXFUN (Fbuffer_enable_undo, 1);
 EXFUN (Ferase_buffer, 0);
 extern Lisp_Object Qoverlayp;
-extern Lisp_Object Qevaporate;
+extern Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string;
 extern Lisp_Object get_truename_buffer (Lisp_Object);
 extern struct buffer *all_buffers;
 EXFUN (Fprevious_overlay_change, 1);
@@ -3041,6 +3069,10 @@
 /* Defined in fileio.c */
 
 extern Lisp_Object Qfile_error;
+extern Lisp_Object Qfile_exists_p;
+extern Lisp_Object Qfile_directory_p;
+extern Lisp_Object Qinsert_file_contents;
+extern Lisp_Object Vauto_save_list_file_name;
 EXFUN (Ffind_file_name_handler, 2);
 EXFUN (Ffile_name_as_directory, 1);
 EXFUN (Fmake_temp_name, 1);
@@ -3100,7 +3132,14 @@
 
 /* Defined in minibuf.c */
 
+extern Lisp_Object Qcompletion_ignore_case;
+extern Lisp_Object Vcompletion_regexp_list;
+extern Lisp_Object Vhistory_length;
+extern Lisp_Object Vminibuffer_list;
 extern Lisp_Object last_minibuf_string;
+extern int completion_ignore_case;
+extern int history_delete_duplicates;
+extern int minibuffer_auto_raise;
 extern void choose_minibuf_frame (void);
 EXFUN (Fcompleting_read, 8);
 EXFUN (Fread_from_minibuffer, 7);
@@ -3119,7 +3158,9 @@
 /* Defined in callint.c */
 
 extern Lisp_Object Qminus, Qplus, Vcurrent_prefix_arg;
+extern Lisp_Object Qwhen;
 extern Lisp_Object Vcommand_history;
+extern Lisp_Object Vmark_even_if_inactive;
 extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook;
 EXFUN (Fcall_interactively, 3);
 EXFUN (Fprefix_numeric_value, 1);
@@ -3127,6 +3168,7 @@
 
 /* Defined in casefiddle.c */
 
+extern Lisp_Object Qidentity;
 EXFUN (Fdowncase, 1);
 EXFUN (Fupcase, 1);
 EXFUN (Fcapitalize, 1);
@@ -3150,12 +3192,17 @@
 extern struct kboard *echo_kboard;
 extern void cancel_echoing (void);
 extern Lisp_Object Qdisabled, QCfilter;
+extern Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
+extern Lisp_Object Qup, Qdown, Qbottom, Qend_scroll;
+extern Lisp_Object Qtop, Qratio;
 extern Lisp_Object Vtty_erase_char, Vhelp_form, Vtop_level;
 extern Lisp_Object Vthrow_on_input;
 extern int input_pending;
 EXFUN (Fdiscard_input, 0);
 EXFUN (Frecursive_edit, 0);
-EXFUN (Ftop_level, 0);
+EXFUN (Ftop_level, 0) NO_RETURN;
+EXFUN (Fexit_recursive_edit, 0) NO_RETURN;
+EXFUN (Fabort_recursive_edit, 0) NO_RETURN;
 EXFUN (Fcommand_execute, 4);
 EXFUN (Finput_pending_p, 0);
 extern Lisp_Object menu_bar_items (Lisp_Object);
@@ -3199,6 +3246,7 @@
 extern Lisp_Object Vx_resource_name;
 extern Lisp_Object Vx_resource_class;
 #endif /* HAVE_WINDOW_SYSTEM */
+extern Lisp_Object Qonly;
 extern Lisp_Object Qvisible;
 extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
 extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
@@ -3238,12 +3286,19 @@
 extern void syms_of_frame (void);
 
 /* Defined in emacs.c */
+extern char **initial_argv;
+extern int initial_argc;
+#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
+extern int display_arg;
+#endif
 extern Lisp_Object decode_env_path (const char *, const char *);
 extern Lisp_Object Vinvocation_name, Vinvocation_directory;
 extern Lisp_Object Vbefore_init_time, Vafter_init_time;
 extern Lisp_Object Vinstallation_directory;
 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
-EXFUN (Fkill_emacs, 1);
+extern Lisp_Object Qfile_name_handler_alist;
+extern void (*fatal_error_signal_hook) (void);
+EXFUN (Fkill_emacs, 1) NO_RETURN;
 #if HAVE_SETLOCALE
 void fixup_locale (void);
 void synchronize_system_messages_locale (void);
@@ -3272,6 +3327,7 @@
 extern int running_asynch_code;
 
 /* Defined in process.c */
+extern Lisp_Object QCtype, Qlocal;
 EXFUN (Fget_process, 1);
 EXFUN (Fget_buffer_process, 1);
 EXFUN (Fprocessp, 1);
@@ -3298,6 +3354,7 @@
 extern Lisp_Object Vexec_path, Vexec_suffixes,
                    Vexec_directory, Vdata_directory;
 extern Lisp_Object Vdoc_directory;
+extern Lisp_Object Vshell_file_name;
 EXFUN (Fcall_process, MANY);
 extern int child_setup (int, int, int, char **, int, Lisp_Object);
 extern void init_callproc_1 (void);
@@ -3306,6 +3363,7 @@
 extern void syms_of_callproc (void);
 
 /* Defined in doc.c */
+extern Lisp_Object Qfunction_documentation;
 extern Lisp_Object Vdoc_file_name;
 EXFUN (Fsubstitute_command_keys, 1);
 EXFUN (Fdocumentation, 2);
@@ -3331,6 +3389,7 @@
 extern void syms_of_macros (void);
 
 /* Defined in undo.c */
+extern Lisp_Object Qapply;
 extern Lisp_Object Qinhibit_read_only;
 EXFUN (Fundo_boundary, 0);
 extern void truncate_undo_list (struct buffer *);
@@ -3347,12 +3406,14 @@
 /* Defined in textprop.c */
 extern Lisp_Object Qfont, Qmouse_face;
 extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks;
+extern Lisp_Object Qfront_sticky, Qrear_nonsticky;
+extern Lisp_Object Qminibuffer_prompt;
+
 EXFUN (Fnext_single_property_change, 4);
 EXFUN (Fnext_single_char_property_change, 4);
 EXFUN (Fprevious_single_property_change, 4);
 EXFUN (Fget_text_property, 3);
 EXFUN (Fput_text_property, 5);
-EXFUN (Fget_text_property, 3);
 EXFUN (Fprevious_char_property_change, 2);
 EXFUN (Fnext_char_property_change, 2);
 extern void report_interval_modification (Lisp_Object, Lisp_Object);
@@ -3412,6 +3473,7 @@
 #endif
 
 /* Defined in filelock.c */
+extern Lisp_Object Vtemporary_file_directory;
 EXFUN (Funlock_buffer, 0);
 EXFUN (Ffile_locked_p, 1);
 extern void unlock_all_files (void);
@@ -3441,6 +3503,7 @@
                                              int, Lisp_Object);
 
 /* Defined in term.c */
+extern int *char_ins_del_vector;
 extern void syms_of_term (void);
 extern void fatal (const char *msgid, ...) NO_RETURN;
 
@@ -3460,12 +3523,26 @@
 EXFUN (Fnew_fontset, 2);
 
 /* Defined in xfns.c, w32fns.c, or macfns.c */
+extern Lisp_Object Qfont_param;
+extern Lisp_Object Vx_no_window_manager;
 EXFUN (Fxw_display_color_p, 1);
 EXFUN (Fx_file_dialog, 5);
 EXFUN (Fx_focus_frame, 1);
 #endif
 
 /* Defined in xfaces.c */
+extern Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe;
+extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse, Qmenu;
+extern Lisp_Object Qmode_line_inactive, Qvertical_border;
+extern Lisp_Object Qface;
+extern Lisp_Object Qnormal;
+extern Lisp_Object QCfamily, QCweight, QCslant;
+extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground;
+extern Lisp_Object Vface_alternative_font_family_alist;
+extern Lisp_Object Vface_font_rescale_alist;
+extern Lisp_Object Vface_ignored_fonts;
+extern Lisp_Object Vface_alternative_font_registry_alist;
+extern Lisp_Object Vscalable_fonts_allowed;
 EXFUN (Fclear_face_cache, 1);
 EXFUN (Fx_load_color_file, 1);
 extern void syms_of_xfaces (void);
@@ -3511,6 +3588,11 @@
 void xd_read_queued_messages (void);
 void syms_of_dbusbind (void);
 #endif
+
+#ifdef DOS_NT
+/* Defined in msdos.c, w32.c */
+extern char *emacs_root_dir (void);
+#endif /* DOS_NT */
 
 /* Nonzero means Emacs has already been initialized.
    Used during startup to detect startup of dumped Emacs.  */
--- a/src/lread.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/lread.c	Mon Aug 09 10:51:16 2010 +0900
@@ -75,7 +75,6 @@
 Lisp_Object Qweakness;
 Lisp_Object Qrehash_size;
 Lisp_Object Qrehash_threshold;
-extern Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness;
 
 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
@@ -91,9 +90,6 @@
 
 static Lisp_Object Qload_force_doc_strings;
 
-extern Lisp_Object Qevent_symbol_element_mask;
-extern Lisp_Object Qfile_exists_p;
-
 /* non-zero if inside `load' */
 int load_in_progress;
 static Lisp_Object Qload_in_progress;
--- a/src/m/alpha.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/alpha.h	Mon Aug 09 10:51:16 2010 +0900
@@ -64,12 +64,6 @@
    termio and struct termios are mutually incompatible.  */
 #define NO_TERMIO
 
-#if defined (GNU_LINUX) || defined (__NetBSD__) || defined (__OpenBSD__)
-# ifndef __ELF__
-#  define COFF
-# endif /* notdef __ELF__ */
-#endif
-
 /* Many Alpha implementations (e.g. gas 2.8) can't handle DBL_MIN:
    they generate code that uses a signaling NaN instead of DBL_MIN.
    Define DBL_MIN_REPLACEMENT to be the next value larger than DBL_MIN:
--- a/src/m/arm.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/arm.h	Mon Aug 09 10:51:16 2010 +0900
@@ -22,7 +22,5 @@
    is the most significant byte.  */
 #undef WORDS_BIG_ENDIAN
 
-#define NO_REMAP
-
 /* arch-tag: 07856f0c-f0c8-4bd8-99af-0b7fa1e5ee42
    (do not change this comment) */
--- a/src/m/intel386.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/intel386.h	Mon Aug 09 10:51:16 2010 +0900
@@ -32,8 +32,6 @@
 /* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */
 /* we cannot get the maximum address for brk */
 #define ULIMIT_BREAK_VALUE (32*1024*1024)
-
-#define SEGMENT_MASK ((SEGMENT_SIZE)-1)
 #endif
 
 /* arch-tag: 746338f0-cb7b-4f49-a98c-cb50817cf2ec
--- a/src/m/iris4d.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/iris4d.h	Mon Aug 09 10:51:16 2010 +0900
@@ -36,17 +36,5 @@
 #define DATA_START 0x10000000
 #define DATA_SEG_BITS	0x10000000
 
-
-#if _MIPS_SZLONG != 64
-/* fixme: should there be 64-bit definitions?  (The ones below aren't OK.)  */
-
-/* The standard definitions of these macros would work ok,
-   but these are faster because the constants are short.  */
-#define XUINT(a) (((unsigned)(a) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)
-
-#define XSET(var, type, ptr) \
-   ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS))
-#endif /* _LP64 */
-
 /* arch-tag: fff5e139-9ae0-465d-afec-837c41ea0aa6
    (do not change this comment) */
--- a/src/m/m68k.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/m68k.h	Mon Aug 09 10:51:16 2010 +0900
@@ -40,7 +40,6 @@
 #define DATA_SEG_BITS 0x80000000
 #endif
 
-#define NO_REMAP
 #endif
 
 /* arch-tag: 4eadd161-b4e8-4b82-82a1-e4ce7f42969d
--- a/src/m/sparc.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/sparc.h	Mon Aug 09 10:51:16 2010 +0900
@@ -34,9 +34,6 @@
 /* Convert that into an integer that is 100 for a load average of 1.0  */
 #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
 
-/* Mask for address bits within a memory segment */
-#define SEGMENT_MASK (SEGSIZ - 1)
-
 #ifdef __arch64__		/* GCC, 64-bit ABI.  */
 
 #define BITS_PER_LONG 64
--- a/src/m/template.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/m/template.h	Mon Aug 09 10:51:16 2010 +0900
@@ -47,12 +47,6 @@
    numerically.  */
 #define VIRT_ADDR_VARIES
 
-/* Define NO_REMAP if memory segmentation makes it not work well
-   to change the boundary between the text section and data section
-   when Emacs is dumped.  If you define this, the preloaded Lisp
-   code will not be sharable; but that's better than failing completely.  */
-#define NO_REMAP
-
 /* After adding support for a new machine, modify the large case
    statement in configure.in to recognize reasonable
    configuration names, and add a description of the system to
--- a/src/macros.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/macros.c	Mon Aug 09 10:51:16 2010 +0900
@@ -51,8 +51,6 @@
 
 Lisp_Object executing_kbd_macro;
 
-extern Lisp_Object real_this_command;
-
 Lisp_Object Fexecute_kbd_macro (Lisp_Object macro, Lisp_Object count, Lisp_Object loopfunc);
 
 DEFUN ("start-kbd-macro", Fstart_kbd_macro, Sstart_kbd_macro, 1, 2, "P",
--- a/src/makefile.w32-in	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/makefile.w32-in	Mon Aug 09 10:51:16 2010 +0900
@@ -1506,6 +1506,7 @@
 	$(SRC)/systime.h \
 	$(SRC)/termchar.h \
 	$(SRC)/termhooks.h \
+	$(SRC)/termopts.h \
 	$(SRC)/w32gui.h \
 	$(SRC)/w32term.h \
 	$(SRC)/window.h
--- a/src/mem-limits.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/mem-limits.h	Mon Aug 09 10:51:16 2010 +0900
@@ -34,24 +34,9 @@
 # endif
 #endif
 
-#ifdef BSD4_2
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif /* BSD4_2 */
-
-/* The important properties of this type are that 1) it's a pointer, and
-   2) arithmetic on it should work as if the size of the object pointed
-   to has a size of 1.  */
-typedef POINTER_TYPE *POINTER;
-
 typedef unsigned long SIZE;
 
-#ifdef NULL
-#undef NULL
-#endif
-#define NULL ((POINTER) 0)
-
-extern POINTER start_of_data (void);
+extern char *start_of_data (void);
 #if defined USE_LSB_TAG
 #define EXCEEDS_LISP_PTR(ptr) 0
 #elif defined DATA_SEG_BITS
--- a/src/menu.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/menu.c	Mon Aug 09 10:51:16 2010 +0900
@@ -61,12 +61,6 @@
 #define HAVE_BOXES 1
 #endif
 
-/* The timestamp of the last input event Emacs received from the X server.  */
-/* Defined in keyboard.c.  */
-extern unsigned long last_event_timestamp;
-
-extern Lisp_Object QCtoggle, QCradio;
-
 Lisp_Object menu_items;
 
 /* If non-nil, means that the global vars defined here are already in use.
@@ -668,7 +662,7 @@
 	{
 	  /* Create a new pane.  */
 	  Lisp_Object pane_name, prefix;
-	  char *pane_string;
+	  const char *pane_string;
 
 	  panes_seen++;
 
--- a/src/menu.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/menu.h	Mon Aug 09 10:51:16 2010 +0900
@@ -21,17 +21,24 @@
 
 extern Lisp_Object Vmenu_updating_frame;
 
+extern void x_set_menu_bar_lines (struct frame *f,
+                                  Lisp_Object value,
+                                  Lisp_Object oldval);
+
 extern void init_menu_items (void);
 extern void finish_menu_items (void);
 extern void discard_menu_items (void);
 extern void save_menu_items (void);
 extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void list_of_panes (Lisp_Object);
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
+  || defined (HAVE_NS)
 extern void free_menubar_widget_value_tree (widget_value *);
 extern void update_submenu_strings (widget_value *);
 extern void find_and_call_menu_selection (FRAME_PTR, int,
                                           Lisp_Object, void *);
+extern widget_value *xmalloc_widget_value (void);
+extern widget_value *digest_single_submenu (int, int, int);
 #endif
 
 #ifdef HAVE_X_WINDOWS
--- a/src/minibuf.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/minibuf.c	Mon Aug 09 10:51:16 2010 +0900
@@ -143,11 +143,6 @@
 
 Lisp_Object Qread_expression_history;
 
-extern Lisp_Object Voverriding_local_map;
-
-extern Lisp_Object Qmouse_face;
-
-extern Lisp_Object Qfield;
 
 /* Put minibuf on currently selected frame's minibuffer.
    We do this whenever the user starts a new minibuffer
@@ -444,9 +439,6 @@
   Lisp_Object empty_minibuf;
   Lisp_Object dummy, frame;
 
-  extern Lisp_Object Qfront_sticky;
-  extern Lisp_Object Qrear_nonsticky;
-
   specbind (Qminibuffer_default, defalt);
 
   /* If Vminibuffer_completing_file_name is `lambda' on entry, it was t
@@ -824,7 +816,6 @@
 {
   Lisp_Object tail, num, buf;
   char name[24];
-  extern Lisp_Object nconc2 (Lisp_Object, Lisp_Object);
 
   XSETFASTINT (num, depth);
   tail = Fnthcdr (num, Vminibuffer_list);
@@ -1152,7 +1143,7 @@
  If DEF is a list of default values, return its first element.
 Optional third arg REQUIRE-MATCH determines whether non-existing
  buffer names are allowed.  It has the same meaning as the
- REQUIRE-MATCH argument of `confirm-after-completion'.
+ REQUIRE-MATCH argument of `completing-read'.
 The argument PROMPT should be a string ending with a colon and a space.
 If `read-buffer-completion-ignore-case' is non-nil, completion ignores
 case while reading the buffer name.
@@ -2089,7 +2080,8 @@
   staticpro (&Qread_expression_history);
 
   DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
-	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.  */);
+	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.
+The function is called with the arguments passed to `read-buffer'.  */);
   Vread_buffer_function = Qnil;
 
   DEFVAR_BOOL ("read-buffer-completion-ignore-case",
--- a/src/msdos.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/msdos.c	Mon Aug 09 10:51:16 2010 +0900
@@ -1191,7 +1191,6 @@
 
   if (row->enabled_p)
     {
-      extern Lisp_Object Qhelp_echo;
       struct glyph *glyph, *end;
       Lisp_Object help, map;
 
@@ -1330,7 +1329,6 @@
 
       /* Check for mouse-face and help-echo.  */
       {
-	extern Lisp_Object Qmouse_face;
 	Lisp_Object mouse_face, overlay, position, *overlay_vec;
 	int noverlays, obegv, ozv;
 	struct buffer *obuf;
@@ -1455,7 +1453,6 @@
 	/* Look for a `help-echo' property.  */
 	{
 	  Lisp_Object help;
-	  extern Lisp_Object Qhelp_echo;
 
 	  /* Check overlays first.  */
 	  help = Qnil;
@@ -1595,14 +1592,16 @@
       ScreenSetCursor (current_pos_Y, current_pos_X);
       cursor_cleared = 0;
       if (tty->termscript)
-	fprintf (tty->termscript, "\nCURSOR ON");
+	fprintf (tty->termscript, "\nCURSOR ON (%dx%d)",
+		 current_pos_Y, current_pos_X);
     }
   else if (!on && !cursor_cleared)
     {
       ScreenSetCursor (-1, -1);
       cursor_cleared = 1;
       if (tty->termscript)
-	fprintf (tty->termscript, "\nCURSOR OFF");
+	fprintf (tty->termscript, "\nCURSOR OFF (%dx%d)",
+		 current_pos_Y, current_pos_X);
     }
 }
 
--- a/src/nsfns.m	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsfns.m	Mon Aug 09 10:51:16 2010 +0900
@@ -125,7 +125,7 @@
 
 /* Nonzero if we can use mouse menus. */
 int
-have_menus_p ()
+have_menus_p (void)
 {
   return NSApp != nil;
 }
@@ -240,8 +240,7 @@
 /* Return the X display structure for the display named NAME.
    Open a new connection if necessary.  */
 struct ns_display_info *
-ns_display_info_for_name (name)
-     Lisp_Object name;
+ns_display_info_for_name (Lisp_Object name)
 {
   Lisp_Object names;
   struct ns_display_info *dpyinfo;
@@ -925,9 +924,7 @@
 
 /* This is the same as the xfns.c definition.  */
 void
-x_set_cursor_type (f, arg, oldval)
-     FRAME_PTR f;
-     Lisp_Object arg, oldval;
+x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
 {
   set_frame_cursor_types (f, arg);
 
@@ -949,7 +946,7 @@
 #define Xstr(x) Str(x)
 
 static Lisp_Object
-ns_appkit_version_str ()
+ns_appkit_version_str (void)
 {
   char tmp[80];
 
@@ -968,7 +965,7 @@
    have into a single int.  For a better picture of the implementation
    running, use ns_appkit_version_str.*/
 static int
-ns_appkit_version_int ()
+ns_appkit_version_int (void)
 {
 #ifdef NS_IMPL_GNUSTEP
   return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
@@ -2004,8 +2001,7 @@
    string or a number containing the resulting script value.  Otherwise,
    1 is returned. */
 static int
-ns_do_applescript (script, result)
-     Lisp_Object script, *result;
+ns_do_applescript (Lisp_Object script, Lisp_Object *result)
 {
   NSAppleEventDescriptor *desc;
   NSDictionary* errorDict;
@@ -2108,8 +2104,7 @@
 
 
 void
-x_set_scroll_bar_default_width (f)
-     struct frame *f;
+x_set_scroll_bar_default_width (struct frame *f)
 {
   int wid = FRAME_COLUMN_WIDTH (f);
   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT;
@@ -2189,7 +2184,7 @@
 
 
 void
-x_sync (Lisp_Object frame)
+x_sync (struct frame *f)
 {
   /* XXX Not implemented XXX */
   return;
@@ -2367,11 +2362,14 @@
 
 /* TODO: move to xdisp or similar */
 static void
-compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
-     struct frame *f;
-     Lisp_Object parms, dx, dy;
-     int width, height;
-     int *root_x, *root_y;
+compute_tip_xy (struct frame *f,
+                Lisp_Object parms,
+                Lisp_Object dx,
+                Lisp_Object dy,
+                int width,
+                int height,
+                int *root_x,
+                int *root_y)
 {
   Lisp_Object left, top;
   EmacsView *view = FRAME_NS_VIEW (f);
@@ -2595,7 +2593,7 @@
 
 
 void
-syms_of_nsfns ()
+syms_of_nsfns (void)
 {
   int i;
 
--- a/src/nsfont.m	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsfont.m	Mon Aug 09 10:51:16 2010 +0900
@@ -223,7 +223,7 @@
 
 /* Default font entity. */
 static Lisp_Object
-ns_fallback_entity ()
+ns_fallback_entity (void)
 {
   return ns_descriptor_to_entity ([[NSFont userFixedPitchFontOfSize: 0]
       fontDescriptor], Qnil, NULL);
@@ -1510,7 +1510,7 @@
 
 
 void
-syms_of_nsfont ()
+syms_of_nsfont (void)
 {
   nsfont_driver.type = Qns;
   register_font_driver (&nsfont_driver, NULL);
--- a/src/nsimage.m	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsimage.m	Mon Aug 09 10:51:16 2010 +0900
@@ -83,11 +83,11 @@
 ns_load_image (struct frame *f, struct image *img,
                Lisp_Object spec_file, Lisp_Object spec_data)
 {
-  NSTRACE (ns_load_image);
-
   EmacsImage *eImg;
   NSSize size;
 
+  NSTRACE (ns_load_image);
+
   if (NILP (spec_data))
     {
       eImg = [EmacsImage allocInitFromFile: spec_file];
--- a/src/nsmenu.m	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsmenu.m	Mon Aug 09 10:51:16 2010 +0900
@@ -105,7 +105,7 @@
 
 
 int
-popup_activated ()
+popup_activated (void)
 {
   return popup_activated_flag;
 }
@@ -509,8 +509,7 @@
 
 /* Utility (from macmenu.c): is this item a separator? */
 static int
-name_is_separator (name)
-     const char *name;
+name_is_separator ( const char *name)
 {
   const char *start = name;
 
@@ -737,19 +736,21 @@
                  keymaps: (int)keymaps
 {
   EmacsView *view = FRAME_NS_VIEW (f);
+  NSEvent *e, *event;
+  long retVal;
+
 /*   p = [view convertPoint:p fromView: nil]; */
   p.y = NSHeight ([view frame]) - p.y;
-  NSEvent *e = [[view window] currentEvent];
-  NSEvent *event = [NSEvent mouseEventWithType: NSRightMouseDown
-                                      location: p
-                                 modifierFlags: 0
-                                     timestamp: [e timestamp]
-                                  windowNumber: [[view window] windowNumber]
-                                       context: [e context]
-                                   eventNumber: 0/*[e eventNumber] */
-                                    clickCount: 1
-                                      pressure: 0];
-  long retVal;
+  e = [[view window] currentEvent];
+   event = [NSEvent mouseEventWithType: NSRightMouseDown
+                              location: p
+                         modifierFlags: 0
+                             timestamp: [e timestamp]
+                          windowNumber: [[view window] windowNumber]
+                               context: [e context]
+                           eventNumber: 0/*[e eventNumber] */
+                            clickCount: 1
+                              pressure: 0];
 
   context_menu_value = -1;
   [NSMenu popUpContextMenu: self withEvent: event forView: view];
@@ -1801,7 +1802,7 @@
    ========================================================================== */
 
 void
-syms_of_nsmenu ()
+syms_of_nsmenu (void)
 {
   defsubr (&Sx_popup_dialog);
   defsubr (&Sns_reset_menu);
--- a/src/nsterm.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsterm.h	Mon Aug 09 10:51:16 2010 +0900
@@ -21,6 +21,7 @@
 #include "frame.h"
 #include "character.h"
 #include "font.h"
+#include "sysselect.h"
 
 #ifdef HAVE_NS
 
@@ -712,7 +713,9 @@
 extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg);
 
 extern int
-ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
+ns_defined_color (struct frame *f,
+                  const char *name,
+                  XColor *color_def, int alloc,
                   char makeIndex);
 extern void
 ns_query_color (void *col, XColor *color_def, int setPixel);
@@ -742,10 +745,34 @@
 extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
                                     Lisp_Object header);
 
-/* two more prototypes that should be moved to a more general include file */
+/* More prototypes that should be moved to a more general include file */
 extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
 extern void x_set_window_size (struct frame *f, int change_grav,
                               int cols, int rows);
+extern void x_sync (struct frame *);
+extern Lisp_Object x_get_focus_frame (struct frame *);
+extern void x_set_mouse_position (struct frame *f, int h, int v);
+extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
+extern void x_iconify_frame (struct frame *f);
+extern int x_char_width (struct frame *f);
+extern int x_char_height (struct frame *f);
+extern int x_pixel_width (struct frame *f);
+extern int x_pixel_height (struct frame *f);
+extern void x_set_frame_alpha (struct frame *f);
+extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_tool_bar_lines (struct frame *f,
+                                  Lisp_Object value,
+                                  Lisp_Object oldval);
+extern void x_activate_menubar (struct frame *);
+extern void free_frame_menubar (struct frame *);
+
+extern void ns_init_paths (void);
+extern void syms_of_nsterm (void);
+extern void syms_of_nsfns (void);
+extern void syms_of_nsmenu (void);
+extern void syms_of_nsselect (void);
 
 /* From nsimage.m, needed in image.c */
 struct image;
@@ -764,6 +791,8 @@
 extern int x_display_pixel_width (struct ns_display_info *);
 
 /* This in nsterm.m */
+extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
+                      fd_set *exceptfds, struct timeval *timeout);
 extern unsigned long ns_get_rgb_color (struct frame *f,
                                        float r, float g, float b, float a);
 extern NSPoint last_mouse_motion_position;
--- a/src/nsterm.m	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/nsterm.m	Mon Aug 09 10:51:16 2010 +0900
@@ -296,7 +296,7 @@
 
 
 void
-ns_init_paths ()
+ns_init_paths (void)
 /* --------------------------------------------------------------------------
    Used to allow emacs to find its resources under Emacs.app
    Called from emacs.c at startup.
@@ -479,7 +479,7 @@
 
 
 void *
-ns_alloc_autorelease_pool ()
+ns_alloc_autorelease_pool (void)
 /* --------------------------------------------------------------------------
      Allocate a pool for temporary objects (callable from C)
    -------------------------------------------------------------------------- */
@@ -790,7 +790,7 @@
 
 
 static void
-ns_ring_bell ()
+ns_ring_bell (struct frame *f)
 /* --------------------------------------------------------------------------
      "Beep" routine
    -------------------------------------------------------------------------- */
@@ -1186,12 +1186,14 @@
      difference between the real width and Emacs' imagined one.  For
      right-hand bars, don't worry about it since the extra is never used.
      (Obviously doesn't work for vertically split windows tho..) */
-  NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
-    ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
-                  - NS_SCROLL_BAR_WIDTH (f), 0)
-    : NSMakePoint (0, 0);
-  [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
-  [view setBoundsOrigin: origin];
+  {
+    NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
+      ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
+                     - NS_SCROLL_BAR_WIDTH (f), 0)
+      : NSMakePoint (0, 0);
+    [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
+    [view setBoundsOrigin: origin];
+  }
 
   change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */
   FRAME_PIXEL_WIDTH (f) = pixelwidth;
@@ -1507,7 +1509,10 @@
 
 
 int
-ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
+ns_defined_color (struct frame *f,
+                  const char *name,
+                  XColor *color_def,
+                  int alloc,
                   char makeIndex)
 /* --------------------------------------------------------------------------
          Return 1 if named color found, and set color_def rgb accordingly.
@@ -2184,9 +2189,8 @@
       int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ?
         -FRAME_INTERNAL_BORDER_WIDTH (f) : 0;
       int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ?
-        FRAME_INTERNAL_BORDER_WIDTH (f) : 0;
-      if (yAdjust)
-        yIncr += FRAME_INTERNAL_BORDER_WIDTH (f);
+        FRAME_INTERNAL_BORDER_WIDTH (f) : 0
+        + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0);
       NSRect r = NSMakeRect (p->bx+xAdjust, p->by+yAdjust, p->nx, p->ny+yIncr);
       NSRectClip (r);
       [ns_lookup_indexed_color(face->background, f) set];
@@ -2375,7 +2379,7 @@
 
 
 void
-hide_hourglass ()
+hide_hourglass (void)
 {
   if (!hourglass_shown_p)
     return;
@@ -3406,16 +3410,14 @@
    ========================================================================== */
 
 int
-x_display_pixel_height (dpyinfo)
-     struct ns_display_info *dpyinfo;
+x_display_pixel_height (struct ns_display_info *dpyinfo)
 {
   NSScreen *screen = [NSScreen mainScreen];
   return [screen frame].size.height;
 }
 
 int
-x_display_pixel_width (dpyinfo)
-     struct ns_display_info *dpyinfo;
+x_display_pixel_width (struct ns_display_info *dpyinfo)
 {
   NSScreen *screen = [NSScreen mainScreen];
   return [screen frame].size.width;
@@ -5743,9 +5745,10 @@
   NSTRACE (judge);
   if (condemned)
     {
+      EmacsView *view;
       BLOCK_INPUT;
       /* ensure other scrollbar updates after deletion */
-      EmacsView *view = (EmacsView *)FRAME_NS_VIEW (frame);
+      view = (EmacsView *)FRAME_NS_VIEW (frame);
       if (view != nil)
         view->scrollbarsNeedingUpdate++;
       [self removeFromSuperview];
@@ -6122,7 +6125,7 @@
 
 
 void
-syms_of_nsterm ()
+syms_of_nsterm (void)
 {
   NSTRACE (syms_of_nsterm);
 
--- a/src/print.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/print.c	Mon Aug 09 10:51:16 2010 +0900
@@ -42,7 +42,6 @@
 Lisp_Object Qtemp_buffer_setup_hook;
 
 /* These are used to print like we read.  */
-extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
 
 Lisp_Object Vfloat_output_format, Qfloat_output_format;
 
@@ -161,13 +160,6 @@
 #define PRINT_NUMBER_OBJECT(table,i) XVECTOR ((table))->contents[(i) * 2]
 #define PRINT_NUMBER_STATUS(table,i) XVECTOR ((table))->contents[(i) * 2 + 1]
 
-/* Nonzero means print newline to stdout before next minibuffer message.
-   Defined in xdisp.c */
-
-extern int noninteractive_need_newline;
-
-extern int minibuffer_auto_raise;
-
 void print_interval (INTERVAL interval, Lisp_Object printcharfun);
 
 /* GDB resets this to zero on W32 to disable OutputDebugString calls.  */
@@ -1403,7 +1395,6 @@
 /* A flag to control printing of `charset' text property.
    The default value is Qdefault. */
 Lisp_Object Vprint_charset_text_property;
-extern Lisp_Object Qdefault;
 
 static void print_check_string_charset_prop (INTERVAL interval, Lisp_Object string);
 
--- a/src/process.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/process.c	Mon Aug 09 10:51:16 2010 +0900
@@ -43,7 +43,6 @@
 /* Only MS-DOS does not define `subprocesses'.  */
 #ifdef subprocesses
 
-#ifdef HAVE_SOCKETS	/* TCP connection support, if kernel can do it */
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
@@ -59,30 +58,21 @@
 #include <sys/un.h>
 #endif
 #endif
-#endif /* HAVE_SOCKETS */
 
 #if defined(HAVE_SYS_IOCTL_H)
 #include <sys/ioctl.h>
 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
 #include <fcntl.h>
 #endif /* HAVE_PTYS and no O_NDELAY */
+#if defined(HAVE_NET_IF_H)
+#include <net/if.h>
+#endif /* HAVE_NET_IF_H */
 #endif /* HAVE_SYS_IOCTL_H */
 
 #ifdef NEED_BSDTTY
 #include <bsdtty.h>
 #endif
 
-/* Can we use SIOCGIFCONF and/or SIOCGIFADDR */
-#ifdef HAVE_SOCKETS
-#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_NET_IF_H)
-/* sys/ioctl.h may have been included already */
-#ifndef SIOCGIFADDR
-#include <sys/ioctl.h>
-#endif
-#include <net/if.h>
-#endif
-#endif
-
 #ifdef HAVE_SYS_WAIT
 #include <sys/wait.h>
 #endif
@@ -93,6 +83,10 @@
 #include <resolv.h>
 #endif
 
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+
 #endif	/* subprocesses */
 
 #include "lisp.h"
@@ -120,6 +114,27 @@
 #if defined (USE_GTK) || defined (HAVE_GCONF)
 #include "xgselect.h"
 #endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+extern int timers_run;
+
+Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
+Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
+Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
+Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
+Lisp_Object QCname, QCtype;
+
+/* Non-zero if keyboard input is on hold, zero otherwise.  */
+
+static int kbd_is_on_hold;
+
+/* Nonzero means delete a process right away if it exits.  */
+static int delete_exited_processes;
+
+/* Nonzero means don't run process sentinels.  This is used
+   when exiting.  */
+int inhibit_sentinels;
 
 #ifdef subprocesses
 
@@ -150,17 +165,10 @@
 /* QCfilter is defined in keyboard.c.  */
 extern Lisp_Object QCfilter;
 
-#ifdef HAVE_SOCKETS
 #define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
 #define NETCONN1_P(p) (EQ ((p)->type, Qnetwork))
 #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
 #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial))
-#else
-#define NETCONN_P(p) 0
-#define NETCONN1_P(p) 0
-#define SERIALCONN_P(p) 0
-#define SERIALCONN1_P(p) 0
-#endif /* HAVE_SOCKETS */
 
 /* Define first descriptor number available for subprocesses.  */
 #define FIRST_PROC_DESC 3
@@ -206,7 +214,6 @@
 #undef NON_BLOCKING_CONNECT
 #else
 #ifndef NON_BLOCKING_CONNECT
-#ifdef HAVE_SOCKETS
 #ifdef HAVE_SELECT
 #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX)
 #if defined (O_NONBLOCK) || defined (O_NDELAY)
@@ -216,7 +223,6 @@
 #endif /* O_NONBLOCK || O_NDELAY */
 #endif /* HAVE_GETPEERNAME || GNU_LINUX */
 #endif /* HAVE_SELECT */
-#endif /* HAVE_SOCKETS */
 #endif /* NON_BLOCKING_CONNECT */
 #endif /* BROKEN_NON_BLOCKING_CONNECT */
 
@@ -229,13 +235,11 @@
 #undef DATAGRAM_SOCKETS
 #else
 #ifndef DATAGRAM_SOCKETS
-#ifdef HAVE_SOCKETS
 #if defined (HAVE_SELECT) || defined (FIONREAD)
 #if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE)
 #define DATAGRAM_SOCKETS
 #endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
 #endif /* HAVE_SELECT || FIONREAD */
-#endif /* HAVE_SOCKETS */
 #endif /* DATAGRAM_SOCKETS */
 #endif /* BROKEN_DATAGRAM_SOCKETS */
 
@@ -287,29 +291,6 @@
 static Lisp_Object get_process (register Lisp_Object name);
 static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
 
-#endif	/* subprocesses */
-
-extern int timers_run;
-
-Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
-Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
-Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
-Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
-Lisp_Object QCname, QCtype;
-
-/* Non-zero if keyboard input is on hold, zero otherwise.  */
-
-static int kbd_is_on_hold;
-
-/* Nonzero means delete a process right away if it exits.  */
-static int delete_exited_processes;
-
-/* Nonzero means don't run process sentinels.  This is used
-   when exiting.  */
-int inhibit_sentinels;
-
-#ifdef subprocesses
-
 /* Mask of bits indicating the descriptors that we wait for input on.  */
 
 static SELECT_TYPE input_wait_mask;
@@ -1148,7 +1129,6 @@
   return XPROCESS (proc)->type;
 }
 
-#ifdef HAVE_SOCKETS
 DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
        1, 2, 0,
        doc: /* Convert network ADDRESS from internal format to a string.
@@ -1222,7 +1202,6 @@
 
   return Qnil;
 }
-#endif
 
 static Lisp_Object
 list_processes_1 (Lisp_Object query_only)
@@ -1727,25 +1706,6 @@
 }
 
 
-#if 0  /* This doesn't work; see the note before sigchld_handler.  */
-#ifdef USG
-#ifdef SIGCHLD
-/* Mimic blocking of signals on system V, which doesn't really have it.  */
-
-/* Nonzero means we got a SIGCHLD when it was supposed to be blocked.  */
-int sigchld_deferred;
-
-SIGTYPE
-create_process_sigchld ()
-{
-  signal (SIGCHLD, create_process_sigchld);
-
-  sigchld_deferred = 1;
-}
-#endif
-#endif
-#endif
-
 void
 create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
 {
@@ -2215,8 +2175,6 @@
 }
 
 
-#ifdef HAVE_SOCKETS
-
 /* Convert an internal struct sockaddr to a lisp object (vector or string).
    The address family of sa is not included in the result.  */
 
@@ -2447,7 +2405,7 @@
 static const struct socket_options {
   /* The name of this option.  Should be lowercase version of option
      name without SO_ prefix. */
-  char *name;
+  const char *name;
   /* Option level SOL_... */
   int optlevel;
   /* Option number SO_... */
@@ -3770,10 +3728,9 @@
   UNGCPRO;
   return proc;
 }
-#endif	/* HAVE_SOCKETS */
 
 
-#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
+#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
 
 #ifdef SIOCGIFCONF
 DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0,
@@ -4016,7 +3973,7 @@
   return any ? res : Qnil;
 }
 #endif
-#endif	/* HAVE_SOCKETS */
+#endif	/* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
 
 /* Turn off input and output for process PROC.  */
 
@@ -6064,7 +6021,6 @@
 traffic.  */)
   (Lisp_Object process, Lisp_Object current_group)
 {
-#ifdef HAVE_SOCKETS
   if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
     {
       struct Lisp_Process *p;
@@ -6079,7 +6035,6 @@
       p->command = Qt;
       return process;
     }
-#endif
 #ifndef SIGTSTP
   error ("No SIGTSTP support");
 #else
@@ -6095,7 +6050,6 @@
 traffic.  */)
   (Lisp_Object process, Lisp_Object current_group)
 {
-#ifdef HAVE_SOCKETS
   if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
     {
       struct Lisp_Process *p;
@@ -6118,7 +6072,6 @@
       p->command = Qnil;
       return process;
     }
-#endif
 #ifdef SIGCONT
     process_send_signal (process, SIGCONT, current_group, 0);
 #else
@@ -6402,8 +6355,7 @@
 {
   int old_errno = errno;
   Lisp_Object proc;
-  register struct Lisp_Process *p;
-  extern EMACS_TIME *input_available_clear_time;
+  struct Lisp_Process *p;
 
   SIGNAL_THREAD_CHECK (signo);
 
@@ -7430,7 +7382,6 @@
   memset (datagram_address, 0, sizeof datagram_address);
 #endif
 
-#ifdef HAVE_SOCKETS
  {
    Lisp_Object subfeatures = Qnil;
    const struct socket_options *sopt;
@@ -7466,7 +7417,6 @@
 
    Fprovide (intern_c_string ("make-network-process"), subfeatures);
  }
-#endif /* HAVE_SOCKETS */
 
 #if defined (DARWIN_OS)
   /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
@@ -7725,19 +7675,17 @@
   defsubr (&Sserial_process_configure);
   defsubr (&Smake_serial_process);
 #endif /* HAVE_SERIAL  */
-#ifdef HAVE_SOCKETS
   defsubr (&Sset_network_process_option);
   defsubr (&Smake_network_process);
   defsubr (&Sformat_network_address);
-#endif /* HAVE_SOCKETS */
-#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
+#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
 #ifdef SIOCGIFCONF
   defsubr (&Snetwork_interface_list);
 #endif
 #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
   defsubr (&Snetwork_interface_info);
 #endif
-#endif /* HAVE_SOCKETS ... */
+#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
 #ifdef DATAGRAM_SOCKETS
   defsubr (&Sprocess_datagram_address);
   defsubr (&Sset_process_datagram_address);
--- a/src/process.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/process.h	Mon Aug 09 10:51:16 2010 +0900
@@ -166,6 +166,9 @@
 extern Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
 extern Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtpgid, Qcstime;
 extern Lisp_Object Qtime, Qctime;
+extern Lisp_Object QCport, QCspeed, QCprocess;
+extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
+extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
 
 extern Lisp_Object list_system_processes (void);
 extern Lisp_Object system_process_attributes (Lisp_Object);
--- a/src/s/aix4-2.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/aix4-2.h	Mon Aug 09 10:51:16 2010 +0900
@@ -47,11 +47,6 @@
 /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets.  */
 #define HAVE_SOCKETS
 
-
-/* Define SYSV_SYSTEM_DIR to use the V.3 getdents/readir library
-   functions.  Almost, but not quite the same as the 4.2 functions.  */
-#define SYSV_SYSTEM_DIR
-
 /* The file containing the kernel's symbol table is called /unix.  */
 #define KERNEL_FILE "/unix"
 
--- a/src/s/bsd-common.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/bsd-common.h	Mon Aug 09 10:51:16 2010 +0900
@@ -45,8 +45,6 @@
 #define HAVE_TERMIOS
 #define NO_TERMIO
 
-#define SYSV_SYSTEM_DIR
-
 /* If the system's imake configuration file defines `NeedWidePrototypes'
    as `NO', we must define NARROWPROTO manually.  Such a define is
    generated in the Makefile generated by `xmkmf'.  If we don't
--- a/src/s/cygwin.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/cygwin.h	Mon Aug 09 10:51:16 2010 +0900
@@ -89,7 +89,6 @@
 #define CYGWIN 1
 
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
-#define SYSV_SYSTEM_DIR 1
 
 #define HAVE_SOCKETS
 
--- a/src/s/freebsd.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/freebsd.h	Mon Aug 09 10:51:16 2010 +0900
@@ -28,7 +28,6 @@
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 
 #define HAVE_GETLOADAVG 1
-#define DECLARE_GETPWUID_WITH_UID_T
 
 /* This silences a few compilation warnings.  */
 #undef BSD_SYSTEM
--- a/src/s/gnu-linux.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/gnu-linux.h	Mon Aug 09 10:51:16 2010 +0900
@@ -124,8 +124,6 @@
 #define INTERRUPT_INPUT
 #endif /* emacs */
 
-#define SYSV_SYSTEM_DIR       /* use dirent.h */
-
 #define POSIX                 /* affects getpagesize.h and systty.h */
 
 /* This is to work around mysterious gcc failures in some system versions.
--- a/src/s/hpux10-20.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/hpux10-20.h	Mon Aug 09 10:51:16 2010 +0900
@@ -113,12 +113,6 @@
    on HP-UX.  (You get duplicate symbol errors on linking). */
 #undef _FILE_OFFSET_BITS
 
-/* Define NO_REMAP if memory segmentation makes it not work well
-   to change the boundary between the text section and data section
-   when Emacs is dumped.  If you define this, the preloaded Lisp
-   code will not be sharable; but that's better than failing completely.  */
-#define NO_REMAP
-
 /* Define VIRT_ADDR_VARIES if the virtual addresses of
    pure and impure space as loaded can vary, and even their
    relative order cannot be relied on.
--- a/src/s/irix6-5.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/irix6-5.h	Mon Aug 09 10:51:16 2010 +0900
@@ -20,7 +20,7 @@
 
 
 #define IRIX6_5			/* used in m/iris4d */
-#include "usg5-4.h"
+#include "usg5-4-common.h"
 
 #undef _longjmp /* use system versions, not conservative aliases */
 #undef _setjmp
@@ -91,7 +91,7 @@
 
 #undef SA_RESTART
 
-#undef TIOCSIGSEND		/* defined in usg5-4.h */
+#undef TIOCSIGSEND		/* defined in usg5-4-common.h */
 
 /* Tested on Irix 6.5.  SCM worked on earlier versions.  */
 #define GC_SETJMP_WORKS 1
--- a/src/s/ms-w32.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/ms-w32.h	Mon Aug 09 10:51:16 2010 +0900
@@ -62,10 +62,6 @@
    for received packets, so datagrams are broken too.  */
 #define BROKEN_DATAGRAM_SOCKETS 1
 
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF".  */
-#define COFF 1
-
 #define MAIL_USE_POP 1
 #define MAIL_USE_SYSTEM_LOCK 1
 
--- a/src/s/msdos.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/msdos.h	Mon Aug 09 10:51:16 2010 +0900
@@ -38,17 +38,11 @@
    It sets the Lisp variable system-type.  */
 #define SYSTEM_TYPE "ms-dos"
 
-#define SYSV_SYSTEM_DIR
-
 /* subprocesses should be defined if you want to have code for
    asynchronous subprocesses (as used in M-x compile and M-x shell).
    This is the only system that needs this.  */
 #undef subprocesses
 
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF".  */
-#define COFF
-
 /* Here, on a separate page, add any special hacks needed to make
    Emacs work on this system.  For example, you might define certain
    system call names that don't exist on your system, or that do
@@ -131,7 +125,5 @@
 #define GC_SETJMP_WORKS 1
 #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS
 
-#define NO_REMAP
-
 /* arch-tag: d184f860-815d-4ff4-8187-d05c0f3c37d0
    (do not change this comment) */
--- a/src/s/sol2-6.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/sol2-6.h	Mon Aug 09 10:51:16 2010 +0900
@@ -18,7 +18,7 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "usg5-4.h"
+#include "usg5-4-common.h"
 
 #define SOLARIS2
 
@@ -34,7 +34,7 @@
 #define HAVE_LIBKSTAT
 #endif
 
-/* This is the same definition as in usg5-4.h, but with sigblock/sigunblock
+/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock
    rather than sighold/sigrelse, which appear to be BSD4.1 specific.
    It may also be appropriate for SVR4.x
    (x<2) but I'm not sure.   fnf@cygnus.com */
--- a/src/s/template.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/template.h	Mon Aug 09 10:51:16 2010 +0900
@@ -85,11 +85,6 @@
 
 /* #undef subprocesses */
 
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF".  */
-
-/* #define COFF */
-
 /* Define CLASH_DETECTION if you want lock files to be written
    so that Emacs can tell instantly when you try to modify
    a file that someone else has modified in his Emacs.  */
--- a/src/s/unixware.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/s/unixware.h	Mon Aug 09 10:51:16 2010 +0900
@@ -19,7 +19,7 @@
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "usg5-4.h"
+#include "usg5-4-common.h"
 
 /* fnf@cygnus.com says these exist.  */
 #define HAVE_TCATTR
@@ -28,7 +28,7 @@
 
 #undef HAVE_SYSV_SIGPAUSE
 
-/* This is the same definition as in usg5-4.h, but with sigblock/sigunblock
+/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock
    rather than sighold/sigrelse, which appear to be BSD4.1 specific.
    It may also be appropriate for SVR4.x
    (x<2) but I'm not sure.   fnf@cygnus.com */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/s/usg5-4-common.h	Mon Aug 09 10:51:16 2010 +0900
@@ -0,0 +1,116 @@
+/* Definitions file for GNU Emacs running on AT&T's System V Release 4
+
+Copyright (C) 1987, 1990, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+  2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+
+Written by James Van Artsdalen of Dell Computer Corp. james@bigtex.cactus.org.
+Subsequently improved for Dell 2.2 by Eric S. Raymond <esr@snark.thyrsus.com>.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Use the SysVr3 file for at least base configuration.  */
+#define USG				/* System III, System V, etc */
+
+#define USG5
+#define USG5_4
+
+/* SYSTEM_TYPE should indicate the kind of system you are using.
+   It sets the Lisp variable system-type.  */
+#define SYSTEM_TYPE "usg-unix-v"
+
+/* Define HAVE_TERMIO if the system provides sysV-style ioctls
+   for terminal control.  */
+#define HAVE_TERMIO
+
+/* The file containing the kernel's symbol table is called /unix.  */
+#define KERNEL_FILE "/unix"
+
+/* The kernel symbol where the load average is found is named avenrun.  */
+#define LDAV_SYMBOL "avenrun"
+
+/* setjmp and longjmp can safely replace _setjmp and _longjmp,
+   but they will run slower.  */
+#define _setjmp setjmp
+#define _longjmp longjmp
+
+/* The docs for system V/386 suggest v.3 has sigpause, so let's try it.  */
+#define HAVE_SYSV_SIGPAUSE
+
+/* On USG systems signal handlers return void.  */
+#define SIGTYPE void
+
+/* Get FIONREAD from <sys/filio.h>.  Get <sys/ttold.h> to get struct tchars.
+   But get <termio.h> first to make sure ttold.h doesn't interfere.
+   And don't try to use SIGIO yet.  */
+#include <sys/wait.h>
+
+#ifdef emacs
+#include <sys/filio.h>
+#include <termio.h>
+#include <sys/ttold.h>
+#include <signal.h>
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#include <sys/termios.h>
+#define BROKEN_SIGIO
+#endif
+
+/* Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
+   instead, there's a system variable _sys_nsig.  Unfortunately, we need the
+   constant to dimension an array.  So wire in the appropriate value here.  */
+#define NSIG_MINIMUM 32
+
+/* We can support this.  */
+#define CLASH_DETECTION
+
+/* Define HAVE_PTYS if the system supports pty devices.  */
+#define HAVE_PTYS
+#define HAVE_TERMIOS
+
+/* It is possible to receive SIGCHLD when there are no children
+   waiting, because a previous waitsys(2) cleaned up the carcass of child
+   without clearing the SIGCHLD pending info.  So, use a non-blocking
+   wait3 instead, which maps to waitpid(2) in SysVr4. */
+#define wait3(status, options, rusage) \
+  waitpid ((pid_t) -1, (status), (options))
+#define WRETCODE(w) (w >> 8)
+
+/* TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
+   subprocesses the usual way.  But TIOCSIGNAL does work for PTYs, and
+   this is all we need.  */
+#define TIOCSIGSEND TIOCSIGNAL
+
+/* This change means that we don't loop through allocate_pty too many
+   times in the (rare) event of a failure.  */
+#define FIRST_PTY_LETTER 'z'
+
+/* This sets the name of the master side of the PTY.  */
+#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
+
+/* Push various streams modules onto a PTY channel.  */
+#define SETUP_SLAVE_PTY \
+  if (ioctl (xforkin, I_PUSH, "ptem") == -1)	\
+    fatal ("ioctl I_PUSH ptem", errno);		\
+  if (ioctl (xforkin, I_PUSH, "ldterm") == -1)	\
+    fatal ("ioctl I_PUSH ldterm", errno);	\
+  if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) \
+    fatal ("ioctl I_PUSH ttcompat", errno);
+
+/* This definition was suggested for next release.  So give it a try.  */
+#define HAVE_SOCKETS
+
+/* arch-tag: 1a0ed909-5faa-434b-b7c3-9d86c63d53a6
+   (do not change this comment) */
--- a/src/s/usg5-4.h	Mon Jul 26 13:29:08 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/* Definitions file for GNU Emacs running on AT&T's System V Release 4
-
-Copyright (C) 1987, 1990, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-  2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
-
-Written by James Van Artsdalen of Dell Computer Corp. james@bigtex.cactus.org.
-Subsequently improved for Dell 2.2 by Eric S. Raymond <esr@snark.thyrsus.com>.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Use the SysVr3 file for at least base configuration.  */
-#define USG				/* System III, System V, etc */
-
-#define USG5
-#define USG5_4
-
-/* SYSTEM_TYPE should indicate the kind of system you are using.
-   It sets the Lisp variable system-type.  */
-#define SYSTEM_TYPE "usg-unix-v"
-
-/* Define HAVE_TERMIO if the system provides sysV-style ioctls
-   for terminal control.  */
-#define HAVE_TERMIO
-
-/* Define SYSV_SYSTEM_DIR to use the V.3 getdents/readir library
-   functions. Almost, but not quite the same as the 4.2 functions.  */
-#define SYSV_SYSTEM_DIR
-
-/* The file containing the kernel's symbol table is called /unix.  */
-#define KERNEL_FILE "/unix"
-
-/* The kernel symbol where the load average is found is named avenrun.  */
-#define LDAV_SYMBOL "avenrun"
-
-/* setjmp and longjmp can safely replace _setjmp and _longjmp,
-   but they will run slower.  */
-#define _setjmp setjmp
-#define _longjmp longjmp
-
-/* The docs for system V/386 suggest v.3 has sigpause, so let's try it.  */
-#define HAVE_SYSV_SIGPAUSE
-
-/* On USG systems signal handlers return void.  */
-#define SIGTYPE void
-
-#undef COFF
-
-/* Get FIONREAD from <sys/filio.h>.  Get <sys/ttold.h> to get struct tchars.
-   But get <termio.h> first to make sure ttold.h doesn't interfere.
-   And don't try to use SIGIO yet.  */
-#include <sys/wait.h>
-
-#ifdef emacs
-#include <sys/filio.h>
-#include <termio.h>
-#include <sys/ttold.h>
-#include <signal.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/termios.h>
-#define BROKEN_SIGIO
-#endif
-
-/* Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
-   instead, there's a system variable _sys_nsig.  Unfortunately, we need the
-   constant to dimension an array.  So wire in the appropriate value here.  */
-#define NSIG_MINIMUM 32
-
-/* We can support this.  */
-#define CLASH_DETECTION
-
-/* Define HAVE_PTYS if the system supports pty devices.  */
-#define HAVE_PTYS
-#define HAVE_TERMIOS
-
-/* It is possible to receive SIGCHLD when there are no children
-   waiting, because a previous waitsys(2) cleaned up the carcass of child
-   without clearing the SIGCHLD pending info.  So, use a non-blocking
-   wait3 instead, which maps to waitpid(2) in SysVr4. */
-#define wait3(status, options, rusage) \
-  waitpid ((pid_t) -1, (status), (options))
-#define WRETCODE(w) (w >> 8)
-
-/* TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
-   subprocesses the usual way.  But TIOCSIGNAL does work for PTYs, and
-   this is all we need.  */
-#define TIOCSIGSEND TIOCSIGNAL
-
-/* This change means that we don't loop through allocate_pty too many
-   times in the (rare) event of a failure.  */
-#define FIRST_PTY_LETTER 'z'
-
-/* This sets the name of the master side of the PTY.  */
-#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
-
-/* Push various streams modules onto a PTY channel.  */
-#define SETUP_SLAVE_PTY \
-  if (ioctl (xforkin, I_PUSH, "ptem") == -1)	\
-    fatal ("ioctl I_PUSH ptem", errno);		\
-  if (ioctl (xforkin, I_PUSH, "ldterm") == -1)	\
-    fatal ("ioctl I_PUSH ldterm", errno);	\
-  if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) \
-    fatal ("ioctl I_PUSH ttcompat", errno);
-
-/* This definition was suggested for next release.  So give it a try.  */
-#define HAVE_SOCKETS
-
-/* arch-tag: 1a0ed909-5faa-434b-b7c3-9d86c63d53a6
-   (do not change this comment) */
--- a/src/search.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/search.c	Mon Aug 09 10:51:16 2010 +0900
@@ -504,8 +504,6 @@
    This does not clobber the match data.
    We assume that STRING contains single-byte characters.  */
 
-extern Lisp_Object Vascii_downcase_table;
-
 int
 fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string)
 {
--- a/src/sound.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/sound.c	Mon Aug 09 10:51:16 2010 +0900
@@ -99,7 +99,6 @@
 
 /* Symbols.  */
 
-extern Lisp_Object QCfile, QCdata;
 Lisp_Object QCvolume, QCdevice;
 Lisp_Object Qsound;
 Lisp_Object Qplay_sound_functions;
--- a/src/sysdep.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/sysdep.c	Mon Aug 09 10:51:16 2010 +0900
@@ -96,8 +96,6 @@
 #include <memory.h>
 #endif /* USG */
 
-extern int quit_char;
-
 #include "keyboard.h"
 #include "frame.h"
 #include "window.h"
@@ -107,11 +105,12 @@
 #include "dispextern.h"
 #include "process.h"
 #include "cm.h"  /* for reset_sys_modes */
-
-/* For serial_configure and serial_open.  */
-extern Lisp_Object QCport, QCspeed, QCprocess;
-extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
-extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
+#ifdef HAVE_TERM_H
+/* Include this last.  If it is ncurses header file, it adds a lot of
+   defines that interfere with stuff in other headers.  Someone responsible
+   for ncurses messed up bigtime.  See bug#6812.  */
+#include <term.h>
+#endif
 
 #ifdef WINDOWSNT
 #include <direct.h>
@@ -503,17 +502,29 @@
   s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
 #endif /* AIX */
 
-  /* We used to enable ICANON (and set VEOF to 04), but this leads to
-     problems where process.c wants to send EOFs every once in a while
-     to force the output, which leads to weird effects when the
+  /* We originally enabled ICANON (and set VEOF to 04), and then had
+     proces.c send additional EOF chars to flush the output when faced
+     with long lines, but this leads to weird effects when the
      subprocess has disabled ICANON and ends up seeing those spurious
      extra EOFs.  So we don't send EOFs any more in
-     process.c:send_process, and instead we disable ICANON by default,
-     so if a subsprocess sets up ICANON, it's his problem (or the Elisp
-     package that talks to it) to deal with lines that are too long.  */
-  s.main.c_lflag &= ~ICANON;	/* Disable line editing and eof processing */
+     process.c:send_process.  First we tried to disable ICANON by
+     default, so if a subsprocess sets up ICANON, it's his problem (or
+     the Elisp package that talks to it) to deal with lines that are
+     too long.  But this disables some features, such as the ability
+     to send EOF signals.  So we re-enabled ICANON but there is no
+     more "send eof to flush" going on (which is wrong and unportable
+     in itself).  The correct way to handle too much output is to
+     buffer what could not be written and then write it again when
+     select returns ok for writing.  This has it own set of
+     problems.  Write is now asynchronous, is that a problem?  How much
+     do we buffer, and what do we do when that limit is reached?  */
+
+  s.main.c_lflag |= ICANON;	/* Enable line editing and eof processing */
+  s.main.c_cc[VEOF] = 'D'&037;	/* Control-D */
+#if 0	    /* These settings only apply to non-ICANON mode. */
   s.main.c_cc[VMIN] = 1;
   s.main.c_cc[VTIME] = 0;
+#endif
 
 #else /* not HAVE_TERMIO */
 
@@ -2447,7 +2458,7 @@
 
 /* Directory routines for systems that don't have them. */
 
-#ifdef SYSV_SYSTEM_DIR
+#ifdef HAVE_DIRENT_H
 
 #include <dirent.h>
 
@@ -2464,7 +2475,7 @@
   return rtnval;
 }
 #endif /* not HAVE_CLOSEDIR */
-#endif /* SYSV_SYSTEM_DIR */
+#endif /* HAVE_DIRENT_H */
 
 
 int
--- a/src/syssignal.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/syssignal.h	Mon Aug 09 10:51:16 2010 +0900
@@ -26,10 +26,6 @@
 #define FORWARD_SIGNAL_TO_MAIN_THREAD
 #endif
 
-#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
-extern pthread_t main_thread;
-#endif
-
 /* Don't #include <signal.h>.  That header should always be #included
    before "config.h", because some configuration files (like s/hpux.h)
    indicate that SIGIO doesn't work by #undef-ing SIGIO.  If this file
@@ -69,8 +65,6 @@
 #ifndef sigsetmask
 #define sigsetmask(SIG)  sys_sigsetmask (SIG)
 #endif
-#define sighold(SIG)     ONLY_USED_IN_BSD_4_1
-#define sigrelse(SIG)    ONLY_USED_IN_BSD_4_1
 #undef signal
 #define signal(SIG,ACT)      sys_signal(SIG,ACT)
 
@@ -85,27 +79,6 @@
 
 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
 
-#ifndef SIGMASKTYPE
-#define SIGMASKTYPE int
-#endif
-
-#ifndef SIGEMPTYMASK
-#define SIGEMPTYMASK (0)
-#endif
-
-#ifndef SIGFULLMASK
-#define SIGFULLMASK (0xffffffff)
-#endif
-
-#ifndef sigmask
-#define sigmask(no) (1L << ((no) - 1))
-#endif
-
-#ifndef sigunblock
-#define sigunblock(SIG) \
-{ SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
-#endif
-
 #define sigfree() sigsetmask (SIGEMPTYMASK)
 
 #if defined (SIGINFO) && defined (BROKEN_SIGINFO)
@@ -164,6 +137,7 @@
 #endif
 
 #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
+extern pthread_t main_thread;
 #define SIGNAL_THREAD_CHECK(signo)                                      \
   do {                                                                  \
     if (!pthread_equal (pthread_self (), main_thread))			\
--- a/src/systime.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/systime.h	Mon Aug 09 10:51:16 2010 +0900
@@ -147,6 +147,9 @@
 #ifdef GCPRO1
 /* defined in dired.c */
 extern Lisp_Object make_time (time_t);
+
+/* defined in editfns.c*/
+extern int lisp_time_argument (Lisp_Object, time_t *, int *);
 #endif
 
 /* Compare times T1 and T2.  Value is 0 if T1 and T2 are the same.
--- a/src/term.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/term.c	Mon Aug 09 10:51:16 2010 +0900
@@ -34,6 +34,9 @@
 #if HAVE_TERMIOS_H
 #include <termios.h>		/* For TIOCNOTTY. */
 #endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 
 #include <signal.h>
 #include <stdarg.h>
@@ -132,8 +135,6 @@
 
 /* Display space properties */
 
-extern Lisp_Object Qspace, QCalign_to, QCwidth;
-
 /* Functions to call after suspending a tty. */
 Lisp_Object Vsuspend_tty_functions;
 
@@ -712,7 +713,7 @@
 	    }
 	  else
 	    {
-	      unsigned char *p = SDATA (string), *pend = p + SBYTES (string);
+	      unsigned char *p = SDATA (string);
 
 	      if (! STRING_MULTIBYTE (string))
 		string = string_to_multibyte (string);
@@ -1121,7 +1122,6 @@
   return cost;
 }
 
-#ifndef old
 /* char_ins_del_cost[n] is cost of inserting N characters.
    char_ins_del_cost[-n] is cost of deleting N characters.
    The length of this vector is based on max_frame_cols.  */
@@ -1129,7 +1129,6 @@
 int *char_ins_del_vector;
 
 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_COLS ((f))])
-#endif
 
 /* ARGSUSED */
 static void
@@ -1267,7 +1266,7 @@
      other keys (as on the IBM PC keyboard) they get overridden.
   */
 
-static struct fkey_table keys[] =
+static const struct fkey_table keys[] =
 {
   {"kh", "home"},	/* termcap */
   {"kl", "left"},	/* termcap */
@@ -1383,7 +1382,6 @@
      function key specification, rather than giving the user an error and
      refusing to run at all on such a terminal.  */
 
-  extern Lisp_Object Fidentity (Lisp_Object);
   term_get_fkeys_address = address;
   term_get_fkeys_kboard = kboard;
   internal_condition_case (term_get_fkeys_1, Qerror, Fidentity);
@@ -1507,15 +1505,6 @@
 /***********************************************************************
 		       Character Display Information
  ***********************************************************************/
-
-/* Avoid name clash with functions defined in xterm.c */
-#ifdef static
-#define append_glyph append_glyph_term
-#define produce_stretch_glyph produce_stretch_glyph_term
-#define append_composite_glyph append_composite_glyph_term
-#define produce_composite_glyph produce_composite_glyph_term
-#endif
-
 static void append_glyph (struct it *);
 static void produce_stretch_glyph (struct it *);
 static void append_composite_glyph (struct it *);
@@ -1860,8 +1849,6 @@
 static void
 produce_composite_glyph (struct it *it)
 {
-  int c;
-
   if (it->cmp_it.ch < 0)
     {
       struct composition *cmp = composition_table[it->cmp_it.id];
@@ -2256,7 +2243,6 @@
   Lisp_Object tem, val;
   Lisp_Object color_mode;
   int mode;
-  extern Lisp_Object Qtty_color_mode;
   Lisp_Object tty_color_mode_alist
     = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil);
 
@@ -2795,7 +2781,6 @@
 
       /* Check for mouse-face.  */
       {
-	extern Lisp_Object Qmouse_face;
 	Lisp_Object mouse_face, overlay, position, *overlay_vec;
 	int noverlays, obegv, ozv;
 	struct buffer *obuf;
@@ -2921,7 +2906,6 @@
 	/* Look for a `help-echo' property.  */
 	{
 	  Lisp_Object help;
-	  extern Lisp_Object Qhelp_echo;
 
 	  /* Check overlays first.  */
 	  help = Qnil;
@@ -3350,7 +3334,7 @@
   EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
   if (pgid != -1)
     {
-#if defined (USG)
+#if defined (USG5)
       setpgrp ();
       no_controlling_tty = 1;
 #elif defined (CYGWIN)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/unexcoff.c	Mon Aug 09 10:51:16 2010 +0900
@@ -0,0 +1,665 @@
+/* Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 2001, 2002, 2003,
+                 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+/*
+ * unexcoff.c - Convert a running program into an a.out or COFF file.
+ *
+ * ==================================================================
+ * Note: This file is currently used only by the MSDOS (a.k.a. DJGPP)
+ * build of Emacs.  If you are not interested in the MSDOS build, you
+ * are looking at the wrong version of unexec!
+ * ==================================================================
+ *
+ * Author:	Spencer W. Thomas
+ * 		Computer Science Dept.
+ * 		University of Utah
+ * Date:	Tue Mar  2 1982
+ * Originally under the name unexec.c.
+ * Modified heavily since then.
+ *
+ * Synopsis:
+ *	unexec (new_name, a_name, data_start, bss_start, entry_address)
+ *	char *new_name, *a_name;
+ *	unsigned data_start, bss_start, entry_address;
+ *
+ * Takes a snapshot of the program and makes an a.out format file in the
+ * file named by the string argument new_name.
+ * If a_name is non-NULL, the symbol table will be taken from the given file.
+ * On some machines, an existing a_name file is required.
+ *
+ * The boundaries within the a.out file may be adjusted with the data_start
+ * and bss_start arguments.  Either or both may be given as 0 for defaults.
+ *
+ * Data_start gives the boundary between the text segment and the data
+ * segment of the program.  The text segment can contain shared, read-only
+ * program code and literal data, while the data segment is always unshared
+ * and unprotected.  Data_start gives the lowest unprotected address.
+ * The value you specify may be rounded down to a suitable boundary
+ * as required by the machine you are using.
+ *
+ * Specifying zero for data_start means the boundary between text and data
+ * should not be the same as when the program was loaded.
+ *
+ * Bss_start indicates how much of the data segment is to be saved in the
+ * a.out file and restored when the program is executed.  It gives the lowest
+ * unsaved address, and is rounded up to a page boundary.  The default when 0
+ * is given assumes that the entire data segment is to be stored, including
+ * the previous data and bss as well as any additional storage allocated with
+ * break (2).
+ *
+ * The new file is set up to start at entry_address.
+ *
+ * If you make improvements I'd like to get them too.
+ * harpo!utah-cs!thomas, thomas@Utah-20
+ *
+ */
+
+/* Modified to support SysVr3 shared libraries by James Van Artsdalen
+ * of Dell Computer Corporation.  james@bigtex.cactus.org.
+ */
+
+#ifndef emacs
+#define PERROR(arg) perror (arg); return -1
+#else
+#include <config.h>
+#define PERROR(file) report_error (file, new)
+#endif
+
+#ifndef CANNOT_DUMP  /* all rest of file!  */
+
+#ifdef HAVE_COFF_H
+#include <coff.h>
+#ifdef MSDOS
+#include <fcntl.h>  /* for O_RDONLY, O_RDWR */
+#include <crt0.h>   /* for _crt0_startup_flags and its bits */
+static int save_djgpp_startup_flags;
+#define filehdr external_filehdr
+#define scnhdr external_scnhdr
+#define syment external_syment
+#define auxent external_auxent
+#define n_numaux e_numaux
+#define n_type e_type
+struct aouthdr
+{
+  unsigned short	magic;	/* type of file				*/
+  unsigned short	vstamp;	/* version stamp			*/
+  unsigned long		tsize;	/* text size in bytes, padded to FW bdry*/
+  unsigned long		dsize;	/* initialized data "  "		*/
+  unsigned long		bsize;	/* uninitialized data "   "		*/
+  unsigned long		entry;	/* entry pt.				*/
+  unsigned long	 	text_start;/* base of text used for this file */
+  unsigned long	 	data_start;/* base of data used for this file */
+};
+#endif /* not MSDOS */
+#else  /* not HAVE_COFF_H */
+#include <a.out.h>
+#endif /* not HAVE_COFF_H */
+
+/* Define getpagesize if the system does not.
+   Note that this may depend on symbols defined in a.out.h.  */
+#include "getpagesize.h"
+
+#ifndef makedev			/* Try to detect types.h already loaded */
+#include <sys/types.h>
+#endif /* makedev */
+#include <stdio.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <sys/file.h>
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+#ifndef O_RDWR
+#define O_RDWR 2
+#endif
+
+
+extern char *start_of_text ();		/* Start of text */
+extern char *start_of_data ();		/* Start of initialized data */
+
+static long block_copy_start;		/* Old executable start point */
+static struct filehdr f_hdr;		/* File header */
+static struct aouthdr f_ohdr;		/* Optional file header (a.out) */
+long bias;			/* Bias to add for growth */
+long lnnoptr;			/* Pointer to line-number info within file */
+#define SYMS_START block_copy_start
+
+static long text_scnptr;
+static long data_scnptr;
+
+static long coff_offset;
+
+static int pagemask;
+
+/* Correct an int which is the bit pattern of a pointer to a byte
+   into an int which is the number of a byte.
+   This is a no-op on ordinary machines, but not on all.  */
+
+#define ADDR_CORRECT(x) ((char *)(x) - (char*)0)
+
+#ifdef emacs
+
+#include <setjmp.h>
+#include "lisp.h"
+
+static
+report_error (file, fd)
+     char *file;
+     int fd;
+{
+  if (fd)
+    close (fd);
+  report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
+}
+#endif /* emacs */
+
+#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
+#define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1
+#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1
+
+static
+report_error_1 (fd, msg, a1, a2)
+     int fd;
+     char *msg;
+     int a1, a2;
+{
+  close (fd);
+#ifdef emacs
+  error (msg, a1, a2);
+#else
+  fprintf (stderr, msg, a1, a2);
+  fprintf (stderr, "\n");
+#endif
+}
+
+static int make_hdr ();
+static int copy_text_and_data ();
+static int copy_sym ();
+static void mark_x ();
+
+/* ****************************************************************
+ * make_hdr
+ *
+ * Make the header in the new a.out from the header in core.
+ * Modify the text and data sizes.
+ */
+static int
+make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
+     int new, a_out;
+     unsigned data_start, bss_start, entry_address;
+     char *a_name;
+     char *new_name;
+{
+  int tem;
+  auto struct scnhdr f_thdr;		/* Text section header */
+  auto struct scnhdr f_dhdr;		/* Data section header */
+  auto struct scnhdr f_bhdr;		/* Bss section header */
+  auto struct scnhdr scntemp;		/* Temporary section header */
+  register int scns;
+  unsigned int bss_end;
+
+  pagemask = getpagesize () - 1;
+
+  /* Adjust text/data boundary. */
+  data_start = (int) start_of_data ();
+  data_start = ADDR_CORRECT (data_start);
+  data_start = data_start & ~pagemask; /* (Down) to page boundary. */
+
+  bss_end = ADDR_CORRECT (sbrk (0)) + pagemask;
+  bss_end &= ~ pagemask;
+
+  /* Adjust data/bss boundary. */
+  if (bss_start != 0)
+    {
+      bss_start = (ADDR_CORRECT (bss_start) + pagemask);
+      /* (Up) to page bdry. */
+      bss_start &= ~ pagemask;
+      if (bss_start > bss_end)
+	{
+	  ERROR1 ("unexec: Specified bss_start (%u) is past end of program",
+		  bss_start);
+	}
+    }
+  else
+    bss_start = bss_end;
+
+  if (data_start > bss_start)	/* Can't have negative data size. */
+    {
+      ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)",
+	      data_start, bss_start);
+    }
+
+  coff_offset = 0L;		/* stays zero, except in DJGPP */
+
+  /* Salvage as much info from the existing file as possible */
+  if (a_out >= 0)
+    {
+#ifdef MSDOS
+      /* Support the coff-go32-exe format with a prepended stub, since
+	 this is what GCC 2.8.0 and later generates by default in DJGPP.  */
+      unsigned short mz_header[3];
+
+      if (read (a_out, &mz_header, sizeof (mz_header)) != sizeof (mz_header))
+	{
+	  PERROR (a_name);
+	}
+      if (mz_header[0] == 0x5a4d || mz_header[0] == 0x4d5a) /* "MZ" or "ZM" */
+	{
+	  coff_offset = (long)mz_header[2] * 512L;
+	  if (mz_header[1])
+	    coff_offset += (long)mz_header[1] - 512L;
+	  lseek (a_out, coff_offset, 0);
+	}
+      else
+	lseek (a_out, 0L, 0);
+#endif /* MSDOS */
+      if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
+	{
+	  PERROR (a_name);
+	}
+      block_copy_start += sizeof (f_hdr);
+      if (f_hdr.f_opthdr > 0)
+	{
+	  if (read (a_out, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
+	    {
+	      PERROR (a_name);
+	    }
+	  block_copy_start += sizeof (f_ohdr);
+	}
+      /* Loop through section headers, copying them in */
+      lseek (a_out, coff_offset + sizeof (f_hdr) + f_hdr.f_opthdr, 0);
+      for (scns = f_hdr.f_nscns; scns > 0; scns--) {
+	if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
+	  {
+	    PERROR (a_name);
+	  }
+	if (scntemp.s_scnptr > 0L)
+	  {
+            if (block_copy_start < scntemp.s_scnptr + scntemp.s_size)
+	      block_copy_start = scntemp.s_scnptr + scntemp.s_size;
+	  }
+	if (strcmp (scntemp.s_name, ".text") == 0)
+	  {
+	    f_thdr = scntemp;
+	  }
+	else if (strcmp (scntemp.s_name, ".data") == 0)
+	  {
+	    f_dhdr = scntemp;
+	  }
+	else if (strcmp (scntemp.s_name, ".bss") == 0)
+	  {
+	    f_bhdr = scntemp;
+	  }
+      }
+    }
+  else
+    {
+      ERROR0 ("can't build a COFF file from scratch yet");
+    }
+
+  /* Now we alter the contents of all the f_*hdr variables
+     to correspond to what we want to dump.  */
+
+  f_hdr.f_flags |= (F_RELFLG | F_EXEC);
+  f_ohdr.text_start = (long) start_of_text ();
+  f_ohdr.tsize = data_start - f_ohdr.text_start;
+  f_ohdr.data_start = data_start;
+  f_ohdr.dsize = bss_start - f_ohdr.data_start;
+  f_ohdr.bsize = bss_end - bss_start;
+  f_thdr.s_size = f_ohdr.tsize;
+  f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr);
+  f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr));
+  lnnoptr = f_thdr.s_lnnoptr;
+  text_scnptr = f_thdr.s_scnptr;
+  f_dhdr.s_paddr = f_ohdr.data_start;
+  f_dhdr.s_vaddr = f_ohdr.data_start;
+  f_dhdr.s_size = f_ohdr.dsize;
+  f_dhdr.s_scnptr = f_thdr.s_scnptr + f_thdr.s_size;
+  data_scnptr = f_dhdr.s_scnptr;
+  f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize;
+  f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize;
+  f_bhdr.s_size = f_ohdr.bsize;
+  f_bhdr.s_scnptr = 0L;
+  bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start;
+
+  if (f_hdr.f_symptr > 0L)
+    {
+      f_hdr.f_symptr += bias;
+    }
+
+  if (f_thdr.s_lnnoptr > 0L)
+    {
+      f_thdr.s_lnnoptr += bias;
+    }
+
+  if (write (new, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
+    {
+      PERROR (new_name);
+    }
+
+  if (write (new, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
+    {
+      PERROR (new_name);
+    }
+
+  if (write (new, &f_thdr, sizeof (f_thdr)) != sizeof (f_thdr))
+    {
+      PERROR (new_name);
+    }
+
+  if (write (new, &f_dhdr, sizeof (f_dhdr)) != sizeof (f_dhdr))
+    {
+      PERROR (new_name);
+    }
+
+  if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr))
+    {
+      PERROR (new_name);
+    }
+
+  return (0);
+
+}
+
+write_segment (new, ptr, end)
+     int new;
+     register char *ptr, *end;
+{
+  register int i, nwrite, ret;
+  char buf[80];
+  /* This is the normal amount to write at once.
+     It is the size of block that NFS uses.  */
+  int writesize = 1 << 13;
+  int pagesize = getpagesize ();
+  char zeros[1 << 13];
+
+  memset (zeros, 0, sizeof (zeros));
+
+  for (i = 0; ptr < end;)
+    {
+      /* Distance to next multiple of writesize.  */
+      nwrite = (((int) ptr + writesize) & -writesize) - (int) ptr;
+      /* But not beyond specified end.  */
+      if (nwrite > end - ptr) nwrite = end - ptr;
+      ret = write (new, ptr, nwrite);
+      /* If write gets a page fault, it means we reached
+	 a gap between the old text segment and the old data segment.
+	 This gap has probably been remapped into part of the text segment.
+	 So write zeros for it.  */
+      if (ret == -1
+#ifdef EFAULT
+	  && errno == EFAULT
+#endif
+	  )
+	{
+	  /* Write only a page of zeros at once,
+	     so that we don't overshoot the start
+	     of the valid memory in the old data segment.  */
+	  if (nwrite > pagesize)
+	    nwrite = pagesize;
+	  write (new, zeros, nwrite);
+	}
+#if 0 /* Now that we have can ask `write' to write more than a page,
+	 it is legit for write do less than the whole amount specified.  */
+      else if (nwrite != ret)
+	{
+	  sprintf (buf,
+		   "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
+		   ptr, new, nwrite, ret, errno);
+	  PERROR (buf);
+	}
+#endif
+      i += nwrite;
+      ptr += nwrite;
+    }
+}
+/* ****************************************************************
+ * copy_text_and_data
+ *
+ * Copy the text and data segments from memory to the new a.out
+ */
+static int
+copy_text_and_data (new, a_out)
+     int new, a_out;
+{
+  register char *end;
+  register char *ptr;
+
+#ifdef MSDOS
+  /* Dump the original table of exception handlers, not the one
+     where our exception hooks are registered.  */
+  __djgpp_exception_toggle ();
+
+  /* Switch off startup flags that might have been set at runtime
+     and which might change the way that dumped Emacs works.  */
+  save_djgpp_startup_flags = _crt0_startup_flags;
+  _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR);
+#endif
+
+  lseek (new, (long) text_scnptr, 0);
+  ptr = (char *) f_ohdr.text_start;
+  end = ptr + f_ohdr.tsize;
+  write_segment (new, ptr, end);
+
+  lseek (new, (long) data_scnptr, 0);
+  ptr = (char *) f_ohdr.data_start;
+  end = ptr + f_ohdr.dsize;
+  write_segment (new, ptr, end);
+
+#ifdef MSDOS
+  /* Restore our exception hooks.  */
+  __djgpp_exception_toggle ();
+
+  /* Restore the startup flags.  */
+  _crt0_startup_flags = save_djgpp_startup_flags;
+#endif
+
+
+  return 0;
+}
+
+/* ****************************************************************
+ * copy_sym
+ *
+ * Copy the relocation information and symbol table from the a.out to the new
+ */
+static int
+copy_sym (new, a_out, a_name, new_name)
+     int new, a_out;
+     char *a_name, *new_name;
+{
+  char page[1024];
+  int n;
+
+  if (a_out < 0)
+    return 0;
+
+  if (SYMS_START == 0L)
+    return 0;
+
+  if (lnnoptr)			/* if there is line number info */
+    lseek (a_out, coff_offset + lnnoptr, 0);	/* start copying from there */
+  else
+    lseek (a_out, coff_offset + SYMS_START, 0);	/* Position a.out to symtab. */
+
+  while ((n = read (a_out, page, sizeof page)) > 0)
+    {
+      if (write (new, page, n) != n)
+	{
+	  PERROR (new_name);
+	}
+    }
+  if (n < 0)
+    {
+      PERROR (a_name);
+    }
+  return 0;
+}
+
+/* ****************************************************************
+ * mark_x
+ *
+ * After successfully building the new a.out, mark it executable
+ */
+static void
+mark_x (name)
+     char *name;
+{
+  struct stat sbuf;
+  int um;
+  int new = 0;  /* for PERROR */
+
+  um = umask (777);
+  umask (um);
+  if (stat (name, &sbuf) == -1)
+    {
+      PERROR (name);
+    }
+  sbuf.st_mode |= 0111 & ~um;
+  if (chmod (name, sbuf.st_mode) == -1)
+    PERROR (name);
+}
+
+
+/*
+ *	If the COFF file contains a symbol table and a line number section,
+ *	then any auxiliary entries that have values for x_lnnoptr must
+ *	be adjusted by the amount that the line number section has moved
+ *	in the file (bias computed in make_hdr).  The #@$%&* designers of
+ *	the auxiliary entry structures used the absolute file offsets for
+ *	the line number entry rather than an offset from the start of the
+ *	line number section!
+ *
+ *	When I figure out how to scan through the symbol table and pick out
+ *	the auxiliary entries that need adjustment, this routine will
+ *	be fixed.  As it is now, all such entries are wrong and sdb
+ *	will complain.   Fred Fish, UniSoft Systems Inc.
+ */
+
+/* This function is probably very slow.  Instead of reopening the new
+   file for input and output it should copy from the old to the new
+   using the two descriptors already open (WRITEDESC and READDESC).
+   Instead of reading one small structure at a time it should use
+   a reasonable size buffer.  But I don't have time to work on such
+   things, so I am installing it as submitted to me.  -- RMS.  */
+
+adjust_lnnoptrs (writedesc, readdesc, new_name)
+     int writedesc;
+     int readdesc;
+     char *new_name;
+{
+  register int nsyms;
+  register int new;
+  struct syment symentry;
+  union auxent auxentry;
+
+  if (!lnnoptr || !f_hdr.f_symptr)
+    return 0;
+
+#ifdef MSDOS
+  if ((new = writedesc) < 0)
+#else
+  if ((new = open (new_name, O_RDWR)) < 0)
+#endif
+    {
+      PERROR (new_name);
+      return -1;
+    }
+
+  lseek (new, f_hdr.f_symptr, 0);
+  for (nsyms = 0; nsyms < f_hdr.f_nsyms; nsyms++)
+    {
+      read (new, &symentry, SYMESZ);
+      if (symentry.n_numaux)
+	{
+	  read (new, &auxentry, AUXESZ);
+	  nsyms++;
+	  if (ISFCN (symentry.n_type) || symentry.n_type == 0x2400)
+	    {
+	      auxentry.x_sym.x_fcnary.x_fcn.x_lnnoptr += bias;
+	      lseek (new, -AUXESZ, 1);
+	      write (new, &auxentry, AUXESZ);
+	    }
+	}
+    }
+#ifndef MSDOS
+  close (new);
+#endif
+  return 0;
+}
+
+extern unsigned start __asm__ ("start");
+
+/*
+ *	Return the address of the start of the text segment prior to
+ *	doing an unexec.  After unexec the return value is undefined.
+ *	See crt0.c for further explanation and _start.
+ *
+ */
+
+char *
+start_of_text (void)
+{
+  return ((char *) &start);
+}
+
+/* ****************************************************************
+ * unexec
+ *
+ * driving logic.
+ */
+unexec (new_name, a_name, data_start, bss_start, entry_address)
+     char *new_name, *a_name;
+     unsigned data_start, bss_start, entry_address;
+{
+  int new, a_out = -1;
+
+  if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
+    {
+      PERROR (a_name);
+    }
+  if ((new = creat (new_name, 0666)) < 0)
+    {
+      PERROR (new_name);
+    }
+
+  if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0
+      || copy_text_and_data (new, a_out) < 0
+      || copy_sym (new, a_out, a_name, new_name) < 0
+      || adjust_lnnoptrs (new, a_out, new_name) < 0
+      )
+    {
+      close (new);
+      /* unlink (new_name);	    	/* Failed, unlink new a.out */
+      return -1;
+    }
+
+  close (new);
+  if (a_out >= 0)
+    close (a_out);
+  mark_x (new_name);
+  return 0;
+}
+
+#endif /* not CANNOT_DUMP */
+
+/* arch-tag: 62409b69-e27a-4a7c-9413-0210d6b54e7f
+   (do not change this comment) */
--- a/src/unexec.c	Mon Jul 26 13:29:08 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,746 +0,0 @@
-/* Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
-
-
-/*
- * unexec.c - Convert a running program into an a.out file.
- *
- * Author:	Spencer W. Thomas
- * 		Computer Science Dept.
- * 		University of Utah
- * Date:	Tue Mar  2 1982
- * Modified heavily since then.
- *
- * Synopsis:
- *	unexec (new_name, a_name, data_start, bss_start, entry_address)
- *	char *new_name, *a_name;
- *	unsigned data_start, bss_start, entry_address;
- *
- * Takes a snapshot of the program and makes an a.out format file in the
- * file named by the string argument new_name.
- * If a_name is non-NULL, the symbol table will be taken from the given file.
- * On some machines, an existing a_name file is required.
- *
- * The boundaries within the a.out file may be adjusted with the data_start
- * and bss_start arguments.  Either or both may be given as 0 for defaults.
- *
- * Data_start gives the boundary between the text segment and the data
- * segment of the program.  The text segment can contain shared, read-only
- * program code and literal data, while the data segment is always unshared
- * and unprotected.  Data_start gives the lowest unprotected address.
- * The value you specify may be rounded down to a suitable boundary
- * as required by the machine you are using.
- *
- * Specifying zero for data_start means the boundary between text and data
- * should not be the same as when the program was loaded.
- * If NO_REMAP is defined, the argument data_start is ignored and the
- * segment boundaries are never changed.
- *
- * Bss_start indicates how much of the data segment is to be saved in the
- * a.out file and restored when the program is executed.  It gives the lowest
- * unsaved address, and is rounded up to a page boundary.  The default when 0
- * is given assumes that the entire data segment is to be stored, including
- * the previous data and bss as well as any additional storage allocated with
- * break (2).
- *
- * The new file is set up to start at entry_address.
- *
- * If you make improvements I'd like to get them too.
- * harpo!utah-cs!thomas, thomas@Utah-20
- *
- */
-
-/* Modified to support SysVr3 shared libraries by James Van Artsdalen
- * of Dell Computer Corporation.  james@bigtex.cactus.org.
- */
-
-/* There are several compilation parameters affecting unexec:
-
-* COFF
-
-Define this if your system uses COFF for executables.
-
-* NO_REMAP
-
-Define this if you do not want to try to save Emacs's pure data areas
-as part of the text segment.
-
-Saving them as text is good because it allows users to share more.
-
-However, on machines that locate the text area far from the data area,
-the boundary cannot feasibly be moved.  Such machines require
-NO_REMAP.
-
-Also, remapping can cause trouble with the built-in startup routine
-/lib/crt0.o, which defines `environ' as an initialized variable.
-Dumping `environ' as pure does not work!  So, to use remapping,
-you must write a startup routine for your machine in Emacs's crt0.c.
-If NO_REMAP is defined, Emacs uses the system's crt0.o.
-
-* SECTION_ALIGNMENT
-
-Some machines that use COFF executables require that each section
-start on a certain boundary *in the COFF file*.  Such machines should
-define SECTION_ALIGNMENT to a mask of the low-order bits that must be
-zero on such a boundary.  This mask is used to control padding between
-segments in the COFF file.
-
-If SECTION_ALIGNMENT is not defined, the segments are written
-consecutively with no attempt at alignment.  This is right for
-unmodified system V.
-
-* SEGMENT_MASK
-
-Some machines require that the beginnings and ends of segments
-*in core* be on certain boundaries.  For most machines, a page
-boundary is sufficient.  That is the default.  When a larger
-boundary is needed, define SEGMENT_MASK to a mask of
-the bits that must be zero on such a boundary.
-
-* ADJUST_EXEC_HEADER
-
-This macro can be used to generate statements to adjust or
-initialize nonstandard fields in the file header
-
-*/
-
-#ifndef emacs
-#define PERROR(arg) perror (arg); return -1
-#else
-#include <config.h>
-#define PERROR(file) report_error (file, new)
-#endif
-
-#ifndef CANNOT_DUMP  /* all rest of file!  */
-
-#ifdef HAVE_COFF_H
-#include <coff.h>
-#ifdef MSDOS
-#include <fcntl.h>  /* for O_RDONLY, O_RDWR */
-#include <crt0.h>   /* for _crt0_startup_flags and its bits */
-static int save_djgpp_startup_flags;
-#define filehdr external_filehdr
-#define scnhdr external_scnhdr
-#define syment external_syment
-#define auxent external_auxent
-#define n_numaux e_numaux
-#define n_type e_type
-struct aouthdr
-{
-  unsigned short	magic;	/* type of file				*/
-  unsigned short	vstamp;	/* version stamp			*/
-  unsigned long		tsize;	/* text size in bytes, padded to FW bdry*/
-  unsigned long		dsize;	/* initialized data "  "		*/
-  unsigned long		bsize;	/* uninitialized data "   "		*/
-  unsigned long		entry;	/* entry pt.				*/
-  unsigned long	 	text_start;/* base of text used for this file */
-  unsigned long	 	data_start;/* base of data used for this file */
-};
-#endif /* not MSDOS */
-#else  /* not HAVE_COFF_H */
-#include <a.out.h>
-#endif /* not HAVE_COFF_H */
-
-/* Define getpagesize if the system does not.
-   Note that this may depend on symbols defined in a.out.h.  */
-#include "getpagesize.h"
-
-#ifndef makedev			/* Try to detect types.h already loaded */
-#include <sys/types.h>
-#endif /* makedev */
-#include <stdio.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <sys/file.h>
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-
-
-extern char *start_of_text ();		/* Start of text */
-extern char *start_of_data ();		/* Start of initialized data */
-
-static long block_copy_start;		/* Old executable start point */
-static struct filehdr f_hdr;		/* File header */
-static struct aouthdr f_ohdr;		/* Optional file header (a.out) */
-long bias;			/* Bias to add for growth */
-long lnnoptr;			/* Pointer to line-number info within file */
-#define SYMS_START block_copy_start
-
-static long text_scnptr;
-static long data_scnptr;
-
-static long coff_offset;
-
-static int pagemask;
-
-/* Correct an int which is the bit pattern of a pointer to a byte
-   into an int which is the number of a byte.
-   This is a no-op on ordinary machines, but not on all.  */
-
-#define ADDR_CORRECT(x) ((char *)(x) - (char*)0)
-
-#ifdef emacs
-
-#include <setjmp.h>
-#include "lisp.h"
-
-static
-report_error (file, fd)
-     char *file;
-     int fd;
-{
-  if (fd)
-    close (fd);
-  report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
-}
-#endif /* emacs */
-
-#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
-#define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1
-#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1
-
-static
-report_error_1 (fd, msg, a1, a2)
-     int fd;
-     char *msg;
-     int a1, a2;
-{
-  close (fd);
-#ifdef emacs
-  error (msg, a1, a2);
-#else
-  fprintf (stderr, msg, a1, a2);
-  fprintf (stderr, "\n");
-#endif
-}
-
-static int make_hdr ();
-static int copy_text_and_data ();
-static int copy_sym ();
-static void mark_x ();
-
-/* ****************************************************************
- * make_hdr
- *
- * Make the header in the new a.out from the header in core.
- * Modify the text and data sizes.
- */
-static int
-make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
-     int new, a_out;
-     unsigned data_start, bss_start, entry_address;
-     char *a_name;
-     char *new_name;
-{
-  int tem;
-  auto struct scnhdr f_thdr;		/* Text section header */
-  auto struct scnhdr f_dhdr;		/* Data section header */
-  auto struct scnhdr f_bhdr;		/* Bss section header */
-  auto struct scnhdr scntemp;		/* Temporary section header */
-  register int scns;
-  unsigned int bss_end;
-
-  pagemask = getpagesize () - 1;
-
-  /* Adjust text/data boundary. */
-#ifdef NO_REMAP
-  data_start = (int) start_of_data ();
-#else /* not NO_REMAP */
-  if (!data_start)
-    data_start = (int) start_of_data ();
-#endif /* not NO_REMAP */
-  data_start = ADDR_CORRECT (data_start);
-
-#ifdef SEGMENT_MASK
-  data_start = data_start & ~SEGMENT_MASK; /* (Down) to segment boundary. */
-#else
-  data_start = data_start & ~pagemask; /* (Down) to page boundary. */
-#endif
-
-  bss_end = ADDR_CORRECT (sbrk (0)) + pagemask;
-  bss_end &= ~ pagemask;
-
-  /* Adjust data/bss boundary. */
-  if (bss_start != 0)
-    {
-      bss_start = (ADDR_CORRECT (bss_start) + pagemask);
-      /* (Up) to page bdry. */
-      bss_start &= ~ pagemask;
-      if (bss_start > bss_end)
-	{
-	  ERROR1 ("unexec: Specified bss_start (%u) is past end of program",
-		  bss_start);
-	}
-    }
-  else
-    bss_start = bss_end;
-
-  if (data_start > bss_start)	/* Can't have negative data size. */
-    {
-      ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)",
-	      data_start, bss_start);
-    }
-
-  coff_offset = 0L;		/* stays zero, except in DJGPP */
-
-  /* Salvage as much info from the existing file as possible */
-  if (a_out >= 0)
-    {
-#ifdef MSDOS
-      /* Support the coff-go32-exe format with a prepended stub, since
-	 this is what GCC 2.8.0 and later generates by default in DJGPP.  */
-      unsigned short mz_header[3];
-
-      if (read (a_out, &mz_header, sizeof (mz_header)) != sizeof (mz_header))
-	{
-	  PERROR (a_name);
-	}
-      if (mz_header[0] == 0x5a4d || mz_header[0] == 0x4d5a) /* "MZ" or "ZM" */
-	{
-	  coff_offset = (long)mz_header[2] * 512L;
-	  if (mz_header[1])
-	    coff_offset += (long)mz_header[1] - 512L;
-	  lseek (a_out, coff_offset, 0);
-	}
-      else
-	lseek (a_out, 0L, 0);
-#endif /* MSDOS */
-      if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
-	{
-	  PERROR (a_name);
-	}
-      block_copy_start += sizeof (f_hdr);
-      if (f_hdr.f_opthdr > 0)
-	{
-	  if (read (a_out, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
-	    {
-	      PERROR (a_name);
-	    }
-	  block_copy_start += sizeof (f_ohdr);
-	}
-      /* Loop through section headers, copying them in */
-      lseek (a_out, coff_offset + sizeof (f_hdr) + f_hdr.f_opthdr, 0);
-      for (scns = f_hdr.f_nscns; scns > 0; scns--) {
-	if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
-	  {
-	    PERROR (a_name);
-	  }
-	if (scntemp.s_scnptr > 0L)
-	  {
-            if (block_copy_start < scntemp.s_scnptr + scntemp.s_size)
-	      block_copy_start = scntemp.s_scnptr + scntemp.s_size;
-	  }
-	if (strcmp (scntemp.s_name, ".text") == 0)
-	  {
-	    f_thdr = scntemp;
-	  }
-	else if (strcmp (scntemp.s_name, ".data") == 0)
-	  {
-	    f_dhdr = scntemp;
-	  }
-	else if (strcmp (scntemp.s_name, ".bss") == 0)
-	  {
-	    f_bhdr = scntemp;
-	  }
-      }
-    }
-  else
-    {
-      ERROR0 ("can't build a COFF file from scratch yet");
-    }
-
-  /* Now we alter the contents of all the f_*hdr variables
-     to correspond to what we want to dump.  */
-
-  f_hdr.f_flags |= (F_RELFLG | F_EXEC);
-#ifndef NO_REMAP
-  f_ohdr.text_start = (long) start_of_text ();
-  f_ohdr.tsize = data_start - f_ohdr.text_start;
-  f_ohdr.data_start = data_start;
-#endif /* NO_REMAP */
-  f_ohdr.dsize = bss_start - f_ohdr.data_start;
-  f_ohdr.bsize = bss_end - bss_start;
-  /* On some machines, the old values are right.
-     ??? Maybe on all machines with NO_REMAP.  */
-  f_thdr.s_size = f_ohdr.tsize;
-  f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr);
-  f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr));
-  lnnoptr = f_thdr.s_lnnoptr;
-#ifdef SECTION_ALIGNMENT
-  /* Some systems require special alignment
-     of the sections in the file itself.  */
-  f_thdr.s_scnptr
-    = (f_thdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT;
-#endif /* SECTION_ALIGNMENT */
-  text_scnptr = f_thdr.s_scnptr;
-  f_dhdr.s_paddr = f_ohdr.data_start;
-  f_dhdr.s_vaddr = f_ohdr.data_start;
-  f_dhdr.s_size = f_ohdr.dsize;
-  f_dhdr.s_scnptr = f_thdr.s_scnptr + f_thdr.s_size;
-#ifdef SECTION_ALIGNMENT
-  /* Some systems require special alignment
-     of the sections in the file itself.  */
-  f_dhdr.s_scnptr
-    = (f_dhdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT;
-#endif /* SECTION_ALIGNMENT */
-#ifdef DATA_SECTION_ALIGNMENT
-  /* Some systems require special alignment
-     of the data section only.  */
-  f_dhdr.s_scnptr
-    = (f_dhdr.s_scnptr + DATA_SECTION_ALIGNMENT) & ~DATA_SECTION_ALIGNMENT;
-#endif /* DATA_SECTION_ALIGNMENT */
-  data_scnptr = f_dhdr.s_scnptr;
-  f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize;
-  f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize;
-  f_bhdr.s_size = f_ohdr.bsize;
-  f_bhdr.s_scnptr = 0L;
-  bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start;
-
-  if (f_hdr.f_symptr > 0L)
-    {
-      f_hdr.f_symptr += bias;
-    }
-
-  if (f_thdr.s_lnnoptr > 0L)
-    {
-      f_thdr.s_lnnoptr += bias;
-    }
-
-#ifdef ADJUST_EXEC_HEADER
-  ADJUST_EXEC_HEADER;
-#endif /* ADJUST_EXEC_HEADER */
-
-  if (write (new, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
-    {
-      PERROR (new_name);
-    }
-
-  if (write (new, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
-    {
-      PERROR (new_name);
-    }
-
-  if (write (new, &f_thdr, sizeof (f_thdr)) != sizeof (f_thdr))
-    {
-      PERROR (new_name);
-    }
-
-  if (write (new, &f_dhdr, sizeof (f_dhdr)) != sizeof (f_dhdr))
-    {
-      PERROR (new_name);
-    }
-
-  if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr))
-    {
-      PERROR (new_name);
-    }
-
-  return (0);
-
-}
-
-write_segment (new, ptr, end)
-     int new;
-     register char *ptr, *end;
-{
-  register int i, nwrite, ret;
-  char buf[80];
-  /* This is the normal amount to write at once.
-     It is the size of block that NFS uses.  */
-  int writesize = 1 << 13;
-  int pagesize = getpagesize ();
-  char zeros[1 << 13];
-
-  memset (zeros, 0, sizeof (zeros));
-
-  for (i = 0; ptr < end;)
-    {
-      /* Distance to next multiple of writesize.  */
-      nwrite = (((int) ptr + writesize) & -writesize) - (int) ptr;
-      /* But not beyond specified end.  */
-      if (nwrite > end - ptr) nwrite = end - ptr;
-      ret = write (new, ptr, nwrite);
-      /* If write gets a page fault, it means we reached
-	 a gap between the old text segment and the old data segment.
-	 This gap has probably been remapped into part of the text segment.
-	 So write zeros for it.  */
-      if (ret == -1
-#ifdef EFAULT
-	  && errno == EFAULT
-#endif
-	  )
-	{
-	  /* Write only a page of zeros at once,
-	     so that we don't overshoot the start
-	     of the valid memory in the old data segment.  */
-	  if (nwrite > pagesize)
-	    nwrite = pagesize;
-	  write (new, zeros, nwrite);
-	}
-#if 0 /* Now that we have can ask `write' to write more than a page,
-	 it is legit for write do less than the whole amount specified.  */
-      else if (nwrite != ret)
-	{
-	  sprintf (buf,
-		   "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
-		   ptr, new, nwrite, ret, errno);
-	  PERROR (buf);
-	}
-#endif
-      i += nwrite;
-      ptr += nwrite;
-    }
-}
-/* ****************************************************************
- * copy_text_and_data
- *
- * Copy the text and data segments from memory to the new a.out
- */
-static int
-copy_text_and_data (new, a_out)
-     int new, a_out;
-{
-  register char *end;
-  register char *ptr;
-
-#ifdef MSDOS
-  /* Dump the original table of exception handlers, not the one
-     where our exception hooks are registered.  */
-  __djgpp_exception_toggle ();
-
-  /* Switch off startup flags that might have been set at runtime
-     and which might change the way that dumped Emacs works.  */
-  save_djgpp_startup_flags = _crt0_startup_flags;
-  _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR);
-#endif
-
-  lseek (new, (long) text_scnptr, 0);
-  ptr = (char *) f_ohdr.text_start;
-  end = ptr + f_ohdr.tsize;
-  write_segment (new, ptr, end);
-
-  lseek (new, (long) data_scnptr, 0);
-  ptr = (char *) f_ohdr.data_start;
-  end = ptr + f_ohdr.dsize;
-  write_segment (new, ptr, end);
-
-#ifdef MSDOS
-  /* Restore our exception hooks.  */
-  __djgpp_exception_toggle ();
-
-  /* Restore the startup flags.  */
-  _crt0_startup_flags = save_djgpp_startup_flags;
-#endif
-
-
-  return 0;
-}
-
-/* ****************************************************************
- * copy_sym
- *
- * Copy the relocation information and symbol table from the a.out to the new
- */
-static int
-copy_sym (new, a_out, a_name, new_name)
-     int new, a_out;
-     char *a_name, *new_name;
-{
-  char page[1024];
-  int n;
-
-  if (a_out < 0)
-    return 0;
-
-  if (SYMS_START == 0L)
-    return 0;
-
-  if (lnnoptr)			/* if there is line number info */
-    lseek (a_out, coff_offset + lnnoptr, 0);	/* start copying from there */
-  else
-    lseek (a_out, coff_offset + SYMS_START, 0);	/* Position a.out to symtab. */
-
-  while ((n = read (a_out, page, sizeof page)) > 0)
-    {
-      if (write (new, page, n) != n)
-	{
-	  PERROR (new_name);
-	}
-    }
-  if (n < 0)
-    {
-      PERROR (a_name);
-    }
-  return 0;
-}
-
-/* ****************************************************************
- * mark_x
- *
- * After successfully building the new a.out, mark it executable
- */
-static void
-mark_x (name)
-     char *name;
-{
-  struct stat sbuf;
-  int um;
-  int new = 0;  /* for PERROR */
-
-  um = umask (777);
-  umask (um);
-  if (stat (name, &sbuf) == -1)
-    {
-      PERROR (name);
-    }
-  sbuf.st_mode |= 0111 & ~um;
-  if (chmod (name, sbuf.st_mode) == -1)
-    PERROR (name);
-}
-
-
-/*
- *	If the COFF file contains a symbol table and a line number section,
- *	then any auxiliary entries that have values for x_lnnoptr must
- *	be adjusted by the amount that the line number section has moved
- *	in the file (bias computed in make_hdr).  The #@$%&* designers of
- *	the auxiliary entry structures used the absolute file offsets for
- *	the line number entry rather than an offset from the start of the
- *	line number section!
- *
- *	When I figure out how to scan through the symbol table and pick out
- *	the auxiliary entries that need adjustment, this routine will
- *	be fixed.  As it is now, all such entries are wrong and sdb
- *	will complain.   Fred Fish, UniSoft Systems Inc.
- */
-
-/* This function is probably very slow.  Instead of reopening the new
-   file for input and output it should copy from the old to the new
-   using the two descriptors already open (WRITEDESC and READDESC).
-   Instead of reading one small structure at a time it should use
-   a reasonable size buffer.  But I don't have time to work on such
-   things, so I am installing it as submitted to me.  -- RMS.  */
-
-adjust_lnnoptrs (writedesc, readdesc, new_name)
-     int writedesc;
-     int readdesc;
-     char *new_name;
-{
-  register int nsyms;
-  register int new;
-  struct syment symentry;
-  union auxent auxentry;
-
-  if (!lnnoptr || !f_hdr.f_symptr)
-    return 0;
-
-#ifdef MSDOS
-  if ((new = writedesc) < 0)
-#else
-  if ((new = open (new_name, O_RDWR)) < 0)
-#endif
-    {
-      PERROR (new_name);
-      return -1;
-    }
-
-  lseek (new, f_hdr.f_symptr, 0);
-  for (nsyms = 0; nsyms < f_hdr.f_nsyms; nsyms++)
-    {
-      read (new, &symentry, SYMESZ);
-      if (symentry.n_numaux)
-	{
-	  read (new, &auxentry, AUXESZ);
-	  nsyms++;
-	  if (ISFCN (symentry.n_type) || symentry.n_type == 0x2400)
-	    {
-	      auxentry.x_sym.x_fcnary.x_fcn.x_lnnoptr += bias;
-	      lseek (new, -AUXESZ, 1);
-	      write (new, &auxentry, AUXESZ);
-	    }
-	}
-    }
-#ifndef MSDOS
-  close (new);
-#endif
-  return 0;
-}
-
-extern unsigned start __asm__ ("start");
-
-/*
- *	Return the address of the start of the text segment prior to
- *	doing an unexec.  After unexec the return value is undefined.
- *	See crt0.c for further explanation and _start.
- *
- */
-
-char *
-start_of_text (void)
-{
-  return ((char *) &start);
-}
-
-/* ****************************************************************
- * unexec
- *
- * driving logic.
- */
-unexec (new_name, a_name, data_start, bss_start, entry_address)
-     char *new_name, *a_name;
-     unsigned data_start, bss_start, entry_address;
-{
-  int new, a_out = -1;
-
-  if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
-    {
-      PERROR (a_name);
-    }
-  if ((new = creat (new_name, 0666)) < 0)
-    {
-      PERROR (new_name);
-    }
-
-  if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0
-      || copy_text_and_data (new, a_out) < 0
-      || copy_sym (new, a_out, a_name, new_name) < 0
-      || adjust_lnnoptrs (new, a_out, new_name) < 0
-      )
-    {
-      close (new);
-      /* unlink (new_name);	    	/* Failed, unlink new a.out */
-      return -1;
-    }
-
-  close (new);
-  if (a_out >= 0)
-    close (a_out);
-  mark_x (new_name);
-  return 0;
-}
-
-#endif /* not CANNOT_DUMP */
-
-/* arch-tag: 62409b69-e27a-4a7c-9413-0210d6b54e7f
-   (do not change this comment) */
--- a/src/unexmacosx.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/unexmacosx.c	Mon Aug 09 10:51:16 2010 +0900
@@ -305,7 +305,7 @@
 }
 
 static void
-print_region_list ()
+print_region_list (void)
 {
   struct region_t *r;
 
@@ -316,7 +316,7 @@
 }
 
 static void
-print_regions ()
+print_regions (void)
 {
   task_t target_task = mach_task_self ();
   vm_address_t address = (vm_address_t) 0;
@@ -346,7 +346,7 @@
    cannot be omitted because they some regions created at run time are
    read-only.  */
 static void
-build_region_list ()
+build_region_list (void)
 {
   task_t target_task = mach_task_self ();
   vm_address_t address = (vm_address_t) 0;
@@ -465,7 +465,7 @@
 }
 
 static void
-find_emacs_zone_regions ()
+find_emacs_zone_regions (void)
 {
   num_unexec_regions = 0;
 
@@ -495,7 +495,7 @@
 }
 
 static void
-unexec_regions_merge ()
+unexec_regions_merge (void)
 {
   int i, n;
   unexec_region_info r;
@@ -627,7 +627,7 @@
    the global array lca.  Store the total number of load commands in
    global variable nlc.  */
 static void
-read_load_commands ()
+read_load_commands (void)
 {
   int i;
 
@@ -684,8 +684,8 @@
 	}
     }
 
-  printf ("Highest address of load commands in input file: %#8x\n",
-	  infile_lc_highest_addr);
+  printf ("Highest address of load commands in input file: %#8lx\n",
+	  (unsigned long)infile_lc_highest_addr);
 
   printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n",
 	  text_seg_lowest_offset);
@@ -1143,7 +1143,7 @@
 /* Loop through all load commands and dump them.  Then write the Mach
    header.  */
 static void
-dump_it ()
+dump_it (void)
 {
   int i;
   long linkedit_delta = 0;
@@ -1253,7 +1253,7 @@
 
 
 void
-unexec_init_emacs_zone ()
+unexec_init_emacs_zone (void)
 {
   emacs_zone = malloc_create_zone (0, 0);
   malloc_set_zone_name (emacs_zone, "EmacsZone");
--- a/src/vm-limit.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/vm-limit.c	Mon Aug 09 10:51:16 2010 +0900
@@ -25,10 +25,6 @@
 
 #include "mem-limits.h"
 
-#ifdef HAVE_GETRLIMIT
-#include <sys/resource.h>
-#endif
-
 /*
   Level number of warnings already issued.
   0 -- no warnings issued.
@@ -37,8 +33,9 @@
   3 -- 95% warning issued; keep warning frequently.
 */
 enum warnlevel { not_warned, warned_75, warned_85, warned_95 };
+static enum warnlevel warnlevel;
 
-static enum warnlevel warnlevel;
+typedef POINTER_TYPE *POINTER;
 
 /* Function to call to issue a warning;
    0 means don't issue them.  */
@@ -100,7 +97,7 @@
 }
 
 #else
-#if !defined (BSD4_2) && !defined (__osf__) && !defined (CYGWIN)
+#if !defined (BSD4_2) && !defined (CYGWIN)
 
 #ifdef MSDOS
 void
@@ -148,7 +145,7 @@
 }
 #endif /* not MSDOS */
 
-#else /* BSD4_2 */
+#else /* BSD4_2 || CYGWIN */
 
 static void
 get_lim_data (void)
@@ -260,7 +257,7 @@
  *
  */
 
-POINTER
+char *
 start_of_data (void)
 {
 #ifdef BSD_SYSTEM
--- a/src/w32.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/w32.c	Mon Aug 09 10:51:16 2010 +0900
@@ -140,10 +140,6 @@
 
 /* For serial_configure and serial_open.  */
 #include "process.h"
-/* From process.c  */
-extern Lisp_Object QCport, QCspeed, QCprocess;
-extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
-extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
 
 typedef HRESULT (WINAPI * ShGetFolderPath_fn)
   (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
--- a/src/w32fns.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/w32fns.c	Mon Aug 09 10:51:16 2010 +0900
@@ -7053,7 +7053,7 @@
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
 	       doc: /* Maximum size for tooltips.
-Value is a pair (COLUMNS . ROWS). Text larger than this is clipped.  */);
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
--- a/src/w32font.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/w32font.c	Mon Aug 09 10:51:16 2010 +0900
@@ -72,7 +72,7 @@
 static Lisp_Object Qzh;
 
 /* scripts */
-static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
+static Lisp_Object Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
 static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
 static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu;
 static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao;
--- a/src/w32select.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/w32select.c	Mon Aug 09 10:51:16 2010 +0900
@@ -398,7 +398,6 @@
      with global variables and calling strange looking functions.  Is
      this really the right way to run Lisp callbacks?  */
 
-  extern int waiting_for_input;
   int owfi;
 
   BLOCK_INPUT;
--- a/src/window.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/window.c	Mon Aug 09 10:51:16 2010 +0900
@@ -51,14 +51,11 @@
 #include "nsterm.h"
 #endif
 
-
 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
 Lisp_Object Qdisplay_buffer;
 Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
 Lisp_Object Qwindow_size_fixed;
 
-extern Lisp_Object Qleft_margin, Qright_margin;
-
 static int displayed_window_lines (struct window *);
 static struct window *decode_window (Lisp_Object);
 static int count_windows (struct window *);
@@ -191,16 +188,11 @@
 static int inhibit_frame_unsplittable;
 #endif /* 0 */
 
-extern EMACS_INT scroll_margin;
-
-extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
-
 /* If non-nil, then the `recenter' command with a nil argument
    the entire frame to be redrawn; the special value `tty' causes the
    frame to be redrawn only if it is a tty frame.  */
 
 static Lisp_Object Vrecenter_redisplay;
-extern Lisp_Object Qtty;
 
 
 DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
@@ -508,7 +500,10 @@
        doc: /* Return the number of lines in WINDOW.
 WINDOW defaults to the selected window.
 
-The return value includes WINDOW's mode line and header line, if any.  */)
+The return value includes WINDOW's mode line and header line, if any.
+
+Note: The function does not take into account the value of `line-spacing'
+when calculating the number of lines in WINDOW.  */)
   (Lisp_Object window)
 {
   return decode_any_window (window)->total_lines;
@@ -642,13 +637,18 @@
 #ifdef FRAME_MENUBAR_HEIGHT
   *add_y += FRAME_MENUBAR_HEIGHT (f);
 #endif
-#ifdef FRAME_TOOLBAR_HEIGHT
+#ifdef FRAME_TOOLBAR_TOP_HEIGHT
+  *add_y += FRAME_TOOLBAR_TOP_HEIGHT (f);
+#elif FRAME_TOOLBAR_HEIGHT
   *add_y += FRAME_TOOLBAR_HEIGHT (f);
 #endif
 #ifdef FRAME_NS_TITLEBAR_HEIGHT
   *add_y += FRAME_NS_TITLEBAR_HEIGHT (f);
 #endif
   *add_x = f->left_pos;
+#ifdef FRAME_TOOLBAR_LEFT_WIDTH
+  *add_x += FRAME_TOOLBAR_LEFT_WIDTH (f);
+#endif
 }
 
 DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges,
--- a/src/xdisp.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xdisp.c	Mon Aug 09 10:51:16 2010 +0900
@@ -239,6 +239,7 @@
 #include "macros.h"
 #include "disptab.h"
 #include "termhooks.h"
+#include "termopts.h"
 #include "intervals.h"
 #include "coding.h"
 #include "process.h"
@@ -268,29 +269,6 @@
 
 #define INFINITY 10000000
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined(HAVE_NS) || defined (USE_GTK)
-extern void set_frame_menubar (struct frame *f, int, int);
-#endif
-
-extern int interrupt_input;
-extern int command_loop_level;
-
-extern Lisp_Object do_mouse_tracking;
-
-extern int minibuffer_auto_raise;
-extern Lisp_Object Vminibuffer_list;
-
-extern Lisp_Object Qface;
-extern Lisp_Object Qmode_line, Qmode_line_inactive, Qheader_line;
-
-extern Lisp_Object Voverriding_local_map;
-extern Lisp_Object Voverriding_local_map_menu_flag;
-extern Lisp_Object Qmenu_item;
-extern Lisp_Object Qwhen;
-extern Lisp_Object Qhelp_echo;
-extern Lisp_Object Qbefore_string, Qafter_string;
-
 Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
 Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
 Lisp_Object Qwindow_text_change_functions, Vwindow_text_change_functions;
@@ -381,7 +359,6 @@
 /* Names of text properties relevant for redisplay.  */
 
 Lisp_Object Qdisplay;
-extern Lisp_Object Qface, Qinvisible, Qwidth;
 
 /* Symbols used in text property values.  */
 
@@ -392,10 +369,6 @@
 Lisp_Object Qcenter;
 Lisp_Object Qmargin, Qpointer;
 Lisp_Object Qline_height;
-extern Lisp_Object Qheight;
-extern Lisp_Object QCwidth, QCheight, QCascent;
-extern Lisp_Object Qscroll_bar;
-extern Lisp_Object Qcursor;
 
 /* Non-nil means highlight trailing whitespace.  */
 
@@ -406,7 +379,6 @@
 Lisp_Object Vnobreak_char_display;
 
 #ifdef HAVE_WINDOW_SYSTEM
-extern Lisp_Object Voverflow_newline_into_fringe;
 
 /* Test if overflow newline into fringe.  Called with iterator IT
    at or past right window margin, and with IT->current_x set.  */
@@ -458,7 +430,7 @@
 Lisp_Object Qrect, Qcircle, Qpoly;
 
 /* Tool bar styles */
-Lisp_Object Qtext, Qboth, Qboth_horiz;
+Lisp_Object Qboth, Qboth_horiz, Qtext_image_horiz;
 
 /* Non-zero means print newline to stdout before next mini-buffer
    message.  */
@@ -1020,12 +992,12 @@
 static int display_mode_lines (struct window *);
 static int display_mode_line (struct window *, enum face_id, Lisp_Object);
 static int display_mode_element (struct it *, int, int, int, Lisp_Object, Lisp_Object, int);
-static int store_mode_line_string (char *, Lisp_Object, int, int, int, Lisp_Object);
-static char *decode_mode_spec (struct window *, int, int, int,
-                               Lisp_Object *);
+static int store_mode_line_string (const char *, Lisp_Object, int, int, int, Lisp_Object);
+static const char *decode_mode_spec (struct window *, int, int, int,
+				     Lisp_Object *);
 static void display_menu_bar (struct window *);
 static int display_count_lines (int, int, int, int, int *);
-static int display_string (unsigned char *, Lisp_Object, Lisp_Object,
+static int display_string (const unsigned char *, Lisp_Object, Lisp_Object,
                            EMACS_INT, EMACS_INT, struct it *, int, int, int, int);
 static void compute_line_metrics (struct it *);
 static void run_redisplay_end_trigger_hook (struct it *);
@@ -1048,7 +1020,7 @@
 static void load_overlay_strings (struct it *, int);
 static int init_from_display_pos (struct it *, struct window *,
                                   struct display_pos *);
-static void reseat_to_string (struct it *, unsigned char *,
+static void reseat_to_string (struct it *, const unsigned char *,
                               Lisp_Object, int, int, int, int);
 static enum move_it_result
        move_it_in_display_line_to (struct it *, EMACS_INT, int,
@@ -1063,8 +1035,8 @@
 static struct text_pos string_pos_nchars_ahead (struct text_pos,
                                                 Lisp_Object, int);
 static struct text_pos string_pos (int, Lisp_Object);
-static struct text_pos c_string_pos (int, unsigned char *, int);
-static int number_of_chars (unsigned char *, int);
+static struct text_pos c_string_pos (int, const unsigned char *, int);
+static int number_of_chars (const unsigned char *, int);
 static void compute_stop_pos (struct it *);
 static void compute_string_pos (struct text_pos *, struct text_pos,
                                 Lisp_Object);
@@ -1576,7 +1548,7 @@
    means recognize multibyte characters.  */
 
 static struct text_pos
-c_string_pos (int charpos, unsigned char *s, int multibyte_p)
+c_string_pos (int charpos, const unsigned char *s, int multibyte_p)
 {
   struct text_pos pos;
 
@@ -1608,7 +1580,7 @@
    non-zero means recognize multibyte characters.  */
 
 static int
-number_of_chars (unsigned char *s, int multibyte_p)
+number_of_chars (const unsigned char *s, int multibyte_p)
 {
   int nchars;
 
@@ -3691,7 +3663,6 @@
 
   if (STRINGP (it->string))
     {
-      extern Lisp_Object Qinvisible;
       Lisp_Object prop, end_charpos, limit, charpos;
 
       /* Get the value of the invisible text property at the
@@ -4875,7 +4846,6 @@
 static void
 load_overlay_strings (struct it *it, int charpos)
 {
-  extern Lisp_Object Qwindow, Qpriority;
   Lisp_Object overlay, window, str, invisible;
   struct Lisp_Overlay *ov;
   int start, end;
@@ -5611,7 +5581,7 @@
    calling this function.  */
 
 static void
-reseat_to_string (struct it *it, unsigned char *s, Lisp_Object string,
+reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string,
 		  int charpos, int precision, int field_width, int multibyte)
 {
   /* No region in strings.  */
@@ -7966,7 +7936,7 @@
    to *Messages*.  */
 
 void
-add_to_log (char *format, Lisp_Object arg1, Lisp_Object arg2)
+add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2)
 {
   Lisp_Object args[3];
   Lisp_Object msg, fmt;
@@ -10225,7 +10195,6 @@
       int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
       int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
       int hmargin, vmargin, relief, idx, end;
-      extern Lisp_Object QCrelief, QCmargin, QCconversion;
 
       /* If image is a vector, choose the image according to the
 	 button state.  */
@@ -10587,7 +10556,6 @@
       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);
 
@@ -10679,7 +10647,6 @@
 	 frame parameter.  */
       if (change_height_p)
 	{
-	  extern Lisp_Object Qtool_bar_lines;
 	  Lisp_Object frame;
 	  int old_height = WINDOW_TOTAL_LINES (w);
 	  int nrows;
@@ -11385,6 +11352,8 @@
 	  && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val)))
 	{
 	  if (FRAME_WINDOW_P (it->f)
+	      /* FIXME: if ROW->reversed_p is set, this should test
+		 the right fringe, not the left one.  */
 	      && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0)
 	    {
 #ifdef HAVE_WINDOW_SYSTEM
@@ -14487,7 +14456,6 @@
 
           if (redisplay_tool_bar_p && redisplay_tool_bar (f))
 	    {
-	      extern int ignore_mouse_drag_p;
 	      ignore_mouse_drag_p = 1;
 	    }
         }
@@ -17414,8 +17382,8 @@
 	  row->ends_at_zv_p = 1;
 	  /* A row that displays right-to-left text must always have
 	     its last face extended all the way to the end of line,
-	     even if this row ends in ZV, because we still write to th
-	     screen left to right.  */
+	     even if this row ends in ZV, because we still write to
+	     the screen left to right.  */
 	  if (row->reversed_p)
 	    extend_face_to_end_of_line (it);
 	  break;
@@ -17832,6 +17800,26 @@
       row->truncated_on_left_p = 1;
     }
 
+  /* Remember the position at which this line ends.
+
+     BIDI Note: any code that needs MATRIX_ROW_START/END_CHARPOS
+     cannot be before the call to find_row_edges below, since that is
+     where these positions are determined. */
+  row->end = it->current;
+  if (!it->bidi_p)
+    {
+      row->minpos = row->start.pos;
+      row->maxpos = row->end.pos;
+    }
+  else
+    {
+      /* ROW->minpos and ROW->maxpos must be the smallest and
+	 `1 + the largest' buffer positions in ROW.  But if ROW was
+	 bidi-reordered, these two positions can be anywhere in the
+	 row, so we must determine them now.  */
+      find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
+    }
+
   /* If the start of this line is the overlay arrow-position, then
      mark this glyph row as the one containing the overlay arrow.
      This is clearly a mess with variable size fonts.  It would be
@@ -17877,22 +17865,6 @@
   /* Compute pixel dimensions of this line.  */
   compute_line_metrics (it);
 
-  /* Remember the position at which this line ends.  */
-  row->end = it->current;
-  if (!it->bidi_p)
-    {
-      row->minpos = row->start.pos;
-      row->maxpos = row->end.pos;
-    }
-  else
-    {
-      /* ROW->minpos and ROW->maxpos must be the smallest and
-	 `1 + the largest' buffer positions in ROW.  But if ROW was
-	 bidi-reordered, these two positions can be anywhere in the
-	 row, so we must determine them now.  */
-      find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
-    }
-
   /* Record whether this row ends inside an ellipsis.  */
   row->ends_in_ellipsis_p
     = (it->method == GET_FROM_DISPLAY_VECTOR
@@ -18566,7 +18538,7 @@
 		  {
 		    int multibyte;
 		    int bytepos, charpos;
-		    unsigned char *spec;
+		    const unsigned char *spec;
 		    Lisp_Object string;
 
 		    bytepos = percent_position;
@@ -18836,7 +18808,7 @@
  */
 
 static int
-store_mode_line_string (char *string, Lisp_Object lisp_string, int copy_string,
+store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string,
 			int field_width, int precision, Lisp_Object props)
 {
   int len;
@@ -19252,7 +19224,7 @@
 
 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
 
-static char *
+static const char *
 decode_mode_spec (struct window *w, register int c, int field_width,
 		  int precision, Lisp_Object *string)
 {
@@ -19812,7 +19784,7 @@
    Value is the number of columns displayed.  */
 
 static int
-display_string (unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string,
+display_string (const unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string,
 		EMACS_INT face_string_pos, EMACS_INT start, struct it *it,
 		int field_width, int precision, int max_x, int multibyte)
 {
@@ -25638,6 +25610,8 @@
   staticpro (&Qboth);
   Qboth_horiz = intern_c_string ("both-horiz");
   staticpro (&Qboth_horiz);
+  Qtext_image_horiz = intern_c_string ("text-image-horiz");
+  staticpro (&Qtext_image_horiz);
   QCmap = intern_c_string (":map");
   staticpro (&QCmap);
   QCpointer = intern_c_string (":pointer");
@@ -25981,11 +25955,12 @@
   DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style,
     doc: /* *Tool bar style to use.
 It can be one of
- image      - show images only
- text       - show text only
- both       - show both, text under image
- both-horiz - show text to the right of the image
- any other  - use system default or image if no system default.  */);
+ image            - show images only
+ text             - show text only
+ both             - show both, text below image
+ both-horiz       - show text to the right of the image
+ text-image-horiz - show text to the left of the image
+ any other        - use system default or image if no system default.  */);
   Vtool_bar_style = Qnil;
 
   DEFVAR_INT ("tool-bar-max-label-size", &tool_bar_max_label_size,
--- a/src/xfaces.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xfaces.c	Mon Aug 09 10:51:16 2010 +0900
@@ -321,11 +321,6 @@
 Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit;
 Lisp_Object QCfontset;
 
-/* Keywords symbols used for font properties.  */
-extern Lisp_Object QCfoundry, QCadstyle, QCregistry;
-extern Lisp_Object QCspacing, QCsize, QCavgwidth;
-extern Lisp_Object Qp;
-
 /* Symbols used for attribute values.  */
 
 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight;
@@ -351,7 +346,6 @@
 Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe;
 Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse, Qmenu;
 Lisp_Object Qmode_line_inactive, Qvertical_border;
-extern Lisp_Object Qmode_line;
 
 /* The symbol `face-alias'.  A symbols having that property is an
    alias for another face.  Value of the property is the name of
@@ -359,8 +353,6 @@
 
 Lisp_Object Qface_alias;
 
-extern Lisp_Object Qcircular_list;
-
 /* Default stipple pattern used on monochrome displays.  This stipple
    pattern is used on monochrome displays instead of shades of gray
    for a face background color.  See `set-face-stipple' for possible
@@ -411,7 +403,6 @@
 /* The symbols `face' and `mouse-face' used as text properties.  */
 
 Lisp_Object Qface;
-extern Lisp_Object Qmouse_face;
 
 /* Property for basic faces which other faces cannot inherit.  */
 
@@ -520,7 +511,7 @@
 static struct frame *frame_or_selected_frame (Lisp_Object, int);
 static void load_face_colors (struct frame *, struct face *, Lisp_Object *);
 static void free_face_colors (struct frame *, struct face *);
-static int face_color_gray_p (struct frame *, char *);
+static int face_color_gray_p (struct frame *, const char *);
 static struct face *realize_face (struct face_cache *, Lisp_Object *,
                                   int);
 static struct face *realize_non_ascii_face (struct frame *, Lisp_Object,
@@ -751,10 +742,9 @@
 /* NS emulation of GCs */
 
 static INLINE GC
-x_create_gc (f, mask, xgcv)
-     struct frame *f;
-     unsigned long mask;
-     XGCValues *xgcv;
+x_create_gc (struct frame *f,
+             unsigned long mask,
+             XGCValues *xgcv)
 {
   GC gc = xmalloc (sizeof (*gc));
   if (gc)
@@ -763,9 +753,7 @@
 }
 
 static INLINE void
-x_free_gc (f, gc)
-     struct frame *f;
-     GC gc;
+x_free_gc (struct frame *f, GC gc)
 {
   xfree (gc);
 }
@@ -1171,7 +1159,8 @@
 /* A version of defined_color for non-X frames.  */
 
 int
-tty_defined_color (struct frame *f, char *color_name, XColor *color_def, int alloc)
+tty_defined_color (struct frame *f, const char *color_name,
+		   XColor *color_def, int alloc)
 {
   int status = 1;
 
@@ -1206,7 +1195,7 @@
    This does the right thing for any type of frame.  */
 
 int
-defined_color (struct frame *f, char *color_name, XColor *color_def, int alloc)
+defined_color (struct frame *f, const char *color_name, XColor *color_def, int alloc)
 {
   if (!FRAME_WINDOW_P (f))
     return tty_defined_color (f, color_name, color_def, alloc);
@@ -1266,7 +1255,7 @@
    The criterion implemented here is not a terribly sophisticated one.  */
 
 static int
-face_color_gray_p (struct frame *f, char *color_name)
+face_color_gray_p (struct frame *f, const char *color_name)
 {
   XColor color;
   int gray_p;
@@ -1293,7 +1282,7 @@
    color.  */
 
 static int
-face_color_supported_p (struct frame *f, char *color_name, int background_p)
+face_color_supported_p (struct frame *f, const char *color_name, int background_p)
 {
   Lisp_Object frame;
   XColor not_used;
@@ -3666,8 +3655,6 @@
 	  if (! NILP (xlfd))
 	    {
 #if defined HAVE_X_I18N
-	      extern char *xic_create_fontsetname
-                (char *base_fontname, Bool motif);
 	      char *fontsetname = xic_create_fontsetname (SDATA (xlfd), motif);
 #else
 	      char *fontsetname = (char *) SDATA (xlfd);
--- a/src/xfns.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xfns.c	Mon Aug 09 10:51:16 2010 +0900
@@ -101,6 +101,10 @@
 #include <Xm/FileSB.h>
 #endif
 
+#ifdef USE_LUCID
+#include "../lwlib/xlwmenu.h"
+#endif
+
 #if !defined(NO_EDITRES)
 #define HACK_EDITRES
 extern void _XEditResCheckMessages ();
@@ -157,6 +161,10 @@
 
 int x_gtk_whole_detached_tool_bar;
 
+/* If non-zero, use Gtk+ tooltips.  */
+
+static int x_gtk_use_system_tooltips;
+
 /* The background and shape of the mouse pointer, and shape when not
    over text or in the modeline.  */
 
@@ -194,19 +202,6 @@
 Lisp_Object Qcompound_text, Qcancel_timer;
 Lisp_Object Qfont_param;
 
-/* In dispnew.c */
-
-extern Lisp_Object Vwindow_system_version;
-
-/* In editfns.c */
-
-extern Lisp_Object Vsystem_name;
-
-/* The below are defined in frame.c.  */
-
-extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
-extern Lisp_Object Qtooltip;
-
 #if GLYPH_DEBUG
 int image_cache_refcount, dpyinfo_refcount;
 #endif
@@ -506,7 +501,7 @@
 static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *,
                                                          Lisp_Object,
                                                          Lisp_Object,
-                                                         char *, char *,
+                                                         const char *, const char *,
                                                          int);
 
 
@@ -650,7 +645,8 @@
    no color could be allocated.  */
 
 int
-x_defined_color (struct frame *f, char *color_name, XColor *color, int alloc_p)
+x_defined_color (struct frame *f, const char *color_name,
+		 XColor *color, int alloc_p)
 {
   int success_p;
   Display *dpy = FRAME_X_DISPLAY (f);
@@ -710,6 +706,22 @@
   f->output_data.x->wait_for_wm = !NILP (new_value);
 }
 
+static void
+x_set_tool_bar_position (struct frame *f,
+                         Lisp_Object new_value,
+                         Lisp_Object old_value)
+{
+  if (! EQ (new_value, Qleft) && ! EQ (new_value, Qright)
+      && ! EQ (new_value, Qbottom) && ! EQ (new_value, Qtop))
+    return;
+  if (EQ (new_value, old_value)) return;
+
+#ifdef USE_GTK
+  if (xg_change_toolbar_position (f, new_value)) 
+    f->tool_bar_position = new_value;
+#endif
+}
+
 #ifdef USE_GTK
 
 /* Set icon from FILE for frame F.  By using GTK functions the icon
@@ -750,10 +762,10 @@
 }
 
 int
-xg_set_icon_from_xpm_data (FRAME_PTR f, char **data)
+xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data)
 {
   int result = 0;
-  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data);
+  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
 
   if (!pixbuf)
     return 0;
@@ -991,7 +1003,7 @@
 
   if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
     FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
-  
+
   if (cursor != x->text_cursor
       && x->text_cursor != 0)
     XFreeCursor (dpy, x->text_cursor);
@@ -1755,7 +1767,7 @@
 static Lisp_Object
 x_default_scroll_bar_color_parameter (struct frame *f,
 				      Lisp_Object alist, Lisp_Object prop,
-				      char *xprop, char *xclass,
+				      const char *xprop, const char *xclass,
 				      int foreground_p)
 {
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
@@ -1896,12 +1908,12 @@
 
 /* Create an X fontset on frame F with base font name BASE_FONTNAME.  */
 
-char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
+const char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
 
 /* Create an Xt fontset spec from the name of a base font.
    If `motif' is True use the Motif syntax.  */
 char *
-xic_create_fontsetname (char *base_fontname, int motif)
+xic_create_fontsetname (const char *base_fontname, int motif)
 {
   const char *sep = motif ? ";" : ",";
   char *fontsetname;
@@ -1921,7 +1933,7 @@
 	 - the base font.
 	 - the base font where the charset spec is replaced by -*-*.
 	 - the same but with the family also replaced with -*-*-.  */
-      char *p = base_fontname;
+      const char *p = base_fontname;
       int i;
 
       for (i = 0; *p; p++)
@@ -1940,13 +1952,13 @@
       else
 	{
 	  int len;
-	  char *p1 = NULL, *p2 = NULL, *p3 = NULL;
+	  const char *p1 = NULL, *p2 = NULL, *p3 = NULL;
 	  char *font_allcs = NULL;
 	  char *font_allfamilies = NULL;
 	  char *font_all = NULL;
-	  char *allcs = "*-*-*-*-*-*-*";
-	  char *allfamilies = "-*-*-";
-	  char *all = "*-*-*-*-";
+	  const char *allcs = "*-*-*-*-*-*-*";
+	  const char *allfamilies = "-*-*-";
+	  const char *all = "*-*-*-*-";
 	  char *base;
 
 	  for (i = 0, p = base_fontname; i < 8; p++)
@@ -2075,7 +2087,7 @@
       char **missing_list;
       int missing_count;
       char *def_string;
-      char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*";
+      const char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*";
 
       sprintf (buf, xlfd_format, pixel_size);
       missing_list = NULL;
@@ -2126,7 +2138,7 @@
 	}
       if (! xfs)
 	{
-	  char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
+	  const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
 
 	  missing_list = NULL;
 	  xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
@@ -2339,7 +2351,7 @@
   area.x = FRAME_PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
   area.y = (FRAME_PIXEL_HEIGHT (f) - area.height
 	    - FRAME_MENUBAR_HEIGHT (f)
-	    - FRAME_TOOLBAR_HEIGHT (f)
+	    - FRAME_TOOLBAR_TOP_HEIGHT (f)
             - FRAME_INTERNAL_BORDER_WIDTH (f));
   XFree (needed);
 
@@ -2353,7 +2365,7 @@
    BASE_FONTNAME.  Called when a new Emacs fontset is chosen.  */
 
 void
-xic_set_xfontset (struct frame *f, char *base_fontname)
+xic_set_xfontset (struct frame *f, const char *base_fontname)
 {
   XVaNestedList attr;
   XFontSet xfs;
@@ -2999,7 +3011,7 @@
 
   if (! FONTP (font) && ! STRINGP (font))
     {
-      char *names[]
+      const char *names[]
 	= {
 #ifdef HAVE_XFT
 	    /* This will find the normal Xft font.  */
@@ -3728,7 +3740,7 @@
   (Lisp_Object terminal)
 {
   struct x_display_info *dpyinfo = check_x_display_info (terminal);
-  char *vendor = ServerVendor (dpyinfo->display);
+  const char *vendor = ServerVendor (dpyinfo->display);
 
   if (! vendor) vendor = "";
   return build_string (vendor);
@@ -3922,7 +3934,7 @@
 
 static struct visual_class
 {
-  char *name;
+  const char *name;
   int class;
 }
 visual_classes[] =
@@ -4589,7 +4601,9 @@
    when this happens.  */
 
 static Lisp_Object
-x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms, Lisp_Object text)
+x_create_tip_frame (struct x_display_info *dpyinfo,
+                    Lisp_Object parms,
+                    Lisp_Object text)
 {
   struct frame *f;
   Lisp_Object frame, tem;
@@ -5016,6 +5030,27 @@
   else
     CHECK_NUMBER (dy);
 
+#ifdef USE_GTK
+  if (x_gtk_use_system_tooltips)
+    {
+      int ok; 
+
+      /* Hide a previous tip, if any.  */
+      Fx_hide_tip ();
+
+      BLOCK_INPUT;
+      if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0)
+        {
+	  compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
+          xg_show_tooltip (f, root_x, root_y);
+          /* This is used in Fx_hide_tip.  */
+          XSETFRAME (tip_frame, f);
+        }
+      UNBLOCK_INPUT;
+      if (ok) goto start_timer;
+    }
+#endif /* USE_GTK */
+
   if (NILP (last_show_tip_args))
     last_show_tip_args = Fmake_vector (make_number (3), Qnil);
 
@@ -5176,6 +5211,7 @@
   int count;
   Lisp_Object deleted, frame, timer;
   struct gcpro gcpro1, gcpro2;
+  struct frame *f;
 
   /* Return quickly if nothing to do.  */
   if (NILP (tip_timer) && NILP (tip_frame))
@@ -5193,6 +5229,14 @@
   if (!NILP (timer))
     call1 (Qcancel_timer, timer);
 
+#ifdef USE_GTK
+  /* When using system tooltip, tip_frame is the Emacs frame on which
+     the tip is shown.  */
+  f = XFRAME (frame);
+  if (xg_hide_tooltip (f))
+    frame = Qnil;
+#endif
+
   if (FRAMEP (frame))
     {
       delete_frame (frame, Qnil);
@@ -5203,9 +5247,9 @@
 	 redisplay procedure is not called when a tip frame over menu
 	 items is unmapped.  Redisplay the menu manually...  */
       {
-	struct frame *f = SELECTED_FRAME ();
-	Widget w = f->output_data.x->menubar_widget;
-        extern void xlwmenu_redisplay (Widget);
+        Widget w;
+	f = SELECTED_FRAME ();
+	w = f->output_data.x->menubar_widget;
 
 	if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen)
 	    && w != NULL)
@@ -5235,9 +5279,6 @@
   (void)
 {
 #ifdef USE_GTK
-  extern int use_dialog_box;
-  extern int use_file_dialog;
-
   if (use_dialog_box
       && use_file_dialog
       && have_menus_p ()
@@ -5308,7 +5349,6 @@
   Widget dialog, text, help;
   Arg al[10];
   int ac = 0;
-  extern XtAppContext Xt_app_con;
   XmString dir_xmstring, pattern_xmstring;
   int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
@@ -5558,7 +5598,7 @@
   font_param = Ffont_get (font, intern (":name"));
   if (STRINGP (font_param))
     default_name = xstrdup (SDATA (font_param));
-  else 
+  else
     {
       font_param = Fframe_parameter (frame, Qfont_param);
       if (STRINGP (font_param))
@@ -5569,7 +5609,7 @@
     default_name = xstrdup (x_last_font_name);
 
   /* Convert fontconfig names to Gtk names, i.e. remove - before number */
-  if (default_name) 
+  if (default_name)
     {
       char *p = strrchr (default_name, '-');
       if (p)
@@ -5747,6 +5787,7 @@
   x_set_font_backend,
   x_set_alpha,
   x_set_sticky,
+  x_set_tool_bar_position,
 };
 
 void
@@ -5829,8 +5870,8 @@
   Vx_cursor_fore_pixel = Qnil;
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
-    doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
-Text larger than this is clipped.  */);
+    doc: /* Maximum size for tooltips.
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
@@ -5877,6 +5918,12 @@
 the tool bar buttons.  */);
   x_gtk_whole_detached_tool_bar = 0;
 
+  DEFVAR_BOOL ("x-gtk-use-system-tooltips", &x_gtk_use_system_tooltips,
+    doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used.
+Otherwise use Emacs own tooltip implementation.
+When using Gtk+ tooltips, the tooltip face is not used.  */);
+  x_gtk_use_system_tooltips = 1;
+
   Fprovide (intern_c_string ("x"), Qnil);
 
 #ifdef USE_X_TOOLKIT
@@ -5897,6 +5944,7 @@
      accepts --with-x-toolkit=gtk.  */
   Fprovide (intern_c_string ("x-toolkit"), Qnil);
   Fprovide (intern_c_string ("gtk"), Qnil);
+  Fprovide (intern_c_string ("move-toolbar"), Qnil);
 
   DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
                doc: /* Version info for GTK+.  */);
--- a/src/xfont.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xfont.c	Mon Aug 09 10:51:16 2010 +0900
@@ -154,8 +154,6 @@
     NULL, /* filter_properties */
   };
 
-extern Lisp_Object QCname;
-
 static Lisp_Object
 xfont_get_cache (FRAME_PTR f)
 {
@@ -164,8 +162,6 @@
   return (dpyinfo->name_list_element);
 }
 
-extern Lisp_Object Vface_alternative_font_registry_alist;
-
 static int
 compare_font_names (const void *name1, const void *name2)
 {
@@ -289,8 +285,6 @@
 /* Re-usable vector to store characteristic font properites.   */
 static Lisp_Object xfont_scratch_props;
 
-extern Lisp_Object Qlatin;
-
 /* Return a list of scripts supported by the font of FONTNAME whose
    characteristic properties are in PROPS and whose encoding charset
    is ENCODING.  A caller must call BLOCK_INPUT in advance.  */
@@ -339,10 +333,8 @@
   return scripts;
 }
 
-extern Lisp_Object Vscalable_fonts_allowed;
-
 static Lisp_Object
-xfont_list_pattern (Display *display, char *pattern,
+xfont_list_pattern (Display *display, const char *pattern,
 		    Lisp_Object registry, Lisp_Object script)
 {
   Lisp_Object list = Qnil;
@@ -687,8 +679,6 @@
   return list;
 }
 
-extern Lisp_Object QCavgwidth;
-
 static Lisp_Object
 xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
 {
--- a/src/xftfont.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xftfont.c	Mon Aug 09 10:51:16 2010 +0900
@@ -171,10 +171,6 @@
   return entity;
 }
 
-extern Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object);
-extern FcCharSet *ftfont_get_fc_charset (Lisp_Object);
-extern Lisp_Object QCantialias;
-
 static FcChar8 ascii_printable[95];
 
 static void
@@ -552,8 +548,6 @@
     }
 }
 
-extern Lisp_Object Qja, Qko;
-
 static int
 xftfont_has_char (Lisp_Object font, int c)
 {
--- a/src/xmenu.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xmenu.c	Mon Aug 09 10:51:16 2010 +0900
@@ -89,7 +89,6 @@
 #include <X11/Xaw/Paned.h>
 #endif /* HAVE_XAW3D */
 #endif /* USE_LUCID */
-#include "../lwlib/lwlib.h"
 #else /* not USE_X_TOOLKIT */
 #ifndef USE_GTK
 #include "../oldXMenu/XMenu.h"
@@ -110,29 +109,7 @@
 
 Lisp_Object Qdebug_on_next_call;
 
-extern Lisp_Object Qmenu_bar;
-
-extern Lisp_Object QCtoggle, QCradio;
-
-extern Lisp_Object Voverriding_local_map;
-extern Lisp_Object Voverriding_local_map_menu_flag;
-
-extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
-
-extern Lisp_Object Qmenu_bar_update_hook;
-
-#ifdef USE_X_TOOLKIT
-extern void set_frame_menubar (FRAME_PTR, int, int);
-extern XtAppContext Xt_app_con;
-
-static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
-                                 char **);
-static void popup_get_selection (XEvent *, struct x_display_info *,
-                                 LWLIB_ID, int);
-#endif /* USE_X_TOOLKIT */
-
-#ifdef USE_GTK
-extern void set_frame_menubar (FRAME_PTR, int, int);
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
 static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
                                  char **);
 #endif
@@ -145,12 +122,6 @@
 
 static int next_menubar_widget_id;
 
-/* For NS and NTGUI, these prototypes are defined in keyboard.h.  */
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-extern widget_value *xmalloc_widget_value (void);
-extern widget_value *digest_single_submenu (int, int, int);
-#endif
-
 
 #ifdef USE_X_TOOLKIT
 
@@ -2210,7 +2181,6 @@
 static void
 menu_help_callback (char *help_string, int pane, int item)
 {
-  extern Lisp_Object Qmenu_item;
   Lisp_Object *first_item;
   Lisp_Object pane_name;
   Lisp_Object menu_object;
--- a/src/xrdb.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xrdb.c	Mon Aug 09 10:51:16 2010 +0900
@@ -20,9 +20,7 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef emacs
 #include <config.h>
-#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -52,38 +50,14 @@
 
 extern char *getenv (const char *);
 
-/* This does cause trouble on AIX.  I'm going to take the comment at
-   face value.  */
-#if 0
-extern short getuid ();		/* If this causes portability problems,
-				   I think we should just delete it; it'll
-				   default to `int' anyway.  */
-#endif
-
-#ifdef DECLARE_GETPWUID_WITH_UID_T
 extern struct passwd *getpwuid (uid_t);
 extern struct passwd *getpwnam (const char *);
-#else
-extern struct passwd *getpwuid (uid_t);
-extern struct passwd *getpwnam (const char *);
-#endif
 
 extern char *get_system_name (void);
 
-/* Make sure not to #include anything after these definitions.  Let's
-   not step on anyone's prototypes.  */
-#ifdef emacs
-/* darwin.h may have already defined these.  */
-#undef malloc
-#undef realloc
-#undef free
-#define malloc xmalloc
-#define realloc xrealloc
-#define free xfree
-#endif
-
-char *x_get_string_resource (XrmDatabase rdb, char *name, char *class);
-static int file_p (char *filename);
+char *x_get_string_resource (XrmDatabase rdb, const char *name,
+			     const char *class);
+static int file_p (const char *filename);
 
 
 /* X file search path processing.  */
@@ -98,7 +72,7 @@
    resource, for later use in search path decoding.  If we find no
    such resource, return zero.  */
 char *
-x_get_customization_string (XrmDatabase db, char *name, char *class)
+x_get_customization_string (XrmDatabase db, const char *name, const char *class)
 {
   char *full_name
     = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
@@ -113,7 +87,7 @@
 
   if (result)
     {
-      char *copy = (char *) malloc (strlen (result) + 1);
+      char *copy = (char *) xmalloc (strlen (result) + 1);
       strcpy (copy, result);
       return copy;
     }
@@ -153,20 +127,20 @@
    Return NULL otherwise.  */
 
 static char *
-magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, char *suffix)
+magic_file_p (const char *string, int string_len, const char *class, const char *escaped_suffix, const char *suffix)
 {
   char *lang = getenv ("LANG");
 
   int path_size = 100;
-  char *path = (char *) malloc (path_size);
+  char *path = (char *) xmalloc (path_size);
   int path_len = 0;
 
-  char *p = string;
+  const char *p = string;
 
   while (p < string + string_len)
     {
       /* The chunk we're about to stick on the end of result.  */
-      char *next = NULL;
+      const char *next = NULL;
       int next_len;
 
       if (*p == '%')
@@ -209,7 +183,7 @@
 	      case 'l':
 		if (! lang)
 		  {
-		    free (path);
+		    xfree (path);
 		    return NULL;
 		  }
 
@@ -219,7 +193,7 @@
 
 	      case 't':
 	      case 'c':
-		free (path);
+		xfree (path);
 		return NULL;
 	      }
 	}
@@ -230,7 +204,7 @@
       if (path_len + next_len + 1 > path_size)
 	{
 	  path_size = (path_len + next_len + 1) * 2;
-	  path = (char *) realloc (path, path_size);
+	  path = (char *) xrealloc (path, path_size);
 	}
 
       memcpy (path + path_len, next, next_len);
@@ -256,7 +230,7 @@
       if (path_len + suffix_len + 1 > path_size)
 	{
 	  path_size = (path_len + suffix_len + 1);
-	  path = (char *) realloc (path, path_size);
+	  path = (char *) xrealloc (path, path_size);
 	}
 
       memcpy (path + path_len, suffix, suffix_len);
@@ -267,7 +241,7 @@
 
   if (! file_p (path))
     {
-      free (path);
+      xfree (path);
       return NULL;
     }
 
@@ -297,7 +271,7 @@
   if (ptr == NULL)
     return xstrdup ("/");
 
-  copy = (char *) malloc (strlen (ptr) + 2);
+  copy = (char *) xmalloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
   strcat (copy, "/");
 
@@ -306,7 +280,7 @@
 
 
 static int
-file_p (char *filename)
+file_p (const char *filename)
 {
   struct stat status;
 
@@ -321,9 +295,9 @@
    the path name of the one we found otherwise.  */
 
 static char *
-search_magic_path (char *search_path, char *class, char *escaped_suffix, char *suffix)
+search_magic_path (const char *search_path, const char *class, const char *escaped_suffix, const char *suffix)
 {
-  register char *s, *p;
+  const char *s, *p;
 
   for (s = search_path; *s; s = p)
     {
@@ -332,7 +306,8 @@
 
       if (p > s)
 	{
-	  char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
+	  char *path = magic_file_p (s, p - s, class, escaped_suffix,
+					   suffix);
 	  if (path)
 	    return path;
 	}
@@ -356,7 +331,7 @@
 /* Producing databases for individual sources.  */
 
 static XrmDatabase
-get_system_app (char *class)
+get_system_app (const char *class)
 {
   XrmDatabase db = NULL;
   char *path;
@@ -368,7 +343,7 @@
   if (path)
     {
       db = XrmGetFileDatabase (path);
-      free (path);
+      xfree (path);
     }
 
   return db;
@@ -383,7 +358,7 @@
 
 
 static XrmDatabase
-get_user_app (char *class)
+get_user_app (const char *class)
 {
   char *path;
   char *file = 0;
@@ -407,12 +382,12 @@
 	   || (file = search_magic_path (free_it, class, "%N", 0)))))
     {
       XrmDatabase db = XrmGetFileDatabase (file);
-      free (file);
-      free (free_it);
+      xfree (file);
+      xfree (free_it);
       return db;
     }
 
-  free (free_it);
+  xfree (free_it);
   return NULL;
 }
 
@@ -437,12 +412,12 @@
       char *xdefault;
 
       home = gethomedir ();
-      xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults"));
+      xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
       strcpy (xdefault, home);
       strcat (xdefault, ".Xdefaults");
       db = XrmGetFileDatabase (xdefault);
-      free (home);
-      free (xdefault);
+      xfree (home);
+      xfree (xdefault);
     }
 
 #ifdef HAVE_XSCREENRESOURCESTRING
@@ -469,7 +444,7 @@
     {
       home = gethomedir ();
       host = get_system_name ();
-      path = (char *) malloc (strlen (home)
+      path = (char *) xmalloc (strlen (home)
 			      + sizeof (".Xdefaults-")
 			      + strlen (host));
       sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
@@ -478,8 +453,8 @@
 
   db = XrmGetFileDatabase (p);
 
-  free (path);
-  free (home);
+  xfree (path);
+  xfree (home);
 
   return db;
 }
@@ -494,18 +469,18 @@
 /* Load X resources based on the display and a possible -xrm option. */
 
 XrmDatabase
-x_load_resources (Display *display, char *xrm_string, char *myname, char *myclass)
+x_load_resources (Display *display, const char *xrm_string,
+		  const char *myname, const char *myclass)
 {
   XrmDatabase user_database;
   XrmDatabase rdb;
   XrmDatabase db;
   char line[256];
 
-  char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
+  const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
 
 #ifdef USE_MOTIF
-  char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
-  extern Lisp_Object Vdouble_click_time;
+  const char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
 #endif
 
   x_rm_string = XrmStringToQuark (XrmStringType);
@@ -584,7 +559,7 @@
 
   /* Figure out what the "customization string" is, so we can use it
      to decode paths.  */
-  free (x_customization_string);
+  xfree (x_customization_string);
   x_customization_string
     = x_get_customization_string (user_database, myname, myclass);
 
@@ -628,7 +603,7 @@
    and of type TYPE from database RDB.  The value is returned in RET_VALUE. */
 
 int
-x_get_resource (XrmDatabase rdb, char *name, char *class, XrmRepresentation expected_type, XrmValue *ret_value)
+x_get_resource (XrmDatabase rdb, const char *name, const char *class, XrmRepresentation expected_type, XrmValue *ret_value)
 {
   XrmValue value;
   XrmName namelist[100];
@@ -656,7 +631,7 @@
    database RDB. */
 
 char *
-x_get_string_resource (XrmDatabase rdb, char *name, char *class)
+x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
 {
   XrmValue value;
 
--- a/src/xselect.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xselect.c	Mon Aug 09 10:51:16 2010 +0900
@@ -76,7 +76,8 @@
 static Lisp_Object x_get_window_property_as_lisp_data (Display *,
                                                        Window, Atom,
                                                        Lisp_Object, Atom);
-static Lisp_Object selection_data_to_lisp_data (Display *, unsigned char *,
+static Lisp_Object selection_data_to_lisp_data (Display *,
+						const unsigned char *,
                                                 int, Atom, int);
 static void lisp_data_to_selection_data (Display *, Lisp_Object,
                                          unsigned char **, Atom *,
@@ -391,7 +392,7 @@
   selecting_window = FRAME_X_WINDOW (sf);
   display = FRAME_X_DISPLAY (sf);
   dpyinfo = FRAME_X_DISPLAY_INFO (sf);
-  
+
   CHECK_SYMBOL (selection_name);
   selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
 
@@ -409,10 +410,8 @@
     Lisp_Object prev_value;
 
     selection_time = long_to_cons ((unsigned long) time);
-    selection_data = Fcons (selection_name,
-			    Fcons (selection_value,
-				   Fcons (selection_time,
-					  Fcons (selected_frame, Qnil))));
+    selection_data = list4 (selection_name, selection_value,
+			    selection_time, selected_frame);
     prev_value = assq_no_quit (selection_name, Vselection_alist);
 
     Vselection_alist = Fcons (selection_data, Vselection_alist);
@@ -1014,7 +1013,7 @@
 	  }
       }
   UNBLOCK_INPUT;
-  
+
   selection_symbol = x_atom_to_symbol (display, selection);
 
   local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
@@ -1758,7 +1757,8 @@
 
 
 static Lisp_Object
-selection_data_to_lisp_data (Display *display, unsigned char *data, int size, Atom type, int format)
+selection_data_to_lisp_data (Display *display, const unsigned char *data,
+			     int size, Atom type, int format)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
@@ -2414,7 +2414,7 @@
   Atom props[8];
   Display *display;
   struct frame *sf = SELECTED_FRAME ();
-  
+
   check_x ();
 
   if (! FRAME_X_P (sf))
@@ -2540,7 +2540,8 @@
    Also see comment for selection_data_to_lisp_data above.  */
 
 Lisp_Object
-x_property_data_to_lisp (struct frame *f, unsigned char *data, Atom type, int format, long unsigned int size)
+x_property_data_to_lisp (struct frame *f, const unsigned char *data,
+			 Atom type, int format, long unsigned int size)
 {
   return selection_data_to_lisp_data (FRAME_X_DISPLAY (f),
                                       data, size*format/8, type, format);
@@ -2915,7 +2916,7 @@
 \"*selectionTimeout\" resource.  */);
   x_selection_timeout = 0;
 
-  QPRIMARY   = intern_c_string ("PRIMARY");	staticpro (&QPRIMARY);
+  /* QPRIMARY is defined in keyboard.c.  */
   QSECONDARY = intern_c_string ("SECONDARY");	staticpro (&QSECONDARY);
   QSTRING    = intern_c_string ("STRING");	staticpro (&QSTRING);
   QINTEGER   = intern_c_string ("INTEGER");	staticpro (&QINTEGER);
--- a/src/xsettings.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xsettings.c	Mon Aug 09 10:51:16 2010 +0900
@@ -730,7 +730,8 @@
   if (EQ (Vtool_bar_style, Qimage)
       || EQ (Vtool_bar_style, Qtext)
       || EQ (Vtool_bar_style, Qboth)
-      || EQ (Vtool_bar_style, Qboth_horiz))
+      || EQ (Vtool_bar_style, Qboth_horiz)
+      || EQ (Vtool_bar_style, Qtext_image_horiz))
     return Vtool_bar_style;
   if (!NILP (current_tool_bar_style))
     return current_tool_bar_style;
--- a/src/xsmfns.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xsmfns.c	Mon Aug 09 10:51:16 2010 +0900
@@ -45,10 +45,6 @@
 /* Avoid "differ in sign" warnings */
 #define SSDATA(x)  ((char *) SDATA (x))
 
-/* The user login name.  */
-
-extern Lisp_Object Vuser_login_name;
-
 /* This is the event used when SAVE_SESSION_EVENT occurs.  */
 
 static struct input_event emacs_event;
--- a/src/xterm.c	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xterm.c	Mon Aug 09 10:51:16 2010 +0900
@@ -22,11 +22,7 @@
 /* Xt features made by Fred Pierresteguy.  */
 
 #include <config.h>
-
-/* On 4.3 these lose if they come after xterm.h.  */
-/* Putting these at the beginning seems to be standard for other .c files.  */
 #include <signal.h>
-
 #include <stdio.h>
 #include <setjmp.h>
 
@@ -104,13 +100,7 @@
 #endif
 
 #ifdef USE_LUCID
-extern int xlwmenu_window_p (Widget w, Window window);
-extern void xlwmenu_redisplay (Widget);
-#endif
-
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-
-extern void free_frame_menubar (struct frame *);
+#include "../lwlib/xlwmenu.h"
 #endif
 
 #ifdef USE_X_TOOLKIT
@@ -294,23 +284,6 @@
 
 static int x_noop_count;
 
-/* Initial values of argv and argc.  */
-
-extern char **initial_argv;
-extern int initial_argc;
-
-extern Lisp_Object Vcommand_line_args, Vsystem_name;
-
-/* Tells if a window manager is present or not.  */
-
-extern Lisp_Object Vx_no_window_manager;
-
-extern Lisp_Object Qeql;
-
-/* A mask of extra modifier bits to put into every keyboard char.  */
-
-extern EMACS_INT extra_keyboard_modifiers;
-
 /* The keysyms to use for the various modifiers.  */
 
 Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym;
@@ -330,9 +303,8 @@
 
 /* Used in x_flush.  */
 
-extern Lisp_Object Vinhibit_redisplay;
-
-extern XrmDatabase x_load_resources (Display *, char *, char *, char *);
+extern XrmDatabase x_load_resources (Display *, const char *, const char *,
+				     const char *);
 extern int x_bitmap_mask (FRAME_PTR, int);
 
 static int x_alloc_nearest_color_1 (Display *, Colormap, XColor *);
@@ -379,7 +351,7 @@
                               int *, struct input_event *);
 /* Don't declare this NO_RETURN because we want no
    interference with debugging failing X calls.  */
-static SIGTYPE x_connection_closed (Display *, char *);
+static SIGTYPE x_connection_closed (Display *, const char *);
 
 
 /* Flush display of frame F, or of all frames if F is null.  */
@@ -2842,7 +2814,8 @@
 #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
   /* Make sure scroll bars are redrawn.  As they aren't redrawn by
      redisplay, do it here.  */
-  gtk_widget_queue_draw (FRAME_GTK_WIDGET (f));
+  if (FRAME_GTK_WIDGET (f))
+    gtk_widget_queue_draw (FRAME_GTK_WIDGET (f));
 #endif
 
   XFlush (FRAME_X_DISPLAY (f));
@@ -4398,7 +4371,7 @@
 static void
 x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
 {
-  char *scroll_bar_name = SCROLL_BAR_NAME;
+  const char *scroll_bar_name = SCROLL_BAR_NAME;
 
   BLOCK_INPUT;
   xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
@@ -4531,8 +4504,11 @@
       || f->output_data.x->scroll_bar_bottom_shadow_pixel == -1)
     /* We tried to allocate a color for the top/bottom shadow, and
        failed, so tell Xaw3d to use dithering instead.   */
-    {
-      XtSetArg (av[ac], XtNbeNiceToColormap, True);
+    /* But only if we have a small colormap.  Xaw3d can allocate nice
+       colors itself.  */
+    {
+      XtSetArg (av[ac], XtNbeNiceToColormap,
+                DefaultDepthOfScreen (FRAME_X_SCREEN (f)) < 16);
       ++ac;
     }
   else
@@ -7359,7 +7335,7 @@
    Use ICON_NAME as the text.  */
 
 int
-x_text_icon (struct frame *f, char *icon_name)
+x_text_icon (struct frame *f, const char *icon_name)
 {
   if (FRAME_X_WINDOW (f) == 0)
     return 1;
@@ -7422,7 +7398,7 @@
 
    Calling x_uncatch_errors resumes the normal error handling.  */
 
-void x_check_errors (Display *dpy, char *format);
+void x_check_errors (Display *dpy, const char *format);
 
 void
 x_catch_errors (Display *dpy)
@@ -7464,7 +7440,7 @@
    sprintf (a buffer, FORMAT, the x error message text) as the text.  */
 
 void
-x_check_errors (Display *dpy, char *format)
+x_check_errors (Display *dpy, const char *format)
 {
   /* Make sure to catch any errors incurred so far.  */
   XSync (dpy, False);
@@ -7568,7 +7544,7 @@
    the text of an error message that lead to the connection loss.  */
 
 static SIGTYPE
-x_connection_closed (Display *dpy, char *error_message)
+x_connection_closed (Display *dpy, const char *error_message)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
   Lisp_Object frame, tail;
@@ -7643,7 +7619,6 @@
       /* If DPYINFO is null, this means we didn't open the display
 	 in the first place, so don't try to close it.  */
       {
-        extern void (*fatal_error_signal_hook) (void);
 	fatal_error_signal_hook = x_fatal_error_signal;
 	XtCloseDisplay (dpy);
 	fatal_error_signal_hook = NULL;
@@ -8610,7 +8585,8 @@
 
   compute_fringe_widths (f, 0);
 
-  pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
+  pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols)
+    + FRAME_TOOLBAR_WIDTH (f);
   pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows)
     + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
 
@@ -9010,7 +8986,6 @@
 	    /* It could be confusing if a real alarm arrives while
 	       processing the fake one.  Turn it off and let the
 	       handler reset it.  */
-            extern void poll_for_input_1 (void);
 	    int old_poll_suppress_count = poll_suppress_count;
 	    poll_suppress_count = 1;
 	    poll_for_input_1 ();
@@ -9278,14 +9253,7 @@
 #else  /* !USE_X_TOOLKIT */
 
 #ifdef USE_GTK
-      /* In the GTK version, tooltips are normal X
-         frames.  We must check and free both types. */
-      if (FRAME_GTK_OUTER_WIDGET (f))
-        {
-          gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
-          FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow below */
-          FRAME_GTK_OUTER_WIDGET (f) = 0;
-        }
+      xg_free_frame_widgets (f);
 #endif /* USE_GTK */
 
       if (FRAME_X_WINDOW (f))
@@ -10139,8 +10107,6 @@
   dpyinfo->connection = connection;
 
   {
-    extern int gray_bitmap_width, gray_bitmap_height;
-    extern char *gray_bitmap_bits;
     dpyinfo->gray
       = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
 				     gray_bitmap_bits,
--- a/src/xterm.h	Mon Jul 26 13:29:08 2010 +0900
+++ b/src/xterm.h	Mon Aug 09 10:51:16 2010 +0900
@@ -51,6 +51,10 @@
 #define XSync(d, b) do { gdk_window_process_all_updates (); \
                          XSync (d, b);  } while (0)
 
+/* The GtkTooltip API came in 2.12, but gtk-enable-tooltips in 2.14. */
+#if GTK_MAJOR_VERSION > 2 || GTK_MINOR_VERSION > 13
+#define USE_GTK_TOOLTIP
+#endif
 
 #endif /* USE_GTK */
 
@@ -433,9 +437,15 @@
      if the menubar is turned off.  */
   int menubar_height;
 
-  /* Height of tool bar widget, in pixels.
-     Zero if not using an external tool bar.  */
-  int toolbar_height;
+  /* Height of tool bar widget, in pixels.  top_height is used if tool bar
+     at top, bottom_height if tool bar is at the bottom.
+     Zero if not using an external tool bar or if tool bar is vertical.  */
+  int toolbar_top_height, toolbar_bottom_height;
+
+  /* Width of tool bar widget, in pixels.  left_width is used if tool bar
+     at left, right_width if tool bar is at the right.
+     Zero if not using an external tool bar or if tool bar is horizontal.  */
+  int toolbar_left_width, toolbar_right_width;
 
   /* The tiled border used when the mouse is out of the frame.  */
   Pixmap border_tile;
@@ -480,6 +490,8 @@
   GtkWidget *edit_widget;
   /* The widget used for laying out widgets vertically.  */
   GtkWidget *vbox_widget;
+  /* The widget used for laying out widgets horizontally.  */
+  GtkWidget *hbox_widget;
   /* The menubar in this frame.  */
   GtkWidget *menubar_widget;
   /* The tool bar in this frame  */
@@ -488,11 +500,20 @@
   GtkWidget *handlebox_widget;
   /* Non-zero if the tool bar is detached.  */
   int toolbar_detached;
+  /* Non-zero if tool bar is packed into the hbox widget (i.e. vertical).  */
+  int toolbar_in_hbox;
 
   /* The last size hints set.  */
   GdkGeometry size_hints;
   long hint_flags;
-#endif
+
+#ifdef USE_GTK_TOOLTIP
+  GtkTooltip *ttip_widget;
+  GtkWidget *ttip_lbl;
+  GtkWindow *ttip_window;
+#endif /* USE_GTK_TOOLTIP */
+
+#endif /* USE_GTK */
 
   /* If >=0, a bitmap index.  The indicated bitmap is used for the
      icon. */
@@ -700,7 +721,15 @@
 #define FRAME_FONT(f) ((f)->output_data.x->font)
 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
 #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
-#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.x->toolbar_height)
+#define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height)
+#define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \
+  ((f)->output_data.x->toolbar_bottom_height)
+#define FRAME_TOOLBAR_HEIGHT(f) \
+  (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
+#define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width)
+#define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width)
+#define FRAME_TOOLBAR_WIDTH(f) \
+  (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f))
 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
 
 /* This gives the x_display_info structure for the display F is on.  */
@@ -933,18 +962,21 @@
 EXFUN (Fx_display_color_p, 1);
 EXFUN (Fx_display_grayscale_p, 1);
 extern void x_free_gcs (struct frame *);
+extern int gray_bitmap_width, gray_bitmap_height;
+extern char *gray_bitmap_bits;
 
 /* From xrdb.c.  */
 
-char *x_get_customization_string (XrmDatabase, char *, char *);
-XrmDatabase x_load_resources (Display *, char *, char *, char *);
-int x_get_resource (XrmDatabase, char *, char *,
+char *x_get_customization_string (XrmDatabase, const char *, const char *);
+XrmDatabase x_load_resources (Display *, const char *, const char *,
+			      const char *);
+int x_get_resource (XrmDatabase, const char *, const char *,
                     XrmRepresentation, XrmValue *);
 void x_delete_display (struct x_display_info *);
 void x_make_frame_visible (struct frame *);
 void x_iconify_frame (struct frame *);
 void x_wm_set_size_hint (struct frame *, long, int);
-int x_text_icon (struct frame *, char *);
+int x_text_icon (struct frame *, const char *);
 int x_bitmap_icon (struct frame *, Lisp_Object);
 void x_set_window_size (struct frame *, int, int, int);
 void x_wm_set_window_state (struct frame *, int);
@@ -954,10 +986,10 @@
 
 extern void cancel_mouse_face (struct frame *);
 extern void x_scroll_bar_clear (struct frame *);
-extern int x_text_icon (struct frame *, char *);
+extern int x_text_icon (struct frame *, const char *);
 extern int x_bitmap_icon (struct frame *, Lisp_Object);
 extern void x_catch_errors (Display *);
-extern void x_check_errors (Display *, char *);
+extern void x_check_errors (Display *, const char *);
 extern int x_had_errors_p (Display *);
 extern int x_catching_errors (void);
 extern void x_uncatch_errors (void);
@@ -1018,7 +1050,7 @@
                                   void *,
                                   int);
 extern Lisp_Object x_property_data_to_lisp (struct frame *,
-                                            unsigned char *,
+                                            const unsigned char *,
                                             Atom,
                                             int,
                                             unsigned long);
@@ -1026,14 +1058,15 @@
 /* Defined in xfns.c */
 
 extern struct x_display_info * check_x_display_info (Lisp_Object frame);
+extern Lisp_Object x_get_focus_frame (struct frame *);
 
 #ifdef USE_GTK
 extern int xg_set_icon (struct frame *, Lisp_Object);
-extern int xg_set_icon_from_xpm_data (struct frame *, char**);
+extern int xg_set_icon_from_xpm_data (struct frame *, const char**);
 #endif /* USE_GTK */
 
 extern void x_real_positions (struct frame *, int *, int *);
-extern int defined_color (struct frame *, char *, XColor *, int);
+extern int defined_color (struct frame *, const char *, XColor *, int);
 extern void x_set_border_pixel (struct frame *, int);
 extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
@@ -1042,16 +1075,17 @@
 extern void destroy_frame_xic (struct frame *);
 extern void xic_set_preeditarea (struct window *, int, int);
 extern void xic_set_statusarea (struct frame *);
-extern void xic_set_xfontset (struct frame *, char *);
+extern void xic_set_xfontset (struct frame *, const char *);
 extern int x_pixel_width (struct frame *);
 extern int x_pixel_height (struct frame *);
 extern int x_char_width (struct frame *);
 extern int x_char_height (struct frame *);
 extern int x_screen_planes (struct frame *);
 extern void x_sync (struct frame *);
-extern int x_defined_color (struct frame *, char *, XColor *, int);
+extern int x_defined_color (struct frame *, const char *, XColor *, int);
 #ifdef HAVE_X_I18N
 extern void free_frame_xic (struct frame *);
+extern char * xic_create_fontsetname (const char *base_fontname, int motif);
 #endif
 extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
 
@@ -1135,6 +1169,7 @@
 
 /* Defined in xterm.c */
 
+extern Lisp_Object Qx_gtk_map_stock;
 extern void xembed_set_info (struct frame *f, enum xembed_info flags);
 extern void xembed_send_message (struct frame *f, Time time,
                                  enum xembed_message message,
--- a/test/ChangeLog	Mon Jul 26 13:29:08 2010 +0900
+++ b/test/ChangeLog	Mon Aug 09 10:51:16 2010 +0900
@@ -1,3 +1,20 @@
+2010-08-08  Ulf Jasper  <ulf.jasper@web.de>
+
+	* icalendar-testsuite.el (icalendar-testsuite-run): Added internal tests.
+	(icalendar-testsuite--trim, icalendar-testsuite--compare-strings)
+	(icalendar-testsuite--run-internal-tests): New.
+	(icalendar-testsuite--test-convert-ordinary-to-ical)
+	(icalendar-testsuite--test-convert-block-to-ical)
+	(icalendar-testsuite--test-convert-anniversary-to-ical)
+	(icalendar-testsuite--test-parse-vtimezone)
+	(icalendar-testsuite--do-test-export): Code formatting.
+	(icalendar-testsuite--test-parse-vtimezone): Doc fix.
+	(icalendar-testsuite--do-test-import)
+	(icalendar-testsuite--do-test-cycle): Use icalendar-testsuite--compare-strings
+	(icalendar-testsuite--run-import-tests): Comment added.
+	(icalendar-testsuite--run-import-tests)
+	(icalendar-testsuite--run-real-world-tests): Fixed expected results.
+
 2010-06-25  Chong Yidong  <cyd@stupidchicken.com>
 
 	* redisplay-testsuite.el (test-redisplay-3): New test.
--- a/test/icalendar-testsuite.el	Mon Jul 26 13:29:08 2010 +0900
+++ b/test/icalendar-testsuite.el	Mon Aug 09 10:51:16 2010 +0900
@@ -33,6 +33,7 @@
 (defun icalendar-testsuite-run ()
   "Run icalendar test suite."
   (interactive)
+  (icalendar-testsuite--run-internal-tests)
   (icalendar-testsuite--run-function-tests)
   (icalendar-testsuite--run-import-tests)
   (icalendar-testsuite--run-export-tests)
@@ -41,6 +42,44 @@
   (message "All icalendar tests finished successfully."))
 
 ;; ======================================================================
+;; internal
+;; ======================================================================
+(defun icalendar-testsuite--trim (string)
+  "Remove leading and trailing whitespace from STRING."
+  (replace-regexp-in-string "[ \t\n]+\\'" ""
+                            (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
+
+(defun icalendar-testsuite--compare-strings (str1 str2)
+  "Compare strings STR1 and STR2.
+Return t if strings are equal, else return substring indicating first difference.
+FIXME: make this a little smarter."
+  (let* ((s1 (icalendar-testsuite--trim str1))
+         (s2 (icalendar-testsuite--trim str2))
+         (result (compare-strings s1 0 nil s2 0 nil))
+         (len (length str2)))
+    (if (numberp result)
+        (if (> result 0)
+            (concat "..." (substring str2 (- result 1)
+                                     (min len (+ (- result 1) 3))) "...")
+          (concat "..." (substring str2 (- (+ result 1))
+                                   (min len  (+ (- (+ result 1)) 3))) "..."))
+      t)))
+
+(defun icalendar-testsuite--run-internal-tests ()
+  "Run icalendar-testsuite internal tests."
+  (assert (equal t (icalendar-testsuite--compare-strings " abcde" "abcde ")))
+  (assert
+   (string= "...def..."
+            (icalendar-testsuite--compare-strings "abcxe" "abcdefghijklmn")))
+  (assert (string= "...xe..."
+                   (icalendar-testsuite--compare-strings "abcde" "abcxe")))
+  (assert (string= "...ddd..."
+           (icalendar-testsuite--compare-strings "abc" "abcdddddd")))
+  (assert (string= "......"
+                   (icalendar-testsuite--compare-strings "abcdefghij" "abc"))))
+  
+
+;; ======================================================================
 ;; Test methods for functions
 ;; ======================================================================
 (defun icalendar-testsuite--run-function-tests ()
@@ -260,7 +299,7 @@
     (assert (string= "subject" (cadr result)))
   
     ;; with time
-    (setq result (icalendar--convert-ordinary-to-ical 
+    (setq result (icalendar--convert-ordinary-to-ical
                   "&?" "&2010 2 15 12:34-23:45 s"))
     (assert (= 2 (length result)))
     (assert (string=  (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
@@ -269,7 +308,7 @@
     (assert (string= "s" (cadr result)))
 
     ;; with time, again -- test bug#5549
-    (setq result (icalendar--convert-ordinary-to-ical 
+    (setq result (icalendar--convert-ordinary-to-ical
                   "x?" "x2010 2 15 0:34-1:45 s"))
     (assert (= 2 (length result)))
     (assert (string=  (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
@@ -312,7 +351,7 @@
   "Test method for `icalendar--convert-block-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-block-to-ical 
+    (setq result (icalendar--convert-block-to-ical
                   "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -325,7 +364,7 @@
   "Test method for `icalendar--convert-cyclic-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-block-to-ical 
+    (setq result (icalendar--convert-block-to-ical
                   "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -338,7 +377,7 @@
   "Test method for `icalendar--convert-anniversary-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-anniversary-to-ical 
+    (setq result (icalendar--convert-anniversary-to-ical
                   "" "%%(diary-anniversary 1964 6 30) g"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -386,6 +425,7 @@
     ))
 
 (defun icalendar-testsuite--test-parse-vtimezone ()
+  "Test method for `icalendar--parse-vtimezone'."
   (let (vtimezone result)
     (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
 TZID:thename
@@ -406,7 +446,8 @@
     (setq result (icalendar--parse-vtimezone vtimezone))
     (assert (string= "thename" (car result)))
     (message (cdr result))
-    (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" (cdr result)))
+    (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
+                     (cdr result)))
     (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
 TZID:anothername
 BEGIN:STANDARD
@@ -457,7 +498,7 @@
         (icalendar-testsuite--do-test-export input-iso expected-output)))
     (when input-european
       (let ((calendar-month-name-array
-             ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
+             ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
               "September" "Oktober" "November" "Dezember"])
             (calendar-day-name-array
              ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
@@ -511,12 +552,18 @@
 \\s-*$"
                                     nil t)))
         (error
-         "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s"
+         "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s"
          input
          (or (and (match-beginning 1)
-                  (buffer-substring-no-properties (match-beginning 1) (match-end 1)))
+                  (buffer-substring-no-properties (match-beginning 1)
+                                                  (match-end 1)))
              "<nil>")
-         (or expected-output "<nil>"))))
+         (or expected-output "<nil>")
+         (icalendar-testsuite--compare-strings   (or (and (match-beginning 1)
+                  (buffer-substring-no-properties (match-beginning 1)
+                                                  (match-end 1)))
+             "<nil>")
+         (or expected-output "<nil>")))))
     (kill-buffer (find-buffer-visiting temp-file))
     (delete-file temp-file)))
 
@@ -571,11 +618,13 @@
     (icalendar-import-buffer temp-file t t)
     (save-excursion
       (find-file temp-file)
-      (let ((result (buffer-substring-no-properties (point-min) (point-max))))
-        (unless (string-match (concat "^\\s-*" expected-output "\\s-*$")
-                              result)
-          (error "Import test failed! Found `%s'\nbut expected `%s'" result
-                 expected-output)))
+      (let* ((result (buffer-substring-no-properties (point-min) (point-max)))
+             (difference
+              (icalendar-testsuite--compare-strings result
+                                                    expected-output)))
+        (if (stringp difference)
+          (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
+                 result expected-output difference)))
       (kill-buffer (find-buffer-visiting temp-file))
       (delete-file temp-file))))
 
@@ -626,9 +675,12 @@
       (when (re-search-forward "\nUID:.*\n" nil t)
         (replace-match "\n"))
       (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
-        (unless (string-equal org-input cycled)
-          (error "Import test failed! Found `%s'\nbut expected `%s'" cycled
-                 org-input))))
+        (let ((difference (icalendar-testsuite--compare-strings cycled
+                                                                org-input)))
+          (if (stringp difference)
+              (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
+                     cycled org-input difference)))
+        ))
 
     ;; clean up -- Note this is done only if test is passed
     (kill-buffer (find-buffer-visiting temp-diary))
@@ -660,6 +712,7 @@
    "&9/19/2003 non-recurring allday")
 
   (icalendar-testsuite--test-import
+   ;; do not remove the trailing blank after "long"!
    "SUMMARY:long 
  summary
 DTSTART;VALUE=DATE:20030919"
@@ -678,9 +731,17 @@
 DTEND;VALUE=DATE:20040828
 DTSTAMP:20031103T011641Z
 "
-   "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien"
-   "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien"
-   "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien")
+   "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE
+"
+   "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE
+"
+   "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE")
 
   (icalendar-testsuite--test-import
    "UID
@@ -702,9 +763,15 @@
 LAST-MODIFIED
  :20041118T013640Z
 "
-   "&2004/11/23 14:00-14:30 folded summary"
-   "&23/11/2004 14:00-14:30 folded summary"
-   "&11/23/2004 14:00-14:30 folded summary")
+   "&2004/11/23 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&23/11/2004 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&11/23/2004 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE")
   (icalendar-testsuite--test-import
    "UID
  :6161a312-3902-11d9-b512-f764153bb28b
@@ -723,9 +790,15 @@
 DTSTAMP
  :20041118T013641Z
 "
-   "&2004/11/23 14:45-15:45 another example"
-   "&23/11/2004 14:45-15:45 another example"
-   "&11/23/2004 14:45-15:45 another example")
+   "&2004/11/23 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&23/11/2004 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&11/23/2004 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE")
 
   (icalendar-testsuite--test-import
    "SUMMARY:rrule daily
@@ -890,10 +963,55 @@
 SEQUENCE:1
 CREATED:20041127T183329
 "
-   "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29))  Urlaub"
-   "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001))  Urlaub"
-   "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001))  Urlaub")
-  )
+   "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29))  Urlaub
+ Class: PUBLIC"
+   "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001))  Urlaub
+ Class: PUBLIC"
+   "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001))  Urlaub
+ Class: PUBLIC")
+
+  ;;bug#6766 -- multiple byday values in a weekly rrule
+  (icalendar-testsuite--test-import
+"CLASS:PUBLIC
+DTEND;TZID=America/New_York:20100421T120000
+DTSTAMP:20100525T141214Z
+DTSTART;TZID=America/New_York:20100421T113000
+RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
+SEQUENCE:1
+STATUS:CONFIRMED
+SUMMARY:Scrum
+TRANSP:OPAQUE
+UID:8814e3f9-7482-408f-996c-3bfe486a1262
+END:VEVENT
+BEGIN:VEVENT
+CLASS:PUBLIC
+DTSTAMP:20100525T141214Z
+DTSTART;VALUE=DATE:20100422
+DTEND;VALUE=DATE:20100423
+RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
+SEQUENCE:1
+SUMMARY:Tues + Thurs thinking
+TRANSP:OPAQUE
+UID:8814e3f9-7482-408f-996c-3bfe486a1263
+"
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
+ Class: PUBLIC"
+
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
+ Class: PUBLIC"
+
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
+ Class: PUBLIC")
+)
 
 ;; ======================================================================
 ;; Export tests
@@ -1104,11 +1222,13 @@
    "&9/5/2003 10:30-15:30 On-Site Interview
  Desc: 10:30am - Blah
  Location: Cccc
- Organizer: MAILTO:aaaaaaa@aaaaaaa.com"
+ Organizer: MAILTO:aaaaaaa@aaaaaaa.com
+ Status: CONFIRMED"
    "&5/9/2003 10:30-15:30 On-Site Interview
  Desc: 10:30am - Blah
  Location: Cccc
- Organizer: MAILTO:aaaaaaa@aaaaaaa.com")
+ Organizer: MAILTO:aaaaaaa@aaaaaaa.com
+ Status: CONFIRMED")
 
   ;; 2003-06-18 a
   (icalendar-testsuite--test-import
@@ -1146,11 +1266,13 @@
    "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
  Desc: 753 Zeichen hier radiert
  Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
- Organizer: MAILTO:xxx@xxxxx.com"
+ Organizer: MAILTO:xxx@xxxxx.com
+ Status: CONFIRMED"
    "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
  Desc: 753 Zeichen hier radiert
  Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
- Organizer: MAILTO:xxx@xxxxx.com")
+ Organizer: MAILTO:xxx@xxxxx.com
+ Status: CONFIRMED")
 
   ;; 2003-06-18 b -- uses timezone
   (icalendar-testsuite--test-import
@@ -1188,7 +1310,7 @@
 \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
 LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
-DESCRIPTION:Viele Zeichen standen hier früher
+DESCRIPTION:Viele Zeichen standen hier früher
 SEQUENCE:0
 PRIORITY:5
 CLASS:
@@ -1211,12 +1333,12 @@
 END:VCALENDAR"
    nil
    "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
- Desc: Viele Zeichen standen hier früher
+ Desc: Viele Zeichen standen hier früher
  Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
  Organizer: MAILTO:bbb@bbbbb.com
  Status: CONFIRMED"
    "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
- Desc: Viele Zeichen standen hier früher
+ Desc: Viele Zeichen standen hier früher
  Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
  Organizer: MAILTO:bbb@bbbbb.com
  Status: CONFIRMED")
@@ -1661,9 +1783,13 @@
  :20050128T011209Z"
    nil
    "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
- Desc: abcdef"
+ Desc: abcdef
+ Status: CONFIRMED
+ Class: PRIVATE"
    "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
- Desc: abcdef")
+ Desc: abcdef
+ Status: CONFIRMED
+ Class: PRIVATE")
 
   ;; 2005-03-01 lt
   (icalendar-testsuite--test-import