changeset 108550:339bb0f23bf9

merge trunk
author Kenichi Handa <handa@etlken>
date Thu, 06 May 2010 09:50:39 +0900
parents c6c7a71f6e16 (current diff) b597fe1cdc14 (diff)
children d4c436ea51f4
files src/m/ibmrs6000.inp
diffstat 140 files changed, 3116 insertions(+), 2788 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,57 @@
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (LD_SWITCH_X_SITE_AUX): Use AC_SUBST only, not AC_DEFINE
+	as well.
+	(LD_SWITCH_X_SITE_AUX_RPATH): New output variable.
+
+	* configure.in (LD_SWITCH_SYSTEM_TEMACS): New output variable.
+
+	* configure.in (C_SWITCH_MACHINE, C_SWITCH_SYSTEM): New output
+	variables, replacing c_switch_machine, c_switch_system.
+	* Makefile.in (C_SWITCH_SYSTEM): Use @C_SWITCH_SYSTEM@ rather than
+	@c_switch_system@.
+
+2010-05-03  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (LIBXT_OTHER, LIBX_OTHER): New output variables.
+
+	* make-dist: There are no more src/m/*.inp files.
+
+2010-05-01  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in (LD_SWITCH_MACHINE, ld_switch_machine): Remove, unused.
+	(ac_link): Do not use ld_switch_machine.
+
+2010-05-01  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (OTHER_OBJ): Remove.
+	(PRE_ALLOC_OBJ, POST_ALLOC_OBJ): New output variables.
+
+2010-04-30  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (OTHER_OBJ): Always include vm-limit.o on Cygwin.
+	Elsewhere, maybe include it.
+
+	* configure.in (TOOLKIT_LIBW) [HAVE_GTK]: Set to $GTK_LIBS.
+	(OLDXMENU, LIBXMENU): New output variables.
+
+	* configure.in (OTHER_OBJ): New output variable.
+
+2010-04-28  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (CYGWIN_OBJ): New output variable.
+
+	* configure.in (GPM_MOUSE_SUPPORT): New output variable.
+
+	* configure.in (FONT_OBJ): New output variable.
+
+	* configure.in (LIBXMU): New output variable.
+
+	* configure.in (NS_OBJ, NS_SUPPORT): New output variables.
+
+	* configure.in (machine, canonical): On amdx86-64, check for a 32-bit
+	userland and maybe change values to i386 (move test from s/amdx86-64.h).
+
 2010-04-27  Glenn Morris  <rgm@gnu.org>
 
 	* configure.in (LIBXTR6): New output variable.  Move unixware special
--- a/Makefile.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/Makefile.in	Thu May 06 09:50:39 2010 +0900
@@ -70,7 +70,7 @@
 
 CC=@CC@
 CPP=@CPP@
-C_SWITCH_SYSTEM=@c_switch_system@
+C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
 ALLOCA=@ALLOCA@
 LN_S=@LN_S@
 CFLAGS=@CFLAGS@
--- a/admin/CPP-DEFINES	Wed Apr 28 10:00:38 2010 +0900
+++ b/admin/CPP-DEFINES	Thu May 06 09:50:39 2010 +0900
@@ -67,7 +67,6 @@
 EXPLICIT_SIGN_EXTEND
 LOAD_AVE_CVT
 LOAD_AVE_TYPE
-NO_ARG_ARRAY
 NO_REMAP
 VIRT_ADDR_VARIES
 WORDS_BIG_ENDIAN
@@ -98,13 +97,9 @@
 BROKEN_SIGPTY
 BSD4_2
 BSD4_3
-BSD_PGRPS
 BSD_SYSTEM
 CLASH_DETECTION
 COFF_BSD_SYMBOLS
-CRT0_DUMMIES
-C_SWITCH_MACHINE
-C_SWITCH_SYSTEM
 C_SWITCH_X_SYSTEM
 DATA_SEG_BITS
 DATA_START
@@ -216,20 +211,15 @@
 HAVE_WORKING_VFORK
 HAVE_XRMSETDATABASE
 HPUX
-IBMR2AIX
 INHIBIT_X11R6_XIM
 INTERNAL_TERMINAL
 IS_ANY_SEP
 IS_DIRECTORY_SEP
 KERNEL_FILE
 LDAV_SYMBOL
-LD_SWITCH_MACHINE
-LD_SWITCH_MACHINE_TEMACS
 LD_SWITCH_SYSTEM
-LD_SWITCH_SYSTEM_TEMACS
 LD_SWITCH_SYSTEM_tmp
 LD_SWITCH_X_DEFAULT
-LIBS_MACHINE
 LIBS_SYSTEM
 LIBS_TERMCAP
 LIBXMU
@@ -253,7 +243,6 @@
 NEED_UNISTD_H
 NLIST_STRUCT
 NOT_C_CODE
-NOT_USING_MOTIF
 NO_ABORT
 NO_DIR_LIBRARY
 NO_EDITRES
@@ -278,7 +267,6 @@
 PAGESIZE
 PENDING_OUTPUT_COUNT
 POSIX
-POSIX_SIGNALS
 PREFER_VSUSP
 PTY_ITERATION
 PTY_NAME_SPRINTF
--- a/configure	Wed Apr 28 10:00:38 2010 +0900
+++ b/configure	Thu May 06 09:50:39 2010 +0900
@@ -703,6 +703,8 @@
 GZIP_PROG
 MAKEINFO
 LIB_MATH
+C_SWITCH_MACHINE
+C_SWITCH_SYSTEM
 CRT_DIR
 LIBSOUND
 PKG_CONFIG
@@ -711,6 +713,10 @@
 CFLAGS_SOUND
 SET_MAKE
 XMKMF
+LD_SWITCH_X_SITE_AUX
+LD_SWITCH_X_SITE_AUX_RPATH
+NS_OBJ
+NS_SUPPORT
 HAVE_XSERVER
 RSVG_CFLAGS
 RSVG_LIBS
@@ -724,6 +730,7 @@
 GCONF_LIBS
 LIBSELINUX_LIBS
 LIBXTR6
+LIBXMU
 FONTCONFIG_CFLAGS
 FONTCONFIG_LIBS
 XFT_CFLAGS
@@ -732,6 +739,7 @@
 LIBOTF_LIBS
 M17N_FLT_CFLAGS
 M17N_FLT_LIBS
+FONT_OBJ
 FREETYPE_CFLAGS
 FREETYPE_LIBS
 LIBXPM
@@ -740,6 +748,7 @@
 LIBTIFF
 LIBGIF
 LIBGPM
+GPM_MOUSE_SUPPORT
 LIBXSM
 ALLOCA
 liblockfile
@@ -770,11 +779,8 @@
 bitmapdir
 gamedir
 gameuser
-c_switch_system
-c_switch_machine
 unexec
 LD_SWITCH_X_SITE
-LD_SWITCH_X_SITE_AUX
 C_SWITCH_X_SITE
 C_SWITCH_X_SYSTEM
 X_TOOLKIT_TYPE
@@ -794,6 +800,14 @@
 XOBJ
 WIDGET_OBJ
 TOOLKIT_LIBW
+LIBXT_OTHER
+OLDXMENU
+LIBXMENU
+LIBX_OTHER
+CYGWIN_OBJ
+PRE_ALLOC_OBJ
+POST_ALLOC_OBJ
+LD_SWITCH_SYSTEM_TEMACS
 LTLIBOBJS'
 ac_subst_files=''
 ac_user_opts='
@@ -5448,6 +5462,73 @@
 fi
 
 fi
+
+## Although we're running on an amd64 kernel, we're actually compiling for
+## the x86 architecture.  The user should probably have provided an
+## explicit --build to `configure', but if everything else than the kernel
+## is running in i386 mode, we can help them out.
+if test "$machine" = "amdx86-64"; then
+  { $as_echo "$as_me:$LINENO: checking whether i386 is declared" >&5
+$as_echo_n "checking whether i386 is declared... " >&6; }
+if test "${ac_cv_have_decl_i386+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+#ifndef i386
+  (void) i386;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_have_decl_i386=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_have_decl_i386=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_i386" >&5
+$as_echo "$ac_cv_have_decl_i386" >&6; }
+
+  if test "$ac_cv_have_decl_i386" = "yes"; then
+    canonical=`echo "$canonical" | sed -e 's/^amd64/i386/' -e 's/^x86_64/i386/'`
+    machine=intel386
+    machfile="m/${machine}.h"
+  fi
+fi
+
 # Extract the first word of "install-info", so it can be a program name with args.
 set dummy install-info; ac_word=$2
 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -5787,15 +5868,7 @@
 #ifndef LIBS_SYSTEM
 #define LIBS_SYSTEM
 #endif
-#ifndef C_SWITCH_SYSTEM
-#define C_SWITCH_SYSTEM
-#endif
-#ifndef C_SWITCH_MACHINE
-#define C_SWITCH_MACHINE
-#endif
 configure___ libsrc_libs=LIBS_SYSTEM
-configure___ c_switch_system=C_SWITCH_SYSTEM
-configure___ c_switch_machine=C_SWITCH_MACHINE
 
 configure___ LIBX=-lX11
 
@@ -5825,20 +5898,11 @@
 #define C_WARNINGS_SWITCH ${C_WARNINGS_SWITCH}
 #endif
 
-#ifndef LD_SWITCH_MACHINE
-#define LD_SWITCH_MACHINE
-#endif
-
 #ifndef LD_SWITCH_SYSTEM
 #define LD_SWITCH_SYSTEM
 #endif
 
-#ifndef LD_SWITCH_X_SITE_AUX
-#define LD_SWITCH_X_SITE_AUX
-#endif
-
 configure___ ld_switch_system=LD_SWITCH_SYSTEM
-configure___ ld_switch_machine=LD_SWITCH_MACHINE
 
 #ifdef THIS_IS_CONFIGURE
 
@@ -5876,14 +5940,100 @@
 fi
 rm ${tempcname}
 
-ac_link="$ac_link $ld_switch_machine $ld_switch_system"
+ac_link="$ac_link $ld_switch_system"
+
+
+C_SWITCH_MACHINE=
+if test "$machine" = "alpha"; then
+  { $as_echo "$as_me:$LINENO: checking whether __ELF__ is declared" >&5
+$as_echo_n "checking whether __ELF__ is declared... " >&6; }
+if test "${ac_cv_have_decl___ELF__+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+#ifndef __ELF__
+  (void) __ELF__;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_have_decl___ELF__=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_have_decl___ELF__=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl___ELF__" >&5
+$as_echo "$ac_cv_have_decl___ELF__" >&6; }
+
+  if test "$ac_cv_have_decl___ELF__" = "yes"; then
+    ## With ELF, make sure that all common symbols get allocated to in the
+    ## data section.  Otherwise, the dump of temacs may miss variables in
+    ## the shared library that have been initialized.  For example, with
+    ## GNU libc, __malloc_initialized would normally be resolved to the
+    ## shared library's .bss section, which is fatal.
+    if test "x$GCC" = "xyes"; then
+      C_SWITCH_MACHINE="-fno-common"
+    else
+      { { $as_echo "$as_me:$LINENO: error: What gives?  Fix me if DEC Unix supports ELF now." >&5
+$as_echo "$as_me: error: What gives?  Fix me if DEC Unix supports ELF now." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+
+
+
+C_SWITCH_SYSTEM=
+## Some programs in src produce warnings saying certain subprograms
+## are too complex and need a MAXMEM value greater than 2000 for
+## additional optimization.  --nils@exp-math.uni-essen.de
+test "$opsys" = "aix4.2" && test "x$GCC" = "xyes" && \
+  C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
+## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
+## It is redundant in glibc2, since we define _GNU_SOURCE.
+
+
 
 ### Make sure subsequent tests use flags consistent with the build flags.
 
 if test x"${OVERRIDE_CPPFLAGS}" != x; then
   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
 else
-  CPPFLAGS="$c_switch_system $c_switch_machine $CPPFLAGS"
+  CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
 fi
 
 
@@ -9654,17 +9804,19 @@
 ## Workaround for bug in autoconf <= 2.62.
 ## http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01551.html
 ## No need to do anything special for these standard directories.
-## This is an experiment, take it out if it causes problems.
 if test -n "${x_libraries}" && test x"${x_libraries}" != xNONE; then
 
    x_libraries=`echo :${x_libraries}: | sed -e 's|:/usr/lib64:|:|g' -e 's|:/lib64:|:|g' -e 's|^:||' -e 's|:$||'`
 
 fi
 
+LD_SWITCH_X_SITE_AUX=
+LD_SWITCH_X_SITE_AUX_RPATH=
 if test "${x_libraries}" != NONE; then
   if test -n "${x_libraries}"; then
     LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
     LD_SWITCH_X_SITE_AUX=-R`echo ${x_libraries} | sed -e "s/:/ -R/g"`
+    LD_SWITCH_X_SITE_AUX_RPATH=`echo ${LD_SWITCH_X_SITE_AUX} | sed -e 's/-R/-Wl,-rpath,/'`
   fi
   x_default_search_path=""
   x_search_path=${x_libraries}
@@ -9687,6 +9839,9 @@
     fi
   done
 fi
+
+
+
 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
   C_SWITCH_X_SITE=-I`echo ${x_includes} | sed -e "s/:/ -I/g"`
 fi
@@ -9922,6 +10077,9 @@
     NS_HAVE_NSINTEGER=no
   fi
 fi
+
+NS_OBJ=
+NS_SUPPORT=
 if test "${HAVE_NS}" = yes; then
   window_system=nextstep
   with_xft=no
@@ -9931,10 +10089,14 @@
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
   fi
+  NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
+  NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
 
+
+
 case "${window_system}" in
   x11 )
     HAVE_X_WINDOWS=yes
@@ -13176,6 +13338,15 @@
 fi
 
 
+LIBXMU=-lXmu
+case "$machine" in
+  ## These machines don't supply Xmu.
+  hpux* | aix4-2 )
+    test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
+    ;;
+esac
+
+
 # On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
 if test "${HAVE_X11}" = "yes"; then
   if test "${USE_X_TOOLKIT}" != "none"; then
@@ -14442,6 +14613,15 @@
     HAVE_LIBOTF=no
     HAVE_M17N_FLT=no
 fi
+
+FONT_OBJ=xfont.o
+if test "$HAVE_XFT" = "yes"; then
+  FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
+elif test "$HAVE_FREETYPE" = "yes"; then
+  FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
+fi
+
+
 ### End of font-backend (under X11) section.
 
 
@@ -15735,6 +15915,7 @@
 ### Use -lgpm if available, unless `--with-gpm=no'.
 HAVE_GPM=no
 LIBGPM=
+GPM_MOUSE_SUPPORT=
 if test "${with_gpm}" != "no"; then
   if test "${ac_cv_header_gpm_h+set}" = set; then
   { $as_echo "$as_me:$LINENO: checking for gpm.h" >&5
@@ -15944,8 +16125,10 @@
 _ACEOF
 
     LIBGPM=-lgpm
-  fi
-fi
+    GPM_MOUSE_SUPPORT="\${lispsource}mouse.elc"
+  fi
+fi
+
 
 
 if test "${ac_cv_header_malloc_malloc_h+set}" = set; then
@@ -25889,9 +26072,6 @@
 
 
 
-
-
-
 ## Used in lwlib/Makefile.in.
 
 
@@ -25935,11 +26115,6 @@
 
 
 cat >>confdefs.h <<_ACEOF
-#define LD_SWITCH_X_SITE_AUX ${LD_SWITCH_X_SITE_AUX}
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
 #define C_SWITCH_X_SITE ${C_SWITCH_X_SITE}
 _ACEOF
 
@@ -26002,20 +26177,53 @@
 fi
 
 
+TOOLKIT_LIBW=
 case "$USE_X_TOOLKIT" in
   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
-  *) TOOLKIT_LIBW= ;;
-esac
-
-
+  none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
+esac
+
+
+if test "$USE_X_TOOLKIT" = "none"; then
+  LIBXT_OTHER="\$(LIBXSM)"
+else
+  LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
+fi
+
+
+## The X Menu stuff is present in the X10 distribution, but missing
+## from X11.  If we have X10, just use the installed library;
+## otherwise, use our own copy.
 if test "${HAVE_X11}" = "yes" ; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_X11 1
 _ACEOF
 
-fi
+
+  if test "$USE_X_TOOLKIT" = "none"; then
+    OLDXMENU="\${oldXMenudir}libXMenu11.a"
+  else
+    OLDXMENU="\${lwlibdir}liblw.a"
+  fi
+  LIBXMENU="\$(OLDXMENU)"
+  LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
+else
+  OLDXMENU=
+  LIBXMENU="-lXMenu"
+  LIBX_OTHER=
+fi
+
+if test "$HAVE_GTK" = "yes"; then
+  OLDXMENU=
+  LIBXMENU=
+fi
+
+
+
+
+
 if test "${HAVE_MENUS}" = "yes" ; then
 
 cat >>confdefs.h <<\_ACEOF
@@ -26039,6 +26247,44 @@
 fi
 
 
+if test "$opsys" = "cygwin"; then
+  CYGWIN_OBJ="sheap.o"
+  ## Cygwin differs because of its unexec().
+  PRE_ALLOC_OBJ=
+  POST_ALLOC_OBJ="lastfile.o vm-limit.o"
+else
+  CYGWIN_OBJ=
+  PRE_ALLOC_OBJ=lastfile.o
+  POST_ALLOC_OBJ="\$(vmlimitobj)"
+fi
+
+
+
+
+
+case "$opsys" in
+  aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
+
+  darwin)
+  ## The -headerpad option tells ld (see man page) to leave room at the
+  ## end of the header for adding load commands.  Needed for dumping.
+  ## 0x690 is the total size of 30 segment load commands (at 56
+  ## each); under Cocoa 31 commands are required.
+  if test "$HAVE_NS" = "yes"; then
+    libs_nsgui="-framework AppKit"
+    headerpad_extra=6C8
+  else
+    libs_nsgui=
+    headerpad_extra=690
+  fi
+  LD_SWITCH_SYSTEM_TEMACS="-prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
+  ;;
+
+  *) LD_SWITCH_SYSTEM_TEMACS= ;;
+esac
+
+
+
 
 
 
--- a/configure.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/configure.in	Thu May 06 09:50:39 2010 +0900
@@ -761,6 +761,20 @@
 if test "x$RANLIB" = x; then
   AC_PROG_RANLIB
 fi
+
+## Although we're running on an amd64 kernel, we're actually compiling for
+## the x86 architecture.  The user should probably have provided an
+## explicit --build to `configure', but if everything else than the kernel
+## is running in i386 mode, we can help them out.
+if test "$machine" = "amdx86-64"; then
+  AC_CHECK_DECL([i386])
+  if test "$ac_cv_have_decl_i386" = "yes"; then
+    canonical=`echo "$canonical" | sed -e 's/^amd64/i386/' -e 's/^x86_64/i386/'`
+    machine=intel386
+    machfile="m/${machine}.h"
+  fi
+fi
+
 AC_PATH_PROG(INSTALL_INFO, install-info)
 AC_PATH_PROG(INSTALL_INFO, install-info,, /usr/sbin)
 AC_PATH_PROG(INSTALL_INFO, install-info,:, /sbin)
@@ -869,15 +883,7 @@
 #ifndef LIBS_SYSTEM
 #define LIBS_SYSTEM
 #endif
-#ifndef C_SWITCH_SYSTEM
-#define C_SWITCH_SYSTEM
-#endif
-#ifndef C_SWITCH_MACHINE
-#define C_SWITCH_MACHINE
-#endif
 configure___ libsrc_libs=LIBS_SYSTEM
-configure___ c_switch_system=C_SWITCH_SYSTEM
-configure___ c_switch_machine=C_SWITCH_MACHINE
 
 configure___ LIBX=-lX11
 
@@ -907,20 +913,11 @@
 #define C_WARNINGS_SWITCH ${C_WARNINGS_SWITCH}
 #endif
 
-#ifndef LD_SWITCH_MACHINE
-#define LD_SWITCH_MACHINE
-#endif
-
 #ifndef LD_SWITCH_SYSTEM
 #define LD_SWITCH_SYSTEM
 #endif
 
-#ifndef LD_SWITCH_X_SITE_AUX
-#define LD_SWITCH_X_SITE_AUX
-#endif
-
 configure___ ld_switch_system=LD_SWITCH_SYSTEM
-configure___ ld_switch_machine=LD_SWITCH_MACHINE
 
 #ifdef THIS_IS_CONFIGURE
 
@@ -958,14 +955,45 @@
 fi]
 rm ${tempcname}
 
-ac_link="$ac_link $ld_switch_machine $ld_switch_system"
+ac_link="$ac_link $ld_switch_system"
+
+
+C_SWITCH_MACHINE=
+if test "$machine" = "alpha"; then
+  AC_CHECK_DECL([__ELF__])
+  if test "$ac_cv_have_decl___ELF__" = "yes"; then
+    ## With ELF, make sure that all common symbols get allocated to in the
+    ## data section.  Otherwise, the dump of temacs may miss variables in
+    ## the shared library that have been initialized.  For example, with
+    ## GNU libc, __malloc_initialized would normally be resolved to the
+    ## shared library's .bss section, which is fatal.
+    if test "x$GCC" = "xyes"; then
+      C_SWITCH_MACHINE="-fno-common"
+    else
+      AC_MSG_ERROR([What gives?  Fix me if DEC Unix supports ELF now.])
+    fi
+  fi
+fi
+AC_SUBST(C_SWITCH_MACHINE)
+
+
+C_SWITCH_SYSTEM=
+## Some programs in src produce warnings saying certain subprograms
+## are too complex and need a MAXMEM value greater than 2000 for
+## additional optimization.  --nils@exp-math.uni-essen.de
+test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
+  C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
+## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
+## It is redundant in glibc2, since we define _GNU_SOURCE.
+AC_SUBST(C_SWITCH_SYSTEM)
+
 
 ### Make sure subsequent tests use flags consistent with the build flags.
 
 if test x"${OVERRIDE_CPPFLAGS}" != x; then
   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
 else
-  CPPFLAGS="$c_switch_system $c_switch_machine $CPPFLAGS"
+  CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
 fi
 
 dnl For AC_FUNC_GETLOADAVG, at least:
@@ -1294,17 +1322,19 @@
 ## Workaround for bug in autoconf <= 2.62.
 ## http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01551.html
 ## No need to do anything special for these standard directories.
-## This is an experiment, take it out if it causes problems.
 if test -n "${x_libraries}" && test x"${x_libraries}" != xNONE; then
 
    x_libraries=`echo :${x_libraries}: | sed -e 's|:/usr/lib64:|:|g' -e 's|:/lib64:|:|g' -e 's|^:||' -e 's|:$||'`
 
 fi
 
+LD_SWITCH_X_SITE_AUX=
+LD_SWITCH_X_SITE_AUX_RPATH=
 if test "${x_libraries}" != NONE; then
   if test -n "${x_libraries}"; then
     LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
     LD_SWITCH_X_SITE_AUX=-R`echo ${x_libraries} | sed -e "s/:/ -R/g"`
+    LD_SWITCH_X_SITE_AUX_RPATH=`echo ${LD_SWITCH_X_SITE_AUX} | sed -e 's/-R/-Wl,-rpath,/'`
   fi
   x_default_search_path=""
   x_search_path=${x_libraries}
@@ -1327,6 +1357,9 @@
     fi
   done
 fi
+AC_SUBST(LD_SWITCH_X_SITE_AUX)
+AC_SUBST(LD_SWITCH_X_SITE_AUX_RPATH)
+
 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
   C_SWITCH_X_SITE=-I`echo ${x_includes} | sed -e "s/:/ -I/g"`
 fi
@@ -1390,6 +1423,9 @@
     NS_HAVE_NSINTEGER=no
   fi
 fi
+
+NS_OBJ=
+NS_SUPPORT=
 if test "${HAVE_NS}" = yes; then
   window_system=nextstep
   with_xft=no
@@ -1399,9 +1435,13 @@
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
   fi
+  NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
+  NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
+AC_SUBST(NS_OBJ)
+AC_SUBST(NS_SUPPORT)
 
 case "${window_system}" in
   x11 )
@@ -1869,6 +1909,17 @@
 fi
 AC_SUBST(LIBXTR6)
 
+dnl FIXME the logic here seems weird, but this is what cpp was doing.
+dnl Why not just test for libxmu in the normal way?
+LIBXMU=-lXmu
+case "$machine" in
+  ## These machines don't supply Xmu.
+  hpux* | aix4-2 )
+    test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
+    ;;
+esac
+AC_SUBST(LIBXMU)
+
 # On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
 if test "${HAVE_X11}" = "yes"; then
   if test "${USE_X_TOOLKIT}" != "none"; then
@@ -2089,6 +2140,15 @@
     HAVE_LIBOTF=no
     HAVE_M17N_FLT=no
 fi
+
+FONT_OBJ=xfont.o
+if test "$HAVE_XFT" = "yes"; then
+  FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
+elif test "$HAVE_FREETYPE" = "yes"; then
+  FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
+fi
+AC_SUBST(FONT_OBJ)
+
 ### End of font-backend (under X11) section.
 
 AC_SUBST(FREETYPE_CFLAGS)
@@ -2250,6 +2310,7 @@
 ### Use -lgpm if available, unless `--with-gpm=no'.
 HAVE_GPM=no
 LIBGPM=
+GPM_MOUSE_SUPPORT=
 if test "${with_gpm}" != "no"; then
   AC_CHECK_HEADER(gpm.h,
     [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
@@ -2257,9 +2318,11 @@
   if test "${HAVE_GPM}" = "yes"; then
     AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
     LIBGPM=-lgpm
+    GPM_MOUSE_SUPPORT="\${lispsource}mouse.elc"
   fi
 fi
 AC_SUBST(LIBGPM)
+AC_SUBST(GPM_MOUSE_SUPPORT)
 
 dnl Check for malloc/malloc.h on darwin
 AC_CHECK_HEADER(malloc/malloc.h, [AC_DEFINE(HAVE_MALLOC_MALLOC_H, 1, [Define to 1 if you have the <malloc/malloc.h> header file.])])
@@ -2765,11 +2828,8 @@
 AC_SUBST(bitmapdir)
 AC_SUBST(gamedir)
 AC_SUBST(gameuser)
-AC_SUBST(c_switch_system)
-AC_SUBST(c_switch_machine)
 AC_SUBST(unexec)
 AC_SUBST(LD_SWITCH_X_SITE)
-AC_SUBST(LD_SWITCH_X_SITE_AUX)
 AC_SUBST(C_SWITCH_X_SITE)
 AC_SUBST(C_SWITCH_X_SYSTEM)
 AC_SUBST(CFLAGS)
@@ -2803,9 +2863,6 @@
  HAVE_X_WINDOWS above and your X libraries aren't in a place that
  your loader can find on its own, you might want to add "-L/..." or
  something similar.])
-AC_DEFINE_UNQUOTED(LD_SWITCH_X_SITE_AUX, ${LD_SWITCH_X_SITE_AUX},
-		   [Define LD_SWITCH_X_SITE_AUX with an -R option
-		    in case it's needed (for Solaris, for example).])
 AC_DEFINE_UNQUOTED(C_SWITCH_X_SITE,  ${C_SWITCH_X_SITE},
 [Define C_SWITCH_X_SITE to contain any special flags your compiler
  may need to deal with X Windows.  For instance, if you've defined
@@ -2856,18 +2913,51 @@
 fi
 AC_SUBST(WIDGET_OBJ)
 
+TOOLKIT_LIBW=
 case "$USE_X_TOOLKIT" in
   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
-  *) TOOLKIT_LIBW= ;;
+  none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
 esac
 AC_SUBST(TOOLKIT_LIBW)
 
+if test "$USE_X_TOOLKIT" = "none"; then
+  LIBXT_OTHER="\$(LIBXSM)"
+else
+  LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
+fi
+AC_SUBST(LIBXT_OTHER)
+
+## The X Menu stuff is present in the X10 distribution, but missing
+## from X11.  If we have X10, just use the installed library;
+## otherwise, use our own copy.
 if test "${HAVE_X11}" = "yes" ; then
   AC_DEFINE(HAVE_X11, 1,
 	    [Define to 1 if you want to use version 11 of X windows.
 	     Otherwise, Emacs expects to use version 10.])
+
+  if test "$USE_X_TOOLKIT" = "none"; then
+    OLDXMENU="\${oldXMenudir}libXMenu11.a"
+  else
+    OLDXMENU="\${lwlibdir}liblw.a"
+  fi
+  LIBXMENU="\$(OLDXMENU)"
+  LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
+else
+  OLDXMENU=
+  LIBXMENU="-lXMenu"
+  LIBX_OTHER=
 fi
+
+if test "$HAVE_GTK" = "yes"; then
+  OLDXMENU=
+  LIBXMENU=
+fi
+
+AC_SUBST(OLDXMENU)
+AC_SUBST(LIBXMENU)
+AC_SUBST(LIBX_OTHER)
+
 if test "${HAVE_MENUS}" = "yes" ; then
   AC_DEFINE(HAVE_MENUS, 1,
 	    [Define to 1 if you have mouse menus.
@@ -2885,6 +2975,44 @@
 fi
 
 
+if test "$opsys" = "cygwin"; then
+  CYGWIN_OBJ="sheap.o"
+  ## Cygwin differs because of its unexec().
+  PRE_ALLOC_OBJ=
+  POST_ALLOC_OBJ="lastfile.o vm-limit.o"
+else
+  CYGWIN_OBJ=
+  PRE_ALLOC_OBJ=lastfile.o
+  POST_ALLOC_OBJ="\$(vmlimitobj)"
+fi
+AC_SUBST(CYGWIN_OBJ)
+AC_SUBST(PRE_ALLOC_OBJ)
+AC_SUBST(POST_ALLOC_OBJ)
+
+
+case "$opsys" in
+  aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
+
+  darwin)
+  ## The -headerpad option tells ld (see man page) to leave room at the
+  ## end of the header for adding load commands.  Needed for dumping.
+  ## 0x690 is the total size of 30 segment load commands (at 56
+  ## each); under Cocoa 31 commands are required.
+  if test "$HAVE_NS" = "yes"; then
+    libs_nsgui="-framework AppKit"
+    headerpad_extra=6C8
+  else
+    libs_nsgui=
+    headerpad_extra=690
+  fi
+  LD_SWITCH_SYSTEM_TEMACS="-prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
+  ;;
+
+  *) LD_SWITCH_SYSTEM_TEMACS= ;;
+esac
+AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
+
+
 AH_TOP([/* GNU Emacs site configuration template file.
    Copyright (C) 1988, 1993, 1994, 1999, 2000, 2001, 2002, 2004, 2005,
      2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
--- a/doc/emacs/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/doc/emacs/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,7 @@
+2010-05-02  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* cmdargs.texi (Initial Options): Mention --chdir.
+
 2010-04-21  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* frames.texi (Tool Bars): Add tool-bar-style.
--- a/doc/emacs/cmdargs.texi	Wed Apr 28 10:00:38 2010 +0900
+++ b/doc/emacs/cmdargs.texi	Thu May 06 09:50:39 2010 +0900
@@ -193,6 +193,15 @@
 other files for them.
 
 @table @samp
+@item -chdir @var{directory}
+@opindex -chdir
+@itemx --chdir=@var{directory}
+@opindex --chdir
+@cindex change Emacs directory
+Change to @var{directory} before doing anything else.  This is mainly used
+by session management in X so that Emacs starts in the same directory as it
+stopped.  This makes desktop saving and restoring easier.
+
 @item -t @var{device}
 @opindex -t
 @itemx --terminal=@var{device}
--- a/doc/misc/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/doc/misc/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,12 @@
+2010-05-01  Daniel E. Doherty <ddoherty03@gmail.com> (tiny change)
+
+	* calc.texi (Tutorial): Use "^{\prime}" to indicate primes.
+
+2010-05-01  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (Inline methods, Default Method): Mention
+	`tramp-inline-compress-start-size'.
+
 2010-04-18  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* gnus.texi (Gnus Versions, Oort Gnus): Mention the Git repo instead of
--- a/doc/misc/calc.texi	Wed Apr 28 10:00:38 2010 +0900
+++ b/doc/misc/calc.texi	Thu May 06 09:50:39 2010 +0900
@@ -6234,7 +6234,7 @@
 @end ifnottex
 @tex
 \beforedisplay
-$$ x_{\rm new} = x - {f(x) \over f'(x)} $$
+$$ x_{\rm new} = x - {f(x) \over f^{\prime}(x)} $$
 \afterdisplay
 @end tex
 
@@ -7901,7 +7901,7 @@
 @tex
 \turnoffactive
 \beforedisplay
-$$ 9 a + 3 b + c - 511 n' $$
+$$ 9 a + 3 b + c - 511 n^{\prime} $$
 \afterdisplay
 @end tex
 
Binary file doc/misc/tramp.texi has changed
--- a/etc/NEWS	Wed Apr 28 10:00:38 2010 +0900
+++ b/etc/NEWS	Thu May 06 09:50:39 2010 +0900
@@ -107,11 +107,21 @@
 
 * Editing Changes in Emacs 24.1
 
+** completion-at-point is now an alias for complete-symbol.
+
+** mouse-region-delete-keys has been deleted.
+
+** If delete-file is called with a prefix argument, it really deletes,
+regardless of the value of `delete-by-moving-to-trash'.
+
 
 * Changes in Specialized Modes and Packages in Emacs 24.1
 
 ** Archive Mode has basic support to browse 7z archives.
 
+** In ido-mode, C-v is no longer bound to ido-toggle-vc.
+The reason is that this interferes with cua-mode.
+
 ** partial-completion-mode is now obsolete.
 You can get the same behavior with
 (setq completion-styles '(partial-completion initials)).
@@ -176,6 +186,13 @@
 
 * Lisp changes in Emacs 24.1
 
+** define-minor-mode accepts a new keyword :variable.
+
+** delete-file now accepts an optional second arg, FORCE, which says
+to always delete and ignore the value of delete-by-moving-to-trash.
+
+** buffer-substring-filters is obsoleted by filter-buffer-substring-functions.
+
 ** New completion style `substring'.
 
 ** Image API
--- a/lib-src/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lib-src/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,13 +1,12 @@
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in: Use @C_SWITCH_SYSTEM@, @C_SWITCH_MACHINE@ rather than
+	@c_switch_system@, @c_switch_machine@.
+
 2010-04-26  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* Makefile.in (LIBS_MACHINE): Remove all uses, unused.
 
-2010-04-18  Juanma Barranquero  <lekktu@gmail.com>
-
-	Add stubs for Windows, required after CVE-2010-0825 change.
-	* ntlib.c (getgid, getegid, setegid): New stubs.
-	* ntlib.h (getgid, getegid, setegid): Declare them.
-
 2010-04-12  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* Makefile.in (ALL_CFLAGS, LINK_CFLAGS, CPP_CFLAGS): Move to the
@@ -2998,7 +2997,7 @@
 
 2000-03-02  Gerd Moellmann  <gerd@gnu.org>
 
-	* etags.c (lisp_suffixes)  Add `LSP'.
+	* etags.c (lisp_suffixes): Add `LSP'.
 
 2000-02-10  Francesco Potortì  <pot@gnu.org>
 
--- a/lib-src/Makefile.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/lib-src/Makefile.in	Thu May 06 09:50:39 2010 +0900
@@ -34,8 +34,8 @@
 version=@version@
 configuration=@configuration@
 EXEEXT=@EXEEXT@
-C_SWITCH_SYSTEM=@c_switch_system@
-C_SWITCH_MACHINE=@c_switch_machine@
+C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
+C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
 
 # Program name transformation.
 TRANSFORM = @program_transform_name@
--- a/lisp/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,296 @@
+2010-05-05  Juri Linkov  <juri@jurta.org>
+
+	Add `slow' and `history' tags to the desktop data.
+
+	* info.el (Info-virtual-nodes) [*Index*]: Add `slow' tag.
+	(Info-virtual-files) [*Apropos*]: Add `slow' tag.
+	(Info-finder-find-node): Require `finder.el' to be able
+	to restore node from the desktop.
+	(Info-desktop-buffer-misc-data): Save all nodes.  Save additional
+	data `Info-history' and `slow' tag in the assoc list.
+	(Info-restore-desktop-buffer): Don't restore nodes with the
+	`slow' tag.  Restore `Info-history'.
+
+2010-05-05  Michael Albinus  <michael.albinus@gmx.de>
+
+	Add FORCE argument to `delete-file'.
+
+	* net/ange-ftp.el (ange-ftp-del-tmp-name): Make it a defun,
+	forcing to delete the temporary file.
+	(ange-ftp-delete-file): Add FORCE arg.
+	(ange-ftp-rename-remote-to-remote)
+	(ange-ftp-rename-local-to-remote, ange-ftp-rename-remote-to-local)
+	(ange-ftp-load, ange-ftp-compress, ange-ftp-uncompress): Force
+	file deletion.
+
+	* net/tramp-compat.el (tramp-compat-delete-file): New defun.
+
+	* net/tramp.el (tramp-handle-delete-file): Add FORCE arg.
+	(tramp-handle-make-symbolic-link, tramp-handle-load)
+	(tramp-do-copy-or-rename-file-via-buffer)
+	(tramp-do-copy-or-rename-file-directly)
+	(tramp-do-copy-or-rename-file-out-of-band)
+	(tramp-handle-process-file, tramp-handle-call-process-region)
+	(tramp-handle-shell-command, tramp-handle-file-local-copy)
+	(tramp-handle-insert-file-contents, tramp-handle-write-region)
+	(tramp-delete-temp-file-function): Use `tramp-compat-delete-file'.
+
+	* net/tramp-fish.el (tramp-fish-handle-delete-file): Add FORCE arg.
+	(tramp-fish-handle-make-symbolic-link)
+	(tramp-fish-handle-process-file): Use `tramp-compat-delete-file'.
+
+	* net/tramp-ftp.el (tramp-ftp-file-name-handler): Use
+	`tramp-compat-delete-file'.
+
+	* net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Add FORCE arg.
+	(tramp-gvfs-handle-write-region): Use `tramp-compat-delete-file'.
+
+	* net/tramp-imap.el (tramp-imap-handle-delete-file): Add FORCE arg.
+	(tramp-imap-do-copy-or-rename-file): Use `tramp-compat-delete-file'.
+
+	* net/tramp-smb.el (tramp-smb-handle-delete-file): Add FORCE arg.
+	(tramp-smb-handle-copy-file, tramp-smb-handle-file-local-copy)
+	(tramp-smb-handle-rename-file, tramp-smb-handle-write-region): Use
+	`tramp-compat-delete-file'.
+
+2010-05-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Minor cleanups.
+	* subr.el (add-minor-mode): Use push.
+	* mail/supercite.el (sc-electric-mode): Use more descriptive arg name.
+	* emulation/edt.el (edt-select-mode): Simplify.
+
+	Use define-minor-mode in more cases.
+	* term/tvi970.el (tvi970-set-keypad-mode):
+	* simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
+	(normal-erase-is-backspace-mode):
+	* scroll-bar.el (scroll-bar-mode): Use it and define-minor-mode.
+	(set-scroll-bar-mode-1): (Re)move to its sole caller.
+	(get-scroll-bar-mode): New function.
+	* emacs-lisp/cl-macs.el (eq): Handle a non-variable first arg.
+
+	Use define-minor-mode for less obvious cases.
+	* emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword.
+	* emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method.
+	* international/iso-ascii.el (iso-ascii-mode):
+	* frame.el (auto-raise-mode, auto-lower-mode):
+	* composite.el (global-auto-composition-mode): Use define-minor-mode.
+
+2010-05-04  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-methods): Remove "-q" from `tramp-login-args'
+	in order to see error messages for failed logins.
+
+2010-05-03  Chong Yidong  <cyd@stupidchicken.com>
+
+	* diff.el (diff-sentinel):
+
+	* epg.el (epg--make-temp-file, epg-decrypt-string)
+	(epg-verify-string, epg-sign-string, epg-encrypt-string):
+
+	* jka-compr.el (jka-compr-partial-uncompress)
+	(jka-compr-call-process, jka-compr-write-region, jka-compr-load):
+
+	* server.el (server-sentinel): Use delete-file's new FORCE arg
+	(Bug#6070).
+
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Use define-minor-mode where applicable.
+	* view.el (view-mode):
+	* type-break.el (type-break-query-mode)
+	(type-break-mode-line-message-mode):
+	* textmodes/reftex.el (reftex-mode):
+	* term/vt100.el (vt100-wide-mode):
+	* tar-mode.el (tar-subfile-mode):
+	* savehist.el (savehist-mode):
+	* ibuf-ext.el (ibuffer-auto-mode):
+	* composite.el (auto-composition-mode):
+	* progmodes/vhdl-mode.el (vhdl-electric-mode, vhdl-stutter-mode):
+	Use define-minor-mode.
+	(vhdl-mode): Use static mode-line format.
+	(vhdl-mode-line-update): Delete.
+	(vhdl-create-mode-menu, vhdl-activate-customizations)
+	(vhdl-hs-minor-mode): Don't bother calling it.
+
+2010-05-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (with-wrapper-hook): Move.
+	(buffer-substring-filters): Mark obsolete.
+	(filter-buffer-substring-functions): New variable.
+	(filter-buffer-substring): Use it.  Remove unused arg `noprops'.
+
+	Use a mode-line spec rather than a static string in Semantic.
+	* cedet/semantic/util-modes.el:
+	(semantic-minor-modes-format): New var to replace...
+	(semantic-minor-modes-status): Remove.
+	(semantic-mode-line-update): Construct a mode-line spec rather than
+	a static string so that mouse buttons can be used on individual minor
+	modes and so that semantic-mode-line-update only needs to be called
+	when global settings are changed.
+	(semantic-add-minor-mode, semantic-toggle-minor-mode-globally):
+	Call semantic-mode-line-update.
+	(semantic-toggle-minor-mode-globally): Don't assume mode is on
+	minor-mode-alist, check semantic-minor-mode-alist as well.
+	(semantic-stickyfunc-mode, semantic-show-parser-state-auto-marker)
+	(semantic-show-parser-state-marker, semantic-show-parser-state-mode)
+	(semantic-show-unmatched-syntax-mode, semantic-highlight-edits-mode):
+	* cedet/semantic/mru-bookmark.el (semantic-mru-bookmark-mode):
+	* cedet/semantic/idle.el (semantic-idle-scheduler-mode)
+	(define-semantic-idle-service, semantic-idle-summary-mode):
+	* cedet/semantic/decorate/mode.el (semantic-decoration-mode):
+	Don't call semantic-mode-line-update any more.
+
+2010-05-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Use define-minor-mode in CEDET where applicable.
+
+	* cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode):
+	Use define-minor-mode.
+
+	* cedet/semantic/util-modes.el (semantic-add-minor-mode):
+	Remove unused arg `keymap' and code redundant with define-minor-mode.
+	(semantic-toggle-minor-mode-globally): Only handle arg -1 and 1.
+	(semantic-stickyfunc-mode, global-semantic-show-unmatched-syntax-mode)
+	(semantic-highlight-func-mode, global-semantic-show-parser-state-mode)
+	(global-semantic-highlight-edits-mode, semantic-highlight-edits-mode)
+	(semantic-show-unmatched-syntax-mode, semantic-show-parser-state-mode)
+	(global-semantic-stickyfunc-mode, global-semantic-highlight-func-mode):
+	Use define-minor-mode.
+	(semantic-stickyfunc-mode-setup, semantic-highlight-edits-mode-setup)
+	(semantic-show-unmatched-syntax-mode-setup)
+	(semantic-show-parser-state-mode-setup)
+	(semantic-highlight-func-mode-setup): Inline into sole caller.
+
+	* cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
+	(semantic-mru-bookmark-mode): Use define-minor-mode.
+	(semantic-mru-bookmark-mode-setup): Inline into sole caller.
+
+	* cedet/semantic/idle.el (define-semantic-idle-service):
+	Use define-minor-mode and inline setup function into its sole caller.
+	(semantic-idle-scheduler-mode-setup)
+	(semantic-idle-summary-mode-setup): Inline into sole caller.
+	(global-semantic-idle-scheduler-mode, semantic-idle-scheduler-mode):
+	Use define-minor-mode.
+
+	* cedet/semantic/decorate/mode.el (global-semantic-decoration-mode)
+	(semantic-decoration-mode): Use define-minor-mode.
+	(semantic-decoration-mode-setup): Inline into sole caller.
+
+	* cedet/ede/dired.el (ede-dired-minor-mode): Initialize in declaration.
+	(ede-dired-minor-mode): Use define-minor-mode and derived-mode-p.
+	(ede-dired-add-to-target): Use dolist.
+
+2010-05-01  Toru TSUNEYOSHI  <t_tuneyosi@hotmail.com>
+	    Michael Albinus  <michael.albinus@gmx.de>
+
+	Implement compression for inline methods.
+
+	* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
+	(tramp-copy-size-limit): Allow also nil.
+	(tramp-inline-compress-commands): New defconst.
+	(tramp-find-inline-compress, tramp-get-inline-compress)
+	(tramp-get-inline-coding): New defuns.
+	(tramp-get-remote-coding, tramp-get-local-coding): Remove,
+	replaced by `tramp-get-inline-coding'.
+	(tramp-handle-file-local-copy, tramp-handle-write-region)
+	(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.
+
+2010-05-01  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (mode-line-abbrev-mode, mode-line-auto-fill-mode):
+	Remove unused functions.
+
+	* emacs-lisp/lisp-mode.el (lisp-mode): Use define-derived-mode.
+	Set find-tag-default-function as a variable rather than a property.
+
+	* minibuffer.el (tags-completion-at-point-function): Move to etags.el.
+	* progmodes/etags.el (tags-completion-at-point-function):
+	Remove left over interactive spec.  Add autoloading stub.
+	(complete-tag): Use tags-completion-at-point-function.
+
+2010-04-30  Chong Yidong  <cyd@stupidchicken.com>
+
+	* minibuffer.el (tags-completion-at-point-function): Fix return value.
+
+2010-04-30  Eli Zaretskii  <eliz@gnu.org>
+
+	* composite.el (compose-region, reference-point-alist): Fix typos
+	in the doc strings.
+
+2010-04-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* ido.el (ido-init-completion-maps): Remove C-v binding.
+	(ido-minibuffer-setup): Don't set cua-inhibit-cua-keys (Bug#5765).
+
+2010-04-29  Chong Yidong  <cyd@stupidchicken.com>
+
+	* minibuffer.el (tags-completion-at-point-function): New function.
+	(completion-at-point-functions): Use it.
+
+	* cedet/semantic.el (semantic-completion-at-point-function): New function.
+	(semantic-mode): Use semantic-completion-at-point-function for
+	completion-at-point-functions instead.
+
+	* progmodes/etags.el (complete-tag): Revert last change.
+
+2010-04-29  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-mode.el (c-extend-region-for-CPP): Fix an
+	off-by-one error (in end of macro position).
+
+2010-04-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* net/browse-url.el (browse-url-firefox-program): Use iceweasel if
+	firefox is absent.  Don't autoload.
+	(browse-url-galeon-program): Don't autoload.
+
+2010-04-28  Chong Yidong  <cyd@stupidchicken.com>
+
+	* bindings.el (complete-symbol): Move into minibuffer.el.
+
+	* minibuffer.el (complete-tag): Move from etags.el.  If tags
+	completion cannot be performed, return nil instead of signalling
+	an error.
+	(completion-at-point): Make it an alias for complete-symbol.
+	(complete-symbol): Move from bindings.el, and replace with the
+	body of completion-at-point.
+
+	* progmodes/etags.el (complete-tag): Move to minibuffer.el.
+
+	* cedet/semantic.el (semantic-mode): When enabled, add
+	semantic-ia-complete-symbol to completion-at-point-functions.
+
+	* cedet/semantic/ia.el (semantic-ia-complete-symbol): Return nil
+	if Semantic is not active.
+
+2010-04-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-remote-selinux-p): New defun.
+	(tramp-handle-file-selinux-context)
+	(tramp-handle-set-file-selinux-context): Use it.
+
+2010-04-28  Sam Steingold  <sds@gnu.org>
+
+	* progmodes/bug-reference.el (bug-reference-url-format): Mark as
+	`safe-local-variable' if the value is a string or a symbol with
+	the property `bug-reference-url-format'.
+
+2010-04-28  Chong Yidong  <cyd@stupidchicken.com>
+
+	* progmodes/bug-reference.el (bug-reference-url-format): Revert
+	2010-04-27 change due to security risk.
+
+2010-04-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Make it possible to locally disable a globally enabled mode.
+	* simple.el (fundamental-mode): Run fundamental-mode-hook.
+	* emacs-lisp/derived.el (define-derived-mode): Use fundamental-mode
+	rather than kill-all-local-variables so it runs fundamental-mode-hook.
+	* emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
+	Use fundamental-mode-hook to run MODE-enable-in-buffers earlier, so
+	that subsequent hooks get a chance to disable it.
+
 2010-04-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
--- a/lisp/allout.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/allout.el	Thu May 06 09:50:39 2010 +0900
@@ -2239,13 +2239,13 @@
       (allout-show-to-offshoot)))
 
 ;;;_ #3 Internal Position State-Tracking -- "allout-recent-*" funcs
-;;; All the basic outline functions that directly do string matches to
-;;; evaluate heading prefix location set the variables
-;;; `allout-recent-prefix-beginning'  and `allout-recent-prefix-end'
-;;; when successful.  Functions starting with `allout-recent-' all
-;;; use this state, providing the means to avoid redundant searches
-;;; for just-established data.  This optimization can provide
-;;; significant speed improvement, but it must be employed carefully.
+;; All the basic outline functions that directly do string matches to
+;; evaluate heading prefix location set the variables
+;; `allout-recent-prefix-beginning'  and `allout-recent-prefix-end'
+;; when successful.  Functions starting with `allout-recent-' all
+;; use this state, providing the means to avoid redundant searches
+;; for just-established data.  This optimization can provide
+;; significant speed improvement, but it must be employed carefully.
 ;;;_  = allout-recent-prefix-beginning
 (defvar allout-recent-prefix-beginning 0
   "Buffer point of the start of the last topic prefix encountered.")
--- a/lisp/bindings.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/bindings.el	Thu May 06 09:50:39 2010 +0900
@@ -62,24 +62,6 @@
     (force-mode-line-update)))
 
 
-(defun mode-line-abbrev-mode (event)
-  "Turn off `abbrev-mode' from the mode-line."
-  (interactive "e")
-  (save-selected-window
-    (select-window (posn-window (event-start event)))
-    (abbrev-mode)
-    (force-mode-line-update)))
-
-
-(defun mode-line-auto-fill-mode (event)
-  "Turn off `auto-fill-mode' from the mode-line."
-  (interactive "e")
-  (save-selected-window
-    (select-window (posn-window (event-start event)))
-    (auto-fill-mode)
-    (force-mode-line-update)))
-
-
 (defvar mode-line-input-method-map
   (let ((map (make-sparse-keymap)))
     (define-key map [mode-line mouse-2]
@@ -671,29 +653,6 @@
 
 (define-key esc-map "\t" 'complete-symbol)
 
-(defun complete-symbol (arg)
-  "Perform tags completion on the text around point.
-If a tags table is loaded, call `complete-tag'.
-Otherwise, if Semantic is active, call `semantic-ia-complete-symbol'.
-
-With a prefix argument, this command does completion within
-the collection of symbols listed in the index of the manual for the
-language you are using."
-  (interactive "P")
-  (cond (arg
-	 (info-complete-symbol))
-	((or tags-table-list tags-file-name)
-	 (complete-tag))
-	((and (fboundp 'semantic-ia-complete-symbol)
-	      (fboundp 'semantic-active-p)
-	      (semantic-active-p))
-	 (semantic-ia-complete-symbol))
-	(t
-	 (error "%s"
-		(substitute-command-keys
-		 "No completions available; use \\[visit-tags-table] \
-or \\[semantic-mode]")))))
-
 ;; Reduce total amount of space we must allocate during this function
 ;; that we will not need to keep permanently.
 (garbage-collect)
--- a/lisp/cedet/ede/dired.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/ede/dired.el	Thu May 06 09:50:39 2010 +0900
@@ -27,57 +27,46 @@
 ;; This provides a dired interface to EDE, allowing users to modify
 ;; their project file by adding files (or whatever) directly from a
 ;; dired buffer.
-
+(eval-when-compile (require 'cl))
 (require 'easymenu)
 (require 'dired)
 (require 'ede)
 
 ;;; Code:
-(defvar ede-dired-minor-mode nil
-  "Non-nil when in ede dired minor mode.")
-(make-variable-buffer-local 'ede-dired-minor-mode)
+(defvar ede-dired-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map ".a" 'ede-dired-add-to-target)
+    (define-key map ".t" 'ede-new-target)
+    (define-key map ".s" 'ede-speedbar)
+    (define-key map ".C" 'ede-compile-project)
+    (define-key map ".d" 'ede-make-dist)
 
-(defvar ede-dired-keymap nil
+    (easy-menu-define
+      ede-dired-menu map "EDE Dired Minor Mode Menu"
+      '("Project"
+        [ "Add files to target" ede-dired-add-to-target (ede-current-project) ]
+        ( "Build" :filter ede-build-forms-menu)
+        "-"
+        [ "Create Project" ede-new (not (ede-current-project)) ]
+        [ "Create Target" ede-new-target (ede-current-project) ]
+        "-"
+        ( "Customize Project" :filter ede-customize-forms-menu )
+        [ "View Project Tree" ede-speedbar (ede-current-project) ]
+        ))
+    map)
   "Keymap used for ede dired minor mode.")
 
-(if ede-dired-keymap
-    nil
-  (setq ede-dired-keymap (make-sparse-keymap))
-  (define-key ede-dired-keymap ".a" 'ede-dired-add-to-target)
-  (define-key ede-dired-keymap ".t" 'ede-new-target)
-  (define-key ede-dired-keymap ".s" 'ede-speedbar)
-  (define-key ede-dired-keymap ".C" 'ede-compile-project)
-  (define-key ede-dired-keymap ".d" 'ede-make-dist)
-
-  (easy-menu-define
-   ede-dired-menu ede-dired-keymap "EDE Dired Minor Mode Menu"
-   '("Project"
-     [ "Add files to target" ede-dired-add-to-target (ede-current-project) ]
-     ( "Build" :filter ede-build-forms-menu)
-     "-"
-     [ "Create Project" ede-new (not (ede-current-project)) ]
-     [ "Create Target" ede-new-target (ede-current-project) ]
-     "-"
-     ( "Customize Project" :filter ede-customize-forms-menu )
-     [ "View Project Tree" ede-speedbar (ede-current-project) ]
-     ))
-  )
-
-(defun ede-dired-minor-mode (&optional arg)
+(define-minor-mode ede-dired-minor-mode
   "A minor mode that should only be activated in DIRED buffers.
-If ARG is nil, toggle, if it is a positive number, force on, if
+If ARG is nil or a positive number, force on, if
 negative, force off."
-  (interactive "P")
-  (if (not (or (eq major-mode 'dired-mode)
-	       (eq major-mode 'vc-dired-mode)))
-      (error "Not in DIRED mode"))
-  (setq ede-dired-minor-mode
-	(not (or (and (null arg) ede-dired-minor-mode)
-		 (<= (prefix-numeric-value arg) 0))))
-  (if (and (not (ede-directory-project-p default-directory))
-	   (not (interactive-p)))
-      (setq ede-dired-minor-mode nil))
-  )
+  :lighter " EDE" :keymap ede-dired-keymap
+  (unless (derived-mode-p 'dired-mode)
+    (setq ede-dired-minor-mode nil)
+    (error "Not in DIRED mode"))
+  (unless (or (ede-directory-project-p default-directory)
+              (interactive-p))
+    (setq ede-dired-minor-mode nil)))
 
 (defun ede-dired-add-to-target (target)
   "Add a file, or all marked files into a TARGET."
@@ -85,24 +74,13 @@
 		(let ((ede-object (ede-current-project)))
 		  (ede-invoke-method 'project-interactive-select-target
 				     "Add files to Target: "))))
-  (let ((files (dired-get-marked-files t)))
-    (while files
-      (project-add-file target (car files))
-      ;; Find the buffer for this files, and set it's ede-object
-      (if (get-file-buffer (car files))
-	  (with-current-buffer (get-file-buffer (car files))
-	    (setq ede-object nil)
-	    (setq ede-object (ede-buffer-object (current-buffer)))))
-      ;; Increment.
-      (setq files (cdr files)))))
-
-;; Minor mode management.
-(add-to-list 'minor-mode-alist '(ede-dired-minor-mode " EDE"))
-(let ((a (assoc 'ede-dired-minor-mode minor-mode-map-alist)))
-  (if a
-      (setcdr a ede-dired-keymap)
-    (add-to-list 'minor-mode-map-alist (cons 'ede-dired-minor-mode
-					     ede-dired-keymap))))
+  (dolist (file (dired-get-marked-files t))
+    (project-add-file target file)
+    ;; Find the buffer for this files, and set it's ede-object
+    (if (get-file-buffer file)
+        (with-current-buffer (get-file-buffer file)
+          (setq ede-object nil)
+          (setq ede-object (ede-buffer-object (current-buffer)))))))
 
 (provide 'ede/dired)
 
--- a/lisp/cedet/semantic.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic.el	Thu May 06 09:50:39 2010 +0900
@@ -1080,6 +1080,11 @@
 	    (require 'semantic/db-ebrowse)
 	    (semanticdb-load-ebrowse-caches)))
 	(add-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
+	;; Add semantic-ia-complete-symbol to
+	;; completion-at-point-functions, so that it is run from
+	;; M-TAB.
+	(add-hook 'completion-at-point-functions
+		  'semantic-completion-at-point-function)
 	(if global-ede-mode
 	    (define-key cedet-menu-map [cedet-menu-separator] '("--")))
 	(dolist (b (buffer-list))
@@ -1087,6 +1092,8 @@
 	    (semantic-new-buffer-fcn))))
     ;; Disable all Semantic features.
     (remove-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
+    (remove-hook 'completion-at-point-functions
+		 'semantic-completion-at-point-function)
     (define-key cedet-menu-map [cedet-menu-separator] nil)
     (define-key cedet-menu-map [semantic-options-separator] nil)
     ;; FIXME: handle semanticdb-load-ebrowse-caches
@@ -1094,6 +1101,9 @@
       (if (and (boundp mode) (eval mode))
 	  (funcall mode -1)))))
 
+(defun semantic-completion-at-point-function ()
+  'semantic-ia-complete-symbol)
+
 ;;; Autoload some functions that are not in semantic/loaddefs
 
 (autoload 'global-semantic-idle-completions-mode "semantic/idle"
--- a/lisp/cedet/semantic/decorate/mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic/decorate/mode.el	Thu May 06 09:50:39 2010 +0900
@@ -224,46 +224,34 @@
 ;; Generic mode for handling basic highlighting and decorations.
 ;;
 
-(defcustom global-semantic-decoration-mode nil
-  "*If non-nil, enable global use of command `semantic-decoration-mode'.
-When this mode is activated, decorations specified by
-`semantic-decoration-styles'."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/decorate/mode
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-decoration-mode (if val 1 -1))))
-
 ;;;###autoload
-(defun global-semantic-decoration-mode (&optional arg)
+(define-minor-mode global-semantic-decoration-mode
   "Toggle global use of option `semantic-decoration-mode'.
 Decoration mode turns on all active decorations as specified
-by `semantic-decoration-styles'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-decoration-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-decoration-mode arg)))
+by `semantic-decoration-styles'."
+  :global t :group 'semantic :group 'semantic-modes
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic/decorate/mode
+  (semantic-toggle-minor-mode-globally
+   'semantic-decoration-mode (if global-semantic-decoration-mode 1 -1)))
 
 (defcustom semantic-decoration-mode-hook nil
   "Hook run at the end of function `semantic-decoration-mode'."
   :group 'semantic
   :type 'hook)
 
-;;;;###autoload
-(defvar semantic-decoration-mode nil
-  "Non-nil if command `semantic-decoration-mode' is enabled.
-Use the command `semantic-decoration-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-decoration-mode)
-
-(defun semantic-decoration-mode-setup ()
-  "Setup the `semantic-decoration-mode' minor mode.
-The minor mode can be turned on only if the semantic feature is available
-and the current buffer was set up for parsing.  Return non-nil if the
+(define-minor-mode semantic-decoration-mode
+  "Minor mode for decorating tags.
+Decorations are specified in `semantic-decoration-styles'.
+You can define new decoration styles with
+`define-semantic-decoration-style'.
+With prefix argument ARG, turn on if positive, otherwise off.  The
+minor mode can be turned on only if semantic feature is available and
+the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
+;;
+;;\\{semantic-decoration-map}"
+  nil nil nil
   (if semantic-decoration-mode
       (if (not (and (featurep 'semantic) (semantic-active-p)))
           (progn
@@ -280,8 +268,7 @@
                   'semantic-decorate-tags-after-full-reparse nil t)
         ;; Add decorations to available tags.  The above hooks ensure
         ;; that new tags will be decorated when they become available.
-        (semantic-decorate-add-decorations (semantic-fetch-available-tags))
-        )
+        (semantic-decorate-add-decorations (semantic-fetch-available-tags)))
     ;; Remove decorations from available tags.
     (semantic-decorate-clear-decorations (semantic-fetch-available-tags))
     ;; Cleanup any leftover crap too.
@@ -290,41 +277,10 @@
     (remove-hook 'semantic-after-partial-cache-change-hook
                  'semantic-decorate-tags-after-partial-reparse t)
     (remove-hook 'semantic-after-toplevel-cache-change-hook
-                 'semantic-decorate-tags-after-full-reparse t)
-    )
-  semantic-decoration-mode)
-
-(defun semantic-decoration-mode (&optional arg)
-  "Minor mode for decorating tags.
-Decorations are specified in `semantic-decoration-styles'.
-You can define new decoration styles with
-`define-semantic-decoration-style'.
-With prefix argument ARG, turn on if positive, otherwise off.  The
-minor mode can be turned on only if semantic feature is available and
-the current buffer was set up for parsing.  Return non-nil if the
-minor mode is enabled."
-;;
-;;\\{semantic-decoration-map}"
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-decoration-mode 0 1))))
-  (setq semantic-decoration-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-decoration-mode)))
-  (semantic-decoration-mode-setup)
-  (run-hooks 'semantic-decoration-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "decoration-mode minor mode %sabled"
-               (if semantic-decoration-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-decoration-mode)
+                 'semantic-decorate-tags-after-full-reparse t)))
 
 (semantic-add-minor-mode 'semantic-decoration-mode
-                         ""
-                         nil)
+                         "")
 
 (defun semantic-decorate-tags-after-full-reparse (tag-list)
   "Add decorations after a complete reparse of the current buffer.
--- a/lisp/cedet/semantic/ia.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic/ia.el	Thu May 06 09:50:39 2010 +0900
@@ -110,56 +110,52 @@
 If POS is nil, default to point.
 Completion options are calculated with `semantic-analyze-possible-completions'."
   (interactive "d")
-  (or pos (setq pos (point)))
-  ;; Calculating completions is a two step process.
-  ;;
-  ;; The first analyzer the current context, which finds tags
-  ;; for all the stuff that may be references by the code around
-  ;; POS.
-  ;;
-  ;; The second step derives completions from that context.
-  (let* ((a (semantic-analyze-current-context pos))
-	 (syms (semantic-ia-get-completions a pos))
-	 (pre (car (reverse (oref a prefix))))
-	 )
-    ;; If PRE was actually an already completed symbol, it doesn't
-    ;; come in as a string, but as a tag instead.
-    (if (semantic-tag-p pre)
-	;; We will try completions on it anyway.
-	(setq pre (semantic-tag-name pre)))
-    ;; Complete this symbol.
-    (if (null syms)
-	(progn
-	  ;(message "No smart completions found.  Trying senator-complete-symbol.")
+  (when (semantic-active-p)
+    (or pos (setq pos (point)))
+    ;; Calculating completions is a two step process.
+    ;;
+    ;; The first analyzer the current context, which finds tags for
+    ;; all the stuff that may be references by the code around POS.
+    ;;
+    ;; The second step derives completions from that context.
+    (let* ((a (semantic-analyze-current-context pos))
+	   (syms (semantic-ia-get-completions a pos))
+	   (pre (car (reverse (oref a prefix)))))
+      ;; If PRE was actually an already completed symbol, it doesn't
+      ;; come in as a string, but as a tag instead.
+      (if (semantic-tag-p pre)
+	  ;; We will try completions on it anyway.
+	  (setq pre (semantic-tag-name pre)))
+      ;; Complete this symbol.
+      (if (null syms)
 	  (if (semantic-analyze-context-p a)
 	      ;; This is a clever hack.  If we were unable to find any
 	      ;; smart completions, lets divert to how senator derives
 	      ;; completions.
 	      ;;
-	      ;; This is a way of making this fcn more useful since the
-	      ;; smart completion engine sometimes failes.
-	      (semantic-complete-symbol)))
-      ;; Use try completion to seek a common substring.
-      (let ((tc (try-completion (or pre "")  syms)))
-	(if (and (stringp tc) (not (string= tc (or pre ""))))
-	    (let ((tok (semantic-find-first-tag-by-name
-			tc syms)))
-	      ;; Delete what came before...
-	      (when (and (car (oref a bounds)) (cdr (oref a bounds)))
-		(delete-region (car (oref a bounds))
-			       (cdr (oref a bounds)))
-		(goto-char (car (oref a bounds))))
-	      ;; We have some new text.  Stick it in.
-	      (if tok
-		  (semantic-ia-insert-tag tok)
-		(insert tc)))
-	  ;; We don't have new text.  Show all completions.
-	  (when (cdr (oref a bounds))
-	    (goto-char (cdr (oref a bounds))))
-	  (with-output-to-temp-buffer "*Completions*"
-	    (display-completion-list
-	     (mapcar semantic-ia-completion-format-tag-function syms))
-	    ))))))
+	      ;; This is a way of making this fcn more useful since
+	      ;; the smart completion engine sometimes failes.
+	      (semantic-complete-symbol))
+	;; Use try completion to seek a common substring.
+	(let ((tc (try-completion (or pre "")  syms)))
+	  (if (and (stringp tc) (not (string= tc (or pre ""))))
+	      (let ((tok (semantic-find-first-tag-by-name
+			  tc syms)))
+		;; Delete what came before...
+		(when (and (car (oref a bounds)) (cdr (oref a bounds)))
+		  (delete-region (car (oref a bounds))
+				 (cdr (oref a bounds)))
+		  (goto-char (car (oref a bounds))))
+		;; We have some new text.  Stick it in.
+		(if tok
+		    (semantic-ia-insert-tag tok)
+		  (insert tc)))
+	    ;; We don't have new text.  Show all completions.
+	    (when (cdr (oref a bounds))
+	      (goto-char (cdr (oref a bounds))))
+	    (with-output-to-temp-buffer "*Completions*"
+	      (display-completion-list
+	       (mapcar semantic-ia-completion-format-tag-function syms)))))))))
 
 (defcustom semantic-ia-completion-menu-format-tag-function
   'semantic-uml-concise-prototype-nonterminal
--- a/lisp/cedet/semantic/idle.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic/idle.el	Thu May 06 09:50:39 2010 +0900
@@ -128,16 +128,6 @@
 ;; The minor mode portion of this code just sets up the minor mode
 ;; which does the initial scheduling of the idle timers.
 ;;
-;;;###autoload
-(defcustom global-semantic-idle-scheduler-mode nil
-  "*If non-nil, enable global use of idle-scheduler mode."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/idle
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-idle-scheduler-mode (if val 1 -1))))
 
 (defcustom semantic-idle-scheduler-mode-hook nil
   "Hook run at the end of the function `semantic-idle-scheduler-mode'."
@@ -167,24 +157,8 @@
        (or (<= semantic-idle-scheduler-max-buffer-size 0)
 	   (< (buffer-size) semantic-idle-scheduler-max-buffer-size))))
 
-(defun semantic-idle-scheduler-mode-setup ()
-  "Setup option `semantic-idle-scheduler-mode'.
-The minor mode can be turned on only if semantic feature is available
-and the current buffer was set up for parsing.  When minor mode is
-enabled parse the current buffer if needed.  Return non-nil if the
-minor mode is enabled."
-  (if semantic-idle-scheduler-mode
-      (if (not (and (featurep 'semantic) (semantic-active-p)))
-          (progn
-            ;; Disable minor mode if semantic stuff not available
-            (setq semantic-idle-scheduler-mode nil)
-            (error "Buffer %s was not set up idle time scheduling"
-                   (buffer-name)))
-        (semantic-idle-scheduler-setup-timers)))
-  semantic-idle-scheduler-mode)
-
 ;;;###autoload
-(defun semantic-idle-scheduler-mode (&optional arg)
+(define-minor-mode semantic-idle-scheduler-mode
   "Minor mode to auto parse buffer following a change.
 When this mode is off, a buffer is only rescanned for tokens when
 some command requests the list of available tokens.  When idle-scheduler
@@ -195,26 +169,18 @@
 minor mode can be turned on only if semantic feature is available and
 the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-idle-scheduler-mode 0 1))))
-  (setq semantic-idle-scheduler-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-idle-scheduler-mode)))
-  (semantic-idle-scheduler-mode-setup)
-  (run-hooks 'semantic-idle-scheduler-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "idle-scheduler minor mode %sabled"
-               (if semantic-idle-scheduler-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-idle-scheduler-mode)
+  nil nil nil
+  (if semantic-idle-scheduler-mode
+      (if (not (and (featurep 'semantic) (semantic-active-p)))
+          (progn
+            ;; Disable minor mode if semantic stuff not available
+            (setq semantic-idle-scheduler-mode nil)
+            (error "Buffer %s was not set up idle time scheduling"
+                   (buffer-name)))
+        (semantic-idle-scheduler-setup-timers))))
 
 (semantic-add-minor-mode 'semantic-idle-scheduler-mode
-                         "ARP"
-                         nil)
+                         "ARP")
 
 ;;; SERVICES services
 ;;
@@ -582,31 +548,23 @@
 	(mode 	(intern (concat (symbol-name name) "-mode")))
 	(hook 	(intern (concat (symbol-name name) "-mode-hook")))
 	(map  	(intern (concat (symbol-name name) "-mode-map")))
-	(setup 	(intern (concat (symbol-name name) "-mode-setup")))
 	(func 	(intern (concat (symbol-name name) "-idle-function"))))
 
     `(eval-and-compile
-       (defun ,global (&optional arg)
+       (define-minor-mode ,global
 	 ,(concat "Toggle " (symbol-name global) ".
 With ARG, turn the minor mode on if ARG is positive, off otherwise.
 
 When this minor mode is enabled, `" (symbol-name mode) "' is
 turned on in every Semantic-supported buffer.")
-	 (interactive "P")
-	 (setq ,global
-	       (semantic-toggle-minor-mode-globally
-		',mode arg)))
-
-       (defcustom ,global nil
-	 ,(concat "Non-nil if `" (symbol-name mode) "' is enabled.")
+         :global t
 	 :group 'semantic
 	 :group 'semantic-modes
-	 :type 'boolean
 	 :require 'semantic/idle
-	 :initialize 'custom-initialize-default
-	 :set (lambda (sym val)
-		(,global (if val 1 -1))))
+	 (semantic-toggle-minor-mode-globally
+	  ',mode (if ,global 1 -1)))
 
+       ;; FIXME: Get rid of this when define-minor-mode does it for us.
        (defcustom ,hook nil
 	 ,(concat "Hook run at the end of function `" (symbol-name mode) "'.")
 	 :group 'semantic
@@ -617,14 +575,9 @@
 	   km)
 	 ,(concat "Keymap for `" (symbol-name mode) "'."))
 
-       (defvar ,mode nil
-	 ,(concat "Non-nil if the minor mode `" (symbol-name mode) "' is enabled.
-Use the command `" (symbol-name mode) "' to change this variable."))
-       (make-variable-buffer-local ',mode)
-
-       (defun ,setup ()
-	 ,(concat "Set up `" (symbol-name mode) "'.
-Return non-nil if the minor mode is enabled.")
+       (define-minor-mode ,mode
+	 ,doc
+         :keymap ,map
 	 (if ,mode
 	     (if (not (and (featurep 'semantic) (semantic-active-p)))
 		 (progn
@@ -633,36 +586,12 @@
 		   (error "Buffer %s was not set up for parsing"
 			  (buffer-name)))
 	       ;; Enable the mode mode
-	       (semantic-idle-scheduler-add #',func)
-	       )
+	       (semantic-idle-scheduler-add #',func))
 	   ;; Disable the mode mode
-	   (semantic-idle-scheduler-remove #',func)
-	   )
-	 ,mode)
-
-       (defun ,mode (&optional arg)
-	 ,doc
-	 (interactive
-	  (list (or current-prefix-arg
-		    (if ,mode 0 1))))
-	 (setq ,mode
-	       (if arg
-		   (>
-		    (prefix-numeric-value arg)
-		    0)
-		 (not ,mode)))
-	 (,setup)
-	 (run-hooks ,hook)
-	 (if (called-interactively-p 'interactive)
-	     (message "%s %sabled"
-		      (symbol-name ',mode)
-		      (if ,mode "en" "dis")))
-	 (semantic-mode-line-update)
-	 ,mode)
+	   (semantic-idle-scheduler-remove #',func)))
 
        (semantic-add-minor-mode ',mode
-				""	; idle schedulers are quiet?
-				,map)
+				"")	; idle schedulers are quiet?
 
        (defun ,func ()
 	 ,(concat "Perform idle activity for the minor mode `"
@@ -814,21 +743,6 @@
 of the lexical token at point whenever Emacs is idle."
   :group 'semantic
   :group 'semantic-modes
-  (semantic-idle-summary-mode-setup)
-  (semantic-mode-line-update))
-
-(defun semantic-idle-summary-refresh-echo-area ()
-  (and semantic-idle-summary-mode
-       eldoc-last-message
-       (if (and (not executing-kbd-macro)
-		(not (and (boundp 'edebug-active) edebug-active))
-		(not cursor-in-echo-area)
-		(not (eq (selected-window) (minibuffer-window))))
-           (eldoc-message eldoc-last-message)
-         (setq eldoc-last-message nil))))
-
-(defun semantic-idle-summary-mode-setup ()
-  "Set up `semantic-idle-summary-mode'."
   (if semantic-idle-summary-mode
       ;; Enable the mode
       (progn
@@ -842,8 +756,17 @@
 	(add-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t))
     ;; Disable the mode
     (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function)
-    (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t))
-  semantic-idle-summary-mode)
+    (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)))
+
+(defun semantic-idle-summary-refresh-echo-area ()
+  (and semantic-idle-summary-mode
+       eldoc-last-message
+       (if (and (not executing-kbd-macro)
+		(not (and (boundp 'edebug-active) edebug-active))
+		(not cursor-in-echo-area)
+		(not (eq (selected-window) (minibuffer-window))))
+           (eldoc-message eldoc-last-message)
+         (setq eldoc-last-message nil))))
 
 (semantic-add-minor-mode 'semantic-idle-summary-mode "")
 
@@ -957,22 +880,22 @@
 
 
 ;;;###autoload
-(defun global-semantic-idle-scheduler-mode (&optional arg)
+(define-minor-mode global-semantic-idle-scheduler-mode
   "Toggle global use of option `semantic-idle-scheduler-mode'.
 The idle scheduler will automatically reparse buffers in idle time,
 and then schedule other jobs setup with `semantic-idle-scheduler-add'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t
+  :group 'semantic
+  :group 'semantic-modes
   ;; When turning off, disable other idle modes.
-  (when (or (and (numberp arg) (< arg 0))
-	    (and (null arg) global-semantic-idle-scheduler-mode))
+  (when (null global-semantic-idle-scheduler-mode)
     (global-semantic-idle-summary-mode -1)
     (global-semantic-idle-tag-highlight-mode -1)
     (global-semantic-idle-completions-mode -1))
-  (setq global-semantic-idle-scheduler-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-idle-scheduler-mode arg)))
+  (semantic-toggle-minor-mode-globally
+   'semantic-idle-scheduler-mode
+   (if global-semantic-idle-scheduler-mode 1 -1)))
 
 
 ;;; Completion Popup Mode
--- a/lisp/cedet/semantic/mru-bookmark.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic/mru-bookmark.el	Thu May 06 09:50:39 2010 +0900
@@ -239,27 +239,15 @@
 ;;
 ;; Tracking minor mode.
 
-(defcustom global-semantic-mru-bookmark-mode nil
-  "If non-nil, enable `semantic-mru-bookmark-mode' globally.
-When this mode is enabled, Emacs keeps track of which tags have
-been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic-util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-mru-bookmark-mode (if val 1 -1))))
-
 ;;;###autoload
-(defun global-semantic-mru-bookmark-mode (&optional arg)
+(define-minor-mode global-semantic-mru-bookmark-mode
   "Toggle global use of option `semantic-mru-bookmark-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-mru-bookmark-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-mru-bookmark-mode arg)))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic :group 'semantic-modes
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic-util-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-mru-bookmark-mode (if global-semantic-mru-bookmark-mode 1 -1)))
 
 (defcustom semantic-mru-bookmark-mode-hook nil
   "*Hook run at the end of function `semantic-mru-bookmark-mode'."
@@ -272,17 +260,18 @@
     km)
   "Keymap for mru-bookmark minor mode.")
 
-(defvar semantic-mru-bookmark-mode nil
-  "Non-nil if mru-bookmark minor mode is enabled.
-Use the command `semantic-mru-bookmark-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-mru-bookmark-mode)
+(define-minor-mode semantic-mru-bookmark-mode
+  "Minor mode for tracking tag-based bookmarks automatically.
+When this mode is enabled, Emacs keeps track of which tags have
+been edited, and you can re-visit them with \\[semantic-mrub-switch-tags].
 
-(defun semantic-mru-bookmark-mode-setup ()
-  "Setup option `semantic-mru-bookmark-mode'.
-The minor mode can be turned on only if semantic feature is available
-and the current buffer was set up for parsing.  When minor mode is
-enabled parse the current buffer if needed.  Return non-nil if the
+\\{semantic-mru-bookmark-mode-map}
+
+With prefix argument ARG, turn on if positive, otherwise off.  The
+minor mode can be turned on only if semantic feature is available and
+the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
+  :keymap semantic-mru-bookmark-mode-map
   (if semantic-mru-bookmark-mode
       (if (not (and (featurep 'semantic) (semantic-active-p)))
 	  (progn
@@ -294,47 +283,15 @@
         (add-hook 'semantic-edits-new-change-hooks
                   'semantic-mru-bookmark-change-hook-fcn nil t)
         (add-hook 'semantic-edits-move-change-hooks
-                  'semantic-mru-bookmark-change-hook-fcn nil t)
-        )
+                  'semantic-mru-bookmark-change-hook-fcn nil t))
     ;; Remove hooks
     (remove-hook 'semantic-edits-new-change-hooks
 		 'semantic-mru-bookmark-change-hook-fcn t)
     (remove-hook 'semantic-edits-move-change-hooks
-		 'semantic-mru-bookmark-change-hook-fcn t)
-    )
-  semantic-mru-bookmark-mode)
-
-(defun semantic-mru-bookmark-mode (&optional arg)
-  "Minor mode for tracking tag-based bookmarks automatically.
-When this mode is enabled, Emacs keeps track of which tags have
-been edited, and you can re-visit them with \\[semantic-mrub-switch-tags].
-
-\\{semantic-mru-bookmark-mode-map}
-
-With prefix argument ARG, turn on if positive, otherwise off.  The
-minor mode can be turned on only if semantic feature is available and
-the current buffer was set up for parsing.  Return non-nil if the
-minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-mru-bookmark-mode 0 1))))
-  (setq semantic-mru-bookmark-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-mru-bookmark-mode)))
-  (semantic-mru-bookmark-mode-setup)
-  (run-hooks 'semantic-mru-bookmark-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "mru-bookmark minor mode %sabled"
-               (if semantic-mru-bookmark-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-mru-bookmark-mode)
+		 'semantic-mru-bookmark-change-hook-fcn t)))
 
 (semantic-add-minor-mode 'semantic-mru-bookmark-mode
-                         "k"
-                         semantic-mru-bookmark-mode-map)
+                         "k")
 
 ;;; COMPLETING READ
 ;;
--- a/lisp/cedet/semantic/util-modes.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/semantic/util-modes.el	Thu May 06 09:50:39 2010 +0900
@@ -28,6 +28,10 @@
 ;;
 
 ;;; Code:
+
+;; FIXME: compiling util-modes.el seems to require loading util-modes.el,
+;; so if the previous compilation generated a file that fails to load,
+;; recompiling fails to fix the problem.
 (require 'semantic)
 
 ;;; Group for all semantic enhancing modes
@@ -49,8 +53,7 @@
   :set (lambda (sym val)
          (set-default sym val)
          ;; Update status of all Semantic enabled buffers
-         (semantic-map-buffers
-          #'semantic-mode-line-update)))
+         (semantic-mode-line-update)))
 
 (defcustom semantic-mode-line-prefix
   (propertize "S" 'face 'bold)
@@ -60,59 +63,61 @@
   :require 'semantic/util-modes
   :initialize 'custom-initialize-default)
 
-(defvar semantic-minor-modes-status nil
-  "String showing Semantic minor modes which are locally enabled.
+(defvar semantic-minor-modes-format nil
+  "Mode line format showing Semantic minor modes which are locally enabled.
 It is displayed in the mode line.")
-(make-variable-buffer-local 'semantic-minor-modes-status)
+(put 'semantic-minor-modes-format 'risky-local-variable t)
 
 (defvar semantic-minor-mode-alist nil
   "Alist saying how to show Semantic minor modes in the mode line.
 Like variable `minor-mode-alist'.")
 
 (defun semantic-mode-line-update ()
-  "Update display of Semantic minor modes in the mode line.
+  "Update mode line format of Semantic minor modes.
 Only minor modes that are locally enabled are shown in the mode line."
-  (setq semantic-minor-modes-status nil)
-  (if semantic-update-mode-line
-      (let ((ml semantic-minor-mode-alist)
-            mm ms see)
-        (while ml
-          (setq mm (car ml)
-                ms (cadr mm)
-                mm (car mm)
-                ml (cdr ml))
-          (when (and (symbol-value mm)
-                     ;; Only show local minor mode status
-                     (not (memq mm semantic-init-hook)))
-            (and ms
-                 (symbolp ms)
-                 (setq ms (symbol-value ms)))
-            (and (stringp ms)
-                 (not (member ms see)) ;; Don't duplicate same status
-                 (setq see (cons ms see)
-                       ms (if (string-match "^[ ]*\\(.+\\)" ms)
-                              (match-string 1 ms)))
-                 (setq semantic-minor-modes-status
-                       (if semantic-minor-modes-status
-                           (concat semantic-minor-modes-status "/" ms)
-                         ms)))))
-        (if semantic-minor-modes-status
-            (setq semantic-minor-modes-status
-                  (concat
-                   " "
-                   (if (string-match "^[ ]*\\(.+\\)"
-                                     semantic-mode-line-prefix)
-                       (match-string 1 semantic-mode-line-prefix)
-                     "S")
-                   "/"
-                   semantic-minor-modes-status))))))
+  (setq semantic-minor-modes-format nil)
+  (dolist (x semantic-minor-mode-alist)
+    (setq minor-mode-alist (delq (assq (car x) minor-mode-alist)
+                                 minor-mode-alist)))
+  (when semantic-update-mode-line
+    (let ((locals '()))
+      ;; Select the minor modes that aren't enabled globally and who
+      ;; have a non-empty "name".
+      (dolist (x semantic-minor-mode-alist)
+        (unless (or (memq (car x) semantic-init-hook)
+                    (not (string-match "^[ ]*\\(.+\\)" (cadr x))))
+          (push (list (car x) (concat "/" (match-string 1 (cadr x)))) locals)))
+      ;; Then build the format spec.
+      (when locals
+        (let ((prefix (if (string-match "^[ ]*\\(.+\\)"
+                                        semantic-mode-line-prefix)
+                          (match-string 1 semantic-mode-line-prefix)
+                        "S")))
+          (setq semantic-minor-modes-format
+                `((:eval (if (or ,@(mapcar 'car locals))
+                             ,(concat " " prefix)))))
+          ;; It would be easier to just put `locals' inside
+          ;; semantic-minor-modes-format, but then things like
+          ;; mode-line-minor-mode-help can't find the right major mode
+          ;; any more.  So instead, we carefully put the minor modes
+          ;; in minor-mode-alist.
+          (let* ((elem (or (assq 'semantic-minor-modes-format
+                                 minor-mode-alist)
+                           ;; FIXME: This entry is meaningless for
+                           ;; mode-line-minor-mode-help.
+                           '(semantic-minor-modes-format
+                           semantic-minor-modes-format)))
+                 (tail (or (memq elem minor-mode-alist)
+                           (setq minor-mode-alist
+                                 (cons elem minor-mode-alist)))))
+            (setcdr tail (nconc locals (cdr tail)))))))))      
 
 (defun semantic-desktop-ignore-this-minor-mode (buffer)
   "Installed as a minor-mode initializer for Desktop mode.
 BUFFER is the buffer to not initialize a Semantic minor mode in."
   nil)
 
-(defun semantic-add-minor-mode (toggle name &optional keymap)
+(defun semantic-add-minor-mode (toggle name)
   "Register a new Semantic minor mode.
 TOGGLE is a symbol which is the name of a buffer-local variable that
 is toggled on or off to say whether the minor mode is active or not.
@@ -120,98 +125,58 @@
 
 NAME specifies what will appear in the mode line when the minor mode
 is active.  NAME should be either a string starting with a space, or a
-symbol whose value is such a string.
-
-Optional KEYMAP is the keymap for the minor mode that will be added to
-`minor-mode-map-alist'."
-  ;; Add a dymmy semantic minor mode to display the status
-  (or (assq 'semantic-minor-modes-status minor-mode-alist)
-      (setq minor-mode-alist (cons (list 'semantic-minor-modes-status
-                                         'semantic-minor-modes-status)
-                                   minor-mode-alist)))
-  (if (fboundp 'add-minor-mode)
-      ;; Emacs 21 & XEmacs
-      (add-minor-mode toggle "" keymap)
-    ;; Emacs 20
-    (or (assq toggle minor-mode-alist)
-        (setq minor-mode-alist (cons (list toggle "") minor-mode-alist)))
-    (or (not keymap)
-        (assq toggle minor-mode-map-alist)
-        (setq minor-mode-map-alist (cons (cons toggle keymap)
-                                         minor-mode-map-alist))))
+symbol whose value is such a string."
   ;; Record how to display this minor mode in the mode line
   (let ((mm (assq toggle semantic-minor-mode-alist)))
     (if mm
         (setcdr mm (list name))
       (setq semantic-minor-mode-alist (cons (list toggle name)
                                        semantic-minor-mode-alist))))
+  (semantic-mode-line-update)
 
   ;; Semantic minor modes don't work w/ Desktop restore.
   ;; This line will disable this minor mode from being restored
   ;; by Desktop.
   (when (boundp 'desktop-minor-mode-handlers)
     (add-to-list 'desktop-minor-mode-handlers
-		 (cons toggle 'semantic-desktop-ignore-this-minor-mode)))
-  )
+		 (cons toggle 'semantic-desktop-ignore-this-minor-mode))))
 
 (defun semantic-toggle-minor-mode-globally (mode &optional arg)
   "Toggle minor mode MODE in every Semantic enabled buffer.
 Return non-nil if MODE is turned on in every Semantic enabled buffer.
-If ARG is positive, enable, if it is negative, disable.  If ARG is
-nil, then toggle.  Otherwise do nothing.  MODE must be a valid minor
-mode defined in `minor-mode-alist' and must be too an interactive
-function used to toggle the mode."
-  (or (and (fboundp mode) (assq mode minor-mode-alist))
+If ARG is positive, enable, if it is negative, disable.
+MODE must be a valid minor mode defined in `minor-mode-alist' and must be
+too an interactive function used to toggle the mode."
+  ;; FIXME: All callers should pass a -1 or +1 argument.
+  (or (and (fboundp mode) (or (assq mode minor-mode-alist) ;Needed?
+			      (assq mode semantic-minor-mode-alist)))
       (error "Semantic minor mode %s not found" mode))
-  (if (not arg)
-      (if (memq mode semantic-init-hook)
-	  (setq arg -1)
-	(setq arg 1)))
-  ;; Add or remove the MODE toggle function from
-  ;; `semantic-init-hook'.  Then turn MODE on or off in every
-  ;; Semantic enabled buffer.
+  ;; Add or remove the MODE toggle function from `semantic-init-hook'.
   (cond
    ;; Turn off if ARG < 0
-   ((< arg 0)
-    (remove-hook 'semantic-init-hook mode)
-    (semantic-map-buffers #'(lambda () (funcall mode -1)))
-    nil)
+   ((< arg 0) (remove-hook 'semantic-init-hook mode))
    ;; Turn on if ARG > 0
-   ((> arg 0)
-    (add-hook 'semantic-init-hook mode)
-    (semantic-map-buffers #'(lambda () (funcall mode 1)))
-    t)
+   ((> arg 0) (add-hook 'semantic-init-hook mode))
    ;; Otherwise just check MODE state
    (t
-    (memq mode semantic-init-hook))
-   ))
+    (error "semantic-toggle-minor-mode-globally: arg should be -1 or 1")))
+  ;; Update the minor mode format.
+  (semantic-mode-line-update)
+  ;; Then turn MODE on or off in every Semantic enabled buffer.
+  (semantic-map-buffers #'(lambda () (funcall mode arg))))
 
 ;;;;
 ;;;; Minor mode to highlight areas that a user edits.
 ;;;;
 
 ;;;###autoload
-(defun global-semantic-highlight-edits-mode (&optional arg)
+(define-minor-mode global-semantic-highlight-edits-mode
   "Toggle global use of option `semantic-highlight-edits-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-highlight-edits-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-highlight-edits-mode arg)))
-
-;;;###autoload
-(defcustom global-semantic-highlight-edits-mode nil
-  "If non-nil enable global use of variable `semantic-highlight-edits-mode'.
-When this mode is enabled, changes made to a buffer are highlighted
-until the buffer is reparsed."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-highlight-edits-mode (if val 1 -1))))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic :group 'semantic-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-highlight-edits-mode
+   (if global-semantic-highlight-edits-mode 1 -1)))
 
 (defcustom semantic-highlight-edits-mode-hook nil
   "Hook run at the end of function `semantic-highlight-edits-mode'."
@@ -238,36 +203,8 @@
     km)
   "Keymap for highlight-edits minor mode.")
 
-(defvar semantic-highlight-edits-mode nil
-  "Non-nil if highlight-edits minor mode is enabled.
-Use the command `semantic-highlight-edits-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-highlight-edits-mode)
-
-(defun semantic-highlight-edits-mode-setup ()
-  "Setup option `semantic-highlight-edits-mode'.
-The minor mode can be turned on only if semantic feature is available
-and the current buffer was set up for parsing.  When minor mode is
-enabled parse the current buffer if needed.  Return non-nil if the
-minor mode is enabled."
-  (if semantic-highlight-edits-mode
-      (if (not (and (featurep 'semantic) (semantic-active-p)))
-	  (progn
-	    ;; Disable minor mode if semantic stuff not available
-	    (setq semantic-highlight-edits-mode nil)
-	    (error "Buffer %s was not set up for parsing"
-		   (buffer-name)))
-	(semantic-make-local-hook 'semantic-edits-new-change-hooks)
-	(add-hook 'semantic-edits-new-change-hooks
-		  'semantic-highlight-edits-new-change-hook-fcn nil t)
-	)
-    ;; Remove hooks
-    (remove-hook 'semantic-edits-new-change-hooks
-		 'semantic-highlight-edits-new-change-hook-fcn t)
-    )
-  semantic-highlight-edits-mode)
-
 ;;;###autoload
-(defun semantic-highlight-edits-mode (&optional arg)
+(define-minor-mode semantic-highlight-edits-mode
   "Minor mode for highlighting changes made in a buffer.
 Changes are tracked by semantic so that the incremental parser can work
 properly.
@@ -277,54 +214,38 @@
 minor mode can be turned on only if semantic feature is available and
 the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-highlight-edits-mode 0 1))))
-  (setq semantic-highlight-edits-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-highlight-edits-mode)))
-  (semantic-highlight-edits-mode-setup)
-  (run-hooks 'semantic-highlight-edits-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "highlight-edits minor mode %sabled"
-               (if semantic-highlight-edits-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-highlight-edits-mode)
+  :keymap semantic-highlight-edits-mode-map
+  (if semantic-highlight-edits-mode
+      (if (not (and (featurep 'semantic) (semantic-active-p)))
+	  (progn
+	    ;; Disable minor mode if semantic stuff not available
+	    (setq semantic-highlight-edits-mode nil)
+	    (error "Buffer %s was not set up for parsing"
+		   (buffer-name)))
+	(semantic-make-local-hook 'semantic-edits-new-change-hooks)
+	(add-hook 'semantic-edits-new-change-hooks
+		  'semantic-highlight-edits-new-change-hook-fcn nil t))
+    ;; Remove hooks
+    (remove-hook 'semantic-edits-new-change-hooks
+		 'semantic-highlight-edits-new-change-hook-fcn t)))
 
 (semantic-add-minor-mode 'semantic-highlight-edits-mode
-                         "e"
-                         semantic-highlight-edits-mode-map)
-
+                         "e")
 
 ;;;;
 ;;;; Minor mode to show unmatched-syntax elements
 ;;;;
 
 ;;;###autoload
-(defun global-semantic-show-unmatched-syntax-mode (&optional arg)
+(define-minor-mode global-semantic-show-unmatched-syntax-mode
   "Toggle global use of option `semantic-show-unmatched-syntax-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-show-unmatched-syntax-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-show-unmatched-syntax-mode arg)))
-
-;;;###autoload
-(defcustom global-semantic-show-unmatched-syntax-mode nil
-  "If non-nil, enable global use of `semantic-show-unmatched-syntax-mode'.
-When this mode is enabled, syntax in the current buffer which the
-semantic parser cannot match is highlighted with a red underline."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-show-unmatched-syntax-mode (if val 1 -1))))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic :group 'semantic-modes
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic/util-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-show-unmatched-syntax-mode
+   (if global-semantic-show-unmatched-syntax-mode 1 -1)))
 
 (defcustom semantic-show-unmatched-syntax-mode-hook nil
   "Hook run at the end of function `semantic-show-unmatched-syntax-mode'."
@@ -432,18 +353,21 @@
     km)
   "Keymap for command `semantic-show-unmatched-syntax-mode'.")
 
-(defvar semantic-show-unmatched-syntax-mode nil
-  "Non-nil if show-unmatched-syntax minor mode is enabled.
-Use the command `semantic-show-unmatched-syntax-mode' to change this
-variable.")
-(make-variable-buffer-local 'semantic-show-unmatched-syntax-mode)
+;;;###autoload
+(define-minor-mode semantic-show-unmatched-syntax-mode
+  "Minor mode to highlight unmatched lexical syntax tokens.
+When a parser executes, some elements in the buffer may not match any
+parser rules.  These text characters are considered unmatched syntax.
+Often time, the display of unmatched syntax can expose coding
+problems before the compiler is run.
 
-(defun semantic-show-unmatched-syntax-mode-setup ()
-  "Setup the `semantic-show-unmatched-syntax' minor mode.
-The minor mode can be turned on only if semantic feature is available
-and the current buffer was set up for parsing.  When minor mode is
-enabled parse the current buffer if needed.  Return non-nil if the
-minor mode is enabled."
+With prefix argument ARG, turn on if positive, otherwise off.  The
+minor mode can be turned on only if semantic feature is available and
+the current buffer was set up for parsing.  Return non-nil if the
+minor mode is enabled.
+
+\\{semantic-show-unmatched-syntax-mode-map}"
+  :keymap semantic-show-unmatched-syntax-mode-map
   (if semantic-show-unmatched-syntax-mode
       (if (not (and (featurep 'semantic) (semantic-active-p)))
           (progn
@@ -468,43 +392,10 @@
     (remove-hook 'semantic-pre-clean-token-hooks
 		 'semantic-clean-token-of-unmatched-syntax t)
     ;; Cleanup unmatched-syntax highlighting
-    (semantic-clean-unmatched-syntax-in-buffer))
-  semantic-show-unmatched-syntax-mode)
-
-;;;###autoload
-(defun semantic-show-unmatched-syntax-mode (&optional arg)
-  "Minor mode to highlight unmatched lexical syntax tokens.
-When a parser executes, some elements in the buffer may not match any
-parser rules.  These text characters are considered unmatched syntax.
-Often time, the display of unmatched syntax can expose coding
-problems before the compiler is run.
-
-With prefix argument ARG, turn on if positive, otherwise off.  The
-minor mode can be turned on only if semantic feature is available and
-the current buffer was set up for parsing.  Return non-nil if the
-minor mode is enabled.
-
-\\{semantic-show-unmatched-syntax-mode-map}"
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-show-unmatched-syntax-mode 0 1))))
-  (setq semantic-show-unmatched-syntax-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-show-unmatched-syntax-mode)))
-  (semantic-show-unmatched-syntax-mode-setup)
-  (run-hooks 'semantic-show-unmatched-syntax-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "show-unmatched-syntax minor mode %sabled"
-               (if semantic-show-unmatched-syntax-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-show-unmatched-syntax-mode)
+    (semantic-clean-unmatched-syntax-in-buffer)))
 
 (semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode
-                         "u"
-                         semantic-show-unmatched-syntax-mode-map)
+                         "u")
 
 (defun semantic-show-unmatched-syntax-next ()
   "Move forward to the next occurrence of unmatched syntax."
@@ -519,27 +410,15 @@
 ;;;;
 
 ;;;###autoload
-(defcustom global-semantic-show-parser-state-mode nil
-  "If non-nil enable global use of `semantic-show-parser-state-mode'.
-When enabled, the current parse state of the current buffer is displayed
-in the mode line.  See `semantic-show-parser-state-marker' for details
-on what is displayed."
-  :group 'semantic
-  :type 'boolean
-  :require 'semantic/util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-show-parser-state-mode (if val 1 -1))))
-
-;;;###autoload
-(defun global-semantic-show-parser-state-mode (&optional arg)
+(define-minor-mode global-semantic-show-parser-state-mode
   "Toggle global use of option `semantic-show-parser-state-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-show-parser-state-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-show-parser-state-mode arg)))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic/util-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-show-parser-state-mode
+   (if global-semantic-show-parser-state-mode 1 -1)))
 
 (defcustom semantic-show-parser-state-mode-hook nil
   "Hook run at the end of function `semantic-show-parser-state-mode'."
@@ -551,17 +430,22 @@
     km)
   "Keymap for show-parser-state minor mode.")
 
-(defvar semantic-show-parser-state-mode nil
-  "Non-nil if show-parser-state minor mode is enabled.
-Use the command `semantic-show-parser-state-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-show-parser-state-mode)
-
-(defun semantic-show-parser-state-mode-setup ()
-  "Setup option `semantic-show-parser-state-mode'.
-The minor mode can be turned on only if semantic feature is available
-and the current buffer was set up for parsing.  When minor mode is
-enabled parse the current buffer if needed.  Return non-nil if the
+;;;###autoload
+(define-minor-mode semantic-show-parser-state-mode
+  "Minor mode for displaying parser cache state in the modeline.
+The cache can be in one of three states.  They are
+Up to date, Partial reparse needed, and Full reparse needed.
+The state is indicated in the modeline with the following characters:
+ `-'  ->  The cache is up to date.
+ `!'  ->  The cache requires a full update.
+ `~'  ->  The cache needs to be incrementally parsed.
+ `%'  ->  The cache is not currently parseable.
+ `@'  ->  Auto-parse in progress (not set here.)
+With prefix argument ARG, turn on if positive, otherwise off.  The
+minor mode can be turned on only if semantic feature is available and
+the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
+  :keymap semantic-show-parser-state-mode-map
   (if semantic-show-parser-state-mode
       (if (not (and (featurep 'semantic) (semantic-active-p)))
           (progn
@@ -603,8 +487,7 @@
 		  'semantic-show-parser-state-auto-marker nil t)
 	(semantic-make-local-hook 'semantic-after-idle-scheduler-reparse-hook)
 	(add-hook 'semantic-after-idle-scheduler-reparse-hook
-		  'semantic-show-parser-state-marker nil t)
-        )
+		  'semantic-show-parser-state-marker nil t))
     ;; Remove parts of mode line
     (setq mode-line-modified
 	  (delq 'semantic-show-parser-state-string mode-line-modified))
@@ -626,45 +509,10 @@
     (remove-hook 'semantic-before-idle-scheduler-reparse-hook
 		 'semantic-show-parser-state-auto-marker t)
     (remove-hook 'semantic-after-idle-scheduler-reparse-hook
-		 'semantic-show-parser-state-marker t)
-    )
-  semantic-show-parser-state-mode)
-
-;;;###autoload
-(defun semantic-show-parser-state-mode (&optional arg)
-  "Minor mode for displaying parser cache state in the modeline.
-The cache can be in one of three states.  They are
-Up to date, Partial reparse needed, and Full reparse needed.
-The state is indicated in the modeline with the following characters:
- `-'  ->  The cache is up to date.
- `!'  ->  The cache requires a full update.
- `~'  ->  The cache needs to be incrementally parsed.
- `%'  ->  The cache is not currently parseable.
- `@'  ->  Auto-parse in progress (not set here.)
-With prefix argument ARG, turn on if positive, otherwise off.  The
-minor mode can be turned on only if semantic feature is available and
-the current buffer was set up for parsing.  Return non-nil if the
-minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-show-parser-state-mode 0 1))))
-  (setq semantic-show-parser-state-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-show-parser-state-mode)))
-  (semantic-show-parser-state-mode-setup)
-  (run-hooks 'semantic-show-parser-state-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "show-parser-state minor mode %sabled"
-               (if semantic-show-parser-state-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-show-parser-state-mode)
+		 'semantic-show-parser-state-marker t)))
 
 (semantic-add-minor-mode 'semantic-show-parser-state-mode
-                         ""
-                         semantic-show-parser-state-mode-map)
+                         "")
 
 (defvar semantic-show-parser-state-string nil
   "String showing the parser state for this buffer.
@@ -691,7 +539,7 @@
 	      (t
                "-")))
   ;;(message "Setup mode line indicator to [%s]" semantic-show-parser-state-string)
-  (semantic-mode-line-update))
+  )
 
 (defun semantic-show-parser-state-auto-marker ()
   "Hook function run before an autoparse.
@@ -699,7 +547,6 @@
 to indicate a parse in progress."
   (unless (semantic-parse-tree-up-to-date-p)
     (setq semantic-show-parser-state-string "@")
-    (semantic-mode-line-update)
     ;; For testing.
     ;;(sit-for 1)
     ))
@@ -710,30 +557,14 @@
 ;;;;
 
 ;;;###autoload
-(defun global-semantic-stickyfunc-mode (&optional arg)
+(define-minor-mode global-semantic-stickyfunc-mode
   "Toggle global use of option `semantic-stickyfunc-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-stickyfunc-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-stickyfunc-mode arg)))
-
-;;;###autoload
-(defcustom global-semantic-stickyfunc-mode nil
-  "If non-nil, enable global use of `semantic-stickyfunc-mode'.
-This minor mode only works for Emacs 21 or later.
-When enabled, the header line is enabled, and the first line
-of the current function or method is displayed in it.
-This makes it appear that the first line of that tag is
-`sticky' to the top of the window."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-stickyfunc-mode (if val 1 -1))))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic :group 'semantic-modes
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic/util-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-stickyfunc-mode (if global-semantic-stickyfunc-mode 1 -1)))
 
 (defcustom semantic-stickyfunc-mode-hook nil
   "Hook run at the end of function `semantic-stickyfunc-mode'."
@@ -781,11 +612,6 @@
 	(describe-function 'semantic-stickyfunc-mode)) t])
   )
 
-(defvar semantic-stickyfunc-mode nil
-  "Non-nil if stickyfunc minor mode is enabled.
-Use the command `semantic-stickyfunc-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-stickyfunc-mode)
-
 (defcustom semantic-stickyfunc-indent-string
   (if (and window-system (not (featurep 'xemacs)))
       (concat
@@ -870,11 +696,21 @@
 	(t nil))
   "The header line format used by stickyfunc mode.")
 
-(defun semantic-stickyfunc-mode-setup ()
-  "Setup option `semantic-stickyfunc-mode'.
-For semantic enabled buffers, make the function declaration for the top most
-function \"sticky\".  This is accomplished by putting the first line of
-text for that function in the header line."
+;;;###autoload
+(define-minor-mode semantic-stickyfunc-mode
+  "Minor mode to show the title of a tag in the header line.
+Enables/disables making the header line of functions sticky.
+A function (or other tag class specified by
+`semantic-stickyfunc-sticky-classes') has a header line, meaning the
+first line which describes the rest of the construct.  This first
+line is what is displayed in the header line.
+
+With prefix argument ARG, turn on if positive, otherwise off.  The
+minor mode can be turned on only if semantic feature is available and
+the current buffer was set up for parsing.  Return non-nil if the
+minor mode is enabled."
+  ;; Don't need indicator.  It's quite visible
+  :keymap semantic-stickyfunc-mode-map
   (if semantic-stickyfunc-mode
       (progn
 	(unless (and (featurep 'semantic) (semantic-active-p))
@@ -892,8 +728,7 @@
 			    semantic-stickyfunc-header-line-format)))
 	  (set (make-local-variable 'semantic-stickyfunc-old-hlf)
 	       header-line-format))
-	(setq header-line-format semantic-stickyfunc-header-line-format)
-	)
+	(setq header-line-format semantic-stickyfunc-header-line-format))
     ;; Disable sticky func mode
     ;; Restore previous buffer local value of header line format if
     ;; the current one is the sticky func one.
@@ -901,38 +736,7 @@
       (kill-local-variable 'header-line-format)
       (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer))
 	(setq header-line-format semantic-stickyfunc-old-hlf)
-	(kill-local-variable 'semantic-stickyfunc-old-hlf))))
-  semantic-stickyfunc-mode)
-
-;;;###autoload
-(defun semantic-stickyfunc-mode (&optional arg)
-  "Minor mode to show the title of a tag in the header line.
-Enables/disables making the header line of functions sticky.
-A function (or other tag class specified by
-`semantic-stickyfunc-sticky-classes') has a header line, meaning the
-first line which describes the rest of the construct.  This first
-line is what is displayed in the header line.
-
-With prefix argument ARG, turn on if positive, otherwise off.  The
-minor mode can be turned on only if semantic feature is available and
-the current buffer was set up for parsing.  Return non-nil if the
-minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-stickyfunc-mode 0 1))))
-  (setq semantic-stickyfunc-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-stickyfunc-mode)))
-  (semantic-stickyfunc-mode-setup)
-  (run-hooks 'semantic-stickyfunc-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "Stickyfunc minor mode %sabled"
-               (if semantic-stickyfunc-mode "en" "dis")))
-  (semantic-mode-line-update)
-  semantic-stickyfunc-mode)
+	(kill-local-variable 'semantic-stickyfunc-old-hlf)))))
 
 (defvar semantic-stickyfunc-sticky-classes
   '(function type)
@@ -1012,8 +816,7 @@
 
 
 (semantic-add-minor-mode 'semantic-stickyfunc-mode
-                         "" ;; Don't need indicator.  It's quite visible
-                         semantic-stickyfunc-mode-map)
+                         "") ;; Don't need indicator.  It's quite visible
 
 
 
@@ -1025,26 +828,15 @@
 ;; from the tag going off the top of the screen.
 
 ;;;###autoload
-(defun global-semantic-highlight-func-mode (&optional arg)
+(define-minor-mode global-semantic-highlight-func-mode
   "Toggle global use of option `semantic-highlight-func-mode'.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-semantic-highlight-func-mode
-        (semantic-toggle-minor-mode-globally
-         'semantic-highlight-func-mode arg)))
-
-;;;###autoload
-(defcustom global-semantic-highlight-func-mode nil
-  "If non-nil, enable global use of `semantic-highlight-func-mode'.
-When enabled, the first line of the current tag is highlighted."
-  :group 'semantic
-  :group 'semantic-modes
-  :type 'boolean
-  :require 'semantic/util-modes
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-semantic-highlight-func-mode (if val 1 -1))))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'semantic :group 'semantic-modes
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'semantic/util-modes
+  (semantic-toggle-minor-mode-globally
+   'semantic-highlight-func-mode
+   (if global-semantic-highlight-func-mode 1 -1)))
 
 (defcustom semantic-highlight-func-mode-hook nil
   "Hook run at the end of function `semantic-highlight-func-mode'."
@@ -1108,11 +900,6 @@
       )
     (select-window startwin)))
 
-(defvar semantic-highlight-func-mode nil
-  "Non-nil if highlight-func minor mode is enabled.
-Use the command `semantic-highlight-func-mode' to change this variable.")
-(make-variable-buffer-local 'semantic-highlight-func-mode)
-
 (defvar semantic-highlight-func-ct-overlay nil
   "Overlay used to highlight the tag the cursor is in.")
 (make-variable-buffer-local 'semantic-highlight-func-ct-overlay)
@@ -1126,28 +913,8 @@
   "Face used to show the top of current function."
   :group 'semantic-faces)
 
-
-(defun semantic-highlight-func-mode-setup ()
-  "Setup option `semantic-highlight-func-mode'.
-For Semantic enabled buffers, highlight the first line of the
-current tag declaration."
-  (if semantic-highlight-func-mode
-      (progn
-	(unless (and (featurep 'semantic) (semantic-active-p))
-	  ;; Disable minor mode if semantic stuff not available
-	  (setq semantic-highlight-func-mode nil)
-	  (error "Buffer %s was not set up for parsing" (buffer-name)))
-	;; Setup our hook
-	(add-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag nil t)
-	)
-    ;; Disable highlight func mode
-    (remove-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag t)
-    (semantic-highlight-func-highlight-current-tag t)
-    )
-  semantic-highlight-func-mode)
-
 ;;;###autoload
-(defun semantic-highlight-func-mode (&optional arg)
+(define-minor-mode semantic-highlight-func-mode
   "Minor mode to highlight the first line of the current tag.
 Enables/disables making the current function's first line light up.
 A function (or other tag class specified by
@@ -1162,21 +929,20 @@
 minor mode can be turned on only if semantic feature is available and
 the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled."
-  (interactive
-   (list (or current-prefix-arg
-             (if semantic-highlight-func-mode 0 1))))
-  (setq semantic-highlight-func-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not semantic-highlight-func-mode)))
-  (semantic-highlight-func-mode-setup)
-  (run-hooks 'semantic-highlight-func-mode-hook)
-  (if (called-interactively-p 'interactive)
-      (message "Highlight-Func minor mode %sabled"
-               (if semantic-highlight-func-mode "en" "dis")))
-  semantic-highlight-func-mode)
+  :lighter nil ;; Don't need indicator.  It's quite visible.
+  (if semantic-highlight-func-mode
+      (progn
+	(unless (and (featurep 'semantic) (semantic-active-p))
+	  ;; Disable minor mode if semantic stuff not available
+	  (setq semantic-highlight-func-mode nil)
+	  (error "Buffer %s was not set up for parsing" (buffer-name)))
+	;; Setup our hook
+	(add-hook 'post-command-hook
+                  'semantic-highlight-func-highlight-current-tag nil t))
+    ;; Disable highlight func mode
+    (remove-hook 'post-command-hook
+                 'semantic-highlight-func-highlight-current-tag t)
+    (semantic-highlight-func-highlight-current-tag t)))
 
 (defun semantic-highlight-func-highlight-current-tag (&optional disable)
   "Highlight the current tag under point.
@@ -1223,8 +989,7 @@
   nil)
 
 (semantic-add-minor-mode 'semantic-highlight-func-mode
-                         "" ;; Don't need indicator.  It's quite visible
-                         nil)
+                         "") ;; Don't need indicator.  It's quite visible
 
 (provide 'semantic/util-modes)
 
--- a/lisp/cedet/srecode/mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/cedet/srecode/mode.el	Thu May 06 09:50:39 2010 +0900
@@ -37,19 +37,6 @@
 
 ;;; Code:
 
-(defcustom global-srecode-minor-mode nil
-  "Non-nil in buffers with Semantic Recoder macro keybindings."
-  :group 'srecode
-  :type 'boolean
-  :require 'srecode/mode
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-srecode-minor-mode (if val 1 -1))))
-
-(defvar srecode-minor-mode nil
-  "Non-nil in buffers with Semantic Recoder macro keybindings.")
-(make-variable-buffer-local 'srecode-minor-mode)
-
 (defcustom srecode-minor-mode-hook nil
   "Hook run at the end of the function `srecode-minor-mode'."
   :group 'srecode
@@ -150,7 +137,7 @@
   "Keymap for srecode minor mode.")
 
 ;;;###autoload
-(defun srecode-minor-mode (&optional arg)
+(define-minor-mode srecode-minor-mode
   "Toggle srecode minor mode.
 With prefix argument ARG, turn on if positive, otherwise off.  The
 minor mode can be turned on only if semantic feature is available and
@@ -158,16 +145,7 @@
 minor mode is enabled.
 
 \\{srecode-mode-map}"
-  (interactive
-   (list (or current-prefix-arg
-             (if srecode-minor-mode 0 1))))
-  ;; Flip the bits.
-  (setq srecode-minor-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not srecode-minor-mode)))
+  :keymap srecode-mode-map
   ;; If we are turning things on, make sure we have templates for
   ;; this mode first.
   (when srecode-minor-mode
@@ -176,25 +154,20 @@
 		(mapcar (lambda (map)
 			  (srecode-map-entries-for-mode map major-mode))
 			(srecode-get-maps))))
-      (setq srecode-minor-mode nil))
-    )
-  ;; Run hooks if we are turning this on.
-  (when srecode-minor-mode
-    (run-hooks 'srecode-minor-mode-hook))
-  srecode-minor-mode)
+      (setq srecode-minor-mode nil))))
 
 ;;;###autoload
-(defun global-srecode-minor-mode (&optional arg)
+(define-minor-mode global-srecode-minor-mode
   "Toggle global use of srecode minor mode.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-srecode-minor-mode
-        (semantic-toggle-minor-mode-globally
-         'srecode-minor-mode arg)))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'srecode
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'srecode/mode
+  (semantic-toggle-minor-mode-globally
+   'srecode-minor-mode (if global-srecode-minor-mode 1 -1)))
 
 ;; Use the semantic minor mode magic stuff.
-(semantic-add-minor-mode 'srecode-minor-mode "" srecode-mode-map)
+(semantic-add-minor-mode 'srecode-minor-mode "")
 
 ;;; Menu Filters
 ;;
--- a/lisp/composite.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/composite.el	Thu May 06 09:50:39 2010 +0900
@@ -44,7 +44,7 @@
 A glyph reference point symbol is to be used to specify a composition
 rule in COMPONENTS argument to such functions as `compose-region'.
 
-Meanings of glyph reference point codes are as follows:
+The meaning of glyph reference point codes is as follows:
 
     0----1----2 <---- ascent	0:tl or top-left
     |         |			1:tc or top-center
@@ -212,7 +212,7 @@
 this case, TAB element has a special meaning.  If the first
 characer is TAB, the glyphs are displayed with left padding space
 so that no pixel overlaps with the previous column.  If the last
-character is TAB, the glyphs are displayed with rigth padding
+character is TAB, the glyphs are displayed with right padding
 space so that no pixel overlaps with the following column.
 
 If it is a vector or list, it is a sequence of alternate characters and
@@ -222,7 +222,7 @@
 
 A composition rule is a cons of global and new glyph reference point
 symbols.  See the documentation of `reference-point-alist' for more
-detail.
+details.
 
 Optional 4th argument MODIFICATION-FUNC is a function to call to
 adjust the composition when it gets invalid because of a change of
@@ -332,7 +332,7 @@
 
 WIDTH is a number of columns the composition occupies on the screen.
 
-When Automatic Compostion mode is on, this function also finds a
+When Automatic Composition mode is on, this function also finds a
 chunk of text that is automatically composed.  If such a chunk is
 found closer to POS than the position that has `composition'
 property, the value is a list of FROM, TO, and a glyph-string
@@ -745,14 +745,13 @@
 	  (setq func 'compose-gstring-for-terminal))
       (funcall func gstring))))
 
-(make-variable-buffer-local 'auto-composition-mode)
 (put 'auto-composition-mode 'permanent-local t)
 
 (make-variable-buffer-local 'auto-composition-function)
 (setq-default auto-composition-function 'auto-compose-chars)
 
 ;;;###autoload
-(defun auto-composition-mode (&optional arg)
+(define-minor-mode auto-composition-mode
   "Toggle Auto Composition mode.
 With ARG, turn Auto Composition mode off if and only if ARG is a non-positive
 number; if ARG is nil, toggle Auto Composition mode; anything else turns Auto
@@ -762,24 +761,16 @@
 by functions registered in `composition-function-table' (which see).
 
 You can use `global-auto-composition-mode' to turn on
-Auto Composition mode in all buffers (this is the default)."
-  (interactive "P")
-  (setq auto-composition-mode
-	(if arg
-	    (or (not (integerp arg)) (> arg 0))
-	  (not auto-composition-mode))))
+Auto Composition mode in all buffers (this is the default).")
 
 ;;;###autoload
-(defun global-auto-composition-mode (&optional arg)
+(define-minor-mode global-auto-composition-mode
   "Toggle Auto-Composition mode in every possible buffer.
 With prefix arg, turn Global-Auto-Composition mode on if and only if arg
 is positive.
 See `auto-composition-mode' for more information on Auto-Composition mode."
-  (interactive "P")
-  (setq-default auto-composition-mode
-		(if arg
-		    (or (not (integerp arg)) (> arg 0))
-		  (not (default-value 'auto-composition-mode)))))
+  :variable (default-value 'auto-composition-mode))
+
 (defalias 'toggle-auto-composition 'auto-composition-mode)
 
 
--- a/lisp/diff.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/diff.el	Thu May 06 09:50:39 2010 +0900
@@ -64,8 +64,8 @@
   "Code run when the diff process exits.
 CODE is the exit code of the process.  It should be 0 only if no diffs
 were found."
-  (if diff-old-temp-file (delete-file diff-old-temp-file))
-  (if diff-new-temp-file (delete-file diff-new-temp-file))
+  (if diff-old-temp-file (delete-file diff-old-temp-file t))
+  (if diff-new-temp-file (delete-file diff-new-temp-file t))
   (save-excursion
     (goto-char (point-max))
     (let ((inhibit-read-only t))
--- a/lisp/emacs-lisp/cl-loaddefs.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emacs-lisp/cl-loaddefs.el	Thu May 06 09:50:39 2010 +0900
@@ -282,7 +282,7 @@
 ;;;;;;  flet progv psetq do-all-symbols do-symbols dotimes dolist
 ;;;;;;  do* do loop return-from return block etypecase typecase ecase
 ;;;;;;  case load-time-value eval-when destructuring-bind function*
-;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "7fad7dd60f2f96ba90432f885015d61b")
+;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "0faa39d8f21ae59f2cc1baa835e28a5f")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'gensym "cl-macs" "\
--- a/lisp/emacs-lisp/cl-macs.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emacs-lisp/cl-macs.el	Thu May 06 09:50:39 2010 +0900
@@ -1769,6 +1769,7 @@
 (defsetf frame-visible-p cl-set-frame-visible-p)
 (defsetf frame-width set-screen-width t)
 (defsetf frame-parameter set-frame-parameter t)
+(defsetf terminal-parameter set-terminal-parameter)
 (defsetf getenv setenv t)
 (defsetf get-register set-register)
 (defsetf global-key-binding global-set-key)
@@ -1821,10 +1822,26 @@
 (defsetf x-get-secondary-selection x-own-secondary-selection t)
 (defsetf x-get-selection x-own-selection t)
 
+;; This is a hack that allows (setf (eq a 7) B) to mean either
+;; (setq a 7) or (setq a nil) depending on whether B is nil or not.
+;; This is useful when you have control over the PLACE but not over
+;; the VALUE, as is the case in define-minor-mode's :variable.
+(define-setf-method eq (place val)
+  (let ((method (get-setf-method place cl-macro-environment))
+        (val-temp (make-symbol "--eq-val--"))
+        (store-temp (make-symbol "--eq-store--")))
+    (list (append (nth 0 method) (list val-temp))
+          (append (nth 1 method) (list val))
+          (list store-temp)
+          `(let ((,(car (nth 2 method))
+                  (if ,store-temp ,val-temp (not ,val-temp))))
+             ,(nth 3 method) ,store-temp)
+          `(eq ,(nth 4 method) ,val-temp))))
+
 ;;; More complex setf-methods.
-;;; These should take &environment arguments, but since full arglists aren't
-;;; available while compiling cl-macs, we fake it by referring to the global
-;;; variable cl-macro-environment directly.
+;; These should take &environment arguments, but since full arglists aren't
+;; available while compiling cl-macs, we fake it by referring to the global
+;; variable cl-macro-environment directly.
 
 (define-setf-method apply (func arg1 &rest rest)
   (or (and (memq (car-safe func) '(quote function function*))
--- a/lisp/emacs-lisp/derived.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emacs-lisp/derived.el	Thu May 06 09:50:39 2010 +0900
@@ -230,7 +230,7 @@
 					; Run the parent.
 	 (delay-mode-hooks
 
-	  (,(or parent 'kill-all-local-variables))
+	  (,(or parent 'fundamental-mode))
 					; Identify the child mode.
 	  (setq major-mode (quote ,child))
 	  (setq mode-name ,name)
--- a/lisp/emacs-lisp/easy-mmode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emacs-lisp/easy-mmode.el	Thu May 06 09:50:39 2010 +0900
@@ -116,6 +116,8 @@
 :lighter SPEC	Same as the LIGHTER argument.
 :keymap MAP	Same as the KEYMAP argument.
 :require SYM	Same as in `defcustom'.
+:variable PLACE	The location (as can be used with `setf') to use instead
+		of the variable MODE to store the state of the mode.
 
 For example, you could write
   (define-minor-mode foo-mode \"If enabled, foo on you!\"
@@ -147,6 +149,8 @@
 	 (type nil)
 	 (extra-args nil)
 	 (extra-keywords nil)
+         (variable nil)
+         (modefun mode)
 	 (require t)
 	 (hook (intern (concat mode-name "-hook")))
 	 (hook-on (intern (concat mode-name "-on-hook")))
@@ -167,6 +171,7 @@
 	(:type (setq type (list :type (pop body))))
 	(:require (setq require (pop body)))
 	(:keymap (setq keymap (pop body)))
+        (:variable (setq variable (setq mode (pop body))))
 	(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
 
     (setq keymap-sym (if (and keymap (symbolp keymap)) keymap
@@ -187,12 +192,16 @@
 
     `(progn
        ;; Define the variable to enable or disable the mode.
-       ,(if (not globalp)
-	    `(progn
-	       (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
+       ,(cond
+         ;; If :variable is specified, then the var will be
+         ;; declared elsewhere.
+         (variable nil)
+         ((not globalp)
+          `(progn
+             (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
 Use the command `%s' to change this variable." pretty-name mode))
-	       (make-variable-buffer-local ',mode))
-
+             (make-variable-buffer-local ',mode)))
+         (t
 	  (let ((base-doc-string
                  (concat "Non-nil if %s is enabled.
 See the command `%s' for a description of this minor mode."
@@ -207,10 +216,10 @@
 	       ,@group
 	       ,@type
 	       ,@(unless (eq require t) `(:require ,require))
-               ,@(nreverse extra-keywords))))
+               ,@(nreverse extra-keywords)))))
 
        ;; The actual function.
-       (defun ,mode (&optional arg ,@extra-args)
+       (defun ,modefun (&optional arg ,@extra-args)
 	 ,(or doc
 	      (format (concat "Toggle %s on or off.
 Interactively, with no prefix argument, toggle the mode.
@@ -221,11 +230,11 @@
 	 ;; repeat-command still does the toggling correctly.
 	 (interactive (list (or current-prefix-arg 'toggle)))
 	 (let ((,last-message (current-message)))
-           (setq ,mode
-                 (if (eq arg 'toggle)
-                     (not ,mode)
-                   ;; A nil argument also means ON now.
-                   (> (prefix-numeric-value arg) 0)))
+           (,(if (symbolp mode) 'setq 'setf) ,mode
+            (if (eq arg 'toggle)
+                (not ,mode)
+              ;; A nil argument also means ON now.
+              (> (prefix-numeric-value arg) 0)))
            ,@body
            ;; The on/off hooks are here for backward compatibility only.
            (run-hooks ',hook (if ,mode ',hook-on ',hook-off))
@@ -256,9 +265,10 @@
 		     (t (error "Invalid keymap %S" ,keymap))))
 	     ,(format "Keymap for `%s'." mode-name)))
 
-       (add-minor-mode ',mode ',lighter
-		       ,(if keymap keymap-sym
-			  `(if (boundp ',keymap-sym) ,keymap-sym))))))
+       ,(unless variable
+          `(add-minor-mode ',mode ',lighter
+                           ,(if keymap keymap-sym
+                              `(if (boundp ',keymap-sym) ,keymap-sym)))))))
 
 ;;;
 ;;; make global minor mode
@@ -338,9 +348,11 @@
 	     (progn
 	       (add-hook 'after-change-major-mode-hook
 			 ',MODE-enable-in-buffers)
+	       (add-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
 	       (add-hook 'find-file-hook ',MODE-check-buffers)
 	       (add-hook 'change-major-mode-hook ',MODE-cmhh))
 	   (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers)
+           (remove-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
 	   (remove-hook 'find-file-hook ',MODE-check-buffers)
 	   (remove-hook 'change-major-mode-hook ',MODE-cmhh))
 
--- a/lisp/emacs-lisp/lisp-mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emacs-lisp/lisp-mode.el	Thu May 06 09:50:39 2010 +0900
@@ -466,7 +466,7 @@
   "Keymap for ordinary Lisp mode.
 All commands in `lisp-mode-shared-map' are inherited by this map.")
 
-(defun lisp-mode ()
+(define-derived-mode lisp-mode nil "Lisp"
   "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
 Commands:
 Delete converts tabs to spaces as it moves back.
@@ -478,19 +478,12 @@
 
 Entry to this mode calls the value of `lisp-mode-hook'
 if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map lisp-mode-map)
-  (setq major-mode 'lisp-mode)
-  (setq mode-name "Lisp")
   (lisp-mode-variables nil t)
+  (set (make-local-variable 'find-tag-default-function) 'lisp-find-tag-default)
   (make-local-variable 'comment-start-skip)
   (setq comment-start-skip
        "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
-  (setq imenu-case-fold-search t)
-  (set-syntax-table lisp-mode-syntax-table)
-  (run-mode-hooks 'lisp-mode-hook))
-(put 'lisp-mode 'find-tag-default-function 'lisp-find-tag-default)
+  (setq imenu-case-fold-search t))
 
 (defun lisp-find-tag-default ()
   (let ((default (find-tag-default)))
--- a/lisp/emulation/edt.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/emulation/edt.el	Thu May 06 09:50:39 2010 +0900
@@ -858,8 +858,7 @@
 In select mode, selected text is highlighted."
   (if arg
       (progn
-	(make-local-variable 'edt-select-mode)
-	(setq edt-select-mode 'edt-select-mode-current)
+	(set (make-local-variable 'edt-select-mode) 'edt-select-mode-current)
 	(setq rect-start-point (window-point)))
     (progn
       (kill-local-variable 'edt-select-mode)))
--- a/lisp/epg.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/epg.el	Thu May 06 09:50:39 2010 +0900
@@ -1898,7 +1898,7 @@
 	  ;; Cleanup the tempfile.
 	  (and tempfile
 	       (file-exists-p tempfile)
-	       (delete-file tempfile))
+	       (delete-file tempfile t))
 	  ;; Cleanup the tempdir.
 	  (and tempdir
 	       (file-directory-p tempdir)
@@ -1998,7 +1998,7 @@
 	  (epg-read-output context))
       (epg-delete-output-file context)
       (if (file-exists-p input-file)
-	  (delete-file input-file))
+	  (delete-file input-file t))
       (epg-reset context))))
 
 (defun epg-start-verify (context signature &optional signed-text)
@@ -2202,7 +2202,7 @@
 	  (epg-read-output context))
       (epg-delete-output-file context)
       (if input-file
-	  (delete-file input-file))
+	  (delete-file input-file t))
       (epg-reset context))))
 
 (defun epg-start-encrypt (context plain recipients
@@ -2322,7 +2322,7 @@
 	  (epg-read-output context))
       (epg-delete-output-file context)
       (if input-file
-	  (delete-file input-file))
+	  (delete-file input-file t))
       (epg-reset context))))
 
 (defun epg-start-export-keys (context keys)
--- a/lisp/frame.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/frame.el	Thu May 06 09:50:39 2010 +0900
@@ -24,6 +24,7 @@
 ;;; Commentary:
 
 ;;; Code:
+(eval-when-compile (require 'cl))
 
 (defvar frame-creation-function-alist
   (list (cons nil
@@ -1132,37 +1133,26 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
-(defun auto-raise-mode (arg)
+(define-minor-mode auto-raise-mode
   "Toggle whether or not the selected frame should auto-raise.
 With ARG, turn auto-raise mode on if and only if ARG is positive.
 Note that this controls Emacs's own auto-raise feature.
 Some window managers allow you to enable auto-raise for certain windows.
 You can use that for Emacs windows if you wish, but if you do,
 that is beyond the control of Emacs and this command has no effect on it."
-  (interactive "P")
-  (if (null arg)
-      (setq arg
-	    (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
-		-1 1)))
-  (if (> arg 0)
-      (raise-frame (selected-frame)))
-  (modify-frame-parameters (selected-frame)
-			   (list (cons 'auto-raise (> arg 0)))))
+  :variable (frame-parameter nil 'auto-raise)
+  (if (frame-parameter nil 'auto-raise)
+      (raise-frame)))
 
-(defun auto-lower-mode (arg)
+(define-minor-mode auto-lower-mode
   "Toggle whether or not the selected frame should auto-lower.
 With ARG, turn auto-lower mode on if and only if ARG is positive.
 Note that this controls Emacs's own auto-lower feature.
 Some window managers allow you to enable auto-lower for certain windows.
 You can use that for Emacs windows if you wish, but if you do,
 that is beyond the control of Emacs and this command has no effect on it."
-  (interactive "P")
-  (if (null arg)
-      (setq arg
-	    (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
-		-1 1)))
-  (modify-frame-parameters (selected-frame)
-			   (list (cons 'auto-lower (> arg 0)))))
+  :variable (frame-parameter nil 'auto-lower))
+
 (defun set-frame-name (name)
   "Set the name of the selected frame to NAME.
 When called interactively, prompt for the name of the frame.
--- a/lisp/gnus/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,26 @@
+2010-05-03  Juanma Barranquero  <lekktu@gmail.com>
+
+	* mm-util.el (mm-decompress-buffer): Use `delete-file';
+	alias `jka-compr-delete-temp-file' no longer exists.
+
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Use define-minor-mode in Gnus where applicable.
+	* mml.el (mml-mode): Use define-minor-mode.
+	* gnus-undo.el (gnus-undo-mode-map): Initialize in declaration.
+	(gnus-undo-mode): Use define-minor-mode.
+	* gnus-sum.el (gnus-dead-summary-mode-map): Initialize in declaration.
+	(gnus-dead-summary-mode): Use define-minor-mode.
+	* gnus-salt.el (gnus-pick-mode-map, gnus-binary-mode-map):
+	Initialize in declaration.
+	(gnus-pick-mode, gnus-binary-mode): Use define-minor-mode.
+	* gnus-ml.el (gnus-mailing-list-mode-map): Initialize in declaration.
+	(gnus-mailing-list-mode): Use define-minor-mode.
+	* gnus-draft.el (gnus-draft-mode-map): Initialize in declaration.
+	(gnus-draft-mode): Use define-minor-mode.
+	* gnus-dired.el (gnus-dired-mode-map): Initialize in declaration.
+	(gnus-dired-mode): Use define-minor-mode.
+
 2010-04-27  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-util.el: Don't load tm and apel XEmacs packages when compiling.
--- a/lisp/gnus/gnus-dired.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-dired.el	Thu May 06 09:50:39 2010 +0900
@@ -55,17 +55,12 @@
 (autoload 'message-buffers "message")
 (autoload 'gnus-print-buffer "gnus-sum")
 
-(defvar gnus-dired-mode nil
-  "Minor mode for intersections of MIME mail composition and dired.")
-
-(defvar gnus-dired-mode-map nil)
-
-(unless gnus-dired-mode-map
-  (setq gnus-dired-mode-map (make-sparse-keymap))
-
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-a" 'gnus-dired-attach)
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-l" 'gnus-dired-find-file-mailcap)
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-p" 'gnus-dired-print))
+(defvar gnus-dired-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-m\C-a" 'gnus-dired-attach)
+    (define-key map "\C-c\C-m\C-l" 'gnus-dired-find-file-mailcap)
+    (define-key map "\C-c\C-m\C-p" 'gnus-dired-print)
+    map))
 
 ;; FIXME: Make it customizable, change the default to `mail-user-agent' when
 ;; this file is renamed (e.g. to `dired-mime.el').
@@ -89,19 +84,13 @@
 			       gnus-user-agent)
 		(function :tag "Other")))
 
-(defun gnus-dired-mode (&optional arg)
+(define-minor-mode gnus-dired-mode
   "Minor mode for intersections of gnus and dired.
 
 \\{gnus-dired-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'dired-mode)
-    (set (make-local-variable 'gnus-dired-mode)
-	 (if (null arg) (not gnus-dired-mode)
-	   (> (prefix-numeric-value arg) 0)))
-    (when gnus-dired-mode
-      (add-minor-mode 'gnus-dired-mode "" gnus-dired-mode-map)
-      (save-current-buffer
-	(run-hooks 'gnus-dired-mode-hook)))))
+  :keymap gnus-dired-mode-map
+  (unless (derived-mode-p 'dired-mode)
+    (setq gnus-dired-mode nil)))
 
 ;;;###autoload
 (defun turn-on-gnus-dired-mode ()
--- a/lisp/gnus/gnus-draft.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-draft.el	Thu May 06 09:50:39 2010 +0900
@@ -35,20 +35,15 @@
 
 ;;; Draft minor mode
 
-(defvar gnus-draft-mode nil
-  "Minor mode for providing a draft summary buffers.")
-
-(defvar gnus-draft-mode-map nil)
-
-(unless gnus-draft-mode-map
-  (setq gnus-draft-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-draft-mode-map
-    "Dt" gnus-draft-toggle-sending
-    "e"  gnus-draft-edit-message ;; Use `B w' for `gnus-summary-edit-article'
-    "De" gnus-draft-edit-message
-    "Ds" gnus-draft-send-message
-    "DS" gnus-draft-send-all-messages))
+(defvar gnus-draft-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+     "Dt" gnus-draft-toggle-sending
+     "e"  gnus-draft-edit-message ;; Use `B w' for `gnus-summary-edit-article'
+     "De" gnus-draft-edit-message
+     "Ds" gnus-draft-send-message
+     "DS" gnus-draft-send-all-messages)
+    map))
 
 (defun gnus-draft-make-menu-bar ()
   (unless (boundp 'gnus-draft-menu)
@@ -61,20 +56,17 @@
        ["Send all messages" gnus-draft-send-all-messages t]
        ["Delete draft" gnus-summary-delete-article t]))))
 
-(defun gnus-draft-mode (&optional arg)
+(define-minor-mode gnus-draft-mode
   "Minor mode for providing a draft summary buffers.
 
 \\{gnus-draft-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (when (set (make-local-variable 'gnus-draft-mode)
-	       (if (null arg) (not gnus-draft-mode)
-		 (> (prefix-numeric-value arg) 0)))
-      ;; Set up the menu.
-      (when (gnus-visual-p 'draft-menu 'menu)
-	(gnus-draft-make-menu-bar))
-      (add-minor-mode 'gnus-draft-mode " Draft" gnus-draft-mode-map)
-      (gnus-run-hooks 'gnus-draft-mode-hook))))
+  :lighter " Draft" :keymap gnus-draft-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-draft-mode nil))
+   (gnus-draft-mode
+    ;; Set up the menu.
+    (when (gnus-visual-p 'draft-menu 'menu)
+      (gnus-draft-make-menu-bar)))))
 
 ;;; Commands
 
--- a/lisp/gnus/gnus-ml.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-ml.el	Thu May 06 09:50:39 2010 +0900
@@ -33,24 +33,19 @@
 
 ;;; Mailing list minor mode
 
-(defvar gnus-mailing-list-mode nil
-  "Minor mode for providing mailing-list commands.")
-
-(defvar gnus-mailing-list-mode-map nil)
+(defvar gnus-mailing-list-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "\C-c\C-nh" gnus-mailing-list-help
+      "\C-c\C-ns" gnus-mailing-list-subscribe
+      "\C-c\C-nu" gnus-mailing-list-unsubscribe
+      "\C-c\C-np" gnus-mailing-list-post
+      "\C-c\C-no" gnus-mailing-list-owner
+      "\C-c\C-na" gnus-mailing-list-archive)
+    map))
 
 (defvar gnus-mailing-list-menu)
 
-(unless gnus-mailing-list-mode-map
-  (setq gnus-mailing-list-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-mailing-list-mode-map
-    "\C-c\C-nh" gnus-mailing-list-help
-    "\C-c\C-ns" gnus-mailing-list-subscribe
-    "\C-c\C-nu" gnus-mailing-list-unsubscribe
-    "\C-c\C-np" gnus-mailing-list-post
-    "\C-c\C-no" gnus-mailing-list-owner
-    "\C-c\C-na" gnus-mailing-list-archive))
-
 (defun gnus-mailing-list-make-menu-bar ()
   (unless (boundp 'gnus-mailing-list-menu)
     (easy-menu-define
@@ -88,21 +83,19 @@
       (gnus-message 1 "no list-post in this message."))))
 
 ;;;###autoload
-(defun gnus-mailing-list-mode (&optional arg)
+(define-minor-mode gnus-mailing-list-mode
   "Minor mode for providing mailing-list commands.
 
 \\{gnus-mailing-list-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (when (set (make-local-variable 'gnus-mailing-list-mode)
-	       (if (null arg) (not gnus-mailing-list-mode)
-		 (> (prefix-numeric-value arg) 0)))
-      ;; Set up the menu.
-      (when (gnus-visual-p 'mailing-list-menu 'menu)
-	(gnus-mailing-list-make-menu-bar))
-      (add-minor-mode 'gnus-mailing-list-mode " Mailing-List"
-		      gnus-mailing-list-mode-map)
-      (gnus-run-hooks 'gnus-mailing-list-mode-hook))))
+  :lighter " Mailing-List"
+  :keymap gnus-mailing-list-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode))
+    (setq gnus-mailing-list-mode nil))
+   (gnus-mailing-list-mode
+    ;; Set up the menu.
+    (when (gnus-visual-p 'mailing-list-menu 'menu)
+      (gnus-mailing-list-make-menu-bar)))))
 
 ;;; Commands
 
--- a/lisp/gnus/gnus-salt.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-salt.el	Thu May 06 09:50:39 2010 +0900
@@ -35,10 +35,6 @@
 ;;; gnus-pick-mode
 ;;;
 
-(defvar gnus-pick-mode nil
-  "Minor mode for providing a pick-and-read interface in Gnus
-summary buffers.")
-
 (defcustom gnus-pick-display-summary nil
   "*Display summary while reading."
   :type 'boolean
@@ -72,17 +68,15 @@
 
 ;;; Internal variables.
 
-(defvar gnus-pick-mode-map nil)
-
-(unless gnus-pick-mode-map
-  (setq gnus-pick-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-pick-mode-map
-    " " gnus-pick-next-page
-    "u" gnus-pick-unmark-article-or-thread
-    "." gnus-pick-article-or-thread
-    gnus-down-mouse-2 gnus-pick-mouse-pick-region
-    "\r" gnus-pick-start-reading))
+(defvar gnus-pick-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      " " gnus-pick-next-page
+      "u" gnus-pick-unmark-article-or-thread
+      "." gnus-pick-article-or-thread
+      gnus-down-mouse-2 gnus-pick-mouse-pick-region
+      "\r" gnus-pick-start-reading)
+    map))
 
 (defun gnus-pick-make-menu-bar ()
   (unless (boundp 'gnus-pick-menu)
@@ -104,30 +98,30 @@
 	["Start reading" gnus-pick-start-reading t]
 	["Switch pick mode off" gnus-pick-mode gnus-pick-mode]))))
 
-(defun gnus-pick-mode (&optional arg)
+(define-minor-mode gnus-pick-mode
   "Minor mode for providing a pick-and-read interface in Gnus summary buffers.
 
 \\{gnus-pick-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (if (not (set (make-local-variable 'gnus-pick-mode)
-		  (if (null arg) (not gnus-pick-mode)
-		    (> (prefix-numeric-value arg) 0))))
-	(remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
-      ;; Make sure that we don't select any articles upon group entry.
-      (set (make-local-variable 'gnus-auto-select-first) nil)
-      ;; Change line format.
-      (setq gnus-summary-line-format gnus-summary-pick-line-format)
-      (setq gnus-summary-line-format-spec nil)
-      (gnus-update-format-specifications nil 'summary)
-      (gnus-update-summary-mark-positions)
-      (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
-      (set (make-local-variable 'gnus-summary-goto-unread) 'never)
-      ;; Set up the menu.
-      (when (gnus-visual-p 'pick-menu 'menu)
-	(gnus-pick-make-menu-bar))
-      (add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map)
-      (gnus-run-hooks 'gnus-pick-mode-hook))))
+  :lighter " Pick" :keymap gnus-pick-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-pick-mode nil))
+   ((not gnus-pick-mode)
+    ;; FIXME: a buffer-local minor mode removing globally from a hook??
+    (remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message))
+   (t
+    ;; Make sure that we don't select any articles upon group entry.
+    (set (make-local-variable 'gnus-auto-select-first) nil)
+    ;; Change line format.
+    (setq gnus-summary-line-format gnus-summary-pick-line-format)
+    (setq gnus-summary-line-format-spec nil)
+    (gnus-update-format-specifications nil 'summary)
+    (gnus-update-summary-mark-positions)
+    ;; FIXME: a buffer-local minor mode adding globally to a hook??
+    (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
+    (set (make-local-variable 'gnus-summary-goto-unread) 'never)
+    ;; Set up the menu.
+    (when (gnus-visual-p 'pick-menu 'menu)
+      (gnus-pick-make-menu-bar)))))
 
 (defun gnus-pick-setup-message ()
   "Make Message do the right thing on exit."
@@ -319,20 +313,14 @@
 ;;; gnus-binary-mode
 ;;;
 
-(defvar gnus-binary-mode nil
-  "Minor mode for providing a binary group interface in Gnus summary buffers.")
-
 (defvar gnus-binary-mode-hook nil
   "Hook run in summary binary mode buffers.")
 
-(defvar gnus-binary-mode-map nil)
-
-(unless gnus-binary-mode-map
-  (setq gnus-binary-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys
-      gnus-binary-mode-map
-    "g" gnus-binary-show-article))
+(defvar gnus-binary-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "g" gnus-binary-show-article)
+    map))
 
 (defun gnus-binary-make-menu-bar ()
   (unless (boundp 'gnus-binary-menu)
@@ -341,25 +329,20 @@
       '("Pick"
 	["Switch binary mode off" gnus-binary-mode t]))))
 
-(defun gnus-binary-mode (&optional arg)
+(define-minor-mode gnus-binary-mode
   "Minor mode for providing a binary group interface in Gnus summary buffers."
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (make-local-variable 'gnus-binary-mode)
-    (setq gnus-binary-mode
-	  (if (null arg) (not gnus-binary-mode)
-	    (> (prefix-numeric-value arg) 0)))
-    (when gnus-binary-mode
-      ;; Make sure that we don't select any articles upon group entry.
-      (make-local-variable 'gnus-auto-select-first)
-      (setq gnus-auto-select-first nil)
-      (make-local-variable 'gnus-summary-display-article-function)
-      (setq gnus-summary-display-article-function 'gnus-binary-display-article)
-      ;; Set up the menu.
-      (when (gnus-visual-p 'binary-menu 'menu)
-	(gnus-binary-make-menu-bar))
-      (add-minor-mode 'gnus-binary-mode " Binary" gnus-binary-mode-map)
-      (gnus-run-hooks 'gnus-binary-mode-hook))))
+  :lighter " Binary" :keymap gnus-binary-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-binary-mode nil))
+   (gnus-binary-mode
+    ;; Make sure that we don't select any articles upon group entry.
+    (make-local-variable 'gnus-auto-select-first)
+    (setq gnus-auto-select-first nil)
+    (make-local-variable 'gnus-summary-display-article-function)
+    (setq gnus-summary-display-article-function 'gnus-binary-display-article)
+    ;; Set up the menu.
+    (when (gnus-visual-p 'binary-menu 'menu)
+      (gnus-binary-make-menu-bar)))))
 
 (defun gnus-binary-display-article (article &optional all-header)
   "Run ARTICLE through the binary decode functions."
--- a/lisp/gnus/gnus-start.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-start.el	Thu May 06 09:50:39 2010 +0900
@@ -2960,6 +2960,8 @@
 
 (defun gnus-slave-mode ()
   "Minor mode for slave Gnusae."
+  ;; FIXME: gnus-slave-mode appears to never be set (i.e. it'll always be nil):
+  ;; Remove, or fix and use define-minor-mode.
   (add-minor-mode 'gnus-slave-mode " Slave" (make-sparse-keymap))
   (gnus-run-hooks 'gnus-slave-mode-hook))
 
@@ -3058,6 +3060,7 @@
       nil)
      (t
       (save-excursion
+        ;; FIXME: Shouldn't save-restriction be done after set-buffer?
 	(save-restriction
 	  (set-buffer nntp-server-buffer)
 	  (goto-char (point-min))
--- a/lisp/gnus/gnus-sum.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-sum.el	Thu May 06 09:50:39 2010 +0900
@@ -7237,33 +7237,21 @@
 
 ;;; Dead summaries.
 
-(defvar gnus-dead-summary-mode-map nil)
-
-(unless gnus-dead-summary-mode-map
-  (setq gnus-dead-summary-mode-map (make-keymap))
-  (suppress-keymap gnus-dead-summary-mode-map)
-  (substitute-key-definition
-   'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
-  (dolist (key '("\C-d" "\r" "\177" [delete]))
-    (define-key gnus-dead-summary-mode-map
-      key 'gnus-summary-wake-up-the-dead))
-  (dolist (key '("q" "Q"))
-    (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
-
-(defvar gnus-dead-summary-mode nil
-  "Minor mode for Gnus summary buffers.")
-
-(defun gnus-dead-summary-mode (&optional arg)
+(defvar gnus-dead-summary-mode-map
+  (let ((map (make-keymap)))
+    (suppress-keymap map)
+    (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
+    (dolist (key '("\C-d" "\r" "\177" [delete]))
+      (define-key map key 'gnus-summary-wake-up-the-dead))
+    (dolist (key '("q" "Q"))
+      (define-key map key 'bury-buffer))
+    map))
+
+(define-minor-mode gnus-dead-summary-mode
   "Minor mode for Gnus summary buffers."
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (make-local-variable 'gnus-dead-summary-mode)
-    (setq gnus-dead-summary-mode
-	  (if (null arg) (not gnus-dead-summary-mode)
-	    (> (prefix-numeric-value arg) 0)))
-    (when gnus-dead-summary-mode
-      (add-minor-mode
-       'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
+  :lighter " Dead" :keymap gnus-dead-summary-mode-map
+  (unless (derived-mode-p 'gnus-summary-mode)
+    (setq gnus-dead-summary-mode nil)))
 
 (defun gnus-deaden-summary ()
   "Make the current summary buffer into a dead summary buffer."
--- a/lisp/gnus/gnus-topic.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-topic.el	Thu May 06 09:50:39 2010 +0900
@@ -1140,6 +1140,7 @@
 
 (defun gnus-topic-mode (&optional arg redisplay)
   "Minor mode for topicsifying Gnus group buffers."
+  ;; FIXME: Use define-minor-mode.
   (interactive (list current-prefix-arg t))
   (when (eq major-mode 'gnus-group-mode)
     (make-local-variable 'gnus-topic-mode)
--- a/lisp/gnus/gnus-undo.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/gnus-undo.el	Thu May 06 09:50:39 2010 +0900
@@ -59,6 +59,10 @@
   :group 'gnus-undo)
 
 (defcustom gnus-undo-mode nil
+  ;; FIXME: This is a buffer-local minor mode which requires running
+  ;; code upon activation/deactivation, so defining it as a defcustom
+  ;; doesn't seem very useful: setting it to non-nil via Customize
+  ;; probably won't do the right thing.
   "Minor mode for undoing in Gnus buffers."
   :type 'boolean
   :group 'gnus-undo)
@@ -77,17 +81,15 @@
 
 ;;; Minor mode definition.
 
-(defvar gnus-undo-mode-map nil)
-
-(unless gnus-undo-mode-map
-  (setq gnus-undo-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-undo-mode-map
-    "\M-\C-_"     gnus-undo
-    "\C-_"        gnus-undo
-    "\C-xu"       gnus-undo
-    ;; many people are used to type `C-/' on X terminals and get `C-_'.
-    [(control /)] gnus-undo))
+(defvar gnus-undo-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "\M-\C-_"     gnus-undo
+      "\C-_"        gnus-undo
+      "\C-xu"       gnus-undo
+      ;; many people are used to type `C-/' on X terminals and get `C-_'.
+      [(control /)] gnus-undo)
+    map))
 
 (defun gnus-undo-make-menu-bar ()
   ;; This is disabled for the time being.
@@ -96,24 +98,19 @@
       (cons "Undo" 'gnus-undo-actions)
       [menu-bar file whatever])))
 
-(defun gnus-undo-mode (&optional arg)
+(define-minor-mode gnus-undo-mode
   "Minor mode for providing `undo' in Gnus buffers.
 
 \\{gnus-undo-mode-map}"
-  (interactive "P")
-  (set (make-local-variable 'gnus-undo-mode)
-       (if (null arg) (not gnus-undo-mode)
-	 (> (prefix-numeric-value arg) 0)))
+  :keymap gnus-undo-mode-map
   (set (make-local-variable 'gnus-undo-actions) nil)
   (set (make-local-variable 'gnus-undo-boundary) t)
   (when gnus-undo-mode
     ;; Set up the menu.
     (when (gnus-visual-p 'undo-menu 'menu)
       (gnus-undo-make-menu-bar))
-    (add-minor-mode 'gnus-undo-mode "" gnus-undo-mode-map)
     (gnus-make-local-hook 'post-command-hook)
-    (add-hook 'post-command-hook 'gnus-undo-boundary nil t)
-    (gnus-run-hooks 'gnus-undo-mode-hook)))
+    (add-hook 'post-command-hook 'gnus-undo-boundary nil t)))
 
 ;;; Interface functions.
 
--- a/lisp/gnus/mm-util.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/mm-util.el	Thu May 06 09:50:39 2010 +0900
@@ -1563,7 +1563,7 @@
 	      (error
 	       (setq err-msg (error-message-string err)))))
 	  (when (file-exists-p err-file)
-	    (ignore-errors (jka-compr-delete-temp-file err-file)))
+	    (ignore-errors (delete-file err-file)))
 	  (when inplace
 	    (unless err-msg
 	      (delete-region (point-min) (point-max))
--- a/lisp/gnus/mml.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/gnus/mml.el	Thu May 06 09:50:39 2010 +0900
@@ -898,8 +898,7 @@
     ;; Determine type and stuff.
     (unless (stringp (car handle))
       (unless (setq textp (equal (mm-handle-media-supertype handle) "text"))
-	(save-excursion
-	  (set-buffer (setq buffer (mml-generate-new-buffer " *mml*")))
+	(with-current-buffer (setq buffer (mml-generate-new-buffer " *mml*"))
 	  (if (eq (mail-content-type-get (mm-handle-type handle) 'charset)
 		  'gnus-decoded)
 	      ;; A part that mm-uu dissected from a non-MIME message
@@ -1126,25 +1125,18 @@
      ,@(if (featurep 'xemacs) '(t)
 	 '(:help "Display the EasyPG manual"))]))
 
-(defvar mml-mode nil
-  "Minor mode for editing MML.")
-
-(defun mml-mode (&optional arg)
+(define-minor-mode mml-mode
   "Minor mode for editing MML.
 MML is the MIME Meta Language, a minor mode for composing MIME articles.
 See Info node `(emacs-mime)Composing'.
 
 \\{mml-mode-map}"
-  (interactive "P")
-  (when (set (make-local-variable 'mml-mode)
-	     (if (null arg) (not mml-mode)
-	       (> (prefix-numeric-value arg) 0)))
-    (add-minor-mode 'mml-mode " MML" mml-mode-map)
+  :lighter " MML" :keymap mml-mode-map
+  (when mml-mode
     (easy-menu-add mml-menu mml-mode-map)
     (when (boundp 'dnd-protocol-alist)
       (set (make-local-variable 'dnd-protocol-alist)
-	   (append mml-dnd-protocol-alist dnd-protocol-alist)))
-    (run-hooks 'mml-mode-hook)))
+	   (append mml-dnd-protocol-alist dnd-protocol-alist)))))
 
 ;;;
 ;;; Helper functions for reading MIME stuff from the minibuffer and
--- a/lisp/ibuf-ext.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/ibuf-ext.el	Thu May 06 09:50:39 2010 +0900
@@ -91,11 +91,6 @@
 (defvar ibuffer-tmp-show-regexps nil
   "A list of regexps which should match buffer names to always show.")
 
-(defvar ibuffer-auto-mode nil
-  "If non-nil, Ibuffer auto-mode should be enabled for this buffer.
-Do not set this variable directly!  Use the function
-`ibuffer-auto-mode' instead.")
-
 (defvar ibuffer-auto-buffers-changed nil)
 
 (defcustom ibuffer-saved-filters '(("gnus"
@@ -220,6 +215,16 @@
 	 (ibuffer-included-in-filters-p buf ibuffer-filtering-qualifiers)
 	 (ibuffer-buf-matches-predicates buf ibuffer-always-show-predicates)))))
 
+;;;###autoload
+(define-minor-mode ibuffer-auto-mode
+  "Toggle use of Ibuffer's auto-update facility.
+With numeric ARG, enable auto-update if and only if ARG is positive."
+  nil nil nil
+  (unless (derived-mode-p 'ibuffer-mode)
+    (error "This buffer is not in Ibuffer mode"))
+  (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) ; Initialize state vector
+  (add-hook 'post-command-hook 'ibuffer-auto-update-changed))
+
 (defun ibuffer-auto-update-changed ()
   (when (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed)
     (dolist (buf (buffer-list))
@@ -230,20 +235,6 @@
 	    (ibuffer-update nil t)))))))
 
 ;;;###autoload
-(defun ibuffer-auto-mode (&optional arg)
-  "Toggle use of Ibuffer's auto-update facility.
-With numeric ARG, enable auto-update if and only if ARG is positive."
-  (interactive)
-  (unless (derived-mode-p 'ibuffer-mode)
-    (error "This buffer is not in Ibuffer mode"))
-  (set (make-local-variable 'ibuffer-auto-mode)
-       (if arg
-	   (plusp arg)
-	 (not ibuffer-auto-mode)))
-  (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) ; Initialize state vector
-  (add-hook 'post-command-hook 'ibuffer-auto-update-changed))
-
-;;;###autoload
 (defun ibuffer-mouse-filter-by-mode (event)
   "Enable or disable filtering by the major mode chosen via mouse."
   (interactive "e")
--- a/lisp/ibuffer.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/ibuffer.el	Thu May 06 09:50:39 2010 +0900
@@ -2641,7 +2641,7 @@
 ;;;;;;  ibuffer-backward-filter-group ibuffer-forward-filter-group
 ;;;;;;  ibuffer-toggle-filter-group ibuffer-mouse-toggle-filter-group
 ;;;;;;  ibuffer-interactive-filter-by-mode ibuffer-mouse-filter-by-mode
-;;;;;;  ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" "4fb4f1a32cf4ecf4669a133a866f4a14")
+;;;;;;  ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" "e1272bfdc7c3b6e926b2a68155217303")
 ;;; Generated autoloads from ibuf-ext.el
 
 (autoload 'ibuffer-auto-mode "ibuf-ext" "\
--- a/lisp/ido.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/ido.el	Thu May 06 09:50:39 2010 +0900
@@ -322,7 +322,6 @@
 
 ;;; Code:
 
-(defvar cua-inhibit-cua-keys)
 (defvar recentf-list)
 
 ;;; User Variables
@@ -1624,7 +1623,6 @@
     (define-key map "\C-o" 'ido-copy-current-word)
     (define-key map "\C-w" 'ido-copy-current-file-name)
     (define-key map [(meta ?l)] 'ido-toggle-literal)
-    (define-key map "\C-v" 'ido-toggle-vc)
     (set-keymap-parent map ido-file-dir-completion-map)
     (setq ido-file-completion-map map))
 
@@ -4609,7 +4607,6 @@
   (when (ido-active)
     (add-hook 'pre-command-hook 'ido-tidy nil t)
     (add-hook 'post-command-hook 'ido-exhibit nil t)
-    (setq cua-inhibit-cua-keys t)
     (when (featurep 'xemacs)
       (ido-exhibit)
       (goto-char (point-min)))
--- a/lisp/info.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/info.el	Thu May 06 09:50:39 2010 +0900
@@ -3104,6 +3104,7 @@
 (add-to-list 'Info-virtual-nodes
 	     '("\\`\\*Index.*\\*\\'"
 	       (find-node . Info-virtual-index-find-node)
+	       (slow . t)
 	       ))
 
 (defvar Info-virtual-index-nodes nil
@@ -3193,6 +3194,7 @@
 	       (toc-nodes . Info-apropos-toc-nodes)
 	       (find-file . Info-apropos-find-file)
 	       (find-node . Info-apropos-find-node)
+	       (slow . t)
 	       ))
 
 (defvar Info-apropos-file "*Apropos*"
@@ -3348,6 +3350,7 @@
 
 (defun Info-finder-find-node (filename nodename &optional no-going-back)
   "Finder-specific implementation of Info-find-node-2."
+  (require 'finder)
   (cond
    ((equal nodename "Top")
     ;; Display Top menu with descriptions of the keywords
@@ -4836,21 +4839,35 @@
 
 (defun Info-desktop-buffer-misc-data (desktop-dirname)
   "Auxiliary information to be saved in desktop file."
-  (unless (Info-virtual-file-p Info-current-file)
-    (list Info-current-file Info-current-node)))
+  (list Info-current-file
+	Info-current-node
+	;; Additional data as an association list.
+	(delq nil (list
+		   (and Info-history
+			(cons 'history Info-history))
+		   (and (Info-virtual-fun
+			 'slow Info-current-file Info-current-node)
+			(cons 'slow t))))))
 
 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
                                     desktop-buffer-name
                                     desktop-buffer-misc)
   "Restore an Info buffer specified in a desktop file."
-  (let ((first (nth 0 desktop-buffer-misc))
-        (second (nth 1 desktop-buffer-misc)))
-  (when (and first second)
-    (when desktop-buffer-name
-      (set-buffer (get-buffer-create desktop-buffer-name))
-      (Info-mode))
-    (Info-find-node first second)
-    (current-buffer))))
+  (let* ((file (nth 0 desktop-buffer-misc))
+	 (node (nth 1 desktop-buffer-misc))
+	 (data (nth 2 desktop-buffer-misc))
+	 (hist (assq 'history data))
+	 (slow (assq 'slow data)))
+    ;; Don't restore nodes slow to regenerate.
+    (unless slow
+      (when (and file node)
+	(when desktop-buffer-name
+	  (set-buffer (get-buffer-create desktop-buffer-name))
+	  (Info-mode))
+	(Info-find-node file node)
+	(when hist
+	  (setq Info-history (cdr hist)))
+	(current-buffer)))))
 
 (add-to-list 'desktop-buffer-mode-handlers
 	     '(Info-mode . Info-restore-desktop-buffer))
--- a/lisp/international/iso-ascii.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/international/iso-ascii.el	Thu May 06 09:50:39 2010 +0900
@@ -33,6 +33,7 @@
 ;;; Code:
 
 (require 'disp-table)
+(eval-when-compile (require 'cl))
 
 (defgroup iso-ascii nil
   "Set up char tables for ISO 8859/1 on ASCII terminals."
@@ -162,15 +163,11 @@
 (iso-ascii-display 254 "th")  ; small thorn, Icelandic
 (iso-ascii-display 255 "\"y") ; small y with diaeresis or umlaut mark
 
-(defun iso-ascii-mode (arg)
+(define-minor-mode iso-ascii-mode
   "Toggle ISO-ASCII mode."
-  (interactive "P")
-  (unless arg
-    (setq arg (eq standard-display-table iso-ascii-standard-display-table)))
-  (setq standard-display-table
-	(if arg
-	    iso-ascii-display-table
-	  iso-ascii-standard-display-table)))
+  :variable (eq standard-display-table iso-ascii-display-table)
+  (unless standard-display-table
+    (setq standard-display-table iso-ascii-standard-display-table)))
 
 (provide 'iso-ascii)
 
--- a/lisp/jka-compr.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/jka-compr.el	Thu May 06 09:50:39 2010 +0900
@@ -181,7 +181,8 @@
 			  null-device))
 			jka-compr-acceptable-retval-list)
 		  (jka-compr-error prog args infile message err-file))
-	    (jka-compr-delete-temp-file err-file)))
+	    (delete-file err-file t)))
+
       ;; Run the uncompression program directly.
       ;; We get the whole file and must delete what we don't want.
       (jka-compr-call-process prog message infile t nil args))
@@ -222,7 +223,7 @@
 					   "")))
 		   jka-compr-acceptable-retval-list)
 		  (jka-compr-error prog args infile message err-file))
-	    (jka-compr-delete-temp-file err-file)))
+	    (delete-file err-file t)))
       (or (eq 0
 	      (apply 'call-process
 		     prog infile (if (stringp output) temp output)
@@ -248,9 +249,6 @@
   "This routine will return the name of a new file."
   (make-temp-file jka-compr-temp-name-template))
 
-(defalias 'jka-compr-delete-temp-file 'delete-file)
-
-
 (defun jka-compr-write-region (start end file &optional append visit)
   (let* ((filename (expand-file-name file))
 	 (visit-file (if (stringp visit) (expand-file-name visit) filename))
@@ -337,7 +335,7 @@
 						(and append can-append) 'dont))
 	      (erase-buffer)) )
 
-	  (jka-compr-delete-temp-file temp-file)
+	  (delete-file temp-file t)
 
 	  (and
 	   compress-message
@@ -603,7 +601,7 @@
 	      (setq file (file-name-sans-extension file)))
 	    (setcar l file)))
 
-      (jka-compr-delete-temp-file local-copy))
+      (delete-file local-copy))
 
     t))
 
--- a/lisp/mail/supercite.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/mail/supercite.el	Thu May 06 09:50:39 2010 +0900
@@ -1619,21 +1619,20 @@
 	       (cadr err) sc-eref-style)
 	      (beep))))))
 
-(defun sc-electric-mode (&optional arg)
-  "
-Mode for viewing Supercite reference headers.  Commands are:
+(defun sc-electric-mode (&optional style)
+  "Mode for viewing Supercite reference headers.  Commands are:
 \n\\{sc-electric-mode-map}
 
 `sc-electric-mode' is not intended to be run interactively, but rather
 accessed through Supercite's electric reference feature.  See
-`sc-insert-reference' for more details.  Optional ARG is the initial
+`sc-insert-reference' for more details.  Optional STYLE is the initial
 header style to use, unless not supplied or invalid, in which case
 `sc-preferred-header-style' is used."
 
   (let ((info sc-mail-info))
 
     (setq sc-eref-style
-	  (or (sc-valid-index-p arg)
+	  (or (sc-valid-index-p style)
 	      (sc-valid-index-p sc-preferred-header-style)
 	      0))
 
--- a/lisp/mh-e/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/mh-e/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,8 @@
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* mh-show.el (mh-showing-mode): Move function to mh-e.el.
+	* mh-e.el (mh-showing-mode): Use define-minor-mode.
+
 2010-03-24  Juanma Barranquero  <lekktu@gmail.com>
 
 	* mh-scan.el (mh-scan-cmd-note-width): Doc fix.
--- a/lisp/mh-e/mh-e.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/mh-e/mh-e.el	Thu May 06 09:50:39 2010 +0900
@@ -287,8 +287,10 @@
 (defvar mh-show-buffer nil
   "Buffer that displays message for this folder.")
 
-(defvar mh-showing-mode nil
-  "If non-nil, show the message in a separate window.")
+(define-minor-mode mh-showing-mode
+  "Minor mode to show the message in a separate window."
+  ;; FIXME: maybe this should be moved to mh-show.el.
+  :lighter " Show")
 
 (defvar mh-view-ops nil
   "Stack of operations that change the folder view.
--- a/lisp/mh-e/mh-show.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/mh-e/mh-show.el	Thu May 06 09:50:39 2010 +0900
@@ -170,16 +170,6 @@
     (run-hooks 'mh-show-hook)))
 
 ;;;###mh-autoload
-(defun mh-showing-mode (&optional arg)
-  "Change whether messages should be displayed.
-
-With ARG, display messages if ARG is positive, otherwise don't display them."
-  (setq mh-showing-mode
-        (if (null arg)
-            (not mh-showing-mode)
-          (> (prefix-numeric-value arg) 0))))
-
-;;;###mh-autoload
 (defun mh-start-of-uncleaned-message ()
   "Position uninteresting headers off the top of the window."
   (let ((case-fold-search t))
--- a/lisp/minibuffer.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/minibuffer.el	Thu May 06 09:50:39 2010 +0900
@@ -1157,7 +1157,7 @@
           (call-interactively 'minibuffer-complete)
         (delete-overlay ol)))))
 
-(defvar completion-at-point-functions nil
+(defvar completion-at-point-functions '(tags-completion-at-point-function)
   "Special hook to find the completion table for the thing at point.
 It is called without any argument and should return either nil,
 or a function of no argument to perform completion (discouraged),
@@ -1169,22 +1169,31 @@
  `:predicate'           a predicate that completion candidates need to satisfy.
  `:annotation-function' the value to use for `completion-annotate-function'.")
 
-(defun completion-at-point ()
-  "Complete the thing at point according to local mode."
-  (interactive)
-  (let ((res (run-hook-with-args-until-success
-              'completion-at-point-functions)))
-    (cond
-     ((functionp res) (funcall res))
-     (res
-      (let* ((plist (nthcdr 3 res))
-             (start (nth 0 res))
-             (end (nth 1 res))
-             (completion-annotate-function
-              (or (plist-get plist :annotation-function)
-                  completion-annotate-function)))
-        (completion-in-region start end (nth 2 res)
-                              (plist-get plist :predicate)))))))
+(defun complete-symbol (&optional arg)
+  "Perform completion on the text around point.
+The completion method is determined by `completion-at-point-functions'.
+
+With a prefix argument, this command does completion within
+the collection of symbols listed in the index of the manual for the
+language you are using."
+  (interactive "P")
+  (if arg
+      (info-complete-symbol)
+    (let ((res (run-hook-with-args-until-success
+		'completion-at-point-functions)))
+      (cond
+       ((functionp res) (funcall res))
+       (res
+	(let* ((plist (nthcdr 3 res))
+	       (start (nth 0 res))
+	       (end (nth 1 res))
+	       (completion-annotate-function
+		(or (plist-get plist :annotation-function)
+		    completion-annotate-function)))
+	  (completion-in-region start end (nth 2 res)
+				(plist-get plist :predicate))))))))
+
+(defalias 'completion-at-point 'complete-symbol)
 
 ;;; Key bindings.
 
@@ -1361,7 +1370,9 @@
                     (substitute-in-file-name string)
                   (error string)))
            (comp (completion-file-name-table
-                  str (or pred read-file-name-predicate) action)))
+                  str
+		  (with-no-warnings (or pred read-file-name-predicate))
+		  action)))
 
       (cond
        ((stringp comp)
--- a/lisp/net/ange-ftp.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/ange-ftp.el	Thu May 06 09:50:39 2010 +0900
@@ -1734,7 +1734,10 @@
 		      ange-ftp-gateway-tmp-name-template
 		    ange-ftp-tmp-name-template)))
 
-(defalias 'ange-ftp-del-tmp-name 'delete-file)
+(defun ange-ftp-del-tmp-name (filename)
+  "Force to delete temporary file."
+  (delete-file filename 'force))
+
 
 ;;;; ------------------------------------------------------------
 ;;;; Interactive gateway program support.
@@ -3504,7 +3507,7 @@
 	(file-exists-p file)
       (ange-ftp-real-file-executable-p file))))
 
-(defun ange-ftp-delete-file (file)
+(defun ange-ftp-delete-file (file &optional force)
   (interactive "fDelete file: ")
   (setq file (expand-file-name file))
   (let ((parsed (ange-ftp-ftp-name file)))
@@ -3523,7 +3526,7 @@
 		       (format "FTP Error: \"%s\"" (cdr result))
 		       file)))
 	  (ange-ftp-delete-file-entry file))
-      (ange-ftp-real-delete-file file))))
+      (ange-ftp-real-delete-file file force))))
 
 (defun ange-ftp-file-modtime (file)
   "Return the modification time of remote file FILE.
@@ -3894,7 +3897,7 @@
 	  (ange-ftp-add-file-entry newname)
 	  (ange-ftp-delete-file-entry filename))
       (ange-ftp-copy-file-internal filename newname t nil)
-      (delete-file filename))))
+      (delete-file filename 'force))))
 
 (defun ange-ftp-rename-local-to-remote (filename newname)
   "Rename local file FILENAME to remote file NEWNAME."
@@ -3903,7 +3906,7 @@
 	 (msg (format "Renaming %s to %s" fabbr nabbr)))
     (ange-ftp-copy-file-internal filename newname t nil msg)
     (let (ange-ftp-process-verbose)
-      (delete-file filename))))
+      (delete-file filename 'force))))
 
 (defun ange-ftp-rename-remote-to-local (filename newname)
   "Rename remote file FILENAME to local file NEWNAME."
@@ -3912,7 +3915,7 @@
 	 (msg (format "Renaming %s to %s" fabbr nabbr)))
     (ange-ftp-copy-file-internal filename newname t nil msg)
     (let (ange-ftp-process-verbose)
-      (delete-file filename))))
+      (delete-file filename 'force))))
 
 (defun ange-ftp-rename-file (filename newname &optional ok-if-already-exists)
   (interactive "fRename file: \nFRename %s to file: \np")
@@ -4193,7 +4196,7 @@
 	(if copy
 	    (unwind-protect
 		(funcall 'load copy noerror nomessage nosuffix)
-	      (delete-file copy))
+	      (delete-file copy 'force))
 	  (or noerror
 	      (signal 'file-error (list "Cannot open load file" file)))
 	  nil))
@@ -4264,7 +4267,7 @@
 	  (if (zerop (buffer-size))
 	      (progn
 		(let (ange-ftp-process-verbose)
-		  (delete-file file))
+		  (delete-file file 'force))
 		(ange-ftp-copy-file-internal tmp2 nfile t nil msg2))))
       (ange-ftp-del-tmp-name tmp1)
       (ange-ftp-del-tmp-name tmp2))))
@@ -4300,7 +4303,7 @@
 	  (if (zerop (buffer-size))
 	      (progn
 		(let (ange-ftp-process-verbose)
-		  (delete-file file))
+		  (delete-file file 'force))
 		(ange-ftp-copy-file-internal tmp2 nfile t nil msg2))))
       (ange-ftp-del-tmp-name tmp1)
       (ange-ftp-del-tmp-name tmp2))))
--- a/lisp/net/browse-url.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/browse-url.el	Thu May 06 09:50:39 2010 +0900
@@ -313,8 +313,11 @@
   :type '(repeat (string :tag "Argument"))
   :group 'browse-url)
 
-;;;###autoload
-(defcustom browse-url-firefox-program (purecopy "firefox")
+(defcustom browse-url-firefox-program
+  (let ((candidates '("firefox" "iceweasel")))
+    (while (and candidates (not (executable-find (car candidates))))
+      (setq candidates (cdr candidates)))
+    (or (car candidates) "firefox"))
   "The name by which to invoke Firefox."
   :type 'string
   :group 'browse-url)
@@ -331,8 +334,7 @@
   :type '(repeat (string :tag "Argument"))
   :group 'browse-url)
 
-;;;###autoload
-(defcustom browse-url-galeon-program (purecopy "galeon")
+(defcustom browse-url-galeon-program "galeon"
   "The name by which to invoke Galeon."
   :type 'string
   :group 'browse-url)
--- a/lisp/net/rlogin.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/rlogin.el	Thu May 06 09:50:39 2010 +0900
@@ -249,7 +249,7 @@
 ``\\[universal-argument] 1 M-x rlogin-directory-tracking-mode\'',
 then do directory tracking but assume the remote filesystem is the same as
 the local system.  This only works in general if the remote machine and the
-local one share the same directories (through NFS)."
+local one share the same directories (e.g. through NFS)."
   (interactive "P")
   (cond
    ((or (null prefix)
--- a/lisp/net/tramp-compat.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-compat.el	Thu May 06 09:50:39 2010 +0900
@@ -317,6 +317,17 @@
 	(if keep-time
 	    (set-file-times newname (nth 5 (file-attributes directory))))))))
 
+;; FORCE has been introduced with Emacs 24.1.
+(defun tramp-compat-delete-file (filename &optional force)
+  "Like `delete-file' for Tramp files (compat function)."
+  (condition-case nil
+      (funcall (symbol-function 'delete-file) filename force)
+    ;; This Emacs version does not support the FORCE flag.  Setting
+    ;; `delete-by-moving-to-trash' shall give us the same effect.
+    (error
+     (let ((delete-by-moving-to-trash (null force)))
+       (delete-file filename)))))
+
 ;; RECURSIVE has been introduced with Emacs 23.2.
 (defun tramp-compat-delete-directory (directory &optional recursive)
   "Like `delete-directory' for Tramp files (compat function)."
--- a/lisp/net/tramp-fish.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-fish.el	Thu May 06 09:50:39 2010 +0900
@@ -332,7 +332,7 @@
       (tramp-flush-directory-property v localname)
       (tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
 
-(defun tramp-fish-handle-delete-file (filename)
+(defun tramp-fish-handle-delete-file (filename &optional force)
   "Like `delete-file' for Tramp files."
   (when (file-exists-p filename)
     (with-parsed-tramp-file-name (expand-file-name filename) nil
@@ -658,7 +658,7 @@
 			  localname)))))
 	  (tramp-error
 	   v 'file-already-exists "File %s already exists" localname)
-	(delete-file linkname)))
+	(tramp-compat-delete-file linkname 'force)))
 
     ;; If FILENAME is a Tramp name, use just the localname component.
     (when (tramp-tramp-file-p filename)
@@ -837,8 +837,8 @@
       ;; Provide error file.
       (when tmpstderr (rename-file tmpstderr (cadr destination) t))
       ;; Cleanup.
-      (when tmpinput (delete-file tmpinput))
-      (when tmpoutput (delete-file tmpoutput))
+      (when tmpinput (tramp-compat-delete-file tmpinput 'force))
+      (when tmpoutput (tramp-compat-delete-file tmpoutput 'force))
       ;; Return exit status.
       ret)))
 
--- a/lisp/net/tramp-ftp.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-ftp.el	Thu May 06 09:50:39 2010 +0900
@@ -1,7 +1,7 @@
 ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
@@ -182,7 +182,7 @@
 	  (unwind-protect
 	      (rename-file tmpfile newname (car args))
 	    ;; Cleanup.
-	    (ignore-errors (delete-file tmpfile)))))
+	    (ignore-errors (tramp-compat-delete-file tmpfile 'force)))))
 
        ;; Normally, the handlers must be discarded.
        ;; `inhibit-file-name-handlers' isn't sufficient, because the
--- a/lisp/net/tramp-gvfs.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-gvfs.el	Thu May 06 09:50:39 2010 +0900
@@ -533,9 +533,9 @@
   (tramp-compat-delete-directory
    (tramp-gvfs-fuse-file-name directory) recursive))
 
-(defun tramp-gvfs-handle-delete-file (filename)
+(defun tramp-gvfs-handle-delete-file (filename &optional force)
   "Like `delete-file' for Tramp files."
-  (delete-file (tramp-gvfs-fuse-file-name filename)))
+  (tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) force))
 
 (defun tramp-gvfs-handle-directory-files
   (directory &optional full match nosort)
@@ -741,7 +741,7 @@
 		   "gvfs-save" tmpfile (tramp-get-buffer v) nil
 		   (tramp-gvfs-url-file-name filename)))
 	       (signal (car err) (cdr err)))
-	   (delete-file tmpfile)))))
+	   (tramp-compat-delete-file tmpfile 'force)))))
 
     ;; Set file modification time.
     (when (or (eq visit t) (stringp visit))
--- a/lisp/net/tramp-imap.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-imap.el	Thu May 06 09:50:39 2010 +0900
@@ -268,7 +268,7 @@
       (tramp-message v 0 "Transferring %s to %s...done" filename newname))
 
     (when (eq op 'rename)
-      (delete-file filename))))
+      (tramp-compat-delete-file filename 'force))))
 
 ;; TODO: revise this much
 (defun tramp-imap-handle-expand-file-name (name &optional dir)
@@ -553,7 +553,7 @@
   ;; (file-exists-p (file-name-directory filename)))
   (file-directory-p (file-name-directory filename)))
 
-(defun tramp-imap-handle-delete-file (filename)
+(defun tramp-imap-handle-delete-file (filename &optional force)
   "Like `delete-file' for Tramp files."
   (cond
    ((not (file-exists-p filename)) nil)
--- a/lisp/net/tramp-smb.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp-smb.el	Thu May 06 09:50:39 2010 +0900
@@ -342,7 +342,7 @@
 	(condition-case err
 	    (rename-file tmpfile newname ok-if-already-exists)
 	  ((error quit)
-	   (delete-file tmpfile)
+	   (tramp-compat-delete-file tmpfile 'force)
 	   (signal (car err) (cdr err))))
 
       ;; Remote newname.
@@ -404,7 +404,7 @@
 	  (tramp-error
 	   v 'file-error "%s `%s'" (match-string 0) directory))))))
 
-(defun tramp-smb-handle-delete-file (filename)
+(defun tramp-smb-handle-delete-file (filename &optional force)
   "Like `delete-file' for Tramp files."
   (setq filename (expand-file-name filename))
   (when (file-exists-p filename)
@@ -611,7 +611,7 @@
 	  (tramp-message
 	   v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
 	;; Oops, an error.  We shall cleanup.
-	(delete-file tmpfile)
+	(tramp-compat-delete-file tmpfile 'force)
 	(tramp-error
 	 v 'file-error "Cannot make local copy of file `%s'" filename))
       tmpfile)))
@@ -858,7 +858,7 @@
 	(condition-case err
 	    (rename-file tmpfile newname ok-if-already-exists)
 	  ((error quit)
-	   (delete-file tmpfile)
+	   (tramp-compat-delete-file tmpfile 'force)
 	   (signal (car err) (cdr err))))
 
       ;; Remote newname.
@@ -881,7 +881,7 @@
 	     v 0 "Copying file %s to file %s...done" filename newname)
 	  (tramp-error v 'file-error "Cannot rename `%s'" filename)))))
 
-  (delete-file filename))
+  (tramp-compat-delete-file filename 'force))
 
 (defun tramp-smb-handle-set-file-modes (filename mode)
   "Like `set-file-modes' for Tramp files."
@@ -945,7 +945,7 @@
 	      (tramp-message
 	       v 5 "Writing tmp file %s to file %s...done" tmpfile filename)
 	    (tramp-error v 'file-error "Cannot write `%s'" filename))
-	(delete-file tmpfile))
+	(tramp-compat-delete-file tmpfile 'force))
 
       (unless (equal curbuf (current-buffer))
 	(tramp-error
--- a/lisp/net/tramp.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/net/tramp.el	Thu May 06 09:50:39 2010 +0900
@@ -285,10 +285,19 @@
   :group 'tramp
   :type 'string)
 
+(defcustom tramp-inline-compress-start-size 4096
+  "*The minimum size of compressing where inline transfer.
+When inline transfer, compress transfered data of file
+whose size is this value or above (up to `tramp-copy-size-limit').
+If it is nil, no compression at all will be applied."
+  :group 'tramp
+  :type '(choice (const nil) integer))
+
 (defcustom tramp-copy-size-limit 10240
-  "*The maximum file size where inline copying is preferred over an out-of-the-band copy."
+  "*The maximum file size where inline copying is preferred over an out-of-the-band copy.
+If it is nil, inline out-of-the-band copy will be used without a check."
   :group 'tramp
-  :type 'integer)
+  :type '(choice (const nil) integer))
 
 (defcustom tramp-terminal-type "dumb"
   "*Value of TERM environment variable for logging in to remote host.
@@ -323,7 +332,7 @@
 	     (tramp-copy-recursive       t)
 	     (tramp-password-end-of-line nil))
     ("scp"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -338,7 +347,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-1" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -353,7 +362,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-2" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -438,7 +447,7 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("ssh"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -451,7 +460,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-1" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -464,7 +473,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-2" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -526,7 +535,7 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("scpc"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
 					  ("-e" "none")))
@@ -543,7 +552,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scpx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -556,7 +565,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("sshx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -2502,7 +2511,7 @@
 			    l-localname)))))
 	    (tramp-error
 	     l 'file-already-exists "File %s already exists" l-localname)
-	  (delete-file linkname)))
+	  (tramp-compat-delete-file linkname 'force)))
 
       ;; If FILENAME is a Tramp name, use just the localname component.
       (when (tramp-tramp-file-p filename)
@@ -2550,7 +2559,7 @@
 	;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
 	(unwind-protect
 	    (load local-copy noerror t t)
-	  (delete-file local-copy)))
+	  (tramp-compat-delete-file local-copy 'force)))
       (unless nomessage (tramp-message v 0 "Loading %s...done" file))
       t)))
 
@@ -3030,6 +3039,17 @@
 	 "chown" nil nil nil
          (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
 
+(defun tramp-remote-selinux-p (vec)
+  "Check, whether SELINUX is enabled on the remote host."
+  (with-connection-property (tramp-get-connection-process vec) "selinux-p"
+    (let ((result (tramp-find-executable
+		   vec "getenforce" (tramp-get-remote-path vec) t t)))
+      (and result
+	   (string-equal
+	    (tramp-send-command-and-read
+	     vec (format "echo \\\"`%S`\\\"" result))
+	    "Enforcing")))))
+
 (defun tramp-handle-file-selinux-context (filename)
   "Like `file-selinux-context' for Tramp files."
   (with-parsed-tramp-file-name filename nil
@@ -3037,11 +3057,12 @@
       (let ((context '(nil nil nil nil))
 	    (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
 			    "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)")))
-	(when (zerop (tramp-send-command-and-check
-		      v (format
-			 "%s -d -Z %s"
-			 (tramp-get-ls-command v)
-			 (tramp-shell-quote-argument localname))))
+	(when (and (tramp-remote-selinux-p v)
+		   (zerop (tramp-send-command-and-check
+			   v (format
+			      "%s -d -Z %s"
+			      (tramp-get-ls-command v)
+			      (tramp-shell-quote-argument localname)))))
 	  (with-current-buffer (tramp-get-connection-buffer v)
 	    (goto-char (point-min))
 	    (when (re-search-forward regexp (tramp-compat-line-end-position) t)
@@ -3054,6 +3075,7 @@
   "Like `set-file-selinux-context' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (if (and (consp context)
+	     (tramp-remote-selinux-p v)
 	     (zerop (tramp-send-command-and-check
 		     v (format "chcon %s %s %s %s %s"
 			       (if (stringp (nth 0 context))
@@ -3715,7 +3737,7 @@
   ;; Set the mode.
   (set-file-modes newname (tramp-default-file-modes filename))
   ;; If the operation was `rename', delete the original file.
-  (unless (eq op 'copy) (delete-file filename)))
+  (unless (eq op 'copy) (tramp-compat-delete-file filename 'force)))
 
 (defun tramp-do-copy-or-rename-file-directly
  (op filename newname ok-if-already-exists keep-date preserve-uid-gid)
@@ -3870,7 +3892,7 @@
 
 		;; Save exit.
 		(condition-case nil
-		    (delete-file tmpfile)
+		    (tramp-compat-delete-file tmpfile 'force)
 		  (error)))))))))
 
       ;; Set the time and mode. Mask possible errors.
@@ -3910,7 +3932,7 @@
 		  (if dir-flag
 		      (tramp-compat-delete-directory
 		       (expand-file-name ".." tmpfile) 'recursive)
-		    (delete-file tmpfile))
+		    (tramp-compat-delete-file tmpfile 'force))
 		(error))))
 
 	;; Expand hops.  Might be necessary for gateway methods.
@@ -4028,7 +4050,7 @@
       ;; If the operation was `rename', delete the original file.
       (unless (eq op 'copy)
 	(if (file-regular-p filename)
-	    (delete-file filename)
+	    (tramp-compat-delete-file filename 'force)
 	  (tramp-compat-delete-directory filename 'recursive))))))
 
 (defun tramp-handle-make-directory (dir &optional parents)
@@ -4058,7 +4080,7 @@
 		     (tramp-shell-quote-argument localname))))
       (tramp-error v 'file-error "Couldn't delete %s" directory))))
 
-(defun tramp-handle-delete-file (filename)
+(defun tramp-handle-delete-file (filename &optional force)
   "Like `delete-file' for Tramp files."
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
@@ -4577,7 +4599,7 @@
 
       ;; Cleanup.  We remove all file cache values for the connection,
       ;; because the remote process could have changed them.
-      (when tmpinput (delete-file tmpinput))
+      (when tmpinput (tramp-compat-delete-file tmpinput 'force))
 
       ;; `process-file-side-effects' has been introduced with GNU
       ;; Emacs 23.2.  If set to `nil', no remote file will be changed
@@ -4614,7 +4636,7 @@
     (when delete (delete-region start end))
     (unwind-protect
 	(apply 'call-process program tmpfile buffer display args)
-      (delete-file tmpfile))))
+      (tramp-compat-delete-file tmpfile 'force))))
 
 (defun tramp-handle-shell-command
   (command &optional output-buffer error-buffer)
@@ -4679,7 +4701,7 @@
 	(when (listp buffer)
 	  (with-current-buffer error-buffer
 	    (insert-file-contents (cadr buffer)))
-	  (delete-file (cadr buffer)))
+	  (tramp-compat-delete-file (cadr buffer) 'force))
 	(if current-buffer-p
 	    ;; This is like exchange-point-and-mark, but doesn't
 	    ;; activate the mark.  It is cleaner to avoid activation,
@@ -4709,16 +4731,16 @@
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
 
-    (let ((rem-enc (tramp-get-remote-coding v "remote-encoding"))
-	  (loc-dec (tramp-get-local-coding v "local-decoding"))
-	  (tmpfile (tramp-compat-make-temp-file filename)))
+    (let* ((size (nth 7 (file-attributes filename)))
+	   (rem-enc (tramp-get-inline-coding v "remote-encoding" size))
+	   (loc-dec (tramp-get-inline-coding v "local-decoding" size))
+	   (tmpfile (tramp-compat-make-temp-file filename)))
 
       (condition-case err
 	  (cond
 	   ;; `copy-file' handles direct copy and out-of-band methods.
 	   ((or (tramp-local-host-p v)
-		(tramp-method-out-of-band-p
-		 v (nth 7 (file-attributes filename))))
+		(tramp-method-out-of-band-p v size))
 	    (copy-file filename tmpfile t t))
 
 	   ;; Use inline encoding for file transfer.
@@ -4726,12 +4748,11 @@
 	    (save-excursion
 	      (tramp-message v 5 "Encoding remote file %s..." filename)
 	      (tramp-barf-unless-okay
-	       v
-	       (format "%s < %s" rem-enc (tramp-shell-quote-argument localname))
+	       v (format rem-enc (tramp-shell-quote-argument localname))
 	       "Encoding remote file failed")
 	      (tramp-message v 5 "Encoding remote file %s...done" filename)
 
-	      (if (and (symbolp loc-dec) (fboundp loc-dec))
+	      (if (functionp loc-dec)
 		  ;; If local decoding is a function, we call it.  We
 		  ;; must disable multibyte, because
 		  ;; `uudecode-decode-region' doesn't handle it
@@ -4762,7 +4783,7 @@
 		   filename loc-dec)
 		  (unwind-protect
 		      (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile)
-		    (delete-file tmpfile2))))
+		    (tramp-compat-delete-file tmpfile2 'force))))
 
 	      (tramp-message v 5 "Decoding remote file %s...done" filename)
 	      ;; Set proper permissions.
@@ -4776,7 +4797,7 @@
 
 	;; Error handling.
 	((error quit)
-	 (delete-file tmpfile)
+	 (tramp-compat-delete-file tmpfile 'force)
 	 (signal (car err) (cdr err))))
 
       (run-hooks 'tramp-handle-file-local-copy-hook)
@@ -4922,10 +4943,11 @@
 	    (set-buffer-modified-p nil))
 	  (when (and (stringp local-copy)
 		     (or remote-copy (null tramp-temp-buffer-file-name)))
-	    (delete-file local-copy))
+	    (tramp-compat-delete-file local-copy 'force))
 	  (when (stringp remote-copy)
-	    (delete-file
-	     (tramp-make-tramp-file-name method user host remote-copy))))))
+	    (tramp-compat-delete-file
+	     (tramp-make-tramp-file-name method user host remote-copy)
+	     'force)))))
 
     ;; Result.
     (list (expand-file-name filename)
@@ -5080,12 +5102,10 @@
 	   'write-region
 	   (list start end localname append 'no-message lockname confirm))
 
-	(let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
-	      (loc-enc (tramp-get-local-coding v "local-encoding"))
-	      (modes (save-excursion (tramp-default-file-modes filename)))
+	(let ((modes (save-excursion (tramp-default-file-modes filename)))
 	      ;; We use this to save the value of
-	      ;; `last-coding-system-used' after writing the tmp file.
-	      ;; At the end of the function, we set
+	      ;; `last-coding-system-used' after writing the tmp
+	      ;; file.  At the end of the function, we set
 	      ;; `last-coding-system-used' to this saved value.  This
 	      ;; way, any intermediary coding systems used while
 	      ;; talking to the remote shell or suchlike won't hose
@@ -5108,7 +5128,8 @@
 	  ;; file.  We call `set-visited-file-modtime' ourselves later
 	  ;; on.  We must ensure that `file-coding-system-alist'
 	  ;; matches `tmpfile'.
-	  (let ((file-coding-system-alist
+	  (let (file-name-handler-alist
+		(file-coding-system-alist
 		 (tramp-find-file-name-coding-system-alist filename tmpfile)))
 	    (condition-case err
 		(tramp-run-real-handler
@@ -5116,7 +5137,7 @@
 		 (list start end tmpfile append 'no-message lockname confirm))
 	      ((error quit)
 	       (setq tramp-temp-buffer-file-name nil)
-	       (delete-file tmpfile)
+	       (tramp-compat-delete-file tmpfile 'force)
 	       (signal (car err) (cdr err))))
 
 	    ;; Now, `last-coding-system-used' has the right value.  Remember it.
@@ -5140,124 +5161,125 @@
 	  ;; specified.  However, if the method _also_ specifies an
 	  ;; encoding function, then that is used for encoding the
 	  ;; contents of the tmp file.
-	  (cond
-	   ;; `copy-file' handles direct copy and out-of-band methods.
-	   ((or (tramp-local-host-p v)
-		(tramp-method-out-of-band-p
-		 v (nth 7 (file-attributes tmpfile))))
-	    (if (and (not (stringp start))
-		     (= (or end (point-max)) (point-max))
-		     (= (or start (point-min)) (point-min))
-		     (tramp-get-method-parameter
-		      method 'tramp-copy-keep-tmpfile))
-		(progn
-		  (setq tramp-temp-buffer-file-name tmpfile)
-		  (condition-case err
-		      ;; We keep the local file for performance
-		      ;; reasons, useful for "rsync".
-		      (copy-file tmpfile filename t)
-		    ((error quit)
-		     (setq tramp-temp-buffer-file-name nil)
-		     (delete-file tmpfile)
-		     (signal (car err) (cdr err)))))
-	      (setq tramp-temp-buffer-file-name nil)
-	      ;; Don't rename, in order to keep context in SELinux.
+	  (let* ((size (nth 7 (file-attributes tmpfile)))
+		 (rem-dec (tramp-get-inline-coding v "remote-decoding" size))
+		 (loc-enc (tramp-get-inline-coding v "local-encoding" size)))
+	    (cond
+	     ;; `copy-file' handles direct copy and out-of-band methods.
+	     ((or (tramp-local-host-p v)
+		  (tramp-method-out-of-band-p v size))
+	      (if (and (not (stringp start))
+		       (= (or end (point-max)) (point-max))
+		       (= (or start (point-min)) (point-min))
+		       (tramp-get-method-parameter
+			method 'tramp-copy-keep-tmpfile))
+		  (progn
+		    (setq tramp-temp-buffer-file-name tmpfile)
+		    (condition-case err
+			;; We keep the local file for performance
+			;; reasons, useful for "rsync".
+			(copy-file tmpfile filename t)
+		      ((error quit)
+		       (setq tramp-temp-buffer-file-name nil)
+		       (tramp-compat-delete-file tmpfile 'force)
+		       (signal (car err) (cdr err)))))
+		(setq tramp-temp-buffer-file-name nil)
+		;; Don't rename, in order to keep context in SELinux.
+		(unwind-protect
+		    (copy-file tmpfile filename t)
+		  (tramp-compat-delete-file tmpfile 'force))))
+
+	     ;; Use inline file transfer.
+	     (rem-dec
+	      ;; Encode tmpfile.
+	      (tramp-message v 5 "Encoding region...")
 	      (unwind-protect
-		  (copy-file tmpfile filename t)
-		(delete-file tmpfile))))
-
-	   ;; Use inline file transfer.
-	   (rem-dec
-	    ;; Encode tmpfile.
-	    (tramp-message v 5 "Encoding region...")
-	    (unwind-protect
-		(with-temp-buffer
-		  ;; Use encoding function or command.
-		  (if (and (symbolp loc-enc) (fboundp loc-enc))
-		      (progn
-			(tramp-message
-			 v 5 "Encoding region using function `%s'..."
-			 (symbol-name loc-enc))
-			(let ((coding-system-for-read 'binary))
-			  (insert-file-contents-literally tmpfile))
-			;; The following `let' is a workaround for the
-			;; base64.el that comes with pgnus-0.84.  If
-			;; both of the following conditions are
-			;; satisfied, it tries to write to a local
-			;; file in default-directory, but at this
-			;; point, default-directory is remote.
-			;; (`call-process-region' can't write to
-			;; remote files, it seems.)  The file in
-			;; question is a tmp file anyway.
-			(let ((default-directory
-				(tramp-compat-temporary-file-directory)))
-			  (funcall loc-enc (point-min) (point-max))))
-
-		    (tramp-message
-		     v 5 "Encoding region using command `%s'..." loc-enc)
-		    (unless (equal 0 (tramp-call-local-coding-command
+		  (with-temp-buffer
+		    (set-buffer-multibyte nil)
+		    ;; Use encoding function or command.
+		    (if (functionp loc-enc)
+			(progn
+			  (tramp-message
+			   v 5 "Encoding region using function `%s'..." loc-enc)
+			  (let ((coding-system-for-read 'binary))
+			    (insert-file-contents-literally tmpfile))
+			  ;; The following `let' is a workaround for the
+			  ;; base64.el that comes with pgnus-0.84.  If
+			  ;; both of the following conditions are
+			  ;; satisfied, it tries to write to a local
+			  ;; file in default-directory, but at this
+			  ;; point, default-directory is remote.
+			  ;; (`call-process-region' can't write to
+			  ;; remote files, it seems.)  The file in
+			  ;; question is a tmp file anyway.
+			  (let ((default-directory
+				  (tramp-compat-temporary-file-directory)))
+			    (funcall loc-enc (point-min) (point-max))))
+
+		      (tramp-message
+		       v 5 "Encoding region using command `%s'..." loc-enc)
+		      (unless (zerop (tramp-call-local-coding-command
 				      loc-enc tmpfile t))
-		      (tramp-error
-		       v 'file-error
-		       "Cannot write to `%s', local encoding command `%s' failed"
-		       filename loc-enc)))
-
-		  ;; Send buffer into remote decoding command which
-		  ;; writes to remote file.  Because this happens on
-		  ;; the remote host, we cannot use the function.
-		  (goto-char (point-max))
-		  (unless (bolp) (newline))
-		  (tramp-message
-		   v 5 "Decoding region into remote file %s..." filename)
-		  (tramp-send-command
-		   v
-		   (format
-		    "%s >%s <<'EOF'\n%sEOF"
-		    rem-dec
-		    (tramp-shell-quote-argument localname)
-		    (buffer-string)))
-		  (tramp-barf-unless-okay
-		   v nil
-		   "Couldn't write region to `%s', decode using `%s' failed"
-		   filename rem-dec)
-		  ;; When `file-precious-flag' is set, the region is
-		  ;; written to a temporary file.  Check that the
-		  ;; checksum is equal to that from the local tmpfile.
-		  (when file-precious-flag
-		    (erase-buffer)
-		    (and
-		     ;; cksum runs locally, if possible.
-		     (zerop (tramp-local-call-process "cksum" tmpfile t))
-		     ;; cksum runs remotely.
-		     (zerop
-		      (tramp-send-command-and-check
-		       v
-		       (format
-			"cksum <%s" (tramp-shell-quote-argument localname))))
-		     ;; ... they are different.
-		     (not
-		      (string-equal
-		       (buffer-string)
-		       (with-current-buffer (tramp-get-buffer v)
-			 (buffer-string))))
-		     (tramp-error
-		      v 'file-error
-		      (concat "Couldn't write region to `%s',"
-			      " decode using `%s' failed")
-		      filename rem-dec)))
-		  (tramp-message
-		   v 5 "Decoding region into remote file %s...done" filename))
-
-	      ;; Save exit.
-	      (delete-file tmpfile)))
-
-	   ;; That's not expected.
-	   (t
-	    (tramp-error
-	     v 'file-error
-	     (concat "Method `%s' should specify both encoding and "
-		     "decoding command or an rcp program")
-	     method)))
+			(tramp-error
+			 v 'file-error
+			 "Cannot write to `%s', local encoding command `%s' failed"
+			 filename loc-enc)))
+
+		    ;; Send buffer into remote decoding command which
+		    ;; writes to remote file.  Because this happens on
+		    ;; the remote host, we cannot use the function.
+		    (goto-char (point-max))
+		    (unless (bolp) (newline))
+		    (tramp-message
+		     v 5 "Decoding region into remote file %s..." filename)
+		    (tramp-send-command
+		     v
+		     (format
+		      (concat rem-dec " <<'EOF'\n%sEOF")
+		      (tramp-shell-quote-argument localname)
+		      (buffer-string)))
+		    (tramp-barf-unless-okay
+		     v nil
+		     "Couldn't write region to `%s', decode using `%s' failed"
+		     filename rem-dec)
+		    ;; When `file-precious-flag' is set, the region is
+		    ;; written to a temporary file.  Check that the
+		    ;; checksum is equal to that from the local tmpfile.
+		    (when file-precious-flag
+		      (erase-buffer)
+		      (and
+		       ;; cksum runs locally, if possible.
+		       (zerop (tramp-local-call-process "cksum" tmpfile t))
+		       ;; cksum runs remotely.
+		       (zerop
+			(tramp-send-command-and-check
+			 v
+			 (format
+			  "cksum <%s" (tramp-shell-quote-argument localname))))
+		       ;; ... they are different.
+		       (not
+			(string-equal
+			 (buffer-string)
+			 (with-current-buffer (tramp-get-buffer v)
+			   (buffer-string))))
+		       (tramp-error
+			v 'file-error
+			(concat "Couldn't write region to `%s',"
+				" decode using `%s' failed")
+			filename rem-dec)))
+		    (tramp-message
+		     v 5 "Decoding region into remote file %s...done" filename))
+
+		;; Save exit.
+		(tramp-compat-delete-file tmpfile 'force)))
+
+	     ;; That's not expected.
+	     (t
+	      (tramp-error
+	       v 'file-error
+	       (concat "Method `%s' should specify both encoding and "
+		       "decoding command or an rcp program")
+	       method))))
 
 	  ;; Make `last-coding-system-used' have the right value.
 	  (when coding-system-used
@@ -6329,7 +6351,7 @@
   "Remove temporary files related to current buffer."
   (when (stringp tramp-temp-buffer-file-name)
     (condition-case nil
-	(delete-file tramp-temp-buffer-file-name)
+	(tramp-compat-delete-file tramp-temp-buffer-file-name 'force)
       (error nil))))
 
 (add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
@@ -6924,7 +6946,7 @@
 	  (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
     (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
       (with-current-buffer (tramp-get-debug-buffer vec)
-	;; Keep the debug buffer
+	;; Keep the debug buffer.
 	(rename-buffer
 	 (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
 	(funcall (symbol-function 'tramp-cleanup-connection) vec)
@@ -7187,6 +7209,64 @@
     (if (string-match "%s" cmd) (format cmd input) cmd)
     (if (stringp output) (concat "> " output) ""))))
 
+(defconst tramp-inline-compress-commands
+  '(("gzip" "gzip -d")
+    ("bzip2" "bzip2 -d")
+    ("compress" "compress -d"))
+  "List of compress and decompress commands for inline transfer.
+Each item is a list that looks like this:
+
+\(COMPRESS DECOMPRESS\)
+
+COMPRESS or DECOMPRESS are strings with the respective commands.")
+
+(defun tramp-find-inline-compress (vec)
+  "Find an inline transfer compress command that works.
+Goes through the list `tramp-inline-compress-commands'."
+  (save-excursion
+    (let ((commands tramp-inline-compress-commands)
+	  (magic "xyzzy")
+	  item compress decompress
+	  found)
+      (while (and commands (not found))
+	(catch 'next
+	  (setq item (pop commands)
+		compress (nth 0 item)
+		decompress (nth 1 item))
+	  (tramp-message
+	   vec 5
+	   "Checking local compress command `%s', `%s' for sanity"
+	   compress decompress)
+	  (unless (zerop (tramp-call-local-coding-command
+			  (format "echo %s | %s | %s"
+				  magic compress decompress) nil nil))
+	    (throw 'next nil))
+	  (tramp-message
+	   vec 5
+	   "Checking remote compress command `%s', `%s' for sanity"
+	   compress decompress)
+	  (unless (zerop (tramp-send-command-and-check
+			  vec (format "echo %s | %s | %s"
+				      magic compress decompress) t))
+	    (throw 'next nil))
+	  (setq found t)))
+
+      ;; Did we find something?
+      (if found
+	  (progn
+	    ;; Set connection properties.
+	    (tramp-message
+	     vec 5 "Using inline transfer compress command `%s'" compress)
+	    (tramp-set-connection-property vec "inline-compress" compress)
+	    (tramp-message
+	     vec 5 "Using inline transfer decompress command `%s'" decompress)
+	    (tramp-set-connection-property vec "inline-decompress" decompress))
+
+	(tramp-set-connection-property vec "inline-compress" nil)
+	(tramp-set-connection-property vec "inline-decompress" nil)
+	(tramp-message
+	 vec 2 "Couldn't find an inline transfer compress command")))))
+
 (defun tramp-compute-multi-hops (vec)
   "Expands VEC according to `tramp-default-proxies-alist'.
 Gateway hops are already opened."
@@ -8066,8 +8146,9 @@
    (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)
    ;; Either the file size is large enough, or (in rare cases) there
    ;; does not exist a remote encoding.
-   (or (> size tramp-copy-size-limit)
-       (null (tramp-get-remote-coding vec "remote-encoding")))))
+   (or (null tramp-copy-size-limit)
+       (> size tramp-copy-size-limit)
+       (null (tramp-get-inline-coding vec "remote-encoding" size)))))
 
 (defun tramp-local-host-p (vec)
   "Return t if this points to the local host, nil otherwise."
@@ -8348,31 +8429,82 @@
   (nth 3 (tramp-compat-file-attributes "~/" id-format)))
 
 ;; Some predefined connection properties.
-(defun tramp-get-remote-coding (vec prop)
-  ;; Local coding handles properties like remote coding.  So we could
-  ;; call it without pain.
-  (let ((ret (tramp-get-local-coding vec prop)))
+(defun tramp-get-inline-compress (vec prop size)
+  "Return the compress command related to PROP.
+PROP is either `inline-compress' or `inline-decompress'. SIZE is
+the length of the file to be compressed.
+
+If no corresponding command is found, nil is returned."
+  (when (and (integerp tramp-inline-compress-start-size)
+	     (> size tramp-inline-compress-start-size))
+    (with-connection-property vec prop
+      (tramp-find-inline-compress vec)
+      (tramp-get-connection-property vec prop nil))))
+
+(defun tramp-get-inline-coding (vec prop size)
+  "Return the coding command related to PROP.
+PROP is either `remote-encoding', `remode-decoding',
+`local-encoding' or `local-decoding'.
+
+SIZE is the length of the file to be coded.  Depending on SIZE,
+compression might be applied.
+
+If no corresponding command is found, nil is returned.
+Otherwise, either a string is returned which contains a `%s' mark
+to be used for the respective input or output file; or a Lisp
+function cell is returned to be applied on a buffer."
+  (let ((coding
+	 (with-connection-property vec prop
+	   (tramp-find-inline-encoding vec)
+	   (tramp-get-connection-property vec prop nil)))
+	(prop1 (if (string-match "encoding" prop)
+		   "inline-compress" "inline-decompress"))
+	compress)
     ;; The connection property might have been cached.  So we must send
-    ;; the script - maybe.
-    (when (and ret (symbolp ret))
-      (let ((name (symbol-name ret)))
+    ;; the script to the remote side - maybe.
+    (when (and coding (symbolp coding) (string-match "remote" prop))
+      (let ((name (symbol-name coding)))
 	(while (string-match (regexp-quote "-") name)
 	  (setq name (replace-match "_" nil t name)))
-	(tramp-maybe-send-script vec (symbol-value ret) name)
-	(setq ret name)))
-    ;; Return the value.
-    ret))
-
-(defun tramp-get-local-coding (vec prop)
-  (or
-   (tramp-get-connection-property vec prop nil)
-   (progn
-     (tramp-find-inline-encoding vec)
-     (tramp-get-connection-property vec prop nil))))
+	(tramp-maybe-send-script vec (symbol-value coding) name)
+	(setq coding name)))
+    (when coding
+      ;; Check for the `compress' command.
+      (setq compress (tramp-get-inline-compress vec prop1 size))
+      ;; Return the value.
+      (cond
+       ((and compress (symbolp coding))
+	(if (string-match "decompress" prop1)
+	    `(lambda (beg end)
+	       (,coding beg end)
+	       (let ((coding-system-for-write 'binary)
+		     (coding-system-for-read 'binary))
+		 (apply
+		  'call-process-region (point-min) (point-max)
+		  (car (split-string ,compress)) t t nil
+		  (cdr (split-string ,compress)))))
+	  `(lambda (beg end)
+	     (let ((coding-system-for-write 'binary)
+		   (coding-system-for-read 'binary))
+	       (apply
+		'call-process-region beg end
+		(car (split-string ,compress)) t t nil
+		(cdr (split-string ,compress))))
+	     (,coding (point-min) (point-max)))))
+       ((symbolp coding)
+	coding)
+       ((and compress (string-match "decoding" prop))
+	(format "(%s | %s >%%s)" coding compress))
+       (compress
+	(format "(%s <%%s | %s)" compress coding))
+       ((string-match "decoding" prop)
+	(format "%s >%%s" coding))
+       (t
+	(format "%s <%%s" coding))))))
 
 (defun tramp-get-method-parameter (method param)
   "Return the method parameter PARAM.
-If the `tramp-methods' entry does not exist, return NIL."
+If the `tramp-methods' entry does not exist, return nil."
   (let ((entry (assoc param (assoc method tramp-methods))))
     (when entry (cadr entry))))
 
@@ -8752,7 +8884,6 @@
 ;;   on remote hosts.
 ;; * Use secrets.el for password handling.
 ;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'.
-;; * Implement selinux-context.
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el
--- a/lisp/org/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/org/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,8 +1,16 @@
+2010-05-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* org-table.el (orgtbl-setup):
+	* org-agenda.el (org-agenda-entry-text-mode): Simplify.
+
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* org-table.el (orgtbl-mode): Use define-minor-mode.
+
 2010-04-10  Carsten Dominik  <carsten.dominik@gmail.com>
 
-	* org.el (org-insert-link): Find the link buffer on visible
-	frames.
-	(org-export-latex-default-packages-alist): hyperref must be loaded
+	* org.el (org-insert-link): Find the link buffer on visible frames.
+	(org-export-latex-default-packages-alist): Hyperref must be loaded
 	late.
 	(org-open-file): More care with the new matching for file links.
 
@@ -106,8 +114,6 @@
 	(org-html-entities): Constant removed.
 	(org-export-visible): Add the new export commands.
 
-	* org-entities.el: New file.
-
 	* org-docbook.el (org-docbook-do-expand): Use new entity code.
 
 	* org-ascii.el (org-export-ascii-entities): New variable.
@@ -118,6 +124,11 @@
 	(org-ascii-replace-entities): New function.
 
 2010-04-10  Carsten Dominik  <carsten.dominik@gmail.com>
+	    Ulf Stegemann  <ulf@zeitform.de>
+
+	* org-entities.el: New file.
+
+2010-04-10  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-html.el (org-html-level-start): Catch the case that target
 	might be nil.
@@ -821,6 +832,10 @@
 	* org-latex.el (org-export-latex-treat-backslash-char): Do not by
 	accident protect a character that is before a backslash.
 
+2010-04-10  Paul Sexton  <eeeickythump@gmail.com>
+
+	* org-ctags.el: New file.
+
 2010-04-10  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-agenda.el (org-diary-class): Use
@@ -1099,9 +1114,7 @@
 	* org-exp.el (org-export-select-backend-specific-text): Add the
 	special beamer tags.
 
-	* org-beamer.el
-	(org-export-preprocess-before-selecting-backend-code-hook): New
-	file.
+	* org-beamer.el: New file.
 
 	* org-latex.el (org-export-latex-after-initial-vars-hook): New hook.
 	(org-export-as-latex): Run
--- a/lisp/org/org-agenda.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/org/org-agenda.el	Thu May 06 09:50:39 2010 +0900
@@ -5916,9 +5916,8 @@
 (defun org-agenda-entry-text-mode (&optional arg)
   "Toggle entry text mode in an agenda buffer."
   (interactive "P")
-  (if (integerp arg)
-      (setq org-agenda-entry-text-mode t)
-    (setq org-agenda-entry-text-mode (not org-agenda-entry-text-mode)))
+  (setq org-agenda-entry-text-mode (or (integerp arg)
+                                       (not org-agenda-entry-text-mode)))
   (org-agenda-entry-text-hide)
   (and org-agenda-entry-text-mode
        (let ((org-agenda-entry-text-maxlines
--- a/lisp/org/org-ctags.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/org/org-ctags.el	Thu May 06 09:50:39 2010 +0900
@@ -1,9 +1,9 @@
 ;;; org-ctags.el - Integrate Emacs "tags" facility with org mode.
-;;;
+;;
 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
-;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 1.0
+;; Author: Paul Sexton <eeeickythump@gmail.com>
+;; Version: 1.0
 
 ;; Keywords: org, wp
 ;; Version: 6.35i
@@ -23,116 +23,116 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-;;;
-;;; Synopsis
-;;; ========
-;;;
-;;; Allows org-mode to make use of the Emacs `etags' system. Defines tag
-;;; destinations in org-mode files as any text between <<double angled
-;;; brackets>>. This allows the tags-generation program `exuberant ctags' to
-;;; parse these files and create tag tables that record where these
-;;; destinations are found. Plain [[links]] in org mode files which do not have
-;;; <<matching destinations>> within the same file will then be interpreted as
-;;; links to these 'tagged' destinations, allowing seamless navigation between
-;;; multiple org-mode files. Topics can be created in any org mode file and
-;;; will always be found by plain links from other files. Other file types
-;;; recognised by ctags (source code files, latex files, etc) will also be
-;;; available as destinations for plain links, and similarly, org-mode links
-;;; will be available as tags from source files. Finally, the function
-;;; `org-ctags-find-tag-interactive' lets you choose any known tag, using
-;;; autocompletion, and quickly jump to it.
-;;;
-;;; Installation
-;;; ============
-;;;
-;;; Install org mode
-;;; Ensure org-ctags.el is somewhere in your emacs load path.
-;;; Download and install Exuberant ctags -- "http://ctags.sourceforge.net/"
-;;; Edit your .emacs file (see next section) and load emacs.
+;;
+;; Synopsis
+;; ========
+;;
+;; Allows org-mode to make use of the Emacs `etags' system. Defines tag
+;; destinations in org-mode files as any text between <<double angled
+;; brackets>>. This allows the tags-generation program `exuberant ctags' to
+;; parse these files and create tag tables that record where these
+;; destinations are found. Plain [[links]] in org mode files which do not have
+;; <<matching destinations>> within the same file will then be interpreted as
+;; links to these 'tagged' destinations, allowing seamless navigation between
+;; multiple org-mode files. Topics can be created in any org mode file and
+;; will always be found by plain links from other files. Other file types
+;; recognised by ctags (source code files, latex files, etc) will also be
+;; available as destinations for plain links, and similarly, org-mode links
+;; will be available as tags from source files. Finally, the function
+;; `org-ctags-find-tag-interactive' lets you choose any known tag, using
+;; autocompletion, and quickly jump to it.
+;;
+;; Installation
+;; ============
+;;
+;; Install org mode
+;; Ensure org-ctags.el is somewhere in your emacs load path.
+;; Download and install Exuberant ctags -- "http://ctags.sourceforge.net/"
+;; Edit your .emacs file (see next section) and load emacs.
 
-;;; To put in your init file (.emacs):
-;;; ==================================
-;;;
-;;; Assuming you already have org mode installed and set up:
-;;;
-;;;    (setq org-ctags-path-to-ctags "/path/to/ctags/executable")
-;;;    (add-hook 'org-mode-hook
-;;;      (lambda ()
-;;;        (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))
-;;;
-;;; By default, with org-ctags loaded, org will first try and visit the tag
-;;; with the same name as the link; then, if unsuccessful, ask the user if
-;;; he/she wants to rebuild the 'TAGS' database and try again; then ask if
-;;; the user wishes to append 'tag' as a new toplevel heading at the end of
-;;; the buffer; and finally, defer to org's default behaviour which is to
-;;; search the entire text of the current buffer for 'tag'.
-;;;
-;;; This behaviour can be modified by changing the value of
-;;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my
-;;; .emacs, which describes the same behaviour as the above paragraph with
-;;; one difference:
-;;;
-;;; (setq org-ctags-open-link-functions
-;;;       '(org-ctags-find-tag
-;;;         org-ctags-ask-rebuild-tags-file-then-find-tag
-;;;         org-ctags-ask-append-topic
-;;;         org-ctags-fail-silently))  ; <-- prevents org default behaviour
-;;;
-;;;
-;;; Usage
-;;; =====
-;;;
-;;; When you click on a link "[[foo]]" and org cannot find a matching "<<foo>>"
-;;; in the current buffer, the tags facility will take over. The file TAGS in
-;;; the active directory is examined to see if the tags facility knows about
-;;; "<<foo>>" in any other files. If it does, the matching file will be opened
-;;; and the cursor will jump to the position of "<<foo>>" in that file.
-;;;
-;;; User-visible functions:
-;;; - `org-ctags-find-tag-interactive': type a tag (plain link) name and visit
-;;;   it. With autocompletion. Bound to ctrl-O in the above setup.
-;;; - All the etags functions should work. These include:
-;;;
-;;;      M-.    `find-tag' -- finds the tag at point
-;;;
-;;;      C-M-.  find-tag based on regular expression
-;;;
-;;;      M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT
-;;;             of ALL the files referenced in the TAGS file. A quick way to
-;;;             search through an entire 'project'.
-;;;
-;;;      M-*    "go back" from a tag jump. Like `org-mark-ring-goto'.
-;;;             You may need to bind this key yourself with (eg)
-;;;             (global-set-key (kbd "<M-kp-multiply>") 'pop-tag-mark)
-;;;
-;;;      (see etags chapter in Emacs manual for more)
-;;;
-;;;
-;;; Keeping the TAGS file up to date
-;;; ================================
-;;;
-;;; Tags mode has no way of knowing that you have created new tags by typing in
-;;; your org-mode buffer.  New tags make it into the TAGS file in 3 ways:
-;;;
-;;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file.
-;;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in
-;;;    your `org-open-link-functions' list, as is done in the setup
-;;;    above. This will cause the TAGS file to be rebuilt whenever a link
-;;;    cannot be found. This may be slow with large file collections however.
-;;; 3. You run the following from the command line (all 1 line):
-;;;
-;;;      ctags --langdef=orgmode --langmap=orgmode:.org
-;;;        --regex-orgmode="/<<([^>]+)>>/\1/d,definition/"
-;;;          -f /your/path/TAGS -e -R /your/path/*.org
-;;;
-;;; If you are paranoid, you might want to run (org-ctags-create-tags
-;;; "/path/to/org/files") at startup, by including the following toplevel form
-;;; in .emacs. However this can cause a pause of several seconds if ctags has
-;;; to scan lots of files.
-;;;
-;;;     (progn
-;;;       (message "-- rebuilding tags tables...")
-;;;       (mapc 'org-create-tags tags-table-list))
+;; To put in your init file (.emacs):
+;; ==================================
+;;
+;; Assuming you already have org mode installed and set up:
+;;
+;;    (setq org-ctags-path-to-ctags "/path/to/ctags/executable")
+;;    (add-hook 'org-mode-hook
+;;      (lambda ()
+;;        (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))
+;;
+;; By default, with org-ctags loaded, org will first try and visit the tag
+;; with the same name as the link; then, if unsuccessful, ask the user if
+;; he/she wants to rebuild the 'TAGS' database and try again; then ask if
+;; the user wishes to append 'tag' as a new toplevel heading at the end of
+;; the buffer; and finally, defer to org's default behaviour which is to
+;; search the entire text of the current buffer for 'tag'.
+;;
+;; This behaviour can be modified by changing the value of
+;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my
+;; .emacs, which describes the same behaviour as the above paragraph with
+;; one difference:
+;;
+;; (setq org-ctags-open-link-functions
+;;       '(org-ctags-find-tag
+;;         org-ctags-ask-rebuild-tags-file-then-find-tag
+;;         org-ctags-ask-append-topic
+;;         org-ctags-fail-silently))  ; <-- prevents org default behaviour
+;;
+;;
+;; Usage
+;; =====
+;;
+;; When you click on a link "[[foo]]" and org cannot find a matching "<<foo>>"
+;; in the current buffer, the tags facility will take over. The file TAGS in
+;; the active directory is examined to see if the tags facility knows about
+;; "<<foo>>" in any other files. If it does, the matching file will be opened
+;; and the cursor will jump to the position of "<<foo>>" in that file.
+;;
+;; User-visible functions:
+;; - `org-ctags-find-tag-interactive': type a tag (plain link) name and visit
+;;   it. With autocompletion. Bound to ctrl-O in the above setup.
+;; - All the etags functions should work. These include:
+;;
+;;      M-.    `find-tag' -- finds the tag at point
+;;
+;;      C-M-.  find-tag based on regular expression
+;;
+;;      M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT
+;;             of ALL the files referenced in the TAGS file. A quick way to
+;;             search through an entire 'project'.
+;;
+;;      M-*    "go back" from a tag jump. Like `org-mark-ring-goto'.
+;;             You may need to bind this key yourself with (eg)
+;;             (global-set-key (kbd "<M-kp-multiply>") 'pop-tag-mark)
+;;
+;;      (see etags chapter in Emacs manual for more)
+;;
+;;
+;; Keeping the TAGS file up to date
+;; ================================
+;;
+;; Tags mode has no way of knowing that you have created new tags by typing in
+;; your org-mode buffer.  New tags make it into the TAGS file in 3 ways:
+;;
+;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file.
+;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in
+;;    your `org-open-link-functions' list, as is done in the setup
+;;    above. This will cause the TAGS file to be rebuilt whenever a link
+;;    cannot be found. This may be slow with large file collections however.
+;; 3. You run the following from the command line (all 1 line):
+;;
+;;      ctags --langdef=orgmode --langmap=orgmode:.org
+;;        --regex-orgmode="/<<([^>]+)>>/\1/d,definition/"
+;;          -f /your/path/TAGS -e -R /your/path/*.org
+;;
+;; If you are paranoid, you might want to run (org-ctags-create-tags
+;; "/path/to/org/files") at startup, by including the following toplevel form
+;; in .emacs. However this can cause a pause of several seconds if ctags has
+;; to scan lots of files.
+;;
+;;     (progn
+;;       (message "-- rebuilding tags tables...")
+;;       (mapc 'org-create-tags tags-table-list))
 
 (eval-when-compile (require 'cl))
 (require 'org)
@@ -219,7 +219,7 @@
 
 
 ;;; General utility functions. ===============================================
-;;; These work outside org-ctags mode.
+;; These work outside org-ctags mode.
 
 (defun org-ctags-get-filename-for-tag (tag)
   "TAG is a string. Search the active TAGS file for a matching tag,
@@ -535,5 +535,5 @@
 
 (provide 'org-ctags)
 
-;;; arch-tag: 4b1ddd5a-8529-4b17-bcde-96a922d26343
+;; arch-tag: 4b1ddd5a-8529-4b17-bcde-96a922d26343
 ;;; org-ctags.el ends here
--- a/lisp/org/org-table.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/org/org-table.el	Thu May 06 09:50:39 2010 +0900
@@ -3401,11 +3401,6 @@
 ;; active, this binding is ignored inside tables and replaced with a
 ;; modified self-insert.
 
-(defvar orgtbl-mode nil
-  "Variable controlling `orgtbl-mode', a minor mode enabling the `org-mode'
-table editor in arbitrary modes.")
-(make-variable-buffer-local 'orgtbl-mode)
-
 (defvar orgtbl-mode-map (make-keymap)
   "Keymap for `orgtbl-mode'.")
 
@@ -3426,49 +3421,51 @@
 	      0 (quote 'org-table) 'prepend))
   "Extra font-lock-keywords to be added when orgtbl-mode is active.")
 
+;; Install it as a minor mode.
+(put 'orgtbl-mode :included t)
+(put 'orgtbl-mode :menu-tag "Org Table Mode")
 ;;;###autoload
-(defun orgtbl-mode (&optional arg)
+(define-minor-mode orgtbl-mode
   "The `org-mode' table editor as a minor mode for use in other modes."
-  (interactive)
+  :lighter " OrgTbl" :keymap orgtbl-mode-map
   (org-load-modules-maybe)
-  (if (org-mode-p)
-      ;; Exit without error, in case some hook functions calls this
-      ;; by accident in org-mode.
-      (message "Orgtbl-mode is not useful in org-mode, command ignored")
-    (setq orgtbl-mode
-	  (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode)))
-    (if orgtbl-mode
-	(progn
-	  (and (orgtbl-setup) (defun orgtbl-setup () nil))
-	  ;; Make sure we are first in minor-mode-map-alist
-	  (let ((c (assq 'orgtbl-mode minor-mode-map-alist)))
-	    (and c (setq minor-mode-map-alist
-			 (cons c (delq c minor-mode-map-alist)))))
-	  (org-set-local (quote org-table-may-need-update) t)
-	  (org-add-hook 'before-change-functions 'org-before-change-function
-			nil 'local)
-	  (org-set-local 'org-old-auto-fill-inhibit-regexp
-			 auto-fill-inhibit-regexp)
-	  (org-set-local 'auto-fill-inhibit-regexp
-			 (if auto-fill-inhibit-regexp
-			     (concat orgtbl-line-start-regexp "\\|"
-				     auto-fill-inhibit-regexp)
-			   orgtbl-line-start-regexp))
-	  (org-add-to-invisibility-spec '(org-cwidth))
-	  (when (fboundp 'font-lock-add-keywords)
-	    (font-lock-add-keywords nil orgtbl-extra-font-lock-keywords)
-	    (org-restart-font-lock))
-	  (easy-menu-add orgtbl-mode-menu)
-	  (run-hooks 'orgtbl-mode-hook))
-      (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
-      (org-table-cleanup-narrow-column-properties)
-      (org-remove-from-invisibility-spec '(org-cwidth))
-      (remove-hook 'before-change-functions 'org-before-change-function t)
-      (when (fboundp 'font-lock-remove-keywords)
-	(font-lock-remove-keywords nil orgtbl-extra-font-lock-keywords)
-	(org-restart-font-lock))
-      (easy-menu-remove orgtbl-mode-menu)
-      (force-mode-line-update 'all))))
+  (cond
+   ((org-mode-p)
+    ;; Exit without error, in case some hook functions calls this
+    ;; by accident in org-mode.
+    (message "Orgtbl-mode is not useful in org-mode, command ignored"))
+   (orgtbl-mode
+    (and (orgtbl-setup) (defun orgtbl-setup () nil)) ;; FIXME: Yuck!?!
+    ;; Make sure we are first in minor-mode-map-alist
+    (let ((c (assq 'orgtbl-mode minor-mode-map-alist)))
+      ;; FIXME: maybe it should use emulation-mode-map-alists?
+      (and c (setq minor-mode-map-alist
+                   (cons c (delq c minor-mode-map-alist)))))
+    (org-set-local (quote org-table-may-need-update) t)
+    (org-add-hook 'before-change-functions 'org-before-change-function
+                  nil 'local)
+    (org-set-local 'org-old-auto-fill-inhibit-regexp
+                   auto-fill-inhibit-regexp)
+    (org-set-local 'auto-fill-inhibit-regexp
+                   (if auto-fill-inhibit-regexp
+                       (concat orgtbl-line-start-regexp "\\|"
+                               auto-fill-inhibit-regexp)
+                     orgtbl-line-start-regexp))
+    (org-add-to-invisibility-spec '(org-cwidth))
+    (when (fboundp 'font-lock-add-keywords)
+      (font-lock-add-keywords nil orgtbl-extra-font-lock-keywords)
+      (org-restart-font-lock))
+    (easy-menu-add orgtbl-mode-menu))
+   (t
+    (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
+    (org-table-cleanup-narrow-column-properties)
+    (org-remove-from-invisibility-spec '(org-cwidth))
+    (remove-hook 'before-change-functions 'org-before-change-function t)
+    (when (fboundp 'font-lock-remove-keywords)
+      (font-lock-remove-keywords nil orgtbl-extra-font-lock-keywords)
+      (org-restart-font-lock))
+    (easy-menu-remove orgtbl-mode-menu)
+    (force-mode-line-update 'all))))
 
 (defun org-table-cleanup-narrow-column-properties ()
   "Remove all properties related to narrow-column invisibility."
@@ -3483,11 +3480,6 @@
     (while (setq s (text-property-any s (point-max) 'invisible 'org-cwidth))
       (remove-text-properties s (1+ s) '(invisible t)))))
 
-;; Install it as a minor mode.
-(put 'orgtbl-mode :included t)
-(put 'orgtbl-mode :menu-tag "Org Table Mode")
-(add-minor-mode 'orgtbl-mode " OrgTbl" orgtbl-mode-map)
-
 (defun orgtbl-make-binding (fun n &rest keys)
   "Create a function for binding in the table minor mode.
 FUN is the command to call inside a table.  N is used to create a unique
@@ -3522,34 +3514,33 @@
   "Setup orgtbl keymaps."
   (let ((nfunc 0)
 	(bindings
-	 (list
-	  '([(meta shift left)]  org-table-delete-column)
-	  '([(meta left)]	 org-table-move-column-left)
-	  '([(meta right)]       org-table-move-column-right)
-	  '([(meta shift right)] org-table-insert-column)
-	  '([(meta shift up)]    org-table-kill-row)
-	  '([(meta shift down)]  org-table-insert-row)
-	  '([(meta up)]		 org-table-move-row-up)
-	  '([(meta down)]	 org-table-move-row-down)
-	  '("\C-c\C-w"		 org-table-cut-region)
-	  '("\C-c\M-w"		 org-table-copy-region)
-	  '("\C-c\C-y"		 org-table-paste-rectangle)
-	  '("\C-c-"		 org-table-insert-hline)
-	  '("\C-c}"		 org-table-toggle-coordinate-overlays)
-	  '("\C-c{"		 org-table-toggle-formula-debugger)
-	  '("\C-m"		 org-table-next-row)
-	  '([(shift return)]	 org-table-copy-down)
-	  '("\C-c?"		 org-table-field-info)
-	  '("\C-c "		 org-table-blank-field)
-	  '("\C-c+"		 org-table-sum)
-	  '("\C-c="		 org-table-eval-formula)
-	  '("\C-c'"		 org-table-edit-formulas)
-	  '("\C-c`"		 org-table-edit-field)
-	  '("\C-c*"		 org-table-recalculate)
-	  '("\C-c^"		 org-table-sort-lines)
-	  '("\M-a"		 org-table-beginning-of-field)
-	  '("\M-e"		 org-table-end-of-field)
-	  '([(control ?#)]       org-table-rotate-recalc-marks)))
+	 '(([(meta shift left)]  org-table-delete-column)
+	   ([(meta left)]	 org-table-move-column-left)
+	   ([(meta right)]       org-table-move-column-right)
+	   ([(meta shift right)] org-table-insert-column)
+	   ([(meta shift up)]    org-table-kill-row)
+	   ([(meta shift down)]  org-table-insert-row)
+	   ([(meta up)]		 org-table-move-row-up)
+	   ([(meta down)]	 org-table-move-row-down)
+	   ("\C-c\C-w"		 org-table-cut-region)
+	   ("\C-c\M-w"		 org-table-copy-region)
+	   ("\C-c\C-y"		 org-table-paste-rectangle)
+	   ("\C-c-"		 org-table-insert-hline)
+	   ("\C-c}"		 org-table-toggle-coordinate-overlays)
+	   ("\C-c{"		 org-table-toggle-formula-debugger)
+	   ("\C-m"		 org-table-next-row)
+	   ([(shift return)]	 org-table-copy-down)
+	   ("\C-c?"		 org-table-field-info)
+	   ("\C-c "		 org-table-blank-field)
+	   ("\C-c+"		 org-table-sum)
+	   ("\C-c="		 org-table-eval-formula)
+	   ("\C-c'"		 org-table-edit-formulas)
+	   ("\C-c`"		 org-table-edit-field)
+	   ("\C-c*"		 org-table-recalculate)
+	   ("\C-c^"		 org-table-sort-lines)
+	   ("\M-a"		 org-table-beginning-of-field)
+	   ("\M-e"		 org-table-end-of-field)
+	   ([(control ?#)]       org-table-rotate-recalc-marks)))
 	elt key fun cmd)
     (while (setq elt (pop bindings))
       (setq nfunc (1+ nfunc))
--- a/lisp/progmodes/bug-reference.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/progmodes/bug-reference.el	Thu May 06 09:50:39 2010 +0900
@@ -48,11 +48,18 @@
  1. issue kind (bug, patch, rfe &c)
  2. issue number.
 
-There is no default setting for this, it must be set per file.")
+There is no default setting for this, it must be set per file.
+If you set it to a symbol in the file Local Variables section,
+you need to add a `bug-reference-url-format' property to it:
+\(put 'my-bug-reference-url-format 'bug-reference-url-format t)
+so that it is considered safe, see `enable-local-variables'.")
 
 ;;;###autoload
 (put 'bug-reference-url-format 'safe-local-variable
-     (lambda (s) (or (stringp s) (functionp s))))
+     (lambda (s)
+       (or (stringp s)
+           (and (symbolp s)
+                (get s 'bug-reference-url-format)))))
 
 (defconst bug-reference-bug-regexp
   "\\([Bb]ug ?#\\|[Pp]atch ?#\\|RFE ?#\\|PR [a-z-+]+/\\)\\([0-9]+\\)"
--- a/lisp/progmodes/cc-mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/progmodes/cc-mode.el	Thu May 06 09:50:39 2010 +0900
@@ -818,8 +818,10 @@
   (setq c-old-BOM (point))
 
   (goto-char end)
-  (if (c-beginning-of-macro)
-    (c-end-of-macro))
+  (when (c-beginning-of-macro)
+    (c-end-of-macro)
+    (or (eobp) (forward-char)))	 ; Over the terminating NL which may be marked
+				 ; with a c-cpp-delimiter category property
   (setq c-old-EOM (point)))
 
 (defun c-neutralize-CPP-line (beg end)
--- a/lisp/progmodes/etags.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/progmodes/etags.el	Thu May 06 09:50:39 2010 +0900
@@ -423,9 +423,9 @@
   (if (get-file-buffer file)
       ;; The file is already in a buffer.  Check for the visited file
       ;; having changed since we last used it.
-      (let (win)
+      (progn
 	(set-buffer (get-file-buffer file))
-	(setq win (or verify-tags-table-function (tags-table-mode)))
+        (or verify-tags-table-function (tags-table-mode))
 	(if (or (verify-visited-file-modtime (current-buffer))
 		;; Decide whether to revert the file.
 		;; revert-without-query can say to revert
@@ -787,6 +787,30 @@
           (let ((enable-recursive-minibuffers t))
             (visit-tags-table-buffer))
           (complete-with-action action (tags-completion-table) string pred))))))
+
+;;;###autoload (defun tags-completion-at-point-function ()
+;;;###autoload   (if (or tags-table-list tags-file-name)
+;;;###autoload       (progn
+;;;###autoload         (load "etags")
+;;;###autoload         (tags-completion-at-point-function))))
+
+(defun tags-completion-at-point-function ()
+  "Using tags, return a completion table for the text around point.
+If no tags table is loaded, do nothing and return nil."
+  (when (or tags-table-list tags-file-name)
+    (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
+				      tags-case-fold-search
+				    case-fold-search))
+	  (pattern (funcall (or find-tag-default-function
+				(get major-mode 'find-tag-default-function)
+				'find-tag-default)))
+	  beg)
+      (when pattern
+	(save-excursion
+	  (search-backward pattern) ;FIXME: will fail if we're inside pattern.
+	  (setq beg (point))
+	  (forward-char (length pattern))
+	  (list beg (point) (tags-lazy-completion-table)))))))
 
 (defun find-tag-tag (string)
   "Read a tag name, with defaulting and completion."
@@ -2039,20 +2063,10 @@
       (error "%s"
 	     (substitute-command-keys
 	      "No tags table loaded; try \\[visit-tags-table]")))
-  (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
-				    tags-case-fold-search
-				  case-fold-search))
-	(pattern (funcall (or find-tag-default-function
-			      (get major-mode 'find-tag-default-function)
-			      'find-tag-default)))
-        (comp-table (tags-lazy-completion-table))
-	beg)
-    (or pattern
-	(error "Nothing to complete"))
-    (search-backward pattern)
-    (setq beg (point))
-    (forward-char (length pattern))
-    (completion-in-region beg (point) comp-table)))
+  (let ((comp-data (tags-completion-at-point-function)))
+    (if (null comp-data)
+	(error "Nothing to complete")
+      (apply 'completion-in-region comp-data))))
 
 (dolist (x '("^No tags table in use; use .* to select one$"
 	     "^There is no default tag$"
--- a/lisp/progmodes/idlwave.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/progmodes/idlwave.el	Thu May 06 09:50:39 2010 +0900
@@ -1370,6 +1370,7 @@
 not possible without parsing.  Thus assignment statement become just
 the leftover unidentified statements containing an equal sign.")
 
+;; FIXME: This var seems to only ever be set, but never actually used!
 (defvar idlwave-fill-function 'auto-fill-function
   "IDL mode auto fill function.")
 
--- a/lisp/progmodes/vhdl-mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/progmodes/vhdl-mode.el	Thu May 06 09:50:39 2010 +0900
@@ -199,21 +199,6 @@
   "Customizations for modes."
   :group 'vhdl)
 
-(defcustom vhdl-electric-mode t
-  "*Non-nil enables electrification (automatic template generation).
-If nil, template generators can still be invoked through key bindings and
-menu.  Is indicated in the modeline by \"/e\" after the mode name and can be
-toggled by `\\[vhdl-electric-mode]'."
-  :type 'boolean
-  :group 'vhdl-mode)
-
-(defcustom vhdl-stutter-mode t
-  "*Non-nil enables stuttering.
-Is indicated in the modeline by \"/s\" after the mode name and can be toggled
-by `\\[vhdl-stutter-mode]'."
-  :type 'boolean
-  :group 'vhdl-mode)
-
 (defcustom vhdl-indent-tabs-mode nil
   "*Non-nil means indentation can insert tabs.
 Overrides local variable `indent-tabs-mode'."
@@ -3466,13 +3451,11 @@
      ("Mode"
       ["Electric Mode"
        (progn (customize-set-variable 'vhdl-electric-mode
-				      (not vhdl-electric-mode))
-	      (vhdl-mode-line-update))
+				      (not vhdl-electric-mode)))
        :style toggle :selected vhdl-electric-mode :keys "C-c C-m C-e"]
       ["Stutter Mode"
        (progn (customize-set-variable 'vhdl-stutter-mode
-				      (not vhdl-stutter-mode))
-	      (vhdl-mode-line-update))
+				      (not vhdl-stutter-mode)))
        :style toggle :selected vhdl-stutter-mode :keys "C-c C-m C-s"]
       ["Indent Tabs Mode"
        (progn (customize-set-variable 'vhdl-indent-tabs-mode
@@ -4670,7 +4653,10 @@
   (interactive)
   (kill-all-local-variables)
   (setq major-mode 'vhdl-mode)
-  (setq mode-name "VHDL")
+  (setq mode-name '("VHDL"
+                    (vhdl-electric-mode "/" (vhdl-stutter-mode "/"))
+                    (vhdl-electric-mode "e")
+                    (vhdl-stutter-mode "s")))
 
   ;; set maps and tables
   (use-local-map vhdl-mode-map)
@@ -4737,7 +4723,6 @@
   ;; miscellaneous
   (vhdl-ps-print-init)
   (vhdl-write-file-hooks-init)
-  (vhdl-mode-line-update)
   (message "VHDL Mode %s.%s" vhdl-version
 	   (if noninteractive "" "  See menu for documentation and release notes."))
 
@@ -4757,8 +4742,7 @@
   (vhdl-write-file-hooks-init)
   (vhdl-update-mode-menu)
   (vhdl-hideshow-init)
-  (run-hooks 'menu-bar-update-hook)
-  (vhdl-mode-line-update))
+  (run-hooks 'menu-bar-update-hook))
 
 (defun vhdl-write-file-hooks-init ()
   "Add/remove hooks when buffer is saved."
@@ -8055,31 +8039,15 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  Enabling/disabling
 
-(defun vhdl-mode-line-update ()
-  "Update the modeline string for VHDL major mode."
-  (setq mode-name (concat "VHDL"
-			  (and (or vhdl-electric-mode vhdl-stutter-mode) "/")
-			  (and vhdl-electric-mode "e")
-			  (and vhdl-stutter-mode "s")))
-  (force-mode-line-update t))
-
-(defun vhdl-electric-mode (arg)
+(define-minor-mode vhdl-electric-mode
   "Toggle VHDL electric mode.
 Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
-  (interactive "P")
-  (setq vhdl-electric-mode
-	(cond ((or (not arg) (zerop arg)) (not vhdl-electric-mode))
-	      ((> arg 0) t) (t nil)))
-  (vhdl-mode-line-update))
-
-(defun vhdl-stutter-mode (arg)
+  :global t)
+
+(define-minor-mode vhdl-stutter-mode
   "Toggle VHDL stuttering mode.
 Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
-  (interactive "P")
-  (setq vhdl-stutter-mode
-	(cond ((or (not arg) (zerop arg)) (not vhdl-stutter-mode))
-	      ((> arg 0) t) (t nil)))
-  (vhdl-mode-line-update))
+  :global t)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Stuttering
@@ -12533,7 +12501,7 @@
 	(add-hook 'hs-minor-mode-hook 'hs-hide-all)
       (remove-hook 'hs-minor-mode-hook 'hs-hide-all))
     (hs-minor-mode arg)
-    (vhdl-mode-line-update)))		; hack to update menu bar
+    (force-mode-line-update)))		; hack to update menu bar
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--- a/lisp/savehist.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/savehist.el	Thu May 06 09:50:39 2010 +0900
@@ -59,17 +59,6 @@
   :version "22.1"
   :group 'minibuffer)
 
-;;;###autoload
-(defcustom savehist-mode nil
-  "Mode for automatic saving of minibuffer history.
-Set this by calling the `savehist-mode' function or using the customize
-interface."
-  :type 'boolean
-  :set (lambda (symbol value) (savehist-mode (or value 0)))
-  :initialize 'custom-initialize-default
-  :require 'savehist
-  :group 'savehist)
-
 (defcustom savehist-save-minibuffer-history t
   "If non-nil, save all recorded minibuffer histories.
 If you want to save only specific histories, use `savehist-save-hook' to
@@ -181,7 +170,7 @@
 ;; Functions.
 
 ;;;###autoload
-(defun savehist-mode (arg)
+(define-minor-mode savehist-mode
   "Toggle savehist-mode.
 Positive ARG turns on `savehist-mode'.  When on, savehist-mode causes
 minibuffer history to be saved periodically and when exiting Emacs.
@@ -191,11 +180,7 @@
 This mode should normally be turned on from your Emacs init file.
 Calling it at any other time replaces your current minibuffer histories,
 which is probably undesirable."
-  (interactive "P")
-  (setq savehist-mode
-	(if (null arg)
-	    (not savehist-mode)
-	  (> (prefix-numeric-value arg) 0)))
+  :global t
   (if (not savehist-mode)
       (savehist-uninstall)
     (when (and (not savehist-loaded)
@@ -214,11 +199,7 @@
 	 (setq savehist-mode nil)
 	 (savehist-uninstall)
 	 (signal (car errvar) (cdr errvar)))))
-    (savehist-install)
-    (run-hooks 'savehist-mode-hook))
-  ;; Return the new setting.
-  savehist-mode)
-(add-minor-mode 'savehist-mode "")
+    (savehist-install)))
 
 (defun savehist-load ()
   "Load the variables stored in `savehist-file' and turn on `savehist-mode'.
--- a/lisp/scroll-bar.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/scroll-bar.el	Thu May 06 09:50:39 2010 +0900
@@ -29,6 +29,7 @@
 ;;; Code:
 
 (require 'mouse)
+(eval-when-compile (require 'cl))
 
 
 ;;;; Utilities.
@@ -79,9 +80,6 @@
   "Non-nil means `set-scroll-bar-mode' should really do something.
 This is nil while loading `scroll-bar.el', and t afterward.")
 
-(defun set-scroll-bar-mode-1 (ignore value)
-  (set-scroll-bar-mode value))
-
 (defun set-scroll-bar-mode (value)
   "Set `scroll-bar-mode' to VALUE and put the new value into effect."
   (if scroll-bar-mode
@@ -107,27 +105,23 @@
   ;; The default value for :initialize would try to use :set
   ;; when processing the file in cus-dep.el.
   :initialize 'custom-initialize-default
-  :set 'set-scroll-bar-mode-1)
+  :set (lambda (sym val) (set-scroll-bar-mode val)))
 
 ;; We just set scroll-bar-mode, but that was the default.
 ;; If it is set again, that is for real.
 (setq scroll-bar-mode-explicit t)
 
-(defun scroll-bar-mode (&optional flag)
+(defun get-scroll-bar-mode () scroll-bar-mode)
+(defsetf get-scroll-bar-mode set-scroll-bar-mode)
+(define-minor-mode scroll-bar-mode
   "Toggle display of vertical scroll bars on all frames.
 This command applies to all frames that exist and frames to be
 created in the future.
 With a numeric argument, if the argument is positive
 turn on scroll bars; otherwise turn off scroll bars."
-  (interactive "P")
-
-  ;; Tweedle the variable according to the argument.
-  (set-scroll-bar-mode (if (if (null flag)
-			       (not scroll-bar-mode)
-			     (setq flag (prefix-numeric-value flag))
-			     (or (not (numberp flag)) (> flag 0)))
-			   (or previous-scroll-bar-mode
-			       default-frame-scroll-bars))))
+  :variable (eq (get-scroll-bar-mode)
+                (or previous-scroll-bar-mode
+                    default-frame-scroll-bars)))
 
 (defun toggle-scroll-bar (arg)
   "Toggle whether or not the selected frame has vertical scroll bars.
--- a/lisp/server.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/server.el	Thu May 06 09:50:39 2010 +0900
@@ -344,7 +344,8 @@
   ;; for possible servers before doing anything, so it *should* be ours.
   (and (process-contact proc :server)
        (eq (process-status proc) 'closed)
-       (ignore-errors (delete-file (process-get proc :server-file))))
+       (ignore-errors
+	(delete-file (process-get proc :server-file) t)))
   (server-log (format "Status changed to %s: %s" (process-status proc) msg) proc)
   (server-delete-client proc))
 
@@ -517,7 +518,9 @@
       ;; Delete the socket files made by previous server invocations.
       (if (not (eq t (server-running-p server-name)))
 	  ;; Remove any leftover socket or authentication file
-	  (ignore-errors (delete-file server-file))
+	  (ignore-errors
+	   (let (delete-by-moving-to-trash)
+	     (delete-file server-file)))
 	(setq server-mode nil) ;; already set by the minor mode code
 	(display-warning
 	 'server
@@ -600,7 +603,7 @@
 				    server-auth-dir
 				  server-socket-dir))))
     (condition-case nil
-	(progn
+	(let (delete-by-moving-to-trash)
 	  (delete-file file)
 	  (message "Connection file %S deleted" file))
       (file-error
--- a/lisp/simple.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/simple.el	Thu May 06 09:50:39 2010 +0900
@@ -401,8 +401,7 @@
 Other major modes are defined by comparison with this one."
   (interactive)
   (kill-all-local-variables)
-  (unless delay-mode-hooks
-    (run-hooks 'after-change-major-mode-hook)))
+  (run-mode-hooks 'fundamental-mode-hook))
 
 ;; Special major modes to view specially formatted data rather than files.
 
@@ -2689,6 +2688,60 @@
   (reset-this-command-lengths)
   (restore-overriding-map))
 
+;; This function is here rather than in subr.el because it uses CL.
+(defmacro with-wrapper-hook (var args &rest body)
+  "Run BODY wrapped with the VAR hook.
+VAR is a special hook: its functions are called with a first argument
+which is the \"original\" code (the BODY), so the hook function can wrap
+the original function, or call it any number of times (including not calling
+it at all).  This is similar to an `around' advice.
+VAR is normally a symbol (a variable) in which case it is treated like
+a hook, with a buffer-local and a global part.  But it can also be an
+arbitrary expression.
+ARGS is a list of variables which will be passed as additional arguments
+to each function, after the initial argument, and which the first argument
+expects to receive when called."
+  (declare (indent 2) (debug t))
+  ;; We need those two gensyms because CL's lexical scoping is not available
+  ;; for function arguments :-(
+  (let ((funs (make-symbol "funs"))
+        (global (make-symbol "global"))
+        (argssym (make-symbol "args")))
+    ;; Since the hook is a wrapper, the loop has to be done via
+    ;; recursion: a given hook function will call its parameter in order to
+    ;; continue looping.
+    `(labels ((runrestofhook (,funs ,global ,argssym)
+                 ;; `funs' holds the functions left on the hook and `global'
+                 ;; holds the functions left on the global part of the hook
+                 ;; (in case the hook is local).
+                 (lexical-let ((funs ,funs)
+                               (global ,global))
+                   (if (consp funs)
+                       (if (eq t (car funs))
+                           (runrestofhook
+                            (append global (cdr funs)) nil ,argssym)
+                         (apply (car funs)
+                                (lambda (&rest ,argssym)
+				  (runrestofhook (cdr funs) global ,argssym))
+                                ,argssym))
+                     ;; Once there are no more functions on the hook, run
+                     ;; the original body.
+                     (apply (lambda ,args ,@body) ,argssym)))))
+       (runrestofhook ,var
+                      ;; The global part of the hook, if any.
+                      ,(if (symbolp var)
+                           `(if (local-variable-p ',var)
+                                (default-value ',var)))
+                      (list ,@args)))))
+
+(defvar filter-buffer-substring-functions nil
+  "Wrapper hook around `filter-buffer-substring'.
+The functions on this special hook are called with 4 arguments:
+  NEXT-FUN BEG END DELETE
+NEXT-FUN is a function of 3 arguments (BEG END DELETE)
+that performs the default operation.  The other 3 arguments are like
+the ones passed to `filter-buffer-substring'.")
+
 (defvar buffer-substring-filters nil
   "List of filter functions for `filter-buffer-substring'.
 Each function must accept a single argument, a string, and return
@@ -2698,46 +2751,34 @@
 return value of `filter-buffer-substring'.
 
 If this variable is nil, no filtering is performed.")
-
-(defun filter-buffer-substring (beg end &optional delete noprops)
+(make-obsolete-variable 'buffer-substring-filters
+                        'filter-buffer-substring-functions "24.1")
+
+(defun filter-buffer-substring (beg end &optional delete)
   "Return the buffer substring between BEG and END, after filtering.
-The buffer substring is passed through each of the filter
-functions in `buffer-substring-filters', and the value from the
-last filter function is returned.  If `buffer-substring-filters'
-is nil, the buffer substring is returned unaltered.
+The filtering is performed by `filter-buffer-substring-functions'.
 
 If DELETE is non-nil, the text between BEG and END is deleted
 from the buffer.
 
-If NOPROPS is non-nil, final string returned does not include
-text properties, while the string passed to the filters still
-includes text properties from the buffer text.
-
-Point is temporarily set to BEG before calling
-`buffer-substring-filters', in case the functions need to know
-where the text came from.
-
 This function should be used instead of `buffer-substring',
 `buffer-substring-no-properties', or `delete-and-extract-region'
 when you want to allow filtering to take place.  For example,
-major or minor modes can use `buffer-substring-filters' to
+major or minor modes can use `filter-buffer-substring-functions' to
 extract characters that are special to a buffer, and should not
 be copied into other buffers."
-  (cond
-   ((or delete buffer-substring-filters)
-    (save-excursion
-      (goto-char beg)
-      (let ((string (if delete (delete-and-extract-region beg end)
-		      (buffer-substring beg end))))
-	(dolist (filter buffer-substring-filters)
-	  (setq string (funcall filter string)))
-	(if noprops
-	    (set-text-properties 0 (length string) nil string))
-	string)))
-   (noprops
-    (buffer-substring-no-properties beg end))
-   (t
-    (buffer-substring beg end))))
+  (with-wrapper-hook filter-buffer-substring-functions (beg end delete)
+    (cond
+     ((or delete buffer-substring-filters)
+      (save-excursion
+        (goto-char beg)
+        (let ((string (if delete (delete-and-extract-region beg end)
+                        (buffer-substring beg end))))
+          (dolist (filter buffer-substring-filters)
+            (setq string (funcall filter string)))
+          string)))
+     (t
+      (buffer-substring beg end)))))
 
 
 ;;;; Window system cut and paste hooks.
@@ -5108,7 +5149,7 @@
 (put 'auto-fill-function 'safe-local-variable 'null)
 ;; FIXME: turn into a proper minor mode.
 ;; Add a global minor mode version of it.
-(defun auto-fill-mode (&optional arg)
+(define-minor-mode auto-fill-mode
   "Toggle Auto Fill mode.
 With ARG, turn Auto Fill mode on if and only if ARG is positive.
 In Auto Fill mode, inserting a space at a column beyond `current-fill-column'
@@ -5116,14 +5157,7 @@
 
 The value of `normal-auto-fill-function' specifies the function to use
 for `auto-fill-function' when turning Auto Fill mode on."
-  (interactive "P")
-  (prog1 (setq auto-fill-function
-	       (if (if (null arg)
-		       (not auto-fill-function)
-		       (> (prefix-numeric-value arg) 0))
-		   normal-auto-fill-function
-		   nil))
-    (force-mode-line-update)))
+  :variable (eq auto-fill-function normal-auto-fill-function))
 
 ;; This holds a document string used to document auto-fill-mode.
 (defun auto-fill-function ()
@@ -5222,7 +5256,7 @@
 (defvar overwrite-mode-binary (purecopy " Bin Ovwrt")
   "The string displayed in the mode line when in binary overwrite mode.")
 
-(defun overwrite-mode (arg)
+(define-minor-mode overwrite-mode
   "Toggle overwrite mode.
 With prefix argument ARG, turn overwrite mode on if ARG is positive,
 otherwise turn it off.  In overwrite mode, printing characters typed
@@ -5231,14 +5265,9 @@
 Before a tab, such characters insert until the tab is filled in.
 \\[quoted-insert] still inserts characters in overwrite mode; this
 is supposed to make it easier to insert characters when necessary."
-  (interactive "P")
-  (setq overwrite-mode
-	(if (if (null arg) (not overwrite-mode)
-	      (> (prefix-numeric-value arg) 0))
-	    'overwrite-mode-textual))
-  (force-mode-line-update))
-
-(defun binary-overwrite-mode (arg)
+  :variable (eq overwrite-mode 'overwrite-mode-textual))
+
+(define-minor-mode binary-overwrite-mode
   "Toggle binary overwrite mode.
 With prefix argument ARG, turn binary overwrite mode on if ARG is
 positive, otherwise turn it off.  In binary overwrite mode, printing
@@ -5251,13 +5280,7 @@
 Note that binary overwrite mode is not its own minor mode; it is a
 specialization of overwrite mode, entered by setting the
 `overwrite-mode' variable to `overwrite-mode-binary'."
-  (interactive "P")
-  (setq overwrite-mode
-	(if (if (null arg)
-		(not (eq overwrite-mode 'overwrite-mode-binary))
-	      (> (prefix-numeric-value arg) 0))
-	    'overwrite-mode-binary))
-  (force-mode-line-update))
+  :variable (eq overwrite-mode 'overwrite-mode-binary))
 
 (define-minor-mode line-number-mode
   "Toggle Line Number mode.
@@ -6397,7 +6420,7 @@
              normal-erase-is-backspace)
            1 0)))))
 
-(defun normal-erase-is-backspace-mode (&optional arg)
+(define-minor-mode normal-erase-is-backspace-mode
   "Toggle the Erase and Delete mode of the Backspace and Delete keys.
 
 With numeric ARG, turn the mode on if and only if ARG is positive.
@@ -6427,13 +6450,10 @@
 have both Backspace, Delete and F1 keys.
 
 See also `normal-erase-is-backspace'."
-  (interactive "P")
-  (let ((enabled (or (and arg (> (prefix-numeric-value arg) 0))
-		     (not (or arg
-                              (eq 1 (terminal-parameter
-				      nil 'normal-erase-is-backspace)))))))
-    (set-terminal-parameter nil 'normal-erase-is-backspace
-			    (if enabled 1 0))
+  :variable (eq (terminal-parameter
+                 nil 'normal-erase-is-backspace) 1)
+  (let ((enabled (eq 1 (terminal-parameter
+                        nil 'normal-erase-is-backspace))))
 
     (cond ((or (memq window-system '(x w32 ns pc))
 	       (memq system-type '(ms-dos windows-nt)))
@@ -6469,7 +6489,6 @@
 	     (keyboard-translate ?\C-h ?\C-h)
 	     (keyboard-translate ?\C-? ?\C-?))))
 
-    (run-hooks 'normal-erase-is-backspace-hook)
     (if (called-interactively-p 'interactive)
 	(message "Delete key deletes %s"
 		 (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
@@ -6506,52 +6525,6 @@
 was called."
   (lexical-let ((fun fun) (args1 args))
     (lambda (&rest args2) (apply fun (append args1 args2)))))
-
-;; This function is here rather than in subr.el because it uses CL.
-(defmacro with-wrapper-hook (var args &rest body)
-  "Run BODY wrapped with the VAR hook.
-VAR is a special hook: its functions are called with a first argument
-which is the \"original\" code (the BODY), so the hook function can wrap
-the original function, or call it any number of times (including not calling
-it at all).  This is similar to an `around' advice.
-VAR is normally a symbol (a variable) in which case it is treated like
-a hook, with a buffer-local and a global part.  But it can also be an
-arbitrary expression.
-ARGS is a list of variables which will be passed as additional arguments
-to each function, after the initial argument, and which the first argument
-expects to receive when called."
-  (declare (indent 2) (debug t))
-  ;; We need those two gensyms because CL's lexical scoping is not available
-  ;; for function arguments :-(
-  (let ((funs (make-symbol "funs"))
-        (global (make-symbol "global"))
-        (argssym (make-symbol "args")))
-    ;; Since the hook is a wrapper, the loop has to be done via
-    ;; recursion: a given hook function will call its parameter in order to
-    ;; continue looping.
-    `(labels ((runrestofhook (,funs ,global ,argssym)
-                 ;; `funs' holds the functions left on the hook and `global'
-                 ;; holds the functions left on the global part of the hook
-                 ;; (in case the hook is local).
-                 (lexical-let ((funs ,funs)
-                               (global ,global))
-                   (if (consp funs)
-                       (if (eq t (car funs))
-                           (runrestofhook
-                            (append global (cdr funs)) nil ,argssym)
-                         (apply (car funs)
-                                (lambda (&rest ,argssym)
-				  (runrestofhook (cdr funs) global ,argssym))
-                                ,argssym))
-                     ;; Once there are no more functions on the hook, run
-                     ;; the original body.
-                     (apply (lambda ,args ,@body) ,argssym)))))
-       (runrestofhook ,var
-                      ;; The global part of the hook, if any.
-                      ,(if (symbolp var)
-                           `(if (local-variable-p ',var)
-                                (default-value ',var)))
-                      (list ,@args)))))
 
 ;; Minibuffer prompt stuff.
 
--- a/lisp/subr.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/subr.el	Thu May 06 09:50:39 2010 +0900
@@ -1477,8 +1477,7 @@
 	      (let ((rest (cdr found)))
 		(setcdr found nil)
 		(nconc found (list (list toggle name)) rest))
-	    (setq minor-mode-alist (cons (list toggle name)
-					 minor-mode-alist)))))))
+	    (push (list toggle name) minor-mode-alist))))))
   ;; Add the toggle to the minor-modes menu if requested.
   (when (get toggle :included)
     (define-key mode-line-mode-menu
@@ -1507,8 +1506,7 @@
 	      (let ((rest (cdr found)))
 		(setcdr found nil)
 		(nconc found (list (cons toggle keymap)) rest))
-	    (setq minor-mode-map-alist (cons (cons toggle keymap)
-					     minor-mode-map-alist))))))))
+	    (push (cons toggle keymap) minor-mode-map-alist)))))))
 
 ;;; Load history
 
--- a/lisp/tar-mode.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/tar-mode.el	Thu May 06 09:50:39 2010 +0900
@@ -137,7 +137,6 @@
 (defvar tar-parse-info nil)
 (defvar tar-superior-buffer nil)
 (defvar tar-superior-descriptor nil)
-(defvar tar-subfile-mode nil)
 (defvar tar-file-name-coding-system nil)
 
 (put 'tar-superior-buffer 'permanent-local t)
@@ -672,29 +671,21 @@
      (signal (car err) (cdr err)))))
 
 
-(defun tar-subfile-mode (p)
+(define-minor-mode tar-subfile-mode
   "Minor mode for editing an element of a tar-file.
 This mode arranges for \"saving\" this buffer to write the data
 into the tar-file buffer that it came from.  The changes will actually
 appear on disk when you save the tar-file's buffer."
-  (interactive "P")
+  ;; Don't do this, because it is redundant and wastes mode line space.
+  ;; :lighter " TarFile"
+  nil nil nil
   (or (and (boundp 'tar-superior-buffer) tar-superior-buffer)
       (error "This buffer is not an element of a tar file"))
-  ;; Don't do this, because it is redundant and wastes mode line space.
-  ;;  (or (assq 'tar-subfile-mode minor-mode-alist)
-  ;;      (setq minor-mode-alist (append minor-mode-alist
-  ;;				     (list '(tar-subfile-mode " TarFile")))))
-  (make-local-variable 'tar-subfile-mode)
-  (setq tar-subfile-mode
-	(if (null p)
-	    (not tar-subfile-mode)
-	    (> (prefix-numeric-value p) 0)))
   (cond (tar-subfile-mode
 	 (add-hook 'write-file-functions 'tar-subfile-save-buffer nil t)
 	 ;; turn off auto-save.
 	 (auto-save-mode -1)
-	 (setq buffer-auto-save-file-name nil)
-	 (run-hooks 'tar-subfile-mode-hook))
+	 (setq buffer-auto-save-file-name nil))
 	(t
 	 (remove-hook 'write-file-functions 'tar-subfile-save-buffer t))))
 
--- a/lisp/term/tvi970.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/term/tvi970.el	Thu May 06 09:50:39 2010 +0900
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (defvar tvi970-terminal-map
   (let ((map (make-sparse-keymap)))
 
@@ -102,7 +104,7 @@
 
 
 ;; Should keypad numbers send ordinary digits or distinct escape sequences?
-(defun tvi970-set-keypad-mode (&optional arg)
+(define-minor-mode tvi970-set-keypad-mode
   "Set the current mode of the TVI 970 numeric keypad.
 In ``numeric keypad mode'', the number keys on the keypad act as
 ordinary digits.  In ``alternate keypad mode'', the keys send distinct
@@ -111,12 +113,9 @@
 With no argument, toggle between the two possible modes.
 With a positive argument, select alternate keypad mode.
 With a negative argument, select numeric keypad mode."
-  (interactive "P")
-  (let ((newval (if (null arg)
-                    (not (terminal-parameter nil 'tvi970-keypad-numeric))
-                  (> (prefix-numeric-value arg) 0))))
-    (set-terminal-parameter nil 'tvi970-keypad-numeric newval)
-    (send-string-to-terminal (if newval "\e=" "\e>"))))
+  :variable (terminal-parameter nil 'tvi970-keypad-numeric)
+  (send-string-to-terminal
+   (if (terminal-parameter nil 'tvi970-keypad-numeric) "\e=" "\e>")))
 
 ;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
 ;;; tvi970.el ends here
--- a/lisp/term/vt100.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/term/vt100.el	Thu May 06 09:50:39 2010 +0900
@@ -41,19 +41,13 @@
   (tty-run-terminal-initialization (selected-frame) "lk201"))
 
 ;;; Controlling the screen width.
-(defvar vt100-wide-mode (= (frame-width) 132)
-  "t if vt100 is in 132-column mode.")
-
-(defun vt100-wide-mode (&optional arg)
+(define-minor-mode vt100-wide-mode
   "Toggle 132/80 column mode for vt100s.
 With positive argument, switch to 132-column mode.
 With negative argument, switch to 80-column mode."
- (interactive "P")
- (setq vt100-wide-mode
-	(if (null arg) (not vt100-wide-mode)
-	  (> (prefix-numeric-value arg) 0)))
- (send-string-to-terminal (if vt100-wide-mode "\e[?3h" "\e[?3l"))
- (set-frame-width terminal-frame (if vt100-wide-mode 132 80)))
+  :global t :initial-value (= (frame-width) 132)
+  (send-string-to-terminal (if vt100-wide-mode "\e[?3h" "\e[?3l"))
+  (set-frame-width terminal-frame (if vt100-wide-mode 132 80)))
 
 ;; arch-tag: 9ff41f24-a7c9-4dee-9cf2-fbaa951eb840
 ;;; vt100.el ends here
--- a/lisp/textmodes/reftex.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/textmodes/reftex.el	Thu May 06 09:50:39 2010 +0900
@@ -305,10 +305,6 @@
 (defconst reftex-version "RefTeX version 4.31"
   "Version string for RefTeX.")
 
-(defvar reftex-mode nil
-  "Determines if RefTeX mode is active.")
-(make-variable-buffer-local 'reftex-mode)
-
 (defvar reftex-mode-map (make-sparse-keymap)
   "Keymap for RefTeX mode.")
 
@@ -504,8 +500,10 @@
   "Turn on RefTeX mode."
   (reftex-mode t))
 
+(put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode)))
+(put 'reftex-mode :menu-tag "RefTeX Mode")
 ;;;###autoload
-(defun reftex-mode (&optional arg)
+(define-minor-mode reftex-mode
   "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
 
 \\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing
@@ -535,11 +533,7 @@
 on the menu bar.
 
 ------------------------------------------------------------------------------"
-
-  (interactive "P")
-  (setq reftex-mode (not (or (and (null arg) reftex-mode)
-                             (<= (prefix-numeric-value arg) 0))))
-
+  :lighter " Ref" :keymap reftex-mode-map
   (if reftex-mode
       (progn
         ;; Mode was turned on
@@ -565,24 +559,10 @@
         (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
         (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
         (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
-        (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)
-
-        (run-hooks 'reftex-mode-hook))
+        (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
     ;; Mode was turned off
     (easy-menu-remove reftex-mode-menu)))
 
-(if (fboundp 'add-minor-mode)
-    ;; Use it so that we get the extras
-    (progn
-      (put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode)))
-      (put 'reftex-mode :menu-tag "RefTeX Mode")
-      (add-minor-mode 'reftex-mode " Ref" reftex-mode-map))
-  ;; The standard way
-  (unless (assoc 'reftex-mode minor-mode-alist)
-    (push '(reftex-mode " Ref") minor-mode-alist))
-  (unless (assoc 'reftex-mode minor-mode-map-alist)
-    (push (cons 'reftex-mode reftex-mode-map) minor-mode-map-alist)))
-
 (defvar reftex-docstruct-symbol)
 (defun reftex-kill-buffer-hook ()
   "Save RefTeX's parse file for this buffer if the information has changed."
@@ -625,11 +605,11 @@
 ;;;
 ;;; Multibuffer Variables
 ;;;
-;;; Technical notes: These work as follows: We keep just one list
-;;; of labels for each master file - this can save a lot of memory.
-;;; `reftex-master-index-list' is an alist which connects the true file name
-;;; of each master file with the symbols holding the information on that
-;;; document.  Each buffer has local variables which point to these symbols.
+;; Technical notes: These work as follows: We keep just one list
+;; of labels for each master file - this can save a lot of memory.
+;; `reftex-master-index-list' is an alist which connects the true file name
+;; of each master file with the symbols holding the information on that
+;; document.  Each buffer has local variables which point to these symbols.
 
 ;; List of variables which handle the multifile stuff.
 ;; This list is used to tie, untie, and reset these symbols.
--- a/lisp/type-break.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/type-break.el	Thu May 06 09:50:39 2010 +0900
@@ -152,13 +152,6 @@
   :type 'sexp
   :group 'type-break)
 
-(defcustom type-break-query-mode t
-  "Non-nil means ask whether or not to prompt user for breaks.
-If so, call the function specified in the value of the variable
-`type-break-query-function' to do the asking."
-  :type 'boolean
-  :group 'type-break)
-
 (defcustom type-break-query-function 'yes-or-no-p
   "Function to use for making query for a typing break.
 It should take a string as an argument, the prompt.
@@ -245,14 +238,6 @@
 
 ;; Mode line frobs
 
-(defcustom type-break-mode-line-message-mode nil
-  "Non-nil means put type-break related messages in the mode line.
-Otherwise, messages typically go in the echo area.
-
-See also `type-break-mode-line-format' and its members."
-  :type 'boolean
-  :group 'type-break)
-
 (defvar type-break-mode-line-format
   '(type-break-mode-line-message-mode
     (""
@@ -447,7 +432,7 @@
            (message "Type Break mode is disabled")))))
   type-break-mode)
 
-(defun type-break-mode-line-message-mode (&optional prefix)
+(define-minor-mode type-break-mode-line-message-mode
   "Enable or disable warnings in the mode line about typing breaks.
 
 A negative PREFIX argument disables this mode.
@@ -462,16 +447,9 @@
         `global-mode-string'
         `type-break-mode-line-break-message'
         `type-break-mode-line-warning'"
-  (interactive "P")
-  (setq type-break-mode-line-message-mode
-        (>= (prefix-numeric-value prefix) 0))
-  (and (called-interactively-p 'interactive)
-       (if type-break-mode-line-message-mode
-           (message "type-break-mode-line-message-mode is enabled")
-         (message "type-break-mode-line-message-mode is disabled")))
-  type-break-mode-line-message-mode)
+  :global t)
 
-(defun type-break-query-mode (&optional prefix)
+(define-minor-mode type-break-query-mode
   "Enable or disable warnings in the mode line about typing breaks.
 
 When enabled, the user is periodically queried about whether to take a
@@ -483,14 +461,7 @@
 
 The user may also enable or disable this mode simply by setting the
 variable of the same name."
-  (interactive "P")
-  (setq type-break-query-mode
-        (>= (prefix-numeric-value prefix) 0))
-  (and (called-interactively-p 'interactive)
-       (if type-break-query-mode
-           (message "type-break-query-mode is enabled")
-         (message "type-break-query-mode is disabled")))
-  type-break-query-mode)
+  :global t)
 
 
 ;;; session file functions
--- a/lisp/url/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/url/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,7 @@
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* url-dired.el (url-dired-minor-mode): Use define-minor-mode.
+
 2010-03-24  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* url-http.el (url-http-parse-headers): Fix wrong variable name.
--- a/lisp/url/url-dired.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/url/url-dired.el	Thu May 06 09:50:39 2010 +0900
@@ -31,11 +31,6 @@
     map)
   "Keymap used when browsing directories.")
 
-(defvar url-dired-minor-mode nil
-  "Whether we are in url-dired-minor-mode.")
-
-(make-variable-buffer-local 'url-dired-minor-mode)
-
 (defun url-dired-find-file ()
   "In dired, visit the file or directory named on this line."
   (interactive)
@@ -48,39 +43,9 @@
   (mouse-set-point event)
   (url-dired-find-file))
 
-(defun url-dired-minor-mode (&optional arg)
+(define-minor-mode url-dired-minor-mode
   "Minor mode for directory browsing."
-  (interactive "P")
-  (cond
-   ((null arg)
-    (setq url-dired-minor-mode (not url-dired-minor-mode)))
-   ((equal 0 arg)
-    (setq url-dired-minor-mode nil))
-   (t
-    (setq url-dired-minor-mode t))))
-
-(if (not (fboundp 'add-minor-mode))
-    (defun add-minor-mode (toggle name &optional keymap after toggle-fun)
-      "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
-TOGGLE is a symbol which is used as the variable which toggle the minor mode,
-NAME is the name that should appear in the modeline (it should be a string
-beginning with a space), KEYMAP is a keymap to make active when the minor
-mode is active, and AFTER is the toggling symbol used for another minor
-mode.  If AFTER is non-nil, then it is used to position the new mode in the
-minor-mode alists.  TOGGLE-FUN specifies an interactive function that
-is called to toggle the mode on and off; this affects what appens when
-button2 is pressed on the mode, and when button3 is pressed somewhere
-in the list of modes.  If TOGGLE-FUN is nil and TOGGLE names an
-interactive function, TOGGLE is used as the toggle function.
-
-Example:  (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
-      (if (not (assq toggle minor-mode-alist))
-	  (setq minor-mode-alist (cons (list toggle name) minor-mode-alist)))
-      (if (and keymap (not (assq toggle minor-mode-map-alist)))
-	  (setq minor-mode-map-alist (cons (cons toggle keymap)
-					   minor-mode-map-alist)))))
-
-(add-minor-mode 'url-dired-minor-mode " URL" url-dired-minor-mode-map)
+  :lighter " URL" :keymap url-dired-minor-mode-map)
 
 (defun url-find-file-dired (dir)
   "\"Edit\" directory DIR, but with additional URL-friendly bindings."
--- a/lisp/view.el	Wed Apr 28 10:00:38 2010 +0900
+++ b/lisp/view.el	Thu May 06 09:50:39 2010 +0900
@@ -161,14 +161,6 @@
   "Overlay used to display where a search operation found its match.
 This is local in each buffer, once it is used.")
 (make-variable-buffer-local 'view-overlay)
-
-(unless (assq 'view-mode minor-mode-alist)
-  (setq minor-mode-alist
-	(cons (list 'view-mode
-		    (propertize " View"
-				'local-map mode-line-minor-mode-keymap
-				'help-echo "mouse-3: minor mode menu"))
-	      minor-mode-alist)))
 
 ;; Define keymap inside defvar to make it easier to load changes.
 ;; Some redundant "less"-like key bindings below have been commented out.
@@ -230,10 +222,6 @@
     (define-key map "?" 'describe-mode)	; Maybe do as less instead? See above.
     (define-key map "h" 'describe-mode)
     map))
-
-(or (assq 'view-mode minor-mode-map-alist)
-    (setq minor-mode-map-alist
-	  (cons (cons 'view-mode view-mode-map) minor-mode-map-alist)))
 
 ;;; Commands that enter or exit view mode.
 
@@ -393,7 +381,7 @@
 		     exit-action)))
 
 ;;;###autoload
-(defun view-mode (&optional arg)
+(define-minor-mode view-mode
   ;; In the following documentation string we have to use some explicit key
   ;; bindings instead of using the \\[] construction.  The reason for this
   ;; is that most commands have more than one key binding.
@@ -473,11 +461,8 @@
 then \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] will return to that buffer.
 
 Entry to view-mode runs the normal hook `view-mode-hook'."
-  (interactive "P")
-  (unless (and arg			; Do nothing if already OK.
-	       (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode)))
-    (if view-mode (view-mode-disable)
-      (view-mode-enable))))
+  :lighter " View" :keymap view-mode-map
+  (if view-mode (view-mode-enable) (view-mode-disable)))
 
 (defun view-mode-enable ()
   "Turn on View mode."
--- a/lwlib/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/lwlib/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,9 @@
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE):
+	Use @C_SWITCH_SYSTEM@, @C_SWITCH_MACHINE@ instead of
+	@c_switch_system@, @c_switch_machine@.
+
 2010-04-27  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* Makefile.in (C_SWITCH_X_SYSTEM): Define using autoconf.
--- a/lwlib/Makefile.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/lwlib/Makefile.in	Thu May 06 09:50:39 2010 +0900
@@ -1,6 +1,6 @@
 # Copyright (C) 1992, 1993 Lucid, Inc.
-# Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006,
-#   2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+#   2009, 2010  Free Software Foundation, Inc.
 # 
 # This file is part of the Lucid Widget Library.
 # 
@@ -27,8 +27,8 @@
 VPATH=@srcdir@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
 C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
-C_SWITCH_SYSTEM=@c_switch_system@
-C_SWITCH_MACHINE=@c_switch_machine@
+C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
+C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
 
 CC=@CC@
 CFLAGS=@CFLAGS@
--- a/make-dist	Wed Apr 28 10:00:38 2010 +0900
+++ b/make-dist	Thu May 06 09:50:39 2010 +0900
@@ -469,8 +469,7 @@
 
 echo "Making links to \`src/m'"
 (cd src/m
- # We call files for miscellaneous input (to linker etc) .inp.
- ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
+ ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
 
 echo "Making links to \`src/s'"
 (cd src/s
--- a/nt/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/nt/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,7 @@
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* config.nt (LD_SWITCH_X_SITE_AUX): Remove.
+
 2010-04-20  Lewis Perin  <perin@panix.com>  (tiny change)
 
 	* emacs.manifest: Add trustInfo section to Windows manifest.
--- a/nt/config.nt	Wed Apr 28 10:00:38 2010 +0900
+++ b/nt/config.nt	Thu May 06 09:50:39 2010 +0900
@@ -325,10 +325,6 @@
    something similar.  */
 #undef LD_SWITCH_X_SITE
 
-/* Define LD_SWITCH_X_SITE_AUX with an -R option
-   in case it's needed (for Solaris, for example).  */
-#undef LD_SWITCH_X_SITE_AUX
-
 /* Define C_SWITCH_X_SITE to contain any special flags your compiler
    may need to deal with X Windows.  For instance, if you've defined
    HAVE_X_WINDOWS above and your X include files aren't in a place
--- a/oldXMenu/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/oldXMenu/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,9 @@
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE): Use
+	@C_SWITCH_SYSTEM@, @C_SWITCH_MACHINE@ rather than
+	@c_switch_system@, @c_switch_machine@.
+
 2010-04-27  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* Makefile.in (C_SWITCH_X_SYSTEM): Define using autoconf.
--- a/oldXMenu/Makefile.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/oldXMenu/Makefile.in	Thu May 06 09:50:39 2010 +0900
@@ -47,8 +47,8 @@
 VPATH=@srcdir@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
 C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
-C_SWITCH_SYSTEM=@c_switch_system@
-C_SWITCH_MACHINE=@c_switch_machine@
+C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
+C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
 
 EXTRA=insque.o
 CC=@CC@
--- a/src/ChangeLog	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/ChangeLog	Thu May 06 09:50:39 2010 +0900
@@ -1,3 +1,256 @@
+2010-05-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* syntax.c (Fchar_syntax): Check the arg is a character (bug#6080).
+
+2010-05-05  Lawrence Mitchell  <wence@gmx.li>
+
+	* m/sparc.h: Fix typo in earlier change.
+
+2010-05-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Misc tweaks.
+	* eval.c (Fdefvaralias): Remove unintended nested if.
+	(internal_condition_case_2, internal_condition_case_n): Use ANSI type.
+
+2010-05-04  Bernhard Herzog  <bh@intevation.de>  (tiny change)
+
+	* xsmfns.c (smc_save_yourself_CB): strlen(client_id) => strlen(cwd).
+
+2010-05-04  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Remove BSD_PGRPS.
+	* s/bsd-common.h (BSD_PGRPS): Remove undef.
+	* s/gnu-linux.h (BSD_PGRPS): Remove.
+	* term.c (dissociate_if_controlling_tty):
+	* sysdep.c (narrow_foreground_group, widen_foreground_group)
+	(init_sys_modes, reset_sys_modes):
+	* emacs.c (main):
+	* callproc.c (Fcall_process, child_setup): Remove code depending
+	on BSD_PGRPS.
+
+	Remove POSIX_SIGNALS.
+	* s/usg5-4.h (POSIX_SIGNALS):
+	* s/netbsd.h (POSIX_SIGNALS):
+	* s/msdos.h (POSIX_SIGNALS):
+	* s/ms-w32.h (POSIX_SIGNALS):
+	* s/hpux11.h (POSIX_SIGNALS):
+	* s/gnu.h (POSIX_SIGNALS):
+	* s/gnu-linux.h (POSIX_SIGNALS):
+	* s/freebsd.h (POSIX_SIGNALS):
+	* s/darwin.h (POSIX_SIGNALS):
+	* s/cygwin.h (POSIX_SIGNALS):
+	* s/aix4-2.h (POSIX_SIGNALS): Remove definition.
+	* s/unixware.h:
+	* s/sol2-6.h: Remove comments on POSIX_SIGNALS.
+	* process.c (create_process):
+	* syssignal.h:
+	* sysdep.c (wait_for_termination, init_signals):
+	* process.c (create_process):
+	* msdos.c: POSIX_SIGNALS is always defined on all platforms,
+	remove all code that assumes the contrary.
+
+2010-05-04  Glenn Morris  <rgm@gnu.org>
+
+	* s/gnu-linux.h (LD_SWITCH_SYSTEM): Use LD_SWITCH_X_SITE_AUX as a shell
+	variable.
+	* s/netbsd.h (LD_SWITCH_SYSTEM_tmp): Remove.
+	(LD_SWITCH_SYSTEM): Use $LD_SWITCH_X_SITE_AUX_RPATH.
+	* s/openbsd.h (LD_SWITCH_SYSTEM_tmp): Remove.
+	(LD_SWITCH_SYSTEM): Use $LD_SWITCH_X_SITE_AUX_RPATH instead of
+	LD_SWITCH_SYSTEM_tmp.
+	* Makefile.in (LD_SWITCH_X_SITE_AUX, LD_SWITCH_X_SITE_AUX_RPATH):
+	New variables, set by configure.
+
+	* s/aix4-2.h (LD_SWITCH_SYSTEM_TEMACS): Move to configure.in.
+	* s/darwin.h (HEADERPAD_EXTRA, LIBS_NSGUI): Remove.
+	(LD_SWITCH_SYSTEM_TEMACS): Move to configure.in.
+	* Makefile.in (LD_SWITCH_SYSTEM_TEMACS): New variable, set by configure.
+	(TEMACS_LDFLAGS): Use $LD_SWITCH_SYSTEM_TEMACS.
+
+	* s/aix4-2.h (C_SWITCH_SYSTEM):
+	* m/alpha.h (C_SWITCH_MACHINE):
+	Move to configure.in.
+	* Makefile.in (C_SWITCH_MACHINE, C_SWITCH_SYSTEM):
+	New variables, set by configure.
+	(ALL_CFLAGS): Use $C_SWITCH_MACHINE and $C_SWITCH_SYSTEM in place of
+	$c_switch_machine and $c_switch_system.
+
+2010-05-04  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* s/hpux10-20.h (LIB_STANDARD): New definition.
+	* Makefile.in (ORDINARY_LINK): Remove setting LIB_STANDARD based
+	on it, not used anymore.
+
+2010-05-03  Chong Yidong  <cyd@stupidchicken.com>
+
+	* eval.c (internal_condition_case_n): Rename from
+	internal_condition_case_2.
+	(internal_condition_case_2): New function.
+
+	* xdisp.c (safe_call): Use internal_condition_case_n.
+
+	* fileio.c (Fdelete_file, internal_delete_file): New arg FORCE.
+	(internal_delete_file, Frename_file): Callers changed.
+
+	* buffer.c (Fkill_buffer):
+	* callproc.c (delete_temp_file): Callers changed (Bug#6070).
+
+	* lisp.h: Update prototypes.
+
+2010-05-03  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (LIBX_EXTRA, LIBX_BASE): New variables.
+	(LIBXT_OTHER, LIBX_OTHER): New, set by configure.
+	(LIBXT): Set with configure, not cpp.
+	(LIBX): Remove.
+	(LIBES): Replace $LIBX with $LIBX_BASE and $LIBX_OTHER.
+
+2010-05-02  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* m/amdx86-64.h (START_FILES, LIB_STANDARD): Remove.
+	The FreeBSD is not needed, the default works, Solaris version is
+	not needed, and the remaining case is not supported by configure.
+
+2010-05-02  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsmfns.c (CHDIR_OPT): New define.
+	(smc_save_yourself_CB): Add CHDIR_OPT to options to use when
+	restarting emacs.
+
+	* xterm.c (x_connection_closed): Call Fkill_emacs instead of
+	shut_down_emacs.
+
+	* emacs.c (USAGE1): Mention --chdir.
+	(main): Handle --chdir.
+	(standard_args): Add --chdir.
+	(fatal_error_signal): Call Fkill_emacs for SIGTERM and SIGHUP (Bug
+	#5552).
+
+2010-05-01  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Remove LD_SWITCH_MACHINE.
+	* Makefile.in (LD_SWITCH_MACHINE): Remove definition, unused.
+	(TEMACS_LDFLAGS): Do not use LD_SWITCH_MACHINE.
+
+	Clean up IRIX code.
+	* m/iris4d.h (TERMINFO, FIRST_PTY_LETTER): Move definitions ...
+	* s/irix6-5.h (TERMINFO, FIRST_PTY_LETTER): ... here.
+
+	Clean up AIX code.
+	* m/ibmrs6000.inp: Remove file, unused.
+	* m/ibmrs6000.h (IBMR2AIX): Remove, unused.
+	(LD_SWITCH_MACHINE): Rename to LD_SWITCH_SYSTEM_TEMACS, and move
+	definition ...
+	* s/aix4-2.h (LD_SWITCH_SYSTEM_TEMACS): ... here.
+
+	* sysdep.c (child_setup_tty, init_sys_modes): Remove !IBMR2AIX code,
+	unused.
+
+2010-05-01  Eli Zaretskii  <eliz@gnu.org>
+
+	Emulate POSIX_SIGNALS on MS-Windows.
+
+	* s/ms-w32.h (POSIX_SIGNALS, struct sigaction, SIG_BLOCK)
+	(SIG_SETMASK, SIG_UNBLOCK): Define.
+
+	* sysdep.c (sys_signal) [WINDOWSNT]: #ifdef away.
+	(wait_for_termination) [WINDOWSNT]: Move MS-Windows specific code
+	from non-POSIX_SIGNALS section to POSIX_SIGNALS section.
+
+	* w32.c (sigemptyset, sigaddset, sigfillset, sigprocmask):
+	New stubs.
+
+	Miscellaneous fixes of bidi display.
+
+	* xdisp.c (find_row_end): New function, refactored from display_line.
+	(display_line): Use it.
+	(extend_face_to_end_of_line): In almost-filled rows, extend only
+	if the row is R2L and not continued.
+	(display_line): Fix prepending of truncation glyphs to R2L rows.
+	Preserve overlay and string info in row->end.
+	(insert_left_trunc_glyphs): Support addition of left truncation
+	glyphs to R2L rows.
+	(set_cursor_from_row): Don't place cursor on the vertical border
+	glyph between adjacent windows.  Fix a crash when a display string
+	is continued to the next line.  Don't return zero if cursor was
+	found by `cursor' property of a display string.
+	(try_cursor_movement): Don't assume that row->end == (row+1)->start,
+	test for that explicitly.
+
+2010-05-01  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (gmallocobj, rallocobj, vmlimitobj): Initialize to null,
+	for clarity.
+	(OTHER_OBJ): Remove.
+	(PRE_ALLOC_OBJ, POST_ALLOC_OBJ): New, set by configure.
+	(otherobj): Use PRE_ALLOC_OBJ, POST_ALLOC_OBJ rather than OTHER_OBJ.
+
+2010-05-01  Karel Klíč  <kklic@redhat.com>
+
+	* fileio.c (Ffile_selinux_context): Context functions may return null.
+
+2010-04-30  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* s/gnu.h (POSIX_SIGNALS, START_FILES): New definitions.
+
+2010-04-30  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (vmlimitobj) [!SYSTEM_MALLOC]: New variable.  (Bug#6065)
+	(OTHER_OBJ): Define as a separate variable, for clarity.
+
+2010-04-30  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsettings.c: include limits.h and update file comment.
+
+2010-04-30  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (OLDXMENU, LIBXMENU) [HAVE_MENUS]:
+	Set with configure, not cpp.
+	(LIBW): Remove, replace with $TOOLKIT_LIBW.
+
+	* Makefile.in (mallocobj): Remove.
+	(otherobj): Simplify using @OTHER_OBJ@.
+
+	* Makefile.in (dispnew.o, frame.o, fringe.o, font.o, fontset.o)
+	(keyboard.o, window.o, xdisp.o, xfaces.o, menu.o):
+	Don't bother making nsgui.h dependency platform-specific.
+
+	* Makefile.in (nsfns.o): Remove duplicate nsgui.h dependency.
+
+2010-04-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* process.c (read_process_output, exec_sentinel): Don't burp if the
+	sentinel/filter kills the current buffer (bug#6060).
+
+	Fix wrong-docstring problem introduced with hash-consing.  (Bug#6008)
+	* eval.c (Fautoload): Set doc to a unique number rather than to 0.
+	Remove unused var `args'.
+	* lisp.h (XSETCARFASTINT, XSETCDRFASTINT): Remove.
+	(LOADHIST_ATTACH): Wrap with do...while to avoid surprises for callers.
+	* doc.c (store_function_docstring): Use XSETCAR.
+
+2010-04-28  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (BASE_WINDOW_SUPPORT, X_WINDOW_SUPPORT): New variables.
+	(WINDOW_SUPPORT) [HAVE_WINDOW_SYSTEM]: Use them.
+
+	* Makefile.in (CYGWIN_OBJ): Set with configure, not cpp.
+
+	* Makefile.in (GPM_MOUSE_SUPPORT): New, set by configure.
+	(MOUSE_SUPPORT) [!HAVE_MOUSE]: Use $GPM_MOUSE_SUPPORT.
+
+	* Makefile.in (FONT_OBJ): New, set by configure.
+	(FONT_DRIVERS): Use $FONT_OBJ.
+
+	* Makefile.in (LIBXMU): Set with configure, not cpp.
+	* s/aix4-2.h (LIBXMU):
+	* s/hpux10-20.h (LIBXMU):
+	Remove definition, now set in configure.
+
+	* Makefile.in (NS_OBJ, NS_SUPPORT): Set with configure, not cpp.
+
+	* m/amdx86-64.h [i386]: Move this test to configure.in.
+
 2010-04-27  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (LIBXTR6): Set with configure, not cpp.
@@ -227,7 +480,7 @@
 	(Ftool_bar_get_system_style): New function.
 	(syms_of_xsettings): Define Qmonospace_font_name and
 	Qtool_bar_style.  Initialize current_tool_bar_style to nil.
-	defsubr Stool_bar_get_system_style. Fprovide on
+	defsubr Stool_bar_get_system_style.  Fprovide on
 	dynamic-setting.
 	Move misplaced HAVE_GCONF
 
--- a/src/ChangeLog.4	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/ChangeLog.4	Thu May 06 09:50:39 2010 +0900
@@ -4329,7 +4329,7 @@
 
 1993-11-01  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
-	* s/sunos4-1-3.h (HAVE_TERMIOS): Defined.
+	* s/sunos4-1-3.h (HAVE_TERMIOS): Define.
 
 1993-10-25  Brian J. Fox  (bfox@albert.gnu.ai.mit.edu)
 
@@ -4426,9 +4426,9 @@
 
 	* Makefile.in: File removed.  It is now generated by ../configure.
 
-	* Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end.  This
-	change to ymakefile was mysteriously lost.  Were any others lost
-	too?
+	* Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end.
+	This change to ymakefile was mysteriously lost.
+	Were any others lost too?
 
 1993-10-02  Brian J. Fox  (bfox@ai.mit.edu)
 
@@ -4461,8 +4461,7 @@
 
 1993-09-24  Brian J. Fox  (bfox@ai.mit.edu)
 
-	* textprop.c (validate_plist): Add declaration for `list'
-	argument.
+	* textprop.c (validate_plist): Add declaration for `list' argument.
 
 	* frame.c (Fhandle_switch_frame): Doc fix.
 
@@ -4501,7 +4500,7 @@
 	* doc.c (Fsubstitute_command_keys): Pass new arg.
 	* abbrev.c (Funexpand_abbrev, Fexpand_abbrev): Pass new arg.
 
-	* s/aix3-2.h (AIX3_2): Defined.
+	* s/aix3-2.h (AIX3_2): Define.
 	* m/ibmrs6000.h (LIBS_MACHINE): Include -lrts, -liconv only if AIX3_2.
 
 	* xterm.h (HAVE_X11R4): If AIX, do not define HAVE_X11R4.
@@ -4703,13 +4702,13 @@
 
 	* xfns.c (XScreenNumberOfScreen): New function.
 
-	* m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Defined.
+	* m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Define.
 
 	* m/iris4d.h (START_FILES, LIB_STANDARD): Don't define if USG5_4.
 	(DEFAULT_ENTRY_ADDRESS): Likewise.
 	(UNEXEC): Use unexelfsgi.o if USG5_4.
 
-	* s/irix5-0.h (C_SWITCH_MACHINE): Deleted.
+	* s/irix5-0.h (C_SWITCH_MACHINE): Delete.
 
 1993-08-13  Frederic Pierresteguy  (F.Pierresteguy@frcl.bull.fr)
 
@@ -4809,7 +4808,7 @@
 
 	* m/dpx2.h (HAVE_TCATTR): Macro #defined.
 	(HAVE_CLOSEDIR): #undef to allow use of closedir in sysdep.c.
-	(SIGTSTP): Commented #undef to allow use of ^Z in shell-mode.
+	(SIGTSTP): Comment #undef to allow use of ^Z in shell-mode.
 	(SIGNALS_VIA_CHARACTERS): #defined.
 
 1993-08-09  Paul Eggert  (eggert@twinsun.com)
@@ -4849,10 +4848,10 @@
 	and calculate position properly.
 
 	* s/bsd4-2.h, s/bsd4-3.h, s/umax.h, s/rtu.h, s/dgux.h (HAVE_VFORK):
-	Defined.
+	Define.
 
 	* ymakefile (alloc.o): Don't use DEBUG_MOLE.
-	(DEBUG_MOLE): Deleted.
+	(DEBUG_MOLE): Delete.
 	* gnu-hp300: File deleted.
 
 	* .gdbinit: Don't put -q in args.
@@ -4878,7 +4877,7 @@
 	(main): Call init_buffer, init_callproc and init_cmdargs
 	before init_lread.
 	(syms_of_emacs): Install the function, and protect the variable.
-	* lisp.h (Vinvocation_directory): Declared.
+	* lisp.h (Vinvocation_directory): Declare.
 	* lread.c (init_lread): Normally put Vinvocation_directory
 	at end of Vload_path, if not present already.
 
--- a/src/Makefile.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/Makefile.in	Thu May 06 09:50:39 2010 +0900
@@ -70,12 +70,26 @@
 
 CRT_DIR=@CRT_DIR@
 
+## Machine-specific CFLAGS.
+C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
+## System-specific CFLAGS.
+C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
+## This holds any special options for linking temacs only (ie, not
+## used by configure).
+LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@
+## Next two must come before LD_SWITCH_SYSTEM.
+## If needed, a -R option that says where to find X windows at run time.
+LD_SWITCH_X_SITE_AUX=@LD_SWITCH_X_SITE_AUX@
+## As above, but using -rpath instead.
+LD_SWITCH_X_SITE_AUX_RPATH=@LD_SWITCH_X_SITE_AUX_RPATH@
+
 LIBTIFF=@LIBTIFF@
 LIBJPEG=@LIBJPEG@
 LIBPNG=@LIBPNG@
 LIBGIF=@LIBGIF@
 LIBXPM=@LIBXPM@
 XFT_LIBS=@XFT_LIBS@
+LIBX_EXTRA=$(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) -lX11 $(XFT_LIBS)
 
 DBUS_CFLAGS = @DBUS_CFLAGS@
 DBUS_LIBS = @DBUS_LIBS@
@@ -86,10 +100,16 @@
 
 GTK_OBJ=@GTK_OBJ@
 
+LIBXMU=@LIBXMU@
+
 LIBXSM=@LIBXSM@
 
 LIBXTR6=@LIBXTR6@
 
+## $(LIBXMU) -lXt $(LIBXTR6) -lXext if USE_X_TOOLKIT, else $(LIBXSM).
+## Only used if HAVE_X_WINDOWS.
+LIBXT_OTHER=@LIBXT_OTHER@
+
 XMENU_OBJ=@XMENU_OBJ@
 XOBJ=@XOBJ@
 
@@ -104,6 +124,26 @@
 ## widget.o if USE_X_TOOLKIT, otherwise empty.
 WIDGET_OBJ=@WIDGET_OBJ@
 
+## sheap.o if CYGWIN, otherwise empty.
+CYGWIN_OBJ=@CYGWIN_OBJ@
+
+NS_OBJ=@NS_OBJ@
+NS_SUPPORT=@NS_SUPPORT@
+
+## Only used if HAVE_X_WINDOWS and HAVE_WINDOW_SYSTEM.
+FONT_OBJ=@FONT_OBJ@
+
+## ${lispsource}mouse.elc if HAVE_GPM, otherwise empty.
+## Not used if HAVE_MOUSE.
+GPM_MOUSE_SUPPORT=@GPM_MOUSE_SUPPORT@
+
+BASE_WINDOW_SUPPORT=${lispsource}fringe.elc ${lispsource}image.elc \
+  ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
+  ${lispsource}tool-bar.elc ${lispsource}mwheel.elc
+
+X_WINDOW_SUPPORT=${lispsource}x-dnd.elc ${lispsource}term/common-win.elc \
+  ${lispsource}term/x-win.elc ${lispsource}dynamic-setting.elc
+
 LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
 
 INTERVALS_H = dispextern.h intervals.h composite.h
@@ -145,15 +185,9 @@
 #undef register
 
 /* Some machines do not find the standard C libraries in the usual place.  */
-#ifndef ORDINARY_LINK
-#ifndef LIB_STANDARD
-#define LIB_STANDARD -lc
-#endif
-#else
 #ifndef LIB_STANDARD
 #define LIB_STANDARD
 #endif
-#endif
 
 /* Under GNUstep, putting libc on the link line causes problems. */
 #ifdef NS_IMPL_GNUSTEP
@@ -175,17 +209,6 @@
 #endif /* (defined (BSD_SYSTEM) && !defined (COFF)) */
 #endif /* LD_SWITCH_SYSTEM */
 
-/* This holds special options for linking temacs
-   that should be used for linking anything else.  */
-#ifndef LD_SWITCH_SYSTEM_TEMACS
-#define LD_SWITCH_SYSTEM_TEMACS
-#endif
-
-/* Some m/MACHINE.h files define this to request special switches in ld.  */
-#ifndef LD_SWITCH_MACHINE
-#define LD_SWITCH_MACHINE
-#endif
-
 /* These macros are for switches specifically related to X Windows.  */
 #ifndef LD_SWITCH_X_SITE
 #define LD_SWITCH_X_SITE
@@ -216,7 +239,7 @@
 
 /* C_SWITCH_X_SITE must come before C_SWITCH_X_SYSTEM
    since it may have -I options that should override those two.  */
-ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} @c_switch_machine@ @c_switch_system@ @C_SWITCH_X_SITE@ @C_SWITCH_X_SYSTEM@ ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS}
+ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} ${C_SWITCH_MACHINE} ${C_SWITCH_SYSTEM} @C_SWITCH_X_SITE@ @C_SWITCH_X_SYSTEM@ ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS}
 ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@
 
 .SUFFIXES: .m
@@ -232,55 +255,19 @@
 	$(CC) -c $(CPPFLAGS) $(ALL_OBJC_CFLAGS) $<
 
 #ifdef HAVE_X_WINDOWS
+/* This test needs to say in cpp for the time being, since s/ms-w32.h and
+   s/msdos.h define HAVE_MENUS, possibly overriding configure.  */
 #ifdef HAVE_MENUS
-
-/* The X Menu stuff is present in the X10 distribution, but missing
-   from X11.  If we have X10, just use the installed library;
-   otherwise, use our own copy.  */
-#ifdef HAVE_X11
-#ifdef USE_X_TOOLKIT
-OLDXMENU=${lwlibdir}liblw.a
-LIBXMENU= $(OLDXMENU)
-#else /* not USE_X_TOOLKIT */
-OLDXMENU= ${oldXMenudir}libXMenu11.a
-LIBXMENU= $(OLDXMENU)
-#endif /* not USE_X_TOOLKIT */
-#else /* not HAVE_X11 */
-LIBXMENU= -lXMenu
-#endif /* not HAVE_X11 */
-
+OLDXMENU=@OLDXMENU@
+LIBXMENU=@LIBXMENU@
 #else /* not HAVE_MENUS */
-
-/* Otherwise, do not worry about the menu library at all.  */
+OLDXMENU=
 LIBXMENU=
 #endif /* not HAVE_MENUS */
 
-#ifdef USE_X_TOOLKIT
-LIBW=$(TOOLKIT_LIBW)
-
-#ifndef LIBXMU
-#define LIBXMU -lXmu
-#endif
-
-LIBXT= $(LIBW) LIBXMU -lXt $(LIBXTR6) -lXext
-
-#else /* not USE_X_TOOLKIT */
-
-#ifdef USE_GTK
-LIBW=@GTK_LIBS@
-OLDXMENU=
-LIBXMENU=
-#endif /* USE_GTK */
-
-LIBXT=$(LIBW) $(LIBXSM)
-#endif /* not USE_X_TOOLKIT */
-
-#ifdef HAVE_X11
-X11_LDFLAGS = LD_SWITCH_X_SITE
-LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) $(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) -lX11 $(XFT_LIBS)
-#else /* not HAVE_X11 */
-LIBX= $(LIBXMENU) LD_SWITCH_X_SITE
-#endif /* not HAVE_X11 */
+LIBXT=$(TOOLKIT_LIBW) $(LIBXT_OTHER)
+LIBX_BASE=$(LIBXMENU) LD_SWITCH_X_SITE
+LIBX_OTHER=@LIBX_OTHER@
 #endif /* not HAVE_X_WINDOWS */
 
 #ifndef ORDINARY_LINK
@@ -341,7 +328,7 @@
 /* Flags to pass to LD only for temacs.  */
 /* Do not split this line with a backslash.  That can cause trouble with
    some cpps.  */
-TEMACS_LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_TEMACS LD_SWITCH_MACHINE
+TEMACS_LDFLAGS = LD_SWITCH_SYSTEM $(LD_SWITCH_SYSTEM_TEMACS)
 
 /* A macro which other sections of Makefile can redefine to munge the
    flags before they are passed to LD.  This is helpful if you have
@@ -360,29 +347,16 @@
 #endif
 #endif
 
-#ifdef CYGWIN
-CYGWIN_OBJ = sheap.o
-#endif
-
 #ifdef HAVE_NS
 ns_appdir=@ns_appdir@/
 ns_appbindir=@ns_appbindir@/
 ns_appresdir=@ns_appresdir@/
 ns_appsrc=@ns_appsrc@
-/* Object files for NeXTstep */
-NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
-	fontset.o fringe.o image.o
 #endif  /* HAVE_NS */
 
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef HAVE_X_WINDOWS
-#if defined (HAVE_XFT)
-FONT_DRIVERS = xfont.o ftfont.o xftfont.o ftxfont.o
-#elif defined (HAVE_FREETYPE)
-FONT_DRIVERS = xfont.o ftfont.o ftxfont.o
-#else /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */
-FONT_DRIVERS = xfont.o
-#endif /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */
+FONT_DRIVERS=$(FONT_OBJ)
 #endif /* HAVE_X_WINDOWS */
 #endif /* HAVE_WINDOW_SYSTEM */
 
@@ -428,9 +402,10 @@
 termcapobj = tparam.o
 #endif /* ! defined (TERMINFO) */
 
-
+gmallocobj =
+rallocobj =
+vmlimitobj =
 #ifndef SYSTEM_MALLOC
-
 #ifndef DOUG_LEA_MALLOC
 gmallocobj = gmalloc.o
 #endif
@@ -439,29 +414,23 @@
 rallocobj = ralloc.o
 #endif
 
-mallocobj = $(gmallocobj) $(rallocobj) vm-limit.o
-
-#endif /* SYSTEM_MALLOC */
-
+vmlimitobj = vm-limit.o
+#endif /* !SYSTEM_MALLOC */
 
-/* define otherobj as list of object files that make-docfile
-   should not be told about.  */
-#ifdef CYGWIN
-/* Cygwin differs because of its unexec(). */
-otherobj= $(termcapobj) $(gmallocobj) $(rallocobj) lastfile.o vm-limit.o $(WIDGET_OBJ) $(LIBOBJS)
-#else
-otherobj= $(termcapobj) lastfile.o $(mallocobj) $(WIDGET_OBJ) $(LIBOBJS)
-#endif
+## Empty on Cygwin, lastfile.o elsewhere.
+PRE_ALLOC_OBJ=@PRE_ALLOC_OBJ@
+## lastfile.o vm-limit.o on Cygwin, $vmlimitobj elsewhere.
+POST_ALLOC_OBJ=@POST_ALLOC_OBJ@
+
+/* List of object files that make-docfile should not be told about.  */
+otherobj= $(termcapobj) $(PRE_ALLOC_OBJ) $(gmallocobj) $(rallocobj) \
+  $(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
 
 #ifdef HAVE_MOUSE
 #define MOUSE_SUPPORT ${lispsource}mouse.elc \
   ${lispsource}select.elc ${lispsource}scroll-bar.elc
 #else
-#ifdef HAVE_GPM
-#define MOUSE_SUPPORT ${lispsource}mouse.elc
-#else
-#define MOUSE_SUPPORT
-#endif
+#define MOUSE_SUPPORT $(GPM_MOUSE_SUPPORT)
 #endif
 
 #ifdef MSDOS
@@ -475,15 +444,9 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef HAVE_X_WINDOWS
-#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
- ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
- ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc \
- ${lispsource}term/common-win.elc ${lispsource}term/x-win.elc \
- ${lispsource}dynamic-setting.elc
+#define WINDOW_SUPPORT $(BASE_WINDOW_SUPPORT) $(X_WINDOW_SUPPORT)
 #else
-#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
- ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
- ${lispsource}tool-bar.elc ${lispsource}mwheel.elc
+#define WINDOW_SUPPORT $(BASE_WINDOW_SUPPORT)
 #endif
 #else
 #define WINDOW_SUPPORT
@@ -504,13 +467,6 @@
 #define TOOLTIP_SUPPORT
 #endif
 
-#ifdef HAVE_NS
-#define NS_SUPPORT ${lispsource}emacs-lisp/easymenu.elc \
-  ${lispsource}term/ns-win.elc
-#else
-#define NS_SUPPORT
-#endif
-
 /* This is the platform-specific list of Lisp files loaded into the
    dumped Emacs.  It is arranged like this because it is easier to generate
    it semi-mechanically from loadup.el this way.
@@ -611,7 +567,7 @@
 	MSDOS_SUPPORT \
 	WINNT_SUPPORT \
 	WINDOW_SUPPORT \
-	NS_SUPPORT \
+	${NS_SUPPORT} \
 	${lispsource}widget.elc \
 	${lispsource}window.elc \
 	${lispsource}version.el
@@ -729,8 +685,8 @@
    duplicated symbols.  If the standard libraries were compiled
    with GCC, we might need gnulib again after them.  */
 
-LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) $(DBUS_LIBS) \
-   @LIBGPM@ @LIBRESOLV@ LIBS_SYSTEM LIBS_TERMCAP \
+LIBES = $(LOADLIBES) $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
+   $(RSVG_LIBS) $(DBUS_LIBS) @LIBGPM@ @LIBRESOLV@ LIBS_SYSTEM LIBS_TERMCAP \
    $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \
    @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \
    $(GNULIB_VAR) @LIB_MATH@ LIB_STANDARD $(GNULIB_VAR)
@@ -786,8 +742,8 @@
     ${LIBES}
 #endif
 
-/* We do not use ALL_LDFLAGS because LD_SWITCH_SYSTEM and LD_SWITCH_MACHINE
-   often contain options that have to do with using Emacs''s crt0,
+/* We do not use ALL_LDFLAGS because LD_SWITCH_SYSTEM
+   often contains options that have to do with using Emacs''s crt0,
    which are only good with temacs.  */
 prefix-args${EXEEXT}: prefix-args.o $(config_h)
 	$(CC) $(LDFLAGS) prefix-args.o -o prefix-args
@@ -846,6 +802,14 @@
 
 #ifndef AUTO_DEPEND
 
+## FIXME some of these dependencies are platform-specific.
+## Eg callproc.c only depends on w32.h for WINDOWSNT builds.
+## One way to fix this would be to replace w32.h (etc) by $(W32_H),
+## a variable set by configure.  Doesn't seem worth the trouble.
+
+## nsgui.h: In fact, every .o file depends directly or indirectly on
+## dispextern.h and hence nsgui.h under NS.  But the ones that actually
+## use stuff there are more limited.
 atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \
  $(config_h)
 bidi.o: bidi.c buffer.h character.h dispextern.h lisp.h $(config_h)
@@ -881,7 +845,7 @@
    coding.h regex.h systime.h blockinput.h atimer.h composite.h
 dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \
    window.h buffer.h termchar.h termopts.h termhooks.h cm.h \
-   disptab.h indent.h $(INTERVALS_H) \
+   disptab.h indent.h $(INTERVALS_H) nsgui.h \
    xterm.h blockinput.h atimer.h character.h msdos.h keyboard.h \
    syssignal.h lisp.h $(config_h)
 doc.o: doc.c lisp.h $(config_h) epaths.h buffer.h keyboard.h keymap.h \
@@ -902,18 +866,19 @@
 filemode.o: filemode.c $(config_h)
 frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
    blockinput.h atimer.h systime.h buffer.h character.h fontset.h font.h    \
-   msdos.h dosfns.h dispextern.h w32term.h termchar.h coding.h composite.h \
-   lisp.h $(config_h) termhooks.h ccl.h
-fringe.o: fringe.c dispextern.h frame.h window.h buffer.h termhooks.h \
+   msdos.h dosfns.h dispextern.h w32term.h nsgui.h termchar.h coding.h \
+   composite.h lisp.h $(config_h) termhooks.h ccl.h
+fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \
    blockinput.h atimer.h systime.h lisp.h $(config_h)
 font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \
-   font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h
+   font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h nsgui.h
 ftfont.o: dispextern.h frame.h character.h charset.h composite.h font.h \
    lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h fontset.h \
    ccl.h ftfont.h
 fontset.o: fontset.c fontset.h ccl.h buffer.h character.h \
    charset.h frame.h keyboard.h termhooks.h font.h lisp.h $(config_h) \
-   blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) window.h xterm.h
+   blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) nsgui.h \
+   window.h xterm.h
 getloadavg.o: getloadavg.c $(config_h)
 gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \
   blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \
@@ -929,7 +894,7 @@
 keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \
    commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
    systime.h syntax.h $(INTERVALS_H) blockinput.h atimer.h composite.h \
-   xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h coding.h \
+   xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h nsgui.h coding.h \
    lisp.h $(config_h)
 keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
    atimer.h systime.h puresize.h character.h charset.h $(INTERVALS_H) keymap.h window.h \
@@ -950,7 +915,7 @@
    termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \
    keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h lisp.h $(config_h)
 nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \
-  dispextern.h nsgui.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \
+  dispextern.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \
   atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h)
 nsfont.o: nsterm.h dispextern.h frame.h lisp.h lisp.h $(config_h)
 nsimage.o: nsimage.m nsterm.h lisp.h $(config_h)
@@ -1008,16 +973,16 @@
 window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
    disptab.h keyboard.h msdos.h coding.h termhooks.h \
    keymap.h blockinput.h atimer.h systime.h $(INTERVALS_H) \
-   xterm.h w32term.h nsterm.h lisp.h $(config_h)
+   xterm.h w32term.h nsterm.h nsgui.h lisp.h $(config_h)
 xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \
-   coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h     \
-   charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h xterm.h    \
-   w32term.h nsterm.h msdos.h composite.h fontset.h ccl.h \
+   coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h \
+   charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h \
+   xterm.h w32term.h nsterm.h nsgui.h msdos.h composite.h fontset.h ccl.h \
    blockinput.h atimer.h systime.h keymap.h font.h
 xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h	\
    window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h	\
    systime.h keyboard.h fontset.h w32term.h nsterm.h coding.h ccl.h \
-   $(INTERVALS_H) termchar.h termhooks.h font.h lisp.h $(config_h)
+   $(INTERVALS_H) nsgui.h termchar.h termhooks.h font.h lisp.h $(config_h)
 xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
    $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
    character.h charset.h coding.h gtkutil.h lisp.h $(config_h) termhooks.h \
@@ -1030,7 +995,7 @@
    font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h
 menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \
    dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \
-   lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h
+   lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h nsgui.h
 xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
    charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \
    systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \
@@ -1088,12 +1053,6 @@
    select which of these should be compiled.  */
 
 #ifdef HAVE_NS
-/* In fact, every .o file depends directly or indirectly on dispextern.h
-   and hence nsgui.h under NS.  But the ones that actually use stuff there
-   are more limited.  */
-dispnew.o font.o fontset.o frame.o fringe.o image.o keyboard.o menu.o \
-   window.o xdisp.o xfaces.o: nsgui.h
-
 ${ns_appdir}: ${ns_appsrc}
 	rm -fr ${ns_appdir}
 	mkdir -p ${ns_appdir}
--- a/src/buffer.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/buffer.c	Thu May 06 09:50:39 2010 +0900
@@ -1547,7 +1547,7 @@
       Lisp_Object tem;
       tem = Fsymbol_value (intern ("delete-auto-save-files"));
       if (! NILP (tem))
-	internal_delete_file (b->auto_save_file_name);
+	internal_delete_file (b->auto_save_file_name, Qt);
     }
 
   if (b->base_buffer)
--- a/src/callproc.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/callproc.c	Thu May 06 09:50:39 2010 +0900
@@ -91,7 +91,7 @@
 #endif
 
 #ifdef HAVE_SETPGID
-#if !defined (USG) || defined (BSD_PGRPS)
+#if !defined (USG)
 #undef setpgrp
 #define setpgrp setpgid
 #endif
@@ -581,7 +581,7 @@
 #ifdef HAVE_SETSID
         setsid ();
 #endif
-#if defined (USG) && !defined (BSD_PGRPS)
+#if defined (USG)
         setpgrp ();
 #else
         setpgrp (pid, pid);
@@ -856,7 +856,7 @@
   /* Suppress jka-compr handling, etc.  */
   int count = SPECPDL_INDEX ();
   specbind (intern ("file-name-handler-alist"), Qnil);
-  internal_delete_file (name);
+  internal_delete_file (name, Qt);
   unbind_to (count, Qnil);
   return Qnil;
 }
@@ -1251,7 +1251,7 @@
 #endif /* not MSDOS */
 #endif /* not WINDOWSNT */
 
-#if defined(USG) && !defined(BSD_PGRPS)
+#if defined(USG)
 #ifndef SETPGRP_RELEASES_CTTY
   setpgrp ();			/* No arguments but equivalent in this case */
 #endif
--- a/src/config.in	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/config.in	Thu May 06 09:50:39 2010 +0900
@@ -807,10 +807,6 @@
    its own, you might want to add "-L/..." or something similar. */
 #undef LD_SWITCH_X_SITE
 
-/* Define LD_SWITCH_X_SITE_AUX with an -R option in case it's needed (for
-   Solaris, for example). */
-#undef LD_SWITCH_X_SITE_AUX
-
 /* Define to 1 if localtime caches TZ. */
 #undef LOCALTIME_CACHE
 
--- a/src/doc.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/doc.c	Thu May 06 09:50:39 2010 +0900
@@ -538,7 +538,7 @@
 	{
 	  tem = Fcdr (Fcdr (fun));
 	  if (CONSP (tem) && INTEGERP (XCAR (tem)))
-	    XSETCARFASTINT (tem, offset);
+	    XSETCAR (tem, make_number (offset));
 	}
       else if (EQ (tem, Qmacro))
 	store_function_docstring (XCDR (fun), offset);
--- a/src/emacs.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/emacs.c	Thu May 06 09:50:39 2010 +0900
@@ -81,7 +81,7 @@
 #endif
 
 #ifdef HAVE_SETPGID
-#if !defined (USG) || defined (BSD_PGRPS)
+#if !defined (USG)
 #undef setpgrp
 #define setpgrp setpgid
 #endif
@@ -193,11 +193,6 @@
    data on the first attempt to change it inside asynchronous code.  */
 int running_asynch_code;
 
-#ifdef BSD_PGRPS
-/* See sysdep.c.  */
-extern int inherited_pgroup;
-#endif
-
 #if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
 /* If non-zero, -d was specified, meaning we're using some window system.  */
 int display_arg;
@@ -268,6 +263,7 @@
 Initialization options:\n\
 \n\
 --batch                     do not do interactive display; implies -q\n\
+--chdir DIR                 change to directory DIR\n\
 --daemon                    start a server in the background\n\
 --debug-init                enable Emacs Lisp debugger for init file\n\
 --display, -d DISPLAY       use X server DISPLAY\n\
@@ -385,6 +381,9 @@
     {
       fatal_error_in_progress = 1;
 
+      if (sig == SIGTERM || sig == SIGHUP)
+        Fkill_emacs (make_number (sig));
+
       shut_down_emacs (sig, 0, Qnil);
     }
 
@@ -765,6 +764,7 @@
 #ifdef NS_IMPL_COCOA
   char dname_arg2[80];
 #endif
+  char *ch_to_dir;
 
 #if GC_MARK_STACK
   extern Lisp_Object *stack_base;
@@ -832,6 +832,14 @@
 	  exit (0);
 	}
     }
+  if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args))
+      if (chdir (ch_to_dir) == -1)
+        {
+          fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+                   argv[0], ch_to_dir, strerror (errno));
+          exit (1);
+        }
+
 
 #ifdef HAVE_PERSONALITY_LINUX32
   if (!initialized
@@ -1174,17 +1182,9 @@
 
   if (! noninteractive)
     {
-#ifdef BSD_PGRPS
-      if (initialized)
-	{
-	  inherited_pgroup = EMACS_GETPGRP (0);
-	  setpgrp (0, getpid ());
-	}
-#else
 #if defined (USG5) && defined (INTERRUPT_INPUT)
       setpgrp ();
 #endif
-#endif
 #if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
       {
 	extern void malloc_enable_thread P_ ((void));
@@ -1802,6 +1802,7 @@
 const struct standard_args standard_args[] =
 {
   { "-version", "--version", 150, 0 },
+  { "-chdir", "--chdir", 130, 1 },
   { "-t", "--terminal", 120, 1 },
   { "-nw", "--no-window-system", 110, 0 },
   { "-nw", "--no-windows", 110, 0 },
--- a/src/eval.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/eval.c	Thu May 06 09:50:39 2010 +0900
@@ -770,11 +770,8 @@
   sym = XSYMBOL (new_alias);
 
   if (sym->constant)
-    if (sym->redirect == SYMBOL_VARALIAS)
-      sym->constant = 0;	/* Reset.  */
-    else
-      /* Not sure why.  */
-      error ("Cannot make a constant an alias");
+    /* Not sure why, but why not?  */
+    error ("Cannot make a constant an alias");
 
   switch (sym->redirect)
     {
@@ -1563,17 +1560,64 @@
   return val;
 }
 
+/* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as
+   its arguments.  */
+
+Lisp_Object
+internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
+			   Lisp_Object arg1,
+			   Lisp_Object arg2,
+			   Lisp_Object handlers,
+			   Lisp_Object (*hfun) (Lisp_Object))
+{
+  Lisp_Object val;
+  struct catchtag c;
+  struct handler h;
+
+  /* Since Fsignal will close off all calls to x_catch_errors,
+     we will get the wrong results if some are not closed now.  */
+#if HAVE_X_WINDOWS
+  if (x_catching_errors ())
+    abort ();
+#endif
+
+  c.tag = Qnil;
+  c.val = Qnil;
+  c.backlist = backtrace_list;
+  c.handlerlist = handlerlist;
+  c.lisp_eval_depth = lisp_eval_depth;
+  c.pdlcount = SPECPDL_INDEX ();
+  c.poll_suppress_count = poll_suppress_count;
+  c.interrupt_input_blocked = interrupt_input_blocked;
+  c.gcpro = gcprolist;
+  c.byte_stack = byte_stack_list;
+  if (_setjmp (c.jmp))
+    {
+      return (*hfun) (c.val);
+    }
+  c.next = catchlist;
+  catchlist = &c;
+  h.handler = handlers;
+  h.var = Qnil;
+  h.next = handlerlist;
+  h.tag = &c;
+  handlerlist = &h;
+
+  val = (*bfun) (arg1, arg2);
+  catchlist = c.next;
+  handlerlist = h.next;
+  return val;
+}
 
 /* Like internal_condition_case but call BFUN with NARGS as first,
    and ARGS as second argument.  */
 
 Lisp_Object
-internal_condition_case_2 (bfun, nargs, args, handlers, hfun)
-     Lisp_Object (*bfun) ();
-     int nargs;
-     Lisp_Object *args;
-     Lisp_Object handlers;
-     Lisp_Object (*hfun) ();
+internal_condition_case_n (Lisp_Object (*bfun) (int, Lisp_Object*),
+			   int nargs,
+			   Lisp_Object *args,
+			   Lisp_Object handlers,
+			   Lisp_Object (*hfun) (Lisp_Object))
 {
   Lisp_Object val;
   struct catchtag c;
@@ -2134,8 +2178,6 @@
      (function, file, docstring, interactive, type)
      Lisp_Object function, file, docstring, interactive, type;
 {
-  Lisp_Object args[4];
-
   CHECK_SYMBOL (function);
   CHECK_STRING (file);
 
@@ -2151,8 +2193,11 @@
     LOADHIST_ATTACH (Fcons (Qautoload, function));
   else
     /* We don't want the docstring in purespace (instead,
-       Snarf-documentation should (hopefully) overwrite it).  */
-    docstring = make_number (0);
+       Snarf-documentation should (hopefully) overwrite it).
+       We used to use 0 here, but that leads to accidental sharing in
+       purecopy's hash-consing, so we use a (hopefully) unique integer
+       instead.  */
+    docstring = make_number (XHASH (function));
   return Ffset (function,
 		Fpurecopy (list5 (Qautoload, file, docstring,
 				  interactive, type)));
--- a/src/fileio.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/fileio.c	Thu May 06 09:50:39 2010 +0900
@@ -2194,11 +2194,17 @@
   return Qnil;
 }
 
-DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 1, "fDelete file: ",
+DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, "fDelete file: \nP",
        doc: /* Delete file named FILENAME.  If it is a symlink, remove the symlink.
-If file has multiple names, it continues to exist with the other names.  */)
-     (filename)
+If file has multiple names, it continues to exist with the other names.
+
+If optional arg FORCE is non-nil, really delete the file regardless of
+`delete-by-moving-to-trash'.  Otherwise, \"deleting\" actually moves
+it to the system's trash can if `delete-by-moving-to-trash' is non-nil.
+Interactively, FORCE is non-nil if called with a prefix arg.  */)
+     (filename, force)
      Lisp_Object filename;
+     Lisp_Object force;
 {
   Lisp_Object handler;
   Lisp_Object encoded_file;
@@ -2217,7 +2223,7 @@
   if (!NILP (handler))
     return call2 (handler, Qdelete_file, filename);
 
-  if (delete_by_moving_to_trash)
+  if (delete_by_moving_to_trash && NILP (force))
     return call1 (Qmove_file_to_trash, filename);
 
   encoded_file = ENCODE_FILE (filename);
@@ -2234,14 +2240,15 @@
   return Qt;
 }
 
-/* Delete file FILENAME, returning 1 if successful and 0 if failed.  */
+/* Delete file FILENAME, returning 1 if successful and 0 if failed.
+   FORCE means to ignore `delete-by-moving-to-trash'.  */
 
 int
-internal_delete_file (filename)
-     Lisp_Object filename;
+internal_delete_file (Lisp_Object filename, Lisp_Object force)
 {
   Lisp_Object tem;
-  tem = internal_condition_case_1 (Fdelete_file, filename,
+
+  tem = internal_condition_case_2 (Fdelete_file, filename, force,
 				   Qt, internal_delete_file_1);
   return NILP (tem);
 }
@@ -2335,7 +2342,7 @@
 	      )
 	    call2 (Qdelete_directory, file, Qt);
 	  else
-	    Fdelete_file (file);
+	    Fdelete_file (file, Qt);
 	  unbind_to (count, Qnil);
 	}
       else
@@ -2918,10 +2925,14 @@
       if (conlength > 0)
 	{
 	  context = context_new (con);
-	  values[0] = build_string (context_user_get (context));
-	  values[1] = build_string (context_role_get (context));
-	  values[2] = build_string (context_type_get (context));
-	  values[3] = build_string (context_range_get (context));
+	  if (context_user_get (context))
+	    values[0] = build_string (context_user_get (context));
+	  if (context_role_get (context))
+	    values[1] = build_string (context_role_get (context));
+	  if (context_type_get (context))
+	    values[2] = build_string (context_type_get (context));
+	  if (context_range_get (context))
+	    values[3] = build_string (context_range_get (context));
 	  context_free (context);
 	}
       if (con)
--- a/src/lisp.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/lisp.h	Thu May 06 09:50:39 2010 +0900
@@ -721,11 +721,6 @@
 #define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n))
 #define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n))
 
-/* For performance: Fast storage of positive integers into the
-   fields of a cons cell.  See above caveats.  */
-#define XSETCARFASTINT(c,n)  XSETFASTINT(XCAR_AS_LVALUE(c),(n))
-#define XSETCDRFASTINT(c,n)  XSETFASTINT(XCDR_AS_LVALUE(c),(n))
-
 /* Take the car or cdr of something whose type is not known.  */
 #define CAR(c)					\
  (CONSP ((c)) ? XCAR ((c))			\
@@ -2821,7 +2816,9 @@
 extern Lisp_Object make_symbol P_ ((char *));
 extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int));
 #define LOADHIST_ATTACH(x) \
- if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list)
+  do {									\
+    if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \
+  } while (0)
 extern Lisp_Object Vcurrent_load_list;
 extern Lisp_Object Vload_history, Vload_suffixes, Vload_file_rep_suffixes;
 extern int openp P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
@@ -2904,7 +2901,8 @@
 extern Lisp_Object internal_lisp_condition_case P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
 extern Lisp_Object internal_condition_case P_ ((Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)));
 extern Lisp_Object internal_condition_case_1 P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)));
-extern Lisp_Object internal_condition_case_2 P_ ((Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)));
+extern Lisp_Object internal_condition_case_2 P_ ((Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)));
+extern Lisp_Object internal_condition_case_n P_ ((Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)));
 extern void specbind P_ ((Lisp_Object, Lisp_Object));
 extern void record_unwind_protect P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object));
 extern Lisp_Object unbind_to P_ ((int, Lisp_Object));
@@ -3062,7 +3060,7 @@
 EXFUN (Fread_file_name, 6);
 extern Lisp_Object close_file_unwind P_ ((Lisp_Object));
 extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN;
-extern int internal_delete_file P_ ((Lisp_Object));
+extern int internal_delete_file P_ ((Lisp_Object, Lisp_Object));
 extern void syms_of_fileio P_ ((void));
 extern Lisp_Object make_temp_name P_ ((Lisp_Object, int));
 EXFUN (Fmake_symbolic_link, 3);
--- a/src/m/alpha.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/m/alpha.h	Thu May 06 09:50:39 2010 +0900
@@ -77,16 +77,6 @@
 /* #define SYSTEM_MALLOC */
 
 #ifdef __ELF__
-/* With ELF, make sure that all common symbols get allocated to in the
-   data section.  Otherwise, the dump of temacs may miss variables in
-   the shared library that have been initialized.  For example, with
-   GNU libc, __malloc_initialized would normally be resolved to the
-   shared library's .bss section, which is fatal.  */
-# ifdef __GNUC__
-#  define C_SWITCH_MACHINE	-fno-common
-# else
-#  error What gives?  Fix me if DEC Unix supports ELF now.
-# endif
 
 #undef UNEXEC
 #define UNEXEC unexelf.o
--- a/src/m/amdx86-64.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/m/amdx86-64.h	Thu May 06 09:50:39 2010 +0900
@@ -17,15 +17,6 @@
 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 i386
-/* Although we're running on an amd64 kernel, we're actually compiling for
-   the x86 architecture.  The user should probably have provided an
-   explicit --build to `configure', but if everything else than the kernel
-   is running in i386 mode, then the bug is really ours: we should have
-   guessed better.  */
-#include "m/intel386.h"
-#else
-
 /* The following line tells the configuration script what sort of
    operating system this machine is likely to run.
    USUAL-OPSYS="linux"  */
@@ -67,30 +58,5 @@
 /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
 #undef DATA_SEG_BITS
 
-
-/* For GNU_LINUX,  __OpenBSD__, __NetBSD__, __APPLE__, things are set
-   correctly in s/gnu-linux.h, netbsd.h, darwin.h.  */
-#ifdef SOLARIS2
-#undef START_FILES
-#undef LIB_STANDARD
-#elif defined (__FreeBSD__) || (defined (DARWIN_OS) && !defined (__APPLE__))
-/* On FreeBSD, the libraries for binaries native to the build host's
-   architecture are installed under /usr/lib, and the ones that need
-   special paths are 32-bit compatibility libraries (installed under
-   /usr/lib32).  So to build a native binary of Emacs on FreeBSD/amd64
-   we can just point to /usr/lib (the default $CRT_DIR).  */
-#undef START_FILES
-#define START_FILES pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o
-/* The duplicate -lgcc is intentional in the definition of LIB_STANDARD.
-   The reason is that some functions in libgcc.a call functions from libc.a,
-   and some libc.a functions need functions from libgcc.a.  Since most
-   versions of ld are one-pass linkers, we need to mention -lgcc twice,
-   or else we risk getting unresolved externals.  */
-#undef LIB_STANDARD
-#define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtn.o
-
-#endif /* SOLARIS2 */
-#endif /* !i386 */
-
 /* arch-tag: 8a5e001d-e12e-4692-a3a6-0b15ba271c6e
    (do not change this comment) */
--- a/src/m/ibmrs6000.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/m/ibmrs6000.h	Thu May 06 09:50:39 2010 +0900
@@ -25,8 +25,6 @@
 /* Now define a symbol for the cpu type, if your compiler
    does not define it automatically.  */
 
-#define IBMR2AIX
-
 /* The data segment in this machine always starts at address 0x20000000.
    An address of data cannot be stored correctly in a Lisp object;
    we always lose the high bits.  We must tell XPNTR to add them back.  */
@@ -36,16 +34,6 @@
 #define WORDS_BIG_ENDIAN
 #define DATA_SEG_BITS 0x20000000
 
-/* sfreed@unm.edu says add -bI:/usr/lpp/X11/bin/smt.exp for AIX 3.2.4.  */
-/* marc@sti.com (Marc Pawliger) says ibmrs6000.inp is needed to avoid
-   linker error for updated X11R5 libraries, which references pthread library
-   which most machines don't have.  We use the name .inp instead of .imp
-   because .inp is a better convention to use in make-dist for naming
-   random input files.  */
-#ifdef THIS_IS_MAKEFILE /* Don't use this in configure.  */
-#define LD_SWITCH_MACHINE -Wl,-bnodelcsect
-#endif /* THIS_IS_MAKEFILE */
-
 #ifndef NLIST_STRUCT
 /* AIX supposedly doesn't use this interface, but on the RS/6000
    it apparently does.  */
--- a/src/m/ibmrs6000.inp	Wed Apr 28 10:00:38 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-#!
-pthread_yield
-
-# arch-tag: fc6d01ea-c488-4862-bbdb-e8d3e0f6fdb3
--- a/src/m/iris4d.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/m/iris4d.h	Thu May 06 09:50:39 2010 +0900
@@ -42,15 +42,6 @@
 #define DATA_START 0x10000000
 #define DATA_SEG_BITS	0x10000000
 
-/* Use terminfo instead of termcap.  */
-
-#define TERMINFO
-
-/* Letter to use in finding device name of first pty,
-  if system supports pty's.  'a' means it is /dev/ptya0  */
-
-#undef FIRST_PTY_LETTER
-#define FIRST_PTY_LETTER 'q'
 
 #if _MIPS_SZLONG != 64
 /* fixme: should there be 64-bit definitions?  (The ones below aren't OK.)  */
--- a/src/m/sparc.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/m/sparc.h	Thu May 06 09:50:39 2010 +0900
@@ -52,7 +52,6 @@
 
 #ifdef __arch64__		/* GCC, 64-bit ABI.  */
 #define BITS_PER_LONG 64
-#endif
 
 #ifndef _LP64
 #define _LP64			/* Done on Alpha -- not sure if it
--- a/src/msdos.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/msdos.c	Thu May 06 09:50:39 2010 +0900
@@ -4458,8 +4458,6 @@
 
 #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
 
-#ifdef POSIX_SIGNALS
-
 /* Augment DJGPP library POSIX signal functions.  This is needed
    as of DJGPP v2.01, but might be in the library in later releases. */
 
@@ -4557,12 +4555,6 @@
   return 0;
 }
 
-#else /* not POSIX_SIGNALS */
-
-sigsetmask (x) int x; { return 0; }
-sigblock (mask) int mask; { return 0; }
-
-#endif /* not POSIX_SIGNALS */
 #endif /* not __DJGPP_MINOR__ < 2 */
 
 #ifndef HAVE_SELECT
--- a/src/process.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/process.c	Thu May 06 09:50:39 2010 +0900
@@ -1866,7 +1866,6 @@
 #if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
   int wait_child_setup[2];
 #endif
-#ifdef POSIX_SIGNALS
   sigset_t procmask;
   sigset_t blocked;
   struct sigaction sigint_action;
@@ -1874,7 +1873,6 @@
 #ifdef AIX
   struct sigaction sighup_action;
 #endif
-#endif /* POSIX_SIGNALS */
   /* Use volatile to protect variables from being clobbered by longjmp.  */
   volatile int forkin, forkout;
   volatile int pty_flag = 0;
@@ -1979,7 +1977,6 @@
 
   /* Delay interrupts until we have a chance to store
      the new fork's pid in its process structure */
-#ifdef POSIX_SIGNALS
   sigemptyset (&blocked);
 #ifdef SIGCHLD
   sigaddset (&blocked, SIGCHLD);
@@ -1996,13 +1993,6 @@
 #endif
 #endif /* HAVE_WORKING_VFORK */
   sigprocmask (SIG_BLOCK, &blocked, &procmask);
-#else /* !POSIX_SIGNALS */
-#ifdef SIGCHLD
-#if defined (BSD_SYSTEM)
-  sigsetmask (sigmask (SIGCHLD));
-#endif /* BSD_SYSTEM */
-#endif /* SIGCHLD */
-#endif /* !POSIX_SIGNALS */
 
   FD_SET (inchannel, &input_wait_mask);
   FD_SET (inchannel, &non_keyboard_wait_mask);
@@ -2153,15 +2143,7 @@
 	signal (SIGQUIT, SIG_DFL);
 
 	/* Stop blocking signals in the child.  */
-#ifdef POSIX_SIGNALS
 	sigprocmask (SIG_SETMASK, &procmask, 0);
-#else /* !POSIX_SIGNALS */
-#ifdef SIGCHLD
-#if defined (BSD_SYSTEM)
-	sigsetmask (SIGEMPTYMASK);
-#endif /* BSD_SYSTEM */
-#endif /* SIGCHLD */
-#endif /* !POSIX_SIGNALS */
 
 	if (pty_flag)
 	  child_setup_tty (xforkout);
@@ -2243,7 +2225,6 @@
 
   /* Restore the signal state whether vfork succeeded or not.
      (We will signal an error, below, if it failed.)  */
-#ifdef POSIX_SIGNALS
 #ifdef HAVE_WORKING_VFORK
   /* Restore the parent's signal handlers.  */
   sigaction (SIGINT, &sigint_action, 0);
@@ -2254,13 +2235,6 @@
 #endif /* HAVE_WORKING_VFORK */
   /* Stop blocking signals in the parent.  */
   sigprocmask (SIG_SETMASK, &procmask, 0);
-#else /* !POSIX_SIGNALS */
-#ifdef SIGCHLD
-#if defined (BSD_SYSTEM)
-  sigsetmask (SIGEMPTYMASK);
-#endif /* BSD_SYSTEM */
-#endif /* SIGCHLD */
-#endif /* !POSIX_SIGNALS */
 
   /* Now generate the error if vfork failed.  */
   if (pid < 0)
@@ -5396,7 +5370,7 @@
   /* There's no good reason to let process filters change the current
      buffer, and many callers of accept-process-output, sit-for, and
      friends don't expect current-buffer to be changed from under them.  */
-  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
 
   /* Read and dispose of the process output.  */
   outstream = p->filter;
@@ -6814,7 +6788,7 @@
   /* There's no good reason to let sentinels change the current
      buffer, and many callers of accept-process-output, sit-for, and
      friends don't expect current-buffer to be changed from under them.  */
-  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
 
   sentinel = p->sentinel;
   if (NILP (sentinel))
--- a/src/s/aix4-2.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/aix4-2.h	Thu May 06 09:50:39 2010 +0900
@@ -1,6 +1,6 @@
 /*
-Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-  Free Software Foundation, Inc.
+Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+  2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -100,6 +100,7 @@
 #define LIBS_SYSTEM -lrts -lIM -liconv
 #endif
 
+
 /* Use terminfo instead of termcap.  */
 
 #define TERMINFO
@@ -114,13 +115,6 @@
 /* AIX doesn't define this.  */
 #define unix 1
 
-#ifndef __GNUC__
-/* Some programs in src produce warnings saying certain subprograms
-   are to comples and need a MAXMEM value greater than 2000 for
-   additional optimization.  --nils@exp-math.uni-essen.de */
-#define C_SWITCH_SYSTEM -ma -qmaxmem=4000
-#endif
-
 /* string.h defines rindex as a macro, at least with native cc, so we
    lose declaring char * rindex without this.
    It is just a guess which versions of AIX need this definition.  */
@@ -132,12 +126,9 @@
 #define CLASH_DETECTION
 
 /* Perry Smith <pedz@ddivt1.austin.ibm.com> says these are correct.  */
-#define POSIX_SIGNALS
 #undef sigmask
 
 #ifndef HAVE_LIBXMU
-#define LIBXMU
-
 /* Unfortunately without libXmu we cannot support EditRes.  */
 #define NO_EDITRES
 #endif
@@ -153,8 +144,8 @@
    It is possible to completely override the malloc implementation on
    AIX, but that involves putting the malloc functions in a shared
    library and setting the MALLOCTYPE environment variable to point to
-   tha shared library.
-   
+   that shared library.
+
    Emacs currently calls xrealloc on the results of get_current_dir name,
    to avoid a crash just use the Emacs implementation for that function.
 */
--- a/src/s/bsd-common.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/bsd-common.h	Thu May 06 09:50:39 2010 +0900
@@ -48,9 +48,6 @@
 
 #define SYSV_SYSTEM_DIR
 
-/* POSIX-style pgrp behavior.  */
-#undef BSD_PGRPS
-
 #define UNEXEC unexelf.o
 
 /* If the system's imake configuration file defines `NeedWidePrototypes'
--- a/src/s/cygwin.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/cygwin.h	Thu May 06 09:50:39 2010 +0900
@@ -104,7 +104,6 @@
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 #define SYSV_SYSTEM_DIR 1
 #define UNEXEC unexcw.o
-#define POSIX_SIGNALS 1
 #define LINKER $(CC)
 
 /* Use terminfo instead of termcap.  Fewer environment variables to
--- a/src/s/darwin.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/darwin.h	Thu May 06 09:50:39 2010 +0900
@@ -163,13 +163,8 @@
 /* Definitions for how to compile & link.  */
 
 #ifdef HAVE_NS
-#define LIBS_NSGUI -framework AppKit
 #define SYSTEM_PURESIZE_EXTRA 200000
-#define HEADERPAD_EXTRA 6C8
-#else /* !HAVE_NS */
-#define LIBS_NSGUI
-#define HEADERPAD_EXTRA 690
-#endif /* !HAVE_NS */
+#endif
 
 /* On Darwin, res_init appears not to be useful: see bug#562 and
    http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html  */
@@ -177,12 +172,6 @@
 #undef HAVE_RES_INIT
 #undef HAVE_LIBRESOLV
 
-/* The -headerpad option tells ld (see man page) to leave room at the
-   end of the header for adding load commands.  Needed for dumping.
-   0x690 is the total size of 30 segment load commands (at 56
-   each); under Cocoa 31 commands are required.  */
-#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA
-
 #ifdef emacs
 #define malloc unexec_malloc
 #define realloc unexec_realloc
@@ -226,10 +215,6 @@
    ioctl TIOCSCTTY.  */
 #define DONT_REOPEN_PTY
 
-/* This makes create_process in process.c save and restore signal
-   handlers correctly.  Suggested by Nozomu Ando.*/
-#define POSIX_SIGNALS
-
 /* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the
    stack.  */
 #define GC_MARK_STACK   GC_MAKE_GCPROS_NOOPS
--- a/src/s/freebsd.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/freebsd.h	Thu May 06 09:50:39 2010 +0900
@@ -101,10 +101,5 @@
 
 #define USE_MMAP_FOR_BUFFERS	1
 
-/* Use sigprocmask(2) and friends instead of sigblock(2); the man page
-   of sigblock says it is obsolete.  */
-
-#define POSIX_SIGNALS		1
-
 /* arch-tag: 426529ca-b7c4-448f-b10a-d4dcdc9c78eb
    (do not change this comment) */
--- a/src/s/gnu-linux.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/gnu-linux.h	Thu May 06 09:50:39 2010 +0900
@@ -1,6 +1,7 @@
 /* This file is the configuration file for Linux-based GNU systems
    Copyright (C) 1985, 1986, 1992, 1994, 1996, 1999, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+                 2005, 2006, 2007, 2008, 2009, 2010
+                 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -171,12 +172,12 @@
 #define START_FILES pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o
 
 /* Here is how to find X Windows.  LD_SWITCH_X_SITE_AUX gives an -R option
-   says where to find X windows at run time.  */
+   that says where to find X windows at run time.  */
 
 #ifdef __mips__
-#define LD_SWITCH_SYSTEM -G 0 LD_SWITCH_X_SITE_AUX
+#define LD_SWITCH_SYSTEM -G 0 $(LD_SWITCH_X_SITE_AUX)
 #else
-#define LD_SWITCH_SYSTEM LD_SWITCH_X_SITE_AUX
+#define LD_SWITCH_SYSTEM $(LD_SWITCH_X_SITE_AUX)
 #endif /* __mips__ */
 
 #ifdef emacs
@@ -186,17 +187,11 @@
 #define SYSV_SYSTEM_DIR       /* use dirent.h */
 
 #define POSIX                 /* affects getpagesize.h and systty.h */
-#define POSIX_SIGNALS
 
 #undef LIB_GCC
 #define LIB_GCC
 #define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtn.o
 
-/* _BSD_SOURCE is redundant, at least in glibc2, since we define
-   _GNU_SOURCE.  Left in in case it's relevant to libc5 systems and
-   anyone's still using Emacs on those.  --fx 2002-12-14  */
-/* #define C_SWITCH_SYSTEM -D_BSD_SOURCE */
-
 #ifdef HAVE_LIBNCURSES
 #define TERMINFO
 #define LIBS_TERMCAP -lncurses
@@ -211,11 +206,6 @@
 #define HAVE_XRMSETDATABASE
 #endif
 
-/* Use BSD process groups, but use setpgid() instead of setpgrp() to
-   actually set a process group. */
-/* Interesting: only GNU/Linux defines this,  but the BSDs do not... */
-/* #define BSD_PGRPS */
-
 #define NARROWPROTO 1
 
 /* Use mmap directly for allocating larger buffers.  */
--- a/src/s/gnu.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/gnu.h	Thu May 06 09:50:39 2010 +0900
@@ -44,6 +44,8 @@
 #define ORDINARY_LINK
 #define DATA_START ({ extern int data_start; (char *) &data_start; })
 
+#define START_FILES
+
 /* Some losing code fails to include this and then assumes
    that because it is braindead that O_RDONLY==0.  */
 #ifndef NOT_C_CODE
--- a/src/s/hpux10-20.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/hpux10-20.h	Thu May 06 09:50:39 2010 +0900
@@ -105,12 +105,6 @@
 /* This triggers a conditional in xfaces.c.  */
 #define XOS_NEEDS_TIME_H
 
-#ifndef HAVE_LIBXMU
-/* HP-UX doesn't supply Xmu.  */
-#define LIBXMU
-
-#endif
-
 /* Assar Westerlund <assar@sics.se> says this is necessary for
    HP-UX 10.20, and that it works for HP-UX 0 as well.  */
 #define NO_EDITRES
@@ -140,6 +134,8 @@
 
 #define LIBS_SYSTEM -l:libdld.sl
 
+#define LIB_STANDARD -lc
+
 /* Rainer Malzbender <rainer@displaytech.com> says definining
    HAVE_XRMSETDATABASE allows Emacs to compile on HP-UX 10.20
    using GCC.  */
@@ -160,9 +156,6 @@
 
 #undef _FILE_OFFSET_BITS
 
-/* otherwise sigunblock wont be defined */
-#define POSIX_SIGNALS
-
 /* 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
--- a/src/s/hpux11.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/hpux11.h	Thu May 06 09:50:39 2010 +0900
@@ -1,10 +1,5 @@
 #include "hpux10-20.h"
 
-#ifdef POSIX_SIGNALS
-#undef POSIX_SIGNALS
-#endif
-#define POSIX_SIGNALS 1
-
 /* SA_RESTART resets the timeout of `select', so don't use it.  */
 #define BROKEN_SA_RESTART
 
--- a/src/s/irix6-5.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/irix6-5.h	Thu May 06 09:50:39 2010 +0900
@@ -44,6 +44,16 @@
 /* Make process_send_signal work by "typing" a signal character on the pty.  */
 #define SIGNALS_VIA_CHARACTERS
 
+/* Use terminfo instead of termcap.  */
+
+#define TERMINFO
+
+/* Letter to use in finding device name of first pty,
+  if system supports pty's.  'a' means it is /dev/ptya0  */
+
+#undef FIRST_PTY_LETTER
+#define FIRST_PTY_LETTER 'q'
+
 /* No need to use sprintf to get the tty name--we get that from _getpty.  */
 #define PTY_TTY_NAME_SPRINTF
 /* No need to get the pty name at all.  */
--- a/src/s/ms-w32.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/ms-w32.h	Thu May 06 09:50:39 2010 +0900
@@ -123,6 +123,16 @@
 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
 
+#include <sys/types.h>
+struct sigaction {
+  int sa_flags;
+  void (*sa_handler)(int);
+  sigset_t sa_mask;
+};
+#define SIG_BLOCK       1
+#define SIG_SETMASK     2
+#define SIG_UNBLOCK     3
+
 /* The null device on Windows NT. */
 #define NULL_DEVICE     "NUL:"
 
--- a/src/s/msdos.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/msdos.h	Thu May 06 09:50:39 2010 +0900
@@ -128,9 +128,6 @@
 /* Mode line description of a buffer's type.  */
 #define MODE_LINE_BINARY_TEXT(buf) (NILP(buf->buffer_file_type) ? "T" : "B")
 
-/* Do we have POSIX signals?  */
-#define POSIX_SIGNALS
-
 /* We have (the code to control) a mouse.  */
 #define HAVE_MOUSE
 
--- a/src/s/netbsd.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/netbsd.h	Thu May 06 09:50:39 2010 +0900
@@ -43,11 +43,9 @@
 
 #define AMPERSAND_FULL_NAME
 
-/* Here is how to find X Windows.  LD_SWITCH_X_SITE_AUX gives an -R option
-   says where to find X windows at run time.  We convert it to a -rpath option
-   which is what OSF1 uses.  */
-#define LD_SWITCH_SYSTEM_tmp `echo LD_SWITCH_X_SITE_AUX | sed -e 's/-R/-Wl,-rpath,/'`
-#define LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_tmp -Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib
+/* LD_SWITCH_X_SITE_AUX_RPATH gives a -rpath option (which is what
+   OSF1 uses) that says where to find X windows at run time.  */
+#define LD_SWITCH_SYSTEM $(LD_SWITCH_X_SITE_AUX_RPATH) -Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib
 
 /* On post 1.3 releases of NetBSD, gcc -nostdlib also clears
    the library search parth, i.e. it won't search /usr/lib
@@ -82,10 +80,5 @@
 
 #define GC_MARK_STACK	GC_MAKE_GCPROS_NOOPS
 
-/* Use sigprocmask and friends instead of sigblock;
-   sigblock is considered obsolete on NetBSD.  */
-
-#define POSIX_SIGNALS	1
-
 /* arch-tag: e80f364a-04e9-4faf-93cb-f36a0fe95c81
    (do not change this comment) */
--- a/src/s/openbsd.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/openbsd.h	Thu May 06 09:50:39 2010 +0900
@@ -3,13 +3,6 @@
 /* Mostly the same as NetBSD.  */
 #include "netbsd.h"
 
-/*  This very-badly named symbol is conditionally defined in netbsd.h.
-    Better would be either to not need it in the first place, or to choose
-    a more descriptive name.  */
-#ifndef LD_SWITCH_SYSTEM_tmp
-#define LD_SWITCH_SYSTEM_tmp /* empty */
-#endif
-
 /*  David Mazieres <dm@reeducation-labor.lcs.mit.edu> says this
     is necessary.  Otherwise Emacs dumps core when run -nw.  */
 #undef LIBS_TERMCAP
@@ -21,7 +14,7 @@
 
   /*  Han Boetes <han@mijncomputer.nl> says this
       is necessary,  otherwise Emacs dumps core on elf systems.  */
-#define LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_tmp -Z
+#define LD_SWITCH_SYSTEM $(LD_SWITCH_X_SITE_AUX_RPATH) -Z
 
 /* arch-tag: 7e3f65ca-3f48-4237-933f-2b208b21e8e2
    (do not change this comment) */
--- a/src/s/sol2-6.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/sol2-6.h	Thu May 06 09:50:39 2010 +0900
@@ -49,8 +49,8 @@
 #endif
 
 /* This is the same definition as in usg5-4.h, but with sigblock/sigunblock
-   rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't
-   work if POSIX_SIGNALS is defined.  It may also be appropriate for SVR4.x
+   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 */
 /* This sets the name of the slave side of the PTY.  On SysVr4,
    grantpt(3) forks a subprocess, so keep sigchld_handler() from
--- a/src/s/unixware.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/unixware.h	Thu May 06 09:50:39 2010 +0900
@@ -32,8 +32,8 @@
 #define LIBS_SYSTEM -lsocket -lnsl -lelf -lgen
 
 /* This is the same definition as in usg5-4.h, but with sigblock/sigunblock
-   rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't
-   work if POSIX_SIGNALS is defined.  It may also be appropriate for SVR4.x
+   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 */
 /* This sets the name of the slave side of the PTY.  On SysVr4,
    grantpt(3) forks a subprocess, so keep sigchld_handler() from
--- a/src/s/usg5-4.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/s/usg5-4.h	Thu May 06 09:50:39 2010 +0900
@@ -61,10 +61,6 @@
 
 #define LDAV_SYMBOL "avenrun"
 
-/* Special hacks needed to make Emacs run on this system.  */
-
-#define POSIX_SIGNALS
-
 /* setjmp and longjmp can safely replace _setjmp and _longjmp,
    but they will run slower.  */
 
--- a/src/syntax.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/syntax.c	Thu May 06 09:50:39 2010 +0900
@@ -858,7 +858,7 @@
      Lisp_Object character;
 {
   int char_int;
-  CHECK_NUMBER (character);
+  CHECK_CHARACTER (character);
   char_int = XINT (character);
   SETUP_BUFFER_SYNTAX_TABLE ();
   return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);
--- a/src/sysdep.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/sysdep.c	Thu May 06 09:50:39 2010 +0900
@@ -73,7 +73,7 @@
 #include <errno.h>
 
 #ifdef HAVE_SETPGID
-#if !defined (USG) || defined (BSD_PGRPS)
+#if !defined (USG)
 #undef setpgrp
 #define setpgrp setpgid
 #endif
@@ -419,7 +419,10 @@
       else
 	sigpause (SIGEMPTYMASK);
 #else /* not BSD_SYSTEM, and not HPUX version >= 6 */
-#ifdef POSIX_SIGNALS    /* would this work for GNU/Linux as well? */
+#ifdef WINDOWSNT
+      wait (0);
+      break;
+#else /* not WINDOWSNT */
       sigblock (sigmask (SIGCHLD));
       errno = 0;
       if (kill (pid, 0) == -1 && errno == ESRCH)
@@ -429,29 +432,7 @@
 	}
 
       sigsuspend (&empty_mask);
-#else /* not POSIX_SIGNALS */
-#ifdef HAVE_SYSV_SIGPAUSE
-      sighold (SIGCHLD);
-      if (0 > kill (pid, 0))
-	{
-	  sigrelse (SIGCHLD);
-	  break;
-	}
-      sigpause (SIGCHLD);
-#else /* not HAVE_SYSV_SIGPAUSE */
-#ifdef WINDOWSNT
-      wait (0);
-      break;
-#else /* not WINDOWSNT */
-      if (0 > kill (pid, 0))
-	break;
-      /* Using sleep instead of pause avoids timing error.
-	 If the inferior dies just before the sleep,
-	 we lose just one second.  */
-      sleep (1);
 #endif /* not WINDOWSNT */
-#endif /* not HAVE_SYSV_SIGPAUSE */
-#endif /* not POSIX_SIGNALS */
 #endif /* not BSD_SYSTEM, and not HPUX version >= 6 */
 #else /* not subprocesses */
       break;
@@ -546,11 +527,6 @@
 #endif /* not SIGNALS_VIA_CHARACTERS */
 
 #ifdef AIX
-/* AIX enhanced edit loses NULs, so disable it */
-#ifndef IBMR2AIX
-  s.main.c_line = 0;
-  s.main.c_iflag &= ~ASCEDIT;
-#endif
   /* Also, PTY overloads NUL and BREAK.
      don't ignore break, but don't signal either, so it looks like NUL.  */
   s.main.c_iflag &= ~IGNBRK;
@@ -883,65 +859,7 @@
 #endif /* FASYNC */
 #endif /* F_SETFL */
 #endif /* SIGIO */
-
-/* Saving and restoring the process group of Emacs's terminal.  */
-
-#ifdef BSD_PGRPS
-
-/* The process group of which Emacs was a member when it initially
-   started.
-
-   If Emacs was in its own process group (i.e. inherited_pgroup ==
-   getpid ()), then we know we're running under a shell with job
-   control (Emacs would never be run as part of a pipeline).
-   Everything is fine.
-
-   If Emacs was not in its own process group, then we know we're
-   running under a shell (or a caller) that doesn't know how to
-   separate itself from Emacs (like sh).  Emacs must be in its own
-   process group in order to receive SIGIO correctly.  In this
-   situation, we put ourselves in our own pgroup, forcibly set the
-   tty's pgroup to our pgroup, and make sure to restore and reinstate
-   the tty's pgroup just like any other terminal setting.  If
-   inherited_group was not the tty's pgroup, then we'll get a
-   SIGTTmumble when we try to change the tty's pgroup, and a CONT if
-   it goes foreground in the future, which is what should happen.
-
-   This variable is initialized in emacs.c.  */
-int inherited_pgroup;
-
-/* Split off the foreground process group to Emacs alone.  When we are
-   in the foreground, but not started in our own process group,
-   redirect the tty device handle FD to point to our own process
-   group.  We need to be in our own process group to receive SIGIO
-   properly.  */
-static void
-narrow_foreground_group (int fd)
-{
-  int me = getpid ();
-
-  setpgrp (0, inherited_pgroup);
-#if 0
-  /* XXX inherited_pgroup should not be zero here, but GTK seems to
-     mess this up. */
-  if (! inherited_pgroup)
-    abort ();                   /* Should not happen. */
-#endif
-  if (inherited_pgroup != me)
-      EMACS_SET_TTY_PGRP (fd, &me); /* XXX This only works on the controlling tty. */
-  setpgrp (0, me);
-}
-
-/* Set the tty to our original foreground group.  */
-static void
-widen_foreground_group (int fd)
-{
-  if (inherited_pgroup != getpid ())
-    EMACS_SET_TTY_PGRP (fd, &inherited_pgroup);
-  setpgrp (0, inherited_pgroup);
-}
-
-#endif /* BSD_PGRPS */
+
 
 /* Getting and setting emacs_tty structures.  */
 
@@ -1126,15 +1044,6 @@
   if (!tty_out->output)
     return;                     /* The tty is suspended. */
   
-#ifdef BSD_PGRPS
-#if 0
-  /* read_socket_hook is not global anymore.  I think doing this
-     unconditionally will not cause any problems. */
-  if (! read_socket_hook && EQ (Vinitial_window_system, Qnil))
-#endif
-    narrow_foreground_group (fileno (tty_out->input));
-#endif
-
   if (! tty_out->old_tty)
     tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
       
@@ -1258,16 +1167,10 @@
 #endif /* mips or HAVE_TCATTR */
 
 #ifdef AIX
-#ifndef IBMR2AIX
-  /* AIX enhanced edit loses NULs, so disable it.  */
-  tty.main.c_line = 0;
-  tty.main.c_iflag &= ~ASCEDIT;
-#else
   tty.main.c_cc[VSTRT] = CDISABLE;
   tty.main.c_cc[VSTOP] = CDISABLE;
   tty.main.c_cc[VSUSP] = CDISABLE;
   tty.main.c_cc[VDSUSP] = CDISABLE;
-#endif /* IBMR2AIX */
   if (tty_out->flow_control)
     {
 #ifdef VSTART
@@ -1590,9 +1493,6 @@
   dos_ttcooked ();
 #endif
 
-#ifdef BSD_PGRPS
-  widen_foreground_group (fileno (tty_out->input));
-#endif
 }
 
 #ifdef HAVE_PTYS
@@ -2101,10 +2001,10 @@
 /* POSIX signals support - DJB */
 /* Anyone with POSIX signals should have ANSI C declarations */
 
-#ifdef POSIX_SIGNALS
-
 sigset_t empty_mask, full_mask;
 
+#ifndef WINDOWSNT
+
 signal_handler_t
 sys_signal (int signal_number, signal_handler_t action)
 {
@@ -2133,6 +2033,8 @@
   return (old_action.sa_handler);
 }
 
+#endif	/* WINDOWSNT */
+
 #ifndef __GNUC__
 /* If we're compiling with GCC, we don't need this function, since it
    can be written as a macro.  */
@@ -2175,7 +2077,6 @@
   return (old_mask);
 }
 
-#endif /* POSIX_SIGNALS */
 
 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
 static char *my_sys_siglist[NSIG];
@@ -2188,10 +2089,8 @@
 void
 init_signals ()
 {
-#ifdef POSIX_SIGNALS
   sigemptyset (&empty_mask);
   sigfillset (&full_mask);
-#endif
 
 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
   if (! initialized)
--- a/src/syssignal.h	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/syssignal.h	Thu May 06 09:50:39 2010 +0900
@@ -30,8 +30,6 @@
 extern pthread_t main_thread;
 #endif
 
-#ifdef POSIX_SIGNALS
-
 /* 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
@@ -87,15 +85,6 @@
 
 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
 
-#else /* ! defined (POSIX_SIGNALS) */
-
-#ifndef sigunblock
-#define sigunblock(SIG) \
-{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
-#endif
-
-#endif /* ! defined (POSIX_SIGNALS) */
-
 #ifndef SIGMASKTYPE
 #define SIGMASKTYPE int
 #endif
--- a/src/term.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/term.c	Thu May 06 09:50:39 2010 +0900
@@ -3379,7 +3379,7 @@
   EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
   if (pgid != -1)
     {
-#if defined (USG) && !defined (BSD_PGRPS)
+#if defined (USG)
       setpgrp ();
       no_controlling_tty = 1;
 #elif defined (CYGWIN)
--- a/src/w32.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/w32.c	Thu May 06 09:50:39 2010 +0900
@@ -1482,6 +1482,30 @@
 }
 
 int
+sigemptyset (sigset_t *set)
+{
+  return 0;
+}
+
+int
+sigaddset (sigset_t *set, int signo)
+{
+  return 0;
+}
+
+int
+sigfillset (sigset_t *set)
+{
+  return 0;
+}
+
+int
+sigprocmask (int how, const sigset_t *set, sigset_t *oset)
+{
+  return 0;
+}
+
+int
 setpgrp (int pid, int gid)
 {
   return 0;
--- a/src/xdisp.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/xdisp.c	Thu May 06 09:50:39 2010 +0900
@@ -2451,7 +2451,7 @@
       specbind (Qinhibit_redisplay, Qt);
       /* Use Qt to ensure debugger does not run,
 	 so there is no possibility of wanting to redisplay.  */
-      val = internal_condition_case_2 (Ffuncall, nargs, args, Qt,
+      val = internal_condition_case_n (Ffuncall, nargs, args, Qt,
 				       safe_eval_handler);
       UNGCPRO;
       val = unbind_to (count, val);
@@ -12776,6 +12776,13 @@
 	 rightmost glyph.  Case in point: an empty last line that is
 	 part of an R2L paragraph.  */
       cursor = end - 1;
+      /* Avoid placing the cursor on the last glyph of the row, where
+	 on terminal frames we hold the vertical border between
+	 adjacent windows.  */
+      if (!FRAME_WINDOW_P (WINDOW_XFRAME (w))
+	  && !WINDOW_RIGHTMOST_P (w)
+	  && cursor == row->glyphs[LAST_AREA] - 1)
+	cursor--;
       x = -1;	/* will be computed below, at label compute_x */
     }
 
@@ -13015,7 +13022,8 @@
 
 			  cursor = glyph;
 			  for (glyph += incr;
-			       EQ (glyph->object, str);
+			       (row->reversed_p ? glyph > stop : glyph < stop)
+				 && EQ (glyph->object, str);
 			       glyph += incr)
 			    {
 			      Lisp_Object cprop;
@@ -13055,8 +13063,9 @@
 
 	  /* If we reached the end of the line, and END was from a string,
 	     the cursor is not on this line.  */
-	  if (glyph == end
-	      && STRINGP ((glyph - incr)->object)
+	  if (cursor == NULL
+	      && (row->reversed_p ? glyph <= end : glyph >= end)
+	      && STRINGP (end->object)
 	      && row->continued_p)
 	    return 0;
 	}
@@ -13714,11 +13723,14 @@
 		  ++row;
 		}
 
-	      /* The end position of a row equals the start position
-		 of the next row.  If PT is there, we would rather
-		 display it in the next line.  */
+	      /* If the end position of a row equals the start
+		 position of the next row, and PT is at that position,
+		 we would rather display cursor in the next line.  */
 	      while (MATRIX_ROW_BOTTOM_Y (row) < last_y
 		     && MATRIX_ROW_END_CHARPOS (row) == PT
+		     && row < w->current_matrix->rows
+				+ w->current_matrix->nrows - 1
+		     && MATRIX_ROW_START_CHARPOS (row+1) == PT
 		     && !cursor_row_p (w, row))
 		++row;
 
@@ -16737,24 +16749,61 @@
   produce_special_glyphs (&truncate_it, IT_TRUNCATION);
 
   /* Overwrite glyphs from IT with truncation glyphs.  */
-  from = truncate_it.glyph_row->glyphs[TEXT_AREA];
-  end = from + truncate_it.glyph_row->used[TEXT_AREA];
-  to = it->glyph_row->glyphs[TEXT_AREA];
-  toend = to + it->glyph_row->used[TEXT_AREA];
-
-  while (from < end)
-    *to++ = *from++;
-
-  /* There may be padding glyphs left over.  Overwrite them too.  */
-  while (to < toend && CHAR_GLYPH_PADDING_P (*to))
+  if (!it->glyph_row->reversed_p)
     {
       from = truncate_it.glyph_row->glyphs[TEXT_AREA];
+      end = from + truncate_it.glyph_row->used[TEXT_AREA];
+      to = it->glyph_row->glyphs[TEXT_AREA];
+      toend = to + it->glyph_row->used[TEXT_AREA];
+
       while (from < end)
 	*to++ = *from++;
-    }
-
-  if (to > toend)
-    it->glyph_row->used[TEXT_AREA] = to - it->glyph_row->glyphs[TEXT_AREA];
+
+      /* There may be padding glyphs left over.  Overwrite them too.  */
+      while (to < toend && CHAR_GLYPH_PADDING_P (*to))
+	{
+	  from = truncate_it.glyph_row->glyphs[TEXT_AREA];
+	  while (from < end)
+	    *to++ = *from++;
+	}
+
+      if (to > toend)
+	it->glyph_row->used[TEXT_AREA] = to - it->glyph_row->glyphs[TEXT_AREA];
+    }
+  else
+    {
+      /* In R2L rows, overwrite the last (rightmost) glyphs, and do
+	 that back to front.  */
+      end = truncate_it.glyph_row->glyphs[TEXT_AREA];
+      from = end + truncate_it.glyph_row->used[TEXT_AREA] - 1;
+      toend = it->glyph_row->glyphs[TEXT_AREA];
+      to = toend + it->glyph_row->used[TEXT_AREA] - 1;
+
+      while (from >= end && to >= toend)
+	*to-- = *from--;
+      while (to >= toend && CHAR_GLYPH_PADDING_P (*to))
+	{
+	  from =
+	    truncate_it.glyph_row->glyphs[TEXT_AREA]
+	    + truncate_it.glyph_row->used[TEXT_AREA] - 1;
+	  while (from >= end && to >= toend)
+	    *to-- = *from--;
+	}
+      if (from >= end)
+	{
+	  /* Need to free some room before prepending additional
+	     glyphs.  */
+	  int move_by = from - end + 1;
+	  struct glyph *g0 = it->glyph_row->glyphs[TEXT_AREA];
+	  struct glyph *g = g0 + it->glyph_row->used[TEXT_AREA] - 1;
+
+	  for ( ; g >= g0; g--)
+	    g[move_by] = *g;
+	  while (from >= end)
+	    *to-- = *from--;
+	  it->glyph_row->used[TEXT_AREA] += move_by;
+	}
+    }
 }
 
 
@@ -16946,8 +16995,13 @@
 
   /* If line is already filled, do nothing.  Non window-system frames
      get a grace of one more ``pixel'' because their characters are
-     1-``pixel'' wide, so they hit the equality too early.  */
-  if (it->current_x >= it->last_visible_x + !FRAME_WINDOW_P (f))
+     1-``pixel'' wide, so they hit the equality too early.  This grace
+     is needed only for R2L rows that are not continued, to produce
+     one extra blank where we could display the cursor.  */
+  if (it->current_x >= it->last_visible_x
+      + (!FRAME_WINDOW_P (f)
+	 && it->glyph_row->reversed_p
+	 && !it->glyph_row->continued_p))
     return;
 
   /* Face extension extends the background and box of IT->face_id
@@ -17368,6 +17422,123 @@
     glyph[-n] = *glyph;
 }
 
+/* Find the positions in a bidi-reordered ROW to serve as ROW->start
+   and ROW->end.  */
+static struct display_pos
+find_row_end (it, row)
+     struct it *it;
+     struct glyph_row *row;
+{
+  /* FIXME: Revisit this when glyph ``spilling'' in continuation
+     lines' rows is implemented for bidi-reordered rows.  */
+  EMACS_INT min_pos = ZV + 1, max_pos = 0;
+  struct glyph *g;
+  struct it save_it;
+  struct text_pos tpos;
+  struct display_pos row_end = it->current;
+
+  for (g = row->glyphs[TEXT_AREA];
+       g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
+       g++)
+    {
+      if (BUFFERP (g->object))
+	{
+	  if (g->charpos > 0 && g->charpos < min_pos)
+	    min_pos = g->charpos;
+	  if (g->charpos > max_pos)
+	    max_pos = g->charpos;
+	}
+    }
+  /* Empty lines have a valid buffer position at their first
+     glyph, but that glyph's OBJECT is zero, as if it didn't come
+     from a buffer.  If we didn't find any valid buffer positions
+     in this row, maybe we have such an empty line.  */
+  if (max_pos == 0 && row->used[TEXT_AREA])
+    {
+      for (g = row->glyphs[TEXT_AREA];
+	   g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
+	   g++)
+	{
+	  if (INTEGERP (g->object))
+	    {
+	      if (g->charpos > 0 && g->charpos < min_pos)
+		min_pos = g->charpos;
+	      if (g->charpos > max_pos)
+		max_pos = g->charpos;
+	    }
+	}
+    }
+
+  /* ROW->start is the value of min_pos, the minimal buffer position
+     we have in ROW.  */
+  if (min_pos <= ZV)
+    {
+      /* Avoid calling the costly CHAR_TO_BYTE if possible.  */
+      if (min_pos != row->start.pos.charpos)
+	SET_TEXT_POS (row->start.pos, min_pos, CHAR_TO_BYTE (min_pos));
+      if (max_pos == 0)
+	max_pos = min_pos;
+    }
+
+  /* For ROW->end, we need the position that is _after_ max_pos, in
+     the logical order, unless we are at ZV.  */
+  if (row->ends_at_zv_p)
+    {
+      if (!row->used[TEXT_AREA])
+	row->start.pos = row_end.pos;
+    }
+  else if (row->used[TEXT_AREA] && max_pos)
+    {
+      int at_eol_p;
+
+      SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos));
+      save_it = *it;
+      it->bidi_p = 0;
+      reseat (it, tpos, 0);
+      if (!get_next_display_element (it))
+	abort ();	/* this row cannot be at ZV, see above */
+      at_eol_p = ITERATOR_AT_END_OF_LINE_P (it);
+      set_iterator_to_next (it, 1);
+      row_end = it->current;
+      /* If the character at max_pos is not a newline and the
+	 characters at max_pos+1 is a newline, skip that newline as
+	 well.  Note that this may skip some invisible text.  */
+      if (!at_eol_p
+	  && get_next_display_element (it)
+	  && ITERATOR_AT_END_OF_LINE_P (it))
+	{
+	  set_iterator_to_next (it, 1);
+	  /* Record the position after the newline of a continued row.
+	     We will need that to set ROW->end of the last row
+	     produced for a continued line.  */
+	  if (row->continued_p)
+	    save_it.eol_pos = it->current.pos;
+	  else
+	    {
+	      row_end = it->current;
+	      save_it.eol_pos.charpos = save_it.eol_pos.bytepos = 0;
+	    }
+	}
+      else if (!row->continued_p
+	       && MATRIX_ROW_CONTINUATION_LINE_P (row)
+	       && it->eol_pos.charpos > 0)
+	{
+	  /* Last row of a continued line.  Use the position recorded
+	     in IT->eol_pos, to the effect that the newline belongs to
+	     this row, not to the row which displays the character
+	     with the largest buffer position before the newline.  */
+	  row_end.pos = it->eol_pos;
+	  it->eol_pos.charpos = it->eol_pos.bytepos = 0;
+	}
+      *it = save_it;
+      /* The members of ROW->end that are not taken from buffer
+	 positions are copied from IT->current.  */
+      row_end.string_pos = it->current.string_pos;
+      row_end.overlay_string_index = it->current.overlay_string_index;
+      row_end.dpvec_index = it->current.dpvec_index;
+    }
+  return row_end;
+}
 
 /* Construct the glyph row IT->glyph_row in the desired matrix of
    IT->w from text at the current position of IT.  See dispextern.h
@@ -17386,7 +17557,6 @@
   int wrap_row_used = -1, wrap_row_ascent, wrap_row_height;
   int wrap_row_phys_ascent, wrap_row_phys_height;
   int wrap_row_extra_line_spacing;
-  struct display_pos row_end;
   int cvpos;
 
   /* We always start displaying at hpos zero even if hscrolled.  */
@@ -17815,10 +17985,14 @@
 		  for (i = 0; i < row->used[TEXT_AREA]; i++)
 		    if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i]))
 		      break;
-		  /* Remove padding glyphs at the front of ROW, to
+		  /* Remove any padding glyphs at the front of ROW, to
 		     make room for the truncation glyphs we will be
-		     adding below.  */
-		  unproduce_glyphs (it, i);
+		     adding below.  The loop below always inserts at
+		     least one truncation glyph, so also remove the
+		     last glyph added to ROW.  */
+		  unproduce_glyphs (it, i + 1);
+		  /* Adjust i for the loop below.  */
+		  i = row->used[TEXT_AREA] - (i + 1);
 		}
 
 	      for (n = row->used[TEXT_AREA]; i < n; ++i)
@@ -17910,118 +18084,13 @@
   compute_line_metrics (it);
 
   /* Remember the position at which this line ends.  */
-  row->end = row_end = it->current;
+  row->end = it->current;
+  /* ROW->start and ROW->end must be the smallest and the largest
+     buffer positions in ROW.  But if ROW was bidi-reordered, these
+     two positions can be anywhere in the row, so we must rescan all
+     of the ROW's glyphs to find them.  */
   if (it->bidi_p)
-    {
-      /* ROW->start and ROW->end must be the smallest and largest
-	 buffer positions in ROW.  But if ROW was bidi-reordered,
-	 these two positions can be anywhere in the row, so we must
-	 rescan all of the ROW's glyphs to find them.  */
-      /* FIXME: Revisit this when glyph ``spilling'' in continuation
-	 lines' rows is implemented for bidi-reordered rows.  */
-      EMACS_INT min_pos = ZV + 1, max_pos = 0;
-      struct glyph *g;
-      struct it save_it;
-      struct text_pos tpos;
-
-      for (g = row->glyphs[TEXT_AREA];
-	   g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
-	   g++)
-	{
-	  if (BUFFERP (g->object))
-	    {
-	      if (g->charpos > 0 && g->charpos < min_pos)
-		min_pos = g->charpos;
-	      if (g->charpos > max_pos)
-		max_pos = g->charpos;
-	    }
-	}
-      /* Empty lines have a valid buffer position at their first
-	 glyph, but that glyph's OBJECT is zero, as if it didn't come
-	 from a buffer.  If we didn't find any valid buffer positions
-	 in this row, maybe we have such an empty line.  */
-      if (min_pos == ZV + 1 && row->used[TEXT_AREA])
-	{
-	  for (g = row->glyphs[TEXT_AREA];
-	       g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
-	       g++)
-	    {
-	      if (INTEGERP (g->object))
-		{
-		  if (g->charpos > 0 && g->charpos < min_pos)
-		    min_pos = g->charpos;
-		  if (g->charpos > max_pos)
-		    max_pos = g->charpos;
-		}
-	    }
-	}
-      if (min_pos <= ZV)
-	{
-	  if (min_pos != row->start.pos.charpos)
-	    {
-	      row->start.pos.charpos = min_pos;
-	      row->start.pos.bytepos = CHAR_TO_BYTE (min_pos);
-	    }
-	  if (max_pos == 0)
-	    max_pos = min_pos;
-	}
-      /* For ROW->end, we need the position that is _after_ max_pos,
-	 in the logical order, unless we are at ZV.  */
-      if (row->ends_at_zv_p)
-	{
-	  row_end = row->end = it->current;
-	  if (!row->used[TEXT_AREA])
-	    {
-	      row->start.pos.charpos = row_end.pos.charpos;
-	      row->start.pos.bytepos = row_end.pos.bytepos;
-	    }
-	}
-      else if (row->used[TEXT_AREA] && max_pos)
-	{
-	  SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos));
-	  save_it = *it;
-	  it->bidi_p = 0;
-	  reseat (it, tpos, 0);
-	  if (!get_next_display_element (it))
-	    abort ();	/* row at ZV was already handled above */
-	  set_iterator_to_next (it, 1);
-	  row_end = it->current;
-	  /* If the character at max_pos+1 is a newline, skip that as
-	     well.  Note that this may skip some invisible text.  */
-	  if (get_next_display_element (it)
-	      && ITERATOR_AT_END_OF_LINE_P (it))
-	    {
-	      set_iterator_to_next (it, 1);
-	      /* Record the position after the newline of a continued
-		 row.  We will need that to set ROW->end of the last
-		 row produced for a continued line.  */
-	      if (row->continued_p)
-		{
-		  save_it.eol_pos.charpos = IT_CHARPOS (*it);
-		  save_it.eol_pos.bytepos = IT_BYTEPOS (*it);
-		}
-	      else
-		{
-		  row_end = it->current;
-		  save_it.eol_pos.charpos = save_it.eol_pos.bytepos = 0;
-		}
-	    }
-	  else if (!row->continued_p
-		   && MATRIX_ROW_CONTINUATION_LINE_P (row)
-		   && it->eol_pos.charpos > 0)
-	    {
-	      /* Last row of a continued line.  Use the position
-		 recorded in ROW->eol_pos, to the effect that the
-		 newline belongs to this row, not to the row which
-		 displays the character with the largest buffer
-		 position.  */
-	      row_end.pos = it->eol_pos;
-	      it->eol_pos.charpos = it->eol_pos.bytepos = 0;
-	    }
-	  *it = save_it;
-	  row->end = row_end;
-	}
-    }
+    row->end = find_row_end (it, row);
 
   /* Record whether this row ends inside an ellipsis.  */
   row->ends_in_ellipsis_p
@@ -18075,7 +18144,7 @@
      the flag accordingly.  */
   if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w))
     it->glyph_row->reversed_p = row->reversed_p;
-  it->start = row_end;
+  it->start = row->end;
   return row->displays_text_p;
 }
 
--- a/src/xsettings.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/xsettings.c	Thu May 06 09:50:39 2010 +0900
@@ -1,4 +1,4 @@
-/* Functions for handle font changes dynamically.
+/* Functions for handle font and other changes dynamically.
    Copyright (C) 2009, 2010
                  Free Software Foundation, Inc.
 
@@ -18,6 +18,7 @@
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#include <limits.h>
 #include <setjmp.h>
 #include <fcntl.h>
 #include "lisp.h"
--- a/src/xsmfns.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/xsmfns.c	Thu May 06 09:50:39 2010 +0900
@@ -90,6 +90,10 @@
 
 #define NOSPLASH_OPT "--no-splash"
 
+/* The option to make Emacs start in the given directory.  */
+
+#define CHDIR_OPT "--chdir="
+
 static void
 ice_connection_closed ()
 {
@@ -206,7 +210,7 @@
   int props_idx = 0;
 
   char *cwd = NULL;
-  char *smid_opt;
+  char *smid_opt, *chdir_opt = NULL;
 
   /* How to start a new instance of Emacs.  */
   props[props_idx] = &prop_ptr[props_idx];
@@ -228,11 +232,12 @@
   props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
   ++props_idx;
 
-  /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash).  */
+  /* How to restart Emacs.  */
   props[props_idx] = &prop_ptr[props_idx];
   props[props_idx]->name = SmRestartCommand;
   props[props_idx]->type = SmLISTofARRAY8;
-  props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash  */
+  /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */
+  props[props_idx]->num_vals = 4;
   props[props_idx]->vals = &values[val_idx];
   props[props_idx]->vals[0].length = strlen (emacs_program);
   props[props_idx]->vals[0].value = emacs_program;
@@ -246,7 +251,19 @@
 
   props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT);
   props[props_idx]->vals[2].value = NOSPLASH_OPT;
-  val_idx += 3;
+
+  cwd = get_current_dir_name ();
+  if (cwd) 
+    {
+      chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1);
+      strcpy (chdir_opt, CHDIR_OPT);
+      strcat (chdir_opt, cwd);
+
+      props[props_idx]->vals[3].length = strlen (chdir_opt);
+      props[props_idx]->vals[3].value = chdir_opt;
+    }
+
+  val_idx += cwd ? 4 : 3;
   ++props_idx;
 
   /* User id.  */
@@ -259,7 +276,6 @@
   props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
   ++props_idx;
 
-  cwd = get_current_dir_name ();
 
   if (cwd)
     {
@@ -277,6 +293,7 @@
   SmcSetProperties (smcConn, props_idx, props);
 
   xfree (smid_opt);
+  xfree (chdir_opt);
 
   free (cwd);
 
--- a/src/xterm.c	Wed Apr 28 10:00:38 2010 +0900
+++ b/src/xterm.c	Thu May 06 09:50:39 2010 +0900
@@ -7936,8 +7936,8 @@
       if (terminal_list->next_terminal == NULL)
         {
           fprintf (stderr, "%s\n", error_msg);
-          shut_down_emacs (0, 0, Qnil);
-          exit (70);
+          Fkill_emacs (make_number (70));
+          /* NOTREACHED */
         }
       xg_display_close (dpyinfo->display);
 #endif
@@ -7963,8 +7963,8 @@
   if (terminal_list == 0)
     {
       fprintf (stderr, "%s\n", error_msg);
-      shut_down_emacs (0, 0, Qnil);
-      exit (70);
+      Fkill_emacs (make_number (70));
+      /* NOTREACHED */
     }
 
   /* Ordinary stack unwind doesn't deal with these.  */