changeset 83453:55e22205ba88

Merged from miles@gnu.org--gnu-2005 (patch 683-684) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-683 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-684 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-493
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 06 Jan 2006 16:13:05 +0000
parents 02980fcccc43 (current diff) 484a75387b1b (diff)
children 845a93c68e9a
files ChangeLog configure configure.in lisp/ChangeLog lisp/Makefile.in lisp/cus-face.el lisp/emacs-lisp/bytecomp.el lisp/font-lock.el lisp/simple.el lisp/startup.el lisp/term/mac-win.el lisp/url/url-cookie.el lisp/url/url-history.el lispref/ChangeLog man/ChangeLog src/.gdbinit src/callproc.c src/emacs.c src/keymap.c src/process.c src/window.h
diffstat 59 files changed, 3330 insertions(+), 2418 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,8 @@
+2006-01-02  Chong Yidong  <cyd@stupidchicken.com>
+
+	* configure.in: Use -Wno-pointer-sign if available.
+	* configure: Regenerate.
+
 2005-12-29  Andreas Schwab  <schwab@suse.de>
 
 	* config.guess, config.sub: Updated from master source.
--- a/configure	Thu Jan 05 14:02:59 2006 +0000
+++ b/configure	Fri Jan 06 16:13:05 2006 +0000
@@ -1718,6 +1718,7 @@
     case "${canonical}" in
       alpha*-*-freebsd*)	machine=alpha ;;
       i[3456]86-*-freebsd*)	machine=intel386 ;;
+      amd64-*-freebsd*|x86_64-*-freebsd*) machine=amdx86-64 ;;
     esac
   ;;
 
@@ -3667,6 +3668,65 @@
   CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
+### Use -Wno-pointer-sign if the compiler supports it
+echo "$as_me:$LINENO: checking whether gcc understands -Wno-pointer-sign" >&5
+echo $ECHO_N "checking whether gcc understands -Wno-pointer-sign... $ECHO_C" >&6
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wno-pointer-sign"
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  has_option=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+has_option=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wno-pointer-sign $C_WARNINGS_SWITCH"
+fi
+echo "$as_me:$LINENO: result: $has_option" >&5
+echo "${ECHO_T}$has_option" >&6
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
 #### Some other nice autoconf tests.
 
 echo "$as_me:$LINENO: checking whether ln -s works" >&5
@@ -4254,7 +4314,6 @@
 
 echo "$as_me:$LINENO: checking for -znocombreloc" >&5
 echo $ECHO_N "checking for -znocombreloc... $ECHO_C" >&6
-
 cat >conftest.$ac_ext <<_ACEOF
 main(){return 0;}
 _ACEOF
@@ -4425,6 +4484,10 @@
 #endif
 #endif
 
+#ifndef C_WARNINGS_SWITCH
+#define C_WARNINGS_SWITCH ${C_WARNINGS_SWITCH}
+#endif
+
 #ifndef LD_SWITCH_MACHINE
 #define LD_SWITCH_MACHINE
 #endif
@@ -4453,7 +4516,7 @@
 
 /* Get the CFLAGS for real compilation.  */
 #ifdef __GNUC__
-configure___ REAL_CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH '${SPECIFIED_CFLAGS}'
+configure___ REAL_CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH C_WARNINGS_SWITCH '${SPECIFIED_CFLAGS}'
 #else
 configure___ REAL_CFLAGS=C_DEBUG_SWITCH '${SPECIFIED_CFLAGS}'
 #endif
@@ -8009,7 +8072,7 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
 _ACEOF
 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@@ -8036,7 +8099,7 @@
 sed 's/^/| /' conftest.$ac_ext >&5
 
   for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Xlib.h"; then
+  if test -r "$ac_dir/X11/Intrinsic.h"; then
     ac_x_includes=$ac_dir
     break
   fi
@@ -8050,18 +8113,18 @@
   # See if we find them without any special options.
   # Don't add to $LIBS permanently.
   ac_save_LIBS=$LIBS
-  LIBS="-lX11 $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize ()
+  LIBS="-lXt $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <X11/Intrinsic.h>
+int
+main ()
+{
+XtMalloc (0)
   ;
   return 0;
 }
@@ -8099,7 +8162,7 @@
 do
   # Don't even attempt the hair of trying to link an X program!
   for ac_extension in a so sl; do
-    if test -r $ac_dir/libX11.$ac_extension; then
+    if test -r $ac_dir/libXt.$ac_extension; then
       ac_x_libraries=$ac_dir
       break 2
     fi
@@ -21601,24 +21664,18 @@
   ac_cv_func_fork_works=cross
 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 ()
-{
-
-	  /* By Ruediger Kuhlmann. */
-	  if (fork() < 0)
-	    exit (1);
-	  exit (0);
-
-  ;
-  return 0;
-}
+/* By Ruediger Kuhlmann. */
+      #include <sys/types.h>
+      #if HAVE_UNISTD_H
+      # include <unistd.h>
+      #endif
+      /* Some systems only have a dummy stub for fork() */
+      int main ()
+      {
+	if (fork() < 0)
+	  exit (1);
+	exit (0);
+      }
 _ACEOF
 rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
--- a/configure.in	Thu Jan 05 14:02:59 2006 +0000
+++ b/configure.in	Fri Jan 06 16:13:05 2006 +0000
@@ -1261,6 +1261,19 @@
   CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
+### Use -Wno-pointer-sign if the compiler supports it
+AC_MSG_CHECKING([whether gcc understands -Wno-pointer-sign])
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wno-pointer-sign"
+AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wno-pointer-sign $C_WARNINGS_SWITCH"
+fi
+AC_MSG_RESULT($has_option)
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
 #### Some other nice autoconf tests.
 
 dnl checks for programs
@@ -1394,6 +1407,10 @@
 #endif
 #endif
 
+#ifndef C_WARNINGS_SWITCH
+#define C_WARNINGS_SWITCH ${C_WARNINGS_SWITCH}
+#endif
+
 #ifndef LD_SWITCH_MACHINE
 #define LD_SWITCH_MACHINE
 #endif
@@ -1422,7 +1439,7 @@
 
 /* Get the CFLAGS for real compilation.  */
 #ifdef __GNUC__
-configure___ REAL_CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH '${SPECIFIED_CFLAGS}'
+configure___ REAL_CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH C_WARNINGS_SWITCH '${SPECIFIED_CFLAGS}'
 #else
 configure___ REAL_CFLAGS=C_DEBUG_SWITCH '${SPECIFIED_CFLAGS}'
 #endif
--- a/etc/NEWS	Thu Jan 05 14:02:59 2006 +0000
+++ b/etc/NEWS	Fri Jan 06 16:13:05 2006 +0000
@@ -308,7 +308,7 @@
 
 +++
 ** You can now switch buffers in a cyclic order with C-x C-left
-(previous-buffer) and C-x C-right (next-buffer).  C-x left and 
+(previous-buffer) and C-x C-right (next-buffer).  C-x left and
 C-x right can be used as well.  The functions keep a different buffer
 cycle for each frame, using the frame-local buffer list.
 
@@ -4426,6 +4426,8 @@
 - Datagram connection is selected using :type 'datagram arg.
 - A server can open on a random port using :service t arg.
 - Local sockets are supported using :family 'local arg.
+- IPv6 is supported (when available).  You may explicitly select IPv6
+  using :family 'ipv6 arg.
 - Non-blocking connect is supported using :nowait t arg.
 - The process' property list can be initialized using :plist PLIST arg;
   a copy of the server process' property list is automatically inherited
@@ -4433,6 +4435,7 @@
 
 To test for the availability of a given feature, use featurep like this:
   (featurep 'make-network-process '(:type datagram))
+  (featurep 'make-network-process '(:family ipv6))
 
 *** The old `open-network-stream' now uses `make-network-process'.
 
--- a/etc/orgcard.ps	Thu Jan 05 14:02:59 2006 +0000
+++ b/etc/orgcard.ps	Fri Jan 06 16:13:05 2006 +0000
@@ -10,7 +10,7 @@
 %DVIPSWebPage: (www.radicaleye.com)
 %DVIPSCommandLine: dvips -t landscape -o orgcard.ps orgcard.dvi
 %DVIPSParameters: dpi=600, compressed
-%DVIPSSource:  TeX output 2005.12.20:0859
+%DVIPSSource:  TeX output 2006.01.05:0904
 %%BeginProcSet: texc.pro
 %!
 /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
@@ -352,208 +352,204 @@
 CCBD1F58ABBF1F53AD21E3BFF25EEEB046F66A924E5F431EBD7228050BE2DF43
 0B9B538DAAD511EED97630CD9A9C05CC49DC251325A93EA842C6D07B44BE620F
 08E66B611F54314B0177E299304F2294F8DEDE9914736944F125A50B5007373E
-588AD80D9983CE7824DA30CEE5DC3114D69D7ACEC0758D8201805B82925EF3C2
-C87A1A169C5ADE44B561EC1660E617FB39D1B1547B33C0FEB33C3A1D7340A62A
-CD9CEFA49481F19B39A704A53A0B98A11744143CDDA0E668E6325935C6497A9F
-AFF471194932AFECBF25B441AD55A43751FBAB76F3E544C4254AEC4BEB5CFE4C
-C1318C3A0FAD0E8C1BABEE20B203E1DD9412E66BC55BEBD6FBBEBA84F56604FD
-85D50F733D9794611F4137EC10ACB4C4ECA5A81CAACC45213E92ED3C26726BBE
-91430E7633A2BDB8EA3D0C55259D7DBE468AC0964A63728C9B8EA4E15CF0EEA3
-2E754B9170EAE6B8818DCCDDAD643B9F6C91C3C5B245CD442358C60AF390DC76
-342E659D4EC45552626F069F346F46B18062CE26D5912336C6B29FCBFA5C3113
-ED86E44B529CD95B7B5B934D899762C4F3457F56ACCC763BCCD5BD08975EB5F1
-C5216DA4CBF3409EC71054B0145183F7DFB31517D199EB16D4C6DB0AF05E5720
-10B06F395BE3C8C59CEEBCEA1E00F9EA3FD880AC197508CEC11E33B6B6EABE3C
-0FAEBF246743F62D280875D052656696AA88DABB918F793CB2994A1ACCFA0CAE
-AF6FDDF489109DEF07F93B5B0078FC5FD9829DD296F62F23400F5DD6CB096557
-EDA737413C744FDBB0615BD40A79EA2929EB7AC767E58D886B310700733D2895
-3925911133631F28291974294AACF4A35F92A5E5262DCF33810A6F9C51E9D141
-F84B0C26B5ADECB44B646C79DD1C656529B7122739C0459B2B47A2C357EF9A36
-2B376DDF54F1F4F133419EF14CCC6010D360DFA8A7B122FFC5A4C560ED184F16
-057D3F76B6B2E935B31B17FC4066916FFBA0B9AFF287D251985AB3FC3D0D7E9A
-91F094356B3D6CDBCB2D74A3FDE23526B22C223EA35C9E5054053B23AF004324
-80F023FCDFDFA6B8F0E03A799D87FC2690C5D1ABB9C52B03402E37309091A1FC
-1D66EB5A75DAE988DA5E35B8E67BB084DC7E327BAA29BAA9EC60B63402DCBB4C
-C8FD3B7085ECDF029AEC6D080B62195A6C917CE9A900D02BDA73002650A8B802
-491C6D31EAB59795664FBEA51FD8529AF2384996D55F545DEA08F50E33951BAB
-BE953410B5C59904F4EDEFBB625B23FDE1CFD8222E30E14502D3FE19E37B7113
-190B7758414E048DC1F00ACFCAD4FD2A2E802E0BAF0565535698728E09E90E0D
-C5C8727764E70231D0B2D35317396B7A18F0B7125E2A79DD14F55293D7F0C162
-63F981C32F6DFC5613CC640DC32C14DADADE08E1AD23517C92715CF56A067E4F
-CD64DD84FC5074FBC6332AD5252B6A1CD9F6D0B79D957EBCEFAF348F69FD005A
-0D9988EA2CA91FBFDF72875C90BEEB2C3077858924B963BB54BC078DCEDF4DE5
-AE3AA2EB548FD9DED0B10EF502384E8D0A5D21DA465B564EB2C5D90528133EA2
-162016087ED07369D8EFF5006E0A4E31DF616851F387B4C3987A5101BB478B59
-97A1283A44C77586B2043C78356C5F9199A5DC8228BA6752D6F87AA49180A117
-C44E4E37F9CCFB8801824886A3BB8B45C09C4C3EF6F84D1A792F931142D4D92A
-4AFE82C564A28974AFEB8EBB07F08B2D35686554D4FDE904816AD5216DD9E50E
-594734194EF111F052C64F9EB5D9F643125847C386C3270D72D390F95ACCA259
-163390180BABABCD514E5B62AEDA79047D3D501F04E65D6F7746E6E65B842EE7
-0B45D8177B9155B3A3719B6054F92FC2EA9E9A17CFF146234BFEA708BA65C81B
-ABA8DF53CF17730D838099A5B00B29AEA31B6E59BDCC184A6BB91C3D38E37E86
-A5274FCEE9CE46EA1629A10490C136B03FCBF4ED56EE9BE8E2C7047320CF375F
-AA345383EE934DF28971CFAFC24F155546E24C399A5E91E5B7FBB127C7594718
-05CBE48E093BF76265A2E3499BE07F2967EC5A1F1B71B2716CDBF21A3BBCCDFD
-750E5BDE0E7354EC9994F5F5934949EEC70E0F84450828D851F6A4507F299E14
-D5CF89AFBB0B136D6704C6ADA1DFA98812C38D55AF4DE4DEAC2DA2F1D97EC7BF
-0F08F2CCF3D994044A59957698C532E7E4DEBDE4E19339ACC10F9E51CD6AE95B
-F6EDCF24604AA1D0E4C32E20F4078ADB2A22BFA93BA0E182F612FD57F606105B
-30F669CC646D3F50C26F1108D06DE3C8388EF2713295B1546E72E79B17999964
-8A739D2B83144AD0D0763E4EBA6C140182DD8B48AA20BFBFFB34D105F4738E50
-056F56C95AFFCE0192CAAEE4A910560A3124ACF504051327DED441E5347AB4C8
-BA566D84961FA34CC0A96D3B60BCF2075416D89F8C653D552561004EC42715AD
-706DEC4842B3526C0134718C81EFD988A6A86BEBD58B66A1EEA6C8067521D43D
-F23C72788F4D325D083BFA68224E40606E5E1FFAFB57979E3E85F0E8CEC4059C
-630DDF5F8665F00D824C94292A5882B5320CF1143D6FFE9B3EABA993CB6438D9
-5D7817C144451672C84EC88B3C7BCE2F50DF72733FDCCB62861AC3FBCE509D63
-E7E55E7F8A92FB18751BFE1E9FA5597562E756FE93C76CE9E1F8C0E199E568C0
-913B5F2E13F37E64D40A48FAB264188F45A2BF24757A516A5F63D057684B9B98
-77080D5BCDA67AF263D060DD7C4A434D2B769BFE6666C3E543D2807EF64DA025
-4136E09C9208A5166346BF4BEDEA772B1939ED947C5F86EB056AFCAD57ACF6FE
-F9B314ADFB521DB4D555881AFBA0F0E8FDC010CD3D62E80A5E0E267DD8200D08
-044F8CA818F496FBDE6E28749CF7EB01EDE032B507BDA2EEB30AD4B052D838FF
-C03C91F9FF6EB370258C69C62464BE1A3F97D829989F38161B6E1BE8CB6CF03C
-70A899F129316B44DC1DFDD2EC395E565BE75262B01881593D1C746C8C3CE8C8
-86CF532DBC7545EB71FEFB0DDE02D41F0CBBCE397A3268ED38AC09FEFB447957
-EC3E378A2202546E6931F21A1E7530BE3523BDE30E131A9993F39CE17FDEE438
-853D1F3D57E45D91E8A4B930FC00420943E78C942D8458F0A1B1DFA6492F82F8
-60FCCC61C3489AB2711270A6CF28BE65DBA89499B243503FE69CD77224F3021F
-CE71A9FF70B1C43C88F8E42387461428A841D1DA38CB352079CC08B41131B404
-DC95786F4C74ACF1D2930228A40E168CF84B122AE41797496D603D95263F9948
-AD0BFC5C30D74D3F90C18DEF1C3BB0611EC24460FD4F966995F1AA234E8808DF
-BE2B6DE6AAE516228380443CF3AEE8D89533CF255AC2D0982FE663ACF360A2D3
-7B2F9E5AE9A3464137380675BAA98A93DF016E6347BBB474E28B5E399A4C8CDA
-95A3B9CEA9F666ECE9F41F3CE151E10B1D5F1DFED5CB72F5EF113EDA32377C22
-DD0B49EF1A7C504EA453647ECD2DE34ED0D3CB42EDDEA85F4D6A1454BDF42AD9
-CA45E910A2FD55F73CEF456F0083EB85F70B762A9F9A60682DDDCCD3258C5473
-F65EA74CD5FC2D564DE3FB61FFA65F03479DE6AFA0A622D35A085C0253DBF87B
-DC6B608A90987775F99DAB0AB986C4D434DED6F272E30620A47E8CA434FEAEBC
-AD761DEA4762FD36E8CDE681E24B11F7BE2334070C677F78932BFCF06B8165CA
-B4420AC4779852FBA083CF46A260C2211D7B43BC4A40290552F4ECC0A4F8B46B
-8ECB8D06145A6ADD646B26589FF6031FEAFCFA699948C6C5495010F3E9234789
-57812F71766F83E232FBAFF49229276737A386D977A69D1EE47D32652451D924
-4698E1549BF460605D185F972A85FC9705B2E5F1632F1E076E83C8C90E474B6D
-BFC6E4A0744333F04931D5303BF8763A3DD01C6450AB9EFCE3C30F0BE6830EA4
-C10550AFAD304C2F2469D6EE1EF8471A4B71E5C8DEB4269448F79A34951C3E8B
-B93E7AE0A35C0913878819687DB77AF56A2B52495F9CE51A8618F93470B446FF
-1A98159CCCF9F1B8E63F1CC8CC65A3FA89D5D1F2A33A15AF2D6D4A05B59D0571
-A307B8227B362E9AAAEAEC72EFEF780D50814DFC8176C2F4D764DB89011C1A45
-12E8FCACDD32AACAC1FA34EDA96D79CB94D00C9D034BD0932652A09AD0E71823
-87044876E7E4E6AD4EE60E9268DA89F9B74976D6AE73A7519E99BA07E3F713D3
-EB374CC6CE999ED0C8F2C6E7AFC86DB62CA067999CA3CF3493BDC8E0F14F8807
-3D6B78B69983DB7652E4D512CC2E2EAC2EFAB1D2B84294D0E6EFC0ED689E01E3
-3C964ECA7779953A2F253A75B3395E2307E250D49E2EB5BFE629457F4E123105
-A6277B0DE169C5A4A61C51A611378140A27883C4BB1EA002CD9869CE71E1EC62
-22DF61F5927CC11DDC33A475CBC32FB85E082719B1F49E33D887CF3488376E2C
-F7ABE7FEE41A29D1A18F766F78BF70C867A989F29A4F476DD7BF839AF76E88BD
-A77546053516551E1625F8C175C736CE531743F2A18F8E223A2F4CEBF0D44385
-18C0827521B66AFE490DE54DF202309629F978AE5D55ACE621DCDFEF8588C0B7
-C5CC4E369AA9DFC5D18A91FA8F41D8818E3EF939C6516D46FFFAE220CE014F85
-C6FBA21C6A85F68585FE84F4B1F5E58D8EA211CB4B845F51C02ED57F09E642EE
-F5CF7FF95563D88AABC474669B52D7311721C2A96C1C3FB084DE1D1EEEDE81E6
-723E85CB2F68A10772B0B5174848F5D80C4032805C66FE017F909E0963543131
-AA65592D6588BCDDA9EAAC04A2A5D61CFD913D8FE1F41F3DA45754DE58100369
-66F2A0EBEE5F4A020BC0DB5497036E47BBCBD862BCFAA69BCF44A26D6382AB23
-5ED978572CB0FBC849256FC5AF95D1FFBA1D1B886B4C118741D19831073460D0
-F1EF54AAF24B6E0F11F6285D882FC12758D27C5F10F7FDCE0705D3DE172407FA
-E66F64B21AD68F4B840688098EB612F934A3BCC77D795EAA42CE26A2DE9D3CC8
-FCFDF16226CC17B92A297E240D785E533C587F973F0AC7ADE63A46B742C14594
-F76173284FE76BBBF54F1EA746214AA8723E22AF100A61D0356F001247A68656
-0636B7C4664B9DC4D9E5D5CA61F13C24E02777B10D9150420B924CB2F82FA44B
-39347503C1CBADB7E7666DF511365D5779B9BB3E053691E83E01A9F1529A6939
-9C2EEA1EE2602F9B9E2013A8388AFC43D1468C62DC825D5810F3BCBD6C3461D0
-98265AD96C4AD4D3D7E9D2B8B2C5A12A75B075BEFADC6BDDA74BB8E5E06706CB
-F071192AA34AF71F1031BDA9A3C84537E9FF14DDF538FBDA52F9D9B902AC2663
-873505F5D96E75A4648F91507F6DF299CA90BD1DCE0B2C78229D47E000D06639
-668C4C4540B99F964662931D95809B57097F40B215DFF190E5FB9EFCCC4D6B8F
-BFFC303F106994AB90BF40FCE4AF1764B6961BF7F9C391ED4BABC67698E23532
-8625573193FC2B7DA4FF344B7EE53368A75D568ED9E9703AF41E747C2CCD93A2
-07939715066E0CF30012D44C4044B4537D75CC311FAA881E18CCF9D157F87AF3
-75924E8DF44280A3F35C20E7B6E577D602FB6D67EA43D6AF7F98354EAD72840B
-5DAA49E41FDF6ECBFA5D80B9FEF10E976B3BAE6974EFB494699D0C5A6606CD19
-9084E93C4D4C9C1C23B48B9EACD0AD34C17BABA64C01BE4A5DADFA505F086DEA
-D21A76AF639F8ED341458762C5E6E25FC190BED50808E748CE61FBA24D188FE9
-10D441A4774427F61A2F9FDCBAFB9FA701E4879AD0B3132E31313342C4301A3D
-D5698BC21F9943269F5B02B3E1511C8076F44D49AFE2D2E8F58F986C4F77D63B
-83A9F2DB2C40A49782D6399F9BFFB44F6B5AF4D3A6637D60CCF31067107CF836
-A4201362EDDA47DD22DB94D98F26044C4BCAE0B5E2C11D04E05FD418E7D543A8
-42425D0068291AFBA2E5A3F2417F279C4F7D3A2B65D7875A07293830D181C9B3
-1FCB23C9CD236E861C8A9B771E0F76638B6AF3B9030A594948A470715603EED1
-759279D519C1336D7A13D031076A7D600D475171CB888B48D93CAEBD0FC40657
-0430F5312CFD124B3A848A5A3E947E7F63655C58721B7BD400C2AF4124321C5B
-31A0F0D4F45FA1E381DBE391840CDBBFB4F1C8BEEDCDEF65DC6C76FE1FA153AE
-5D7AF7A637CD62F7B3E97AC58B3B4ED8751689E981C6324F6C5779A511AFB506
-D5032B8F08BD146DC32481EFD9B3A6F6B62A3F6E1ABAAFC914B7C99BED2C3F17
-0672B57C2062BA589A720341E5837DDFAEDCB938DD796B7101DC1D6C06381709
-C9B7BF8693ACA95B731423CA51DE111059D88C60108AEBA388BEF931C0765352
-667548B2BC583D71A76E9EB521F10EA096540F50B20B8C07EE205A8189EDE811
-0CE29F5B6728297575879950B3BD6435E2A7F8F39519107557F72702B3BD3A22
-0FBBCF6ECF5A467133360975F74B1E67BCD082F486E7712183EBE2BF41E25DBC
-33FE043AB4FD9596DE10B3994B839D0C1734C3D8B92992A35ABB839D6B6E7D49
-233A0E0A2203562FF3C55D03496AEF3E0D32ED8F565E3B6E73A3FBCB8D8DC0BD
-7D36A4EAA2086618657E6775E083187D6340CA5BABC2AA8605D4AC0184406B96
-EA9E53B257FE600663E9E8430AB874EE8DA594B4D5414FDC8B76B94376A16FE9
-E2B98A5F0FDE4BA0614A67AF83270347EBC98A5AC9B962171EC337BB711E65A8
-D2E0184AC041CBCCB109744487FF25045693A22DCEDEFF949972D66F15FF0D6B
-96294011AFAA11AB7AD70C573022779716AFC303E5689D194BA0A2B401933B77
-7077EE767B3CCAB29D3FED8050DE8563675FA600DCD1DAB01FFA69671C050E1E
-C94E850BF916143CB175F6532B8F16A24835A684490B3377BDAACA1B6D1FEDA8
-94FCCD0D9922F085B4277D4C8A737BAF5B83CA6EF22D8583B3773C53E07EFFA6
-7F4186DE5B6D8BADE173932D07A5E7E66349E1360ADAD3976B23F2EEE7F4AF16
-ABF1FB9EE93792BFA78959A27AE1A4A942EBB27DB8DD7E9087C3221920C067A0
-B7AC2E61935BEA07199A1005DDADFD6212F31CEAB4E35A98CA4955AF1E9F3101
-FB829CBEDF719AD84C3A46DFCB274F71E44AD5A9DD761728C0BAD505F708DBCA
-C1DE916DA8323CCE8ECEC44EB3FE8BB1D5FDD022F3D2552E659BB10C5B603337
-64AD364473F01AE7A2D94C8F948B470059C49ED0AD738286799F85C82610F550
-B89CF1EA73D78F80FFB9EEC2C657D0174BF769F1E43D03F641A8DE9399AA848B
-BFF6FD45FC754C929F360915F92E9B3583F15ECD02F56333368EA044484C8691
-48C40D27259AE8348B978DA0873D09B0F1AE22B413DB994A10069ADCABF1B849
-3CA5CDE63956101B29B2923DE91CB738FDF629C66F8BA17559B911FCC000D416
-EB789D824184E74E1372C6408584BC2EB7E4FDFC22FA743ACD07C8C50AA15DB1
-03C3C7E8AD8EC10471C38B07FE9116BAC46B796E363940C622A66FE2EF2DAE3B
-0C4981865608A335241455CBF6B4DEC47B68F03E8213DFCBE2CACD7E58560BEA
-737C1670B54B4340460A294129BAF10EEBCAE5CDDA6F93E235136FA1EC12D6A4
-4ED6CE266B0D890437D79EAB499F924C8713E73846D208AE58D35B485C9BCE8C
-9A8CEFFA63740DB2CB9733DB9BA466180356ACB22F2314525AE04EA4D087764F
-D3522B3456C2275FE9BB3D0CDA2CB59D7E92148E739D711A2F10F7894C86608A
-8044744C88F91C808EC592E70DBDE2ADB7BD14D8FBAA1810D3D224028F58134F
-760010605FC4ACB37915ED950040AD5F26EBCEA3F7713939049F8B775C2E7926
-F47EDA3F302B80646CA7A853C6834D88A85936A88EE74EB3A5D3C98F9929CC70
-738F553FD115D264DA5112DC1B5032575D70EC5A3BC3876918C54CA46DB2D3EA
-6A9A92FA33FC10E0DC8E215FFA7E16D08C4E700401FC8DB499F49253DB1E0280
-788593A67F431D91DF1AE222426537C1357BAFD0480C4BB4BEABAB9B0DA4E42A
-7022A6CFC8A1F2A450F54EC48447657BDCD04D8A499893D452DB44E5006A0C2A
-35FC721B127E47854F899BEC7EDC5788D114C48A97A919A5A0D9D09A7D8B1B14
-5EE76BAE2B268787797231C86129B2B2C5A69452944F43DB4ED4E8EC96984262
-CB1DA28A965B7BD5FAB5509018584C67B770357AA4D74B944BFF2919E110308E
-346B80ECA9265BFF0A0663EE4735E7FC146464AE18B3EB1A05F2E8B0730DE422
-E79959C61B60FD403965FF937F409BF578B339154CEBD0A0BB6F2971B0DC3420
-579638EFBE19287D9FEBFC55196C4B9AEC60E6029D203F32109BF23BD6AFFE03
-CF1CF34C9B4F1DE35AD5002ED3649C69B3B8026D202C1890AB9AAFF5A0AC515D
-F0D2EF855FE7CF38EE5951649CB5A942296B636FA5FB3A6F8EF9FD23CEE18028
-D9A60365BE650ABA903E6A484EDF0F71028869DED5A88BC73977485F4277E036
-23AC65148BFC9CE1963049E674B88ADF6DB30CC4F6C8C4BFC3F3AF085E7B3976
-0B22DCF6DA40C63ABBD054A62ED9BBC200C1508D4F7681C1D6945C36FFD90F07
-83029A21900B6F738BBB2F2AA05D27DE3D6902E23CE4A5B40FCD03B47E5C2D24
-A02FFF8E3634CC4EC6F299F15547F28047585A356BBB244AB7BAC36D98309AA1
-BDC5380D9C47315F8DAAD1E859C725761AEB8E9B78A88F3391BAF35F7EBA488E
-94FB7B0C6FA08A451CE40486703E4FFAE3F870B6A72077238F347642983DC4D9
-3F5D3085B5047C841D5315D434FC6874E5B3B5E28607E4227AF81CE22E5E5FF9
-052977E442ED3FCCCB23F7B14139EC8CC123E33B136A06C6CCC40654701E803D
-D1FBF72DE6280EA2BDBD47C7F181F2D54DD0D0131F1A5763645990C42094B073
-0F9200566CF0B1554214C9D6F84C71AE24D5B9447016116B03E1FB4489F07288
-C2B58B66D5D624443E0CFDAACA79AB702B29E5AA024E5E17C49E675CF1EC7F3B
-90F3446686F40DE0629493BFFA0CD9CE240BDB2999F254DEC756C53091C5C23C
-22950E56B09C88250EB802948A5069801CF9ADE91BEF62AF9135DD19E0CDF451
-D70835489137045E6094F1F2A7A5878E1E5E495E528B460D509568A942304A43
-16DEB2A9B20E4512E7C611626ADEDB2DD04AB2FD65A27508317E9DDB9C97E44C
-E181D04C266B6761C5A63D5A22F44381BDD7CFF52F3AE364A5196853639CBC2F
-CB6D8E9F95291997E1B0FC7915E1BB30F1879CB6A0CD98A87AC6DD3F01E85B8B
-0836ADB32D7E6FCA2F03A7EFE38B5DBB2487132E7BF1FA8EF9AD9C940BEAA65C
-9F272A9E483A058624158FFCDF9D48E54BC1C38D9010E766DC1E99E9C7A9AF0A
-9D49AC8AA78A4F3A8364F84CD33FA29120F15936E06DD5064880E2D4F5FD8FB3
-7E47F8B0350FD52E7537F5CAA75E05717A5CB84D56DA8FCF061AAEE227DEE7D5
-8BF5E4C72DA6C7DB1FCA7D
+588AD80D9983CE7824DA30CEE5DC3114D69D7ACEC0758D8201805B82925EF3C1
+3A6757674B84D9B585F981DDFFB42163EADF90346248E014A74E3FB3E6276FC1
+B4289FCDB4FDBE9C70CAF38E410965A3610F649DF8F81C73B87FBE27D44A3CA6
+D7883821CA22795E3EED184F4F59AC687AC06DC4DE7FD098E0EA61C494A5E960
+643D78025B1D18B4B7FBACCE2DEA453E35C08A6AC093F45FA0B1DE132F743CBA
+75F2E7BE0311132C0E63C69D5182B98AEFC610F61D1E1EA51120D8A9F5DFFA8C
+37C0ECCA2120E1DF7A551343BD7573FA24144A8D59CA684FF9FCC1E023A3401E
+9797D658E92CED2255A273E429FAF43B0355E27EC83974BA4675520B2DC70DDA
+DF783452C679BB77759479CB02FF3377BCCD8580E3D87D34CD579AA3F89AAB44
+E526EE761B0D371E27B5A02A5C494C5169651FA79795D332045B3E7F2CA100FA
+FA8ADA74DCA851DA1BC7531E58EE08FC22F2F35E94D5DA013A4C9669B2825D26
+021982566B4347E518E82602B0CE5CBA1CD38E8B3CEBBFDF9E9811C896313F37
+51D5F7162441E4B2DF18A7A34326114950BE85B3E5AB465D54652575AAC03DF3
+E50E9FE8D184D33534E12AB92DF20BD72DC129A86CCC24981FF82E297D0B0F9E
+0B66137443B501B5FA711C7DF380DB1F64404DA241D1EF5F2D012A0293405302
+F828BF879F46962DFAF75F44D4A394DB9D42E4874477097FF6F8DB9BC8712BC8
+661A95A2467073355FE697CBE1D8E298569935E5405C22555C40DB775A808F54
+642939D8E4F76C61B2FE966F4FB55319873127C8EEB05732A1538FE03EC2D8CB
+9089DE328A396DAB3908179FEA2FC3F2ECC48593049FD23114A04B474FF4FBED
+4D3B8835148CCB742574F4914B7201CE41A57A42EF61099509E5C42B744611C2
+B40581A6BCF6FA223E5B5221B8BB16AC6EEE3774130E121F23A04E1548F58899
+41C9DD31E720AE7392E4E2CE0ED4B691620CDB0228D3BEE1F4BA6E289E33B7A5
+6DFDA767F5927F00BD22D4BA6397B37BBDE84BF9017C01DD5319AC7D33F8C007
+AF43EF247FDF67CE6627D4A0B0F00A3E58DF6323BDF1100660FF18496649C2EE
+6BF1D9940404E2E4B7BB00C807808BACEFF0581E38B9A7F03888BA67E73E002F
+871DA37277AB6ED4FB27AF66B9A02C62313495E94113D667CB3FA94DE087C6FA
+2481136385B557165CDEA492CE335DB20BFAFE7A3015C95D8C88F6F3065D7F72
+5484F8B665295CAF3E207C758FD9533889D7EE5E16D08577A97185871BAB4CFE
+CC58C88B3B0BA4130727C2800D2C305855369729B8CD09AFF83FFFCC3A85014E
+7358281AD0C842CC1FB985DB59470AE90BE27190DE79134F2C18447150A6706F
+5597A256370F4EFCDF59A7EA8C9BFA2A194DC5F1975D7E875F036BBA686FDC22
+8E9934A3ECE619598C0CD24B3226D55BDC6BF23ED4659DE24072454622A47FC1
+ECDF8D1B202F9178BC1075A4AD29D85545F9C08E16F5BC07C7218FE4C8914D89
+BC259609E90B47B956DE309C40E2943ED6CD471A8506FD38066AB96F573E7922
+B77B4386FDFBB8AC7154342C810D452827169AB8FDB73F50AB7EB6E38A930807
+F91212373CDDBE84FFF86ABAFBAE766F519D1DA26404D7EDFFA803DCB8382EFE
+DA1C3D22D195805069C848619646B126333D0605BD76497030E0D3E32EFFAD65
+F84003741FCCC4DFF67CA124B41DA9F0CAD27A1A46E38DA588B443C4301216DA
+5DA7A473F9C5F04B2B47446168A2017136ABFA92F6EE9C5DA2B1A92CE664659A
+027899D7BE0B322ACC0EF38EA681B4D90F5073C4B4064F8053AC54ABC1594883
+E4D836FD382F00043D97ECE2DEDDFE704F10CC450E4451679E373041B9814AF1
+0D2FE34CC22F7938562B506BC63C03AC904943C4CDCEE5D25F9B65816561962A
+68EC20E9BD6E4964226F8C64DC410AEE5DF5F607ACC023BB583D471EAD0B8190
+912DC0D8BFFA623F944AA1AB0BB1545DFBA26229F161201DADB7E07FBFA9040F
+5D6D30EBAF57A2EF4A82A30D67825A35E24F350F9F700B42BC926ADF418F6375
+A7C7AE27FF720E9A71817E395F33E8341B70DEF491B6C4AE4051D825B09535D3
+4A0E7B0853CC42956A0A2F1A7421FEBB020D1F178371271DA9893AA2082DED36
+F834704E1CDCACEEC30EFC5514FA218E88E8C9EBD5814124D637221AE0D898D1
+2EFDDF9296D8AD971873D821B5E972F89E24659DADC4D82EE284F6247933EBD6
+643E846894BF9F2A272965E7D3E1466C1AD086099C214CD475F5191FFA282F92
+6EE857FE6AFDD3FF7664E82E0E265CD5487389254F38042EBB5F9866C5B24154
+DA003C177D7E9384E8426D7B88D5701AE7C530A50F6D027904C041F690143008
+D6246306E4644AED88E76F83949352CE1329B1A5D07A1FDA04DA0BBE5F30A925
+740235EAC5DD32F81545836873EC429AD95E7F56BFE4DF70399A7AD2476EF29E
+45517385D898071118D2DE56D7A2294CB12D3E22EA35234E752DF7F061A5FF8F
+5765C7C13FC74144738679B42351E3B82CA2C91F619B5D06C1FD36661F4397B0
+7540457CCB3D2FB735BBD9ADAA24756DAD45CD5921AAB588DCC80103E1C50290
+204EC4F7F5DF74D8CFF0EEA530CA2D0E88C86431F22062276E9BF9BD68FB8517
+7245261F180FEB9CD574A82A17B8A134BBBDC9B5B7954831DCFA68E0B4266C6C
+F99588BF404005CE59C53E94B767B9EFDC1E5674970D097CC221C0C3BC825F17
+62D9F00A1B46B915BC8F0BF7AB31B3F688C9C968F516FC3DEEB149981EED2A47
+C51C8E8CA61F1744B31F483A52ECBE76606F24D90B13569A546420032EAE0F29
+0A564955B4BE1058A9E6EA3B320A15282EE2449E928C8E405BF3FECE131B30E3
+77FC3A735A6E2242C1E4A27793A0E1BB63FF7F6958E5312FE1549DDDD8E15BD1
+7BB07C6564D029C830B89880B4F49207C1602EE590898896EC49BE45DA8906B7
+380D59CE86D7AAB6B0762F624C88D886488B7F6AE9F1328FC400869CE4EEFD7E
+7BF55C3DFD059FA20338C9BB33D807236EA2EF6E1C0C1E9EB095DA69FE2831FA
+4A0F750418D935F1F0E45AECAA61ADE9D96012511981710FC4225F5C7660A2F7
+0A417E5910F4F05D43E8AE0872B16F4E46554848927F59BDA1EBC5724ACA6B1B
+6A62FA03E86D85104E88ADCBD253734F9D078543E3A9F1985FA4D4A77DF2C55C
+6F5E9257851A953F1BEF7192B89A409B5566AAC7DDA66F6DE4D89FDF39994611
+5B95857B8B6362BAEA1C939F638E527CA9F58683236B1886E5763B518D5A9F50
+012A1D991AECF0E327594A12476A68C715130D197C1EE81CEEB4DE9E05F7F4EB
+0F06054BA90F9CC30C27BE06803ADBE520115F0FB8BA26B0DA1E5A8D28F1CB00
+F7808BD2B0D629A0BE002C11FEAD0A59555E90851E47D466BD87069845B2A6E8
+53E054711A465359DAF057550B8EE9F11F8CA6DEFE6FA70FCAC9856ED992244D
+B6D8DF2428F1D09C54C41F54F939DB26081DC63D0E8AC0690E72E76EF2F004B3
+7204E227BD70421CE589A5689FA540C2889BE8B9841193BC020FC07B7B245580
+996EB478FDB9C2F3F7CF02CAFAF3005F12CC496EA254D56F4A26D841E31B2360
+8A1716DBC1A0312F66A2B19A55399BFD9D80DF17982829C3A5F790634FD86DAB
+542413C0E19CC1F40FBFB296DCF1DAD4135F688AE11C2A5896EF0C8A54F298B8
+B9C21D82E15BE4B03C7F4D0D6861F28E86D25D98292D7C7C38EE483C2D6AE68F
+5CC883C30B92FFDE6D60FD21E9E0E3441C317EE946448D26F8D169A074C92CD7
+D2FE4ADA122D99FDBACEC5D884F728266B21A6B5974B74A21884CC847747F648
+1CF5A52ADB32B3CA4DF108D086734E7F57E2DD6800F22D73F1A579B06EBE6F81
+BD6DBEFF758FC63934F89E8CCE37101AC52AE651F3BD8BC6689297E04D740F6D
+56543897EFD747491B65582F6C2896FF3C8521E6948745BA255720AD93C36766
+5669C5C91E00A093608D3376F3107F2536046299BEFE221929CE0414E50D8054
+F07AA336F93C01F28FFF407F6B726155F48F339D97E10D628DE2D5E0A2ECF9AC
+6E17695CFBEC59A0EAF50110EDE388579FE3C3EEC98A1F0414F2EC9D3A1612E2
+849A21EB33FFED0B4A753D44B6CCF61D7DA8603513059E5A5523D2FE01D2E970
+EFC7152105BB94A40C08792A75D94EF8333B6A392C51F6FF1BE5904B5877B655
+28E17551A83463B9DD6D6B2F419BD21119B7A9D14325311066AC1A20DB8986C5
+4DB51E16782B5AE654F4C0C9A92C5A1555FB54B1B7E70DADF9A303514E7F7E7B
+E99C885DF161FA302CF928BC04535666D5508D2E01514B2DC740E3715BFD603C
+D1CEF587FA9AF69D6D8019A2DF5DC33D61F1D324037A06563AE6985CA5DE4C61
+28663AAF1815F8F0B1266C2EDF1A3322FF108170DFCBC13DF794B6A4E64D7202
+E4200951568C73DCF0F2153D724DBC35F1EDA6B31FBF8E1E35C6781A47D1899C
+5710361657554359A7B07794967936966E29765A4E2B4741165EABA8A0ED123D
+13B77EA9CAFD065B3DF2967F1FC142B0435583E6D221FD15307C8A388E2CD9F2
+F7012BC7BF2D910F639F60F55508AF5A479FA963E7AA049F23A1D8EC24A90BAF
+3537A956F8F16D2242300ADCAFE145B44F89DD449B2AE64F41BB4F92DD45F6C3
+CC091487708BD252CDF835D511714F4B51749BBD34A5D812700EFBDF072A40BD
+6CE38DFC9A196589D6FC09FCCBCB7CA871FCC35B25354537B959F01E84C1F959
+9E8397B308A3BCCDFA304213116594C3D1925A815B57AA7C631773B5FD518EF6
+238F548ABA462BC1D0A17E76B53CCB2BBF7E8A785620B41C8018109CB45CE895
+BDAD0F89B25B81E4A0478D4A242D3A7A4406D932C0E9FD28E65C57CC3F146E1F
+09867E0FCE83F7C2083ADDA5C5A9FB5BF48F89DA0C4BBD45E7120016314098B4
+C6D2C37F5F7709AD5822EAC452FBA28CFEB01E3BF2DAF25C1B559F07152FAEFD
+96641B74A4249E88962604CC67F39881A685491DA88705585A7EAA097A2688CB
+FC4A8E722D560B2442B3E7EB02F34E30A8A049705DC0C1D181438E85EE53C3D9
+EB5A320A83315AD4B4D26443754B49EA70A16FFCCF753F7B1E6C7EEAD9F7ED75
+7005A52BAC977F57287B77DA642B1467B580E481D97938D1B57519B1970351E6
+A752CE77704369B0E3FA910874DC76415AD1FB4E605F0C806A1A044F300C859C
+9A76CFCF2B65CA446AC2CAFF3D9148D662EB88B39D854A4A799DEBB1BF06F120
+D0DF95A54D183ABB65041EBEB986A132B2543EF98EE749F8976279A5448CD151
+896074E5140A766A0A9E95B73C737D09FB6DE3EF8E85B87F477935A04476B0E8
+50CE7A918AB5DEB38BFB8525587CC5B6759CD3C82C2623F628C116A40D3B2AB1
+AEC0D515C14191760DFDAC3BC2154A356211A12A7EE704096F258C66F786311C
+03E84B5C05C311B04F1BCBF61FA40B6BB8E2E080B42178F225F37CC1A96CDCC0
+4ACD792C9F0AC7E7E3992238C0E4E88B04A93797E17ACBF04FCE6494299AA9B0
+37A73C4059FFBC949ADDBC0AF181B728AC3369CC6DCE58F7AC4A52A686B74C08
+56C30D0BF291B127F7435F8AA711F98342423BD6DD25D69E3D6E197AEBF90AC5
+E9675FFE7BF93DD5E6C8A89780ECC425B3D735A89C671FA5D70125CFE3B72DF3
+A54F27293135BD071CA5D2365A135A3395D39A508CD434F45793A610852E3D62
+1C717D529A82D93B90E2FF31629413B7AC1DF1EC4D6577980C34357F47899BE2
+CC95866E2140CD64D51AECA4BAF717F4D4BA13F1310F51AE6CF80689F7A1BD04
+1474C8E2B7A640DFCDCDECB7FF9690E8E6FF62FA9842293A1264D9C4AA5FC6DE
+84C36FB9334F5F9CA1B3DC4516D4CA3BD116605F5C5D0FB2F30FA080F83891DF
+1A23D9C420B3F204085591E4C88C7B26452B329DD0B1F9EDC7B065F21A4B6F60
+349D37A85C5985667040DDE858B27C832CB50CCE7BB9E1EC9C2D5C1B0F05D027
+65A743C13523FFFD455B9C8DE573E76522A8912AF192008DF97D7DED77FB56E6
+FC220D2E27CA29ABE1A138D3FEF84A0306D4DE8ABA3B65D6AACCF1E456C14293
+13A2E52EEAD3CE4D2980714C087C0606768FCE35D9F84873379C90A118B9F4D3
+6008721909002435E6242C5BDB4F85AD82D5C9D548B5786F50821A59FA41D0CC
+F096FD004329DDB25C494E4E1D63065EF6CE62C5C59084082182E139109B0E25
+09B500940B0B254F6E76445AB01617C35831FF74DDEA2C582D7E1B736A23322A
+4564662F5D21F638CE58055212A66C29755303AF713D54BC4EF5BDD0AF37FE84
+04986F5DB72899B3642B53E80BE87161B5106E8C0114A985CD72DB6E6D3171C0
+8AC789185A6608C45889D19C9574E8B1042846B5E53F303273ACD9985F92874B
+0395250173AABA938AF4551E955106AF3D1FAB12AEF599E758278C9C4B0B6EAC
+346765F34498198FDB4D2ED8EE4399921A3D380DA97F573E76588A46A927E56B
+02EBBE1A628EAD4DCF52726AB2D444450598904C10C0BEEA4D4D313B03ED8BB8
+D5E1125C7F4A24F3F4757365B838BBBB93E232CEB9E8A02531B4E9D116D56E7D
+5A9D547E7A00301433B3B8906D494A47B358C51E09BF70DCBE06D594E4A27C54
+83020848F8052038C052AC353AEF3E9D3EBBCD74357873ACDA704659A7962538
+B2D7829C4808D58E17B2DB2E20E464B53445674ED6B373CDE6DFC48AF4268447
+7DA072CB3B480B0D1C26B9753F5A34BAC7380F43ADE718172C399D335A2E88B3
+F14DBF6F091FA427B89FD51C12401441AD767AEEB19CCC2643FEA6BFAF53A057
+F7594CFB89E5DAECDFE36D1CA884C287B5AD943EEC86FB91BCE72693E7586E59
+F594D067F101A95A1CFE062799F9B6AE9E14E1CEE9A9AC23975B534749D9912E
+B5190AF0CBA729B70BCBF2433BC8C2808CB6A3A64E87A140E4532AF41F55CE51
+2BF9B4EF348B1F8CC7500847A076EAA125670223BA1BBDC979707493F7DE73CC
+78D79A4CF61F4AB8A819F9DF633BE00ACFACFC63438BD5F9CB65F7DBE1C1A99E
+AE9E8141EB065D30C17A79C2FC3686F2D13A187C69353374DDE142619D7C6989
+9414C36749E400F0D56C0DD786448421F4D638A1D545BDA0DA9637953D299743
+7A4519B437DEAB7461B69C96DC33B3834897568ACF6C66628DEF7AE597ACCFBB
+E273232CC0BFE67E9B89B7F0AC82F5C629E512411A9060D02623BAB507671545
+09EA818A7C0A94A01007DD0D7DD286C22B9ED463836B1D328290B3836FAB5F25
+380917C153901773BBE997031F8267CC91FE3C1916DF6AC46E44791A0863198F
+8FB8478724C22BB2732F945B39E4541C0168C45FC18FC7CCAC13FBEA39A93806
+6DEF0FBD7507AD086EA89EB278DB92A9F44D9A8584754643FFFF9C411587D22A
+C317E99C08DD469A3A2CB264C3899725338B923F660E1DB69BDC42D5C8BE2193
+B3139B8F53777949C20CFFE8918249DA5606C5F826997E18664085BCFC8FE460
+8D8B5EE4D0EF5D9C2F78246F757F01D2C2CE8EE265DA8038A276EA69BB8651A5
+2418E8479CB00E750644F3745408AE4ECF34B6774AA58D43D28C46DF56A9CCE0
+D7EB1B3E4010F1914A6AD8B0ED7A9104A16A1B2DED8937A5779B2B7E6F724FCF
+FBAFD79D2B7840E3F6E4378CE20185DAF51CD5DCDA7F797E5EF992C9B7BD2089
+FEB3A7165FA82A23E5CB0C99003BD75E3B9B00D5308C5C71FA9A4B2E3FC31B84
+35AC901ABEF4AEDBD785E30DEB848014955D1D0B25932AD4420B4FA52830FC10
+EFDABB03B27E85BBBFA667C76E4B5A68F4BC2D2F0BF631E43DC0A18522911998
+834B89CBFE29DEF493B9E87B93D7D9D886FAAC41023231E069E6B0FE3BF904A6
+7149D092E733AA2CA5442C49CC496662F11EA262C67CD191E9BB8FCDF54DEFC5
+ABF141056F515EB48AE9DD502F285F2488119652DA821EA3BF2E7D9895601DBA
+0B042D7D2CB609A542734B3F63FC3AF4FDA552BA15DA5E02C23CEB0F0BB14DB5
+2100EC71E868218241E86741638AA14DC1FCE8C1CB035D61C1F9F67EE3D85BFD
+BF9EA07AEC4787D7C40557DCA541E7CBDCCDA950AE2E95ABF82633E20F2A58CF
+14D205265FF7A1A3524562F62C4C3FA62043B4518AFB0616BEA02145B679BEE9
+CF367A8E5C053F22A004B8ECC26CE1FD6C425A37F9F7EA73AF4A9E9E2366B573
+BA26C25CA60D1436CB40824EF20C87734EBF7FB87EFE47C0292750EA29667BFC
+5DA8A01867A94332D779082BDC1114E128ACC6518F8D9B3A21AD8AF7463A42E2
+FB7E29BBBA59189421BAF708893FBB471406F264DEF7F9CA2C42A4956F8CA7D5
+BAC73FCB2B21D6F16836D2E5BC7ED04638ED3D0C480B0E057B05075C0A92464C
+6F6E151C818246B845E5056ABD9DBD8219D4086DF9BE0E13F594450B737C0512
+DE7BCF813764645FC7696D572A873CF1075B1627279D6E3EC493627E06DBD02B
+C978BB7D39F80CF960354B963F4302281538C6EB420E55E899D9D101798D5CD9
+3E8FC2675D6A5CB2F2423542FB62CDD78A962EB2D63833E6DE848FEE15430A66
+AD244BD768A3BC8307C833997EFD0735A852B6539E7E873A62461F32820B062E
+ED77AF1F260D9B4EC55C60C0B2658528C088357C039DF1F3F85AE16917C77273
+55CE42CAC9C5499E07508FEC82BA810C6AF5AB0F597F3174F91DDD9007100491
+1859D303E60AE00ECED21FF7258B613B342C57C22947D60DA3143C3FBC073FB4
+E41E8268DA25ED1D3E030915576519155CCDA8053BBA3BDFBA018C368A077545
+DB789190EC4E7D7EB9AAB77E54F49B07783EEF138026C7101CD5315D14E0F9FB
+2BEFC34B5B1A03D2449A1ED3F26DCB75EA542C995EFE140B51B9508737817A9C
+962FE2A0B3650F7770C6310F8A0DDD48EC86BA3958F5343C61A2971B413B52F2
+38E66EC71F73DBC29E6798DF7CFCB3103F1841A4D8FCE51983F03EA288BC0045
+0D3565C494E7BFF2178F273FD714ECF7DCD6519A9BB36F95E05A3F2449F89DD9
+E564458349C34A3CD770EFF268495183A0
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -2311,8 +2307,8 @@
 @start /Fa 242[61 13[{ TeXbbad153fEncoding ReEncodeFont }1
 49.8132 /CMSY6 rf /Fb 134[32 1[43 32 34 24 24 24 1[34
 30 34 50 18 32 1[18 34 30 19 27 34 27 34 30 13[34 44
-1[41 47 1[54 3[22 1[47 39 2[43 1[45 6[18 4[30 30 1[30
-30 30 1[18 21 18 44[{ TeXf7b6d320Encoding ReEncodeFont }41
+1[41 47 1[54 3[22 1[47 39 2[43 1[45 6[18 3[30 1[30 1[30
+1[30 1[18 21 18 44[{ TeXf7b6d320Encoding ReEncodeFont }40
 49.8132 /CMR6 rf /Fc 135[33 3[24 29 4[40 58 18 2[22 36
 2[33 36 33 33 36 50[22 46[{ TeX74afc74cEncoding ReEncodeFont }14
 66.4176 /CMTI8 rf /Fd 134[43 43 59 43 45 32 32 34 1[45
@@ -2351,7 +2347,7 @@
 %%Page: 1 1
 TeXDict begin @landscape 1 0 bop -169 -357 a Fj(Org-Mo)t(de)45
 b(Reference)h(Card)g(\(1/2\))546 -242 y Fi(\(for)23 b(v)n(ersion)h
-(4.01\))-150 -39 y Fh(Getting)37 b(Started)-150 89 y
+(4.02\))-150 -39 y Fh(Getting)37 b(Started)-150 89 y
 Fg(\(add-to-list)i('auto-mode-alist)h('\("\\\\.org$")e(.)e
 (org-mode\)\))-150 172 y(\(define-key)i(global-map)h("\\C-cl")e
 ('org-store-link\))1504 148 y Ff(2)-150 254 y Fg(\(define-key)h
@@ -2564,7 +2560,7 @@
 %%Page: 2 2
 TeXDict begin @landscape 2 1 bop -169 -357 a Fj(Org-Mo)t(de)45
 b(Reference)h(Card)g(\(2/2\))546 -242 y Fi(\(for)23 b(v)n(ersion)h
-(4.01\))-150 -45 y Fh(Agenda)37 b(Views)-150 102 y Fi(add/mo)n(v)n(e)25
+(4.02\))-150 -45 y Fh(Agenda)37 b(Views)-150 102 y Fi(add/mo)n(v)n(e)25
 b(curren)n(t)f(\014le)g(to)g(fron)n(t)g(of)f(agenda)197
 b Fg(C-c)36 b([)-150 172 y Fi(remo)n(v)n(e)24 b(curren)n(t)g(\014le)g
 (from)f(y)n(our)g(agenda)299 b Fg(C-c)36 b(])-150 242
@@ -2759,9 +2755,9 @@
 (mak)n(e)h(Org-mo)r(de)e(notice)i(the)f(c)n(hange.)4242
 3659 y Ff(4)4303 3683 y Fi(Keybinding)g(a\013ected)i(b)n(y)e
 Fg(org-CUA-compatibility)p Fi(.)4535 3770 y Fb(Cop)n(yrigh)n(t)4838
-3768 y(c)4821 3770 y Fa(\015)d Fb(2005)i(F)-5 b(ree)21
+3768 y(c)4821 3770 y Fa(\015)d Fb(2006)i(F)-5 b(ree)21
 b(Soft)n(w)n(are)i(F)-5 b(oundation,)20 b(Inc.)4795 3826
-y(v4.01)h(for)h(Org-Mo)r(de)e(4.01,)i(2005)4912 3882
+y(v4.02)h(for)h(Org-Mo)r(de)e(4.02,)i(2006)4912 3882
 y(Author:)k(Philip)18 b(Ro)r(ok)n(e)4473 3937 y(based)j(on)g(refcard)g
 (design)g(and)f(format)i(b)n(y)f(Stephen)f(Gildea)4242
 4022 y(P)n(ermission)28 b(is)f(gran)n(ted)i(to)f(mak)n(e)h(and)e
--- a/etc/orgcard.tex	Thu Jan 05 14:02:59 2006 +0000
+++ b/etc/orgcard.tex	Fri Jan 06 16:13:05 2006 +0000
@@ -1,4 +1,4 @@
-% Reference Card for Org Mode 4.01
+% Reference Card for Org Mode 4.02
 %
 %**start of header
 \newcount\columnsperpage
@@ -18,7 +18,7 @@
 
 \columnsperpage=3
 
-% Copyright (c) 2004 Philip Rooke, 2005 Free Software Foundation
+% Copyright (c) 2004 Philip Rooke, 2005, 2006 Free Software Foundation
 
 % GNU Emacs is free software; you can redistribute it and/or modify
 % it under the terms of the GNU General Public License as published by
@@ -58,11 +58,11 @@
 % Thanks to Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik
 % for their many good ideas.
 
-\def\orgversionnumber{4.01}
-\def\year{2005}
+\def\orgversionnumber{4.02}
+\def\year{2006}
 
 \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
-  \centerline{\small \copyright\ 2004, 2005\ Free Software Foundation, Inc.
+  \centerline{\small \copyright\ 2004, 2005, 2006\ Free Software Foundation, Inc.
   Permissions on back.  v\orgversionnumber}}
 
 \def\copyrightnotice{
--- a/lisp/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,221 @@
+2006-01-05  Bill Wohler  <wohler@newt.com>
+
+	* Makefile.in (compile-always): Add mh-autoloads dependency.
+	(bootstrap): Remove mh-autoloads dependency, as compile dependency
+	provides it.
+	(updates): Remove mh-autoloads dependency, since it probably has
+	already run recently (via recompile).
+
+2006-01-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* textmodes/flyspell.el (flyspell-accept-buffer-local-defs): Add an
+	argument `force' to disable the flyspell-last-buffer optimization.
+	(flyspell-mode-on): Use it.
+
+	* progmodes/flymake.el (flymake-get-cleanup-function): Default to
+	flymake-simple-cleanup.
+	(flymake-allowed-file-name-masks): Use this new default.
+	All the functions are now called in the right buffer rather than
+	passing the buffer as argument.
+	(flymake-process-sentinel): Switch to buffer before calling cleanup.
+	(flymake-parse-err-lines): Remove redundant buffer arg.
+	(flymake-get-program-dir): Comment out unused function.
+	(flymake-start-syntax-check, flymake-start-syntax-check-process):
+	Remove redundant buffer argument.
+	(flymake-get-real-file-name, flymake-simple-java-cleanup)
+	(flymake-simple-cleanup, flymake-master-cleanup): Remove buffer arg.
+
+2006-01-05  Richard M. Stallman  <rms@gnu.org>
+
+	* info.el (Info-find-node): Don't record previous node if have none.
+	(info): Go to directory only if history is empty.
+
+	* simple.el (mark): Doc fix.
+
+2006-01-05  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el (mac-ae-parameter): Don't coerce data if it is
+	already of desired type.
+	(mac-ae-list): Coerce parameter to "list" type.
+	(mac-dispatch-apple-event): Replace cadr part of event with a
+	dummy position so that event-start returns it.
+
+2006-01-05  Carsten Dominik  <dominik@science.uva.nl>
+
+	* textmodes/org.el: (org-end-of-subtree): New function.
+	(org-cycle, org-subtree-end-visible-p, org-scan-tags):
+	Use `org-end-of-subtree'.
+	(org-agenda, org-agenda-convert-date): Protect calls to
+	`fit-window-to-buffer'.
+	(org-tags-view): Force matching of sublevels when doing a
+	todo-only search.  Define the correct redo command, including the
+	arguments.
+	(org-agenda-redo): Display message.
+	(org-check-for-org-mode): New function.
+	(org-agenda-type): New variable.
+	(org-timeline, org-agenda-list, org-todo-list, org-tags-view):
+	Set `org-agenda-type'.
+	(org-agenda-check-type): New function.
+	(org-agenda-goto-today, org-agenda-later, org-agenda-earlier)
+	(org-agenda-week-view, org-agenda-day-view)
+	(org-agenda-next-date-line, org-agenda-previous-date-line)
+	(org-agenda-log-mode, org-agenda-toggle-diary)
+	(org-agenda-toggle-time-grid, org-agenda-date-later)
+	(org-agenda-date-prompt, org-agenda-diary-entry)
+	(org-agenda-execute-calendar-command, org-agenda-goto-calendar)
+	(org-agenda-convert-date, org-agenda-menu):
+	Use `org-agenda-check-type'.
+	(org-make-overlay, org-delete-overlay)
+	(org-detatch-overlay, org-move-overlay, org-overlay-put):
+	New compatibility functions.
+	(org-calendar-select-mouse): New command.
+
+2006-01-04  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-edit.el (Custom-reset-current, Custom-reset-saved)
+	(Custom-reset-standard): Fix y-or-n-p messages.
+	(custom-link): New face for links.
+	(custom-buffer-create-internal, custom-manual): Use it.
+	(custom-face-save): Push to theme-face before setting face spec.
+
+	* wid-edit.el (widget-default-mouse-face-get): New function.
+	(widget-specify-button): Handle mouse-face like button-face.
+
+	* custom.el (load-theme): Clear old theme settings if reloading.
+
+2006-01-03  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* cus-edit.el (custom-buffer-create-internal): Move whole buffer
+	"Erase Customization" button back to same position it occupies in
+	the individual State menus.
+
+2006-01-04  Kim F. Storm  <storm@cua.dk>
+
+	* wid-edit.el (key-sequence): Rework widget to read key binding
+	using `kbd' syntax.  Use C-q to insert literal key, event, or code.
+	(widget-key-sequence-default-value): Default value for empty sequence.
+	(widget-key-sequence-map): New map for reading key binding.  Bind C-q.
+	(widget-key-sequence-read-event): New command for C-q.
+	(widget-key-sequence-validate, widget-key-sequence-value-to-internal)
+	(widget-key-sequence-value-to-external): New functions.
+
+2006-01-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/flymake.el (flymake-create-temp-with-folder-structure):
+	Use expand-file-name.
+	(flymake-delete-temp-directory): Use expand-file-name,
+	file-name-directory, and directory-file-name.
+	(flymake-strrchr): Delete.
+	(flymake-start-syntax-check): Don't pass the redundant buffer argument
+	to the init-f function.
+	(flymake-save-buffer-in-file, flymake-init-create-temp-buffer-copy)
+	(flymake-init-find-buildfile-dir)
+	(flymake-init-create-temp-source-and-master-buffer-copy)
+	(flymake-simple-make-init-impl, flymake-simple-make-init)
+	(flymake-master-make-init, flymake-master-make-header-init)
+	(flymake-simple-make-java-init, flymake-simple-ant-java-init)
+	(flymake-perl-init, flymake-simple-tex-init, flymake-master-tex-init)
+	(flymake-xml-init): Remove corresponding redundant buffer argument.
+	(flymake-allowed-file-name-masks): Remove last elems that are equal to
+	the default anyway.  Clean up regexps.
+
+	* progmodes/flymake.el (flymake-temp-source-file-name)
+	(flymake-master-file-name, flymake-temp-master-file-name)
+	(flymake-base-dir): New buffer-local vars.
+	(flymake-buffer-data, flymake-get-buffer-value)
+	(flymake-set-buffer-value): Replace those hash-tables by the new
+	buffer-local vars.  Update callers.
+
+	* progmodes/flymake.el (flymake-check-start-time)
+	(flymake-check-was-interrupted, flymake-err-info, flymake-is-running)
+	(flymake-last-change-time, flymake-new-err-info, flymake-timer):
+	Move definition, so we can remove redundant earlier declaration.
+	(flymake-replace-regexp-in-string, flymake-split-string)
+	(flymake-get-temp-dir): Use defalias.
+	(flymake-popup-menu): Remove `pos' argument.  Use posn-at-point.
+	(flymake-xemacs-window-edges): Remove unused function.
+	(flymake-get-point-pixel-pos): Move.
+	(flymake-pid-to-names, flymake-reg-names)
+	(flymake-get-source-buffer-name, flymake-unreg-names): Remove.
+	Replace by a simple list flymake-processes and by process-buffer.
+	Update callers.  Other than simplify the code, it uses buffers rather
+	than buffer-names so it doesn't get confused by uniquify.
+	(flymake-buffer-data): The global value should just be nil.
+
+	* emacs-lisp/bytecomp.el (byte-compile-file-form-defalias):
+	Optimize the body of a defalias like any other code.
+
+	* font-lock.el (font-lock-fontify-buffer, font-lock-fontify-region):
+	Make sure we've setup font-lock's vars.  It may influence which
+	function we then call.
+	(font-lock-default-fontify-buffer): Don't bother calling set-defaults
+	here since it's too late anyway.
+
+2006-01-03  Romain Francoise  <romain@orebokech.com>
+
+	* startup.el (fancy-splash-tail, normal-splash-screen):
+	Update copyright year.
+
+2006-01-02  J.D. Smith  <jdsmith@as.arizona.edu>
+
+	* mouse.el (mouse-drag-track): Rename, from
+	`mouse-drag-region-1'.  Includes optional argument required to
+	enable post-drag event processing (e.g. delete region keys).
+	Can be used without this argument to track a mouse region and operate
+	on it as soon as the drag completes.
+	(mouse-drag-region): Use `mouse-drag-track'.
+
+2006-01-02  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-edit.el (custom-guess-name-alist, custom-guess-doc-alist):
+	Move to `custom-buffer' group.
+
+	* cus-theme.el: Rewrite the Custom New Theme Mode interface.
+	(custom-new-theme-mode-map, custom-theme-insert-variable-marker)
+	(custom-theme-insert-face-marker, custom-theme-variable-menu)
+	(custom-theme-face-menu): New variables.
+	(custom-theme-add-variable, custom-theme-variable-action)
+	(custom-variable-reset-theme, custom-theme-delete-variable)
+	(custom-face-reset-theme, custom-theme-face-action)
+	(custom-theme-delete-face, custom-theme-merge-theme)
+	(custom-theme-add-face, custom-theme-visit-theme): New functions.
+
+2006-01-01  Chong Yidong  <cyd@stupidchicken.com>
+
+	* custom.el: Move Custom Themes commentary to start of theme code.
+	(custom-known-themes): Rename `standard' theme to `changed'.
+	(custom-push-theme): Caller no longer specifies what theme to use
+	when doing `reset'---the setting is simply removed from the theme.
+	Delete MODE from `theme-value' and `theme-settings' properties.
+	(custom-declare-theme): Ignore &rest args since we don't use them.
+
+	(custom-loaded-themes): Delete variable.
+	(custom-theme-load-themes, custom-theme-loaded-p)
+	(custom-theme-value): Delete functions.
+
+	(custom-declare-theme): Signal error on invalid theme names.
+	(provide-theme): custom-loaded-themes was deleted.
+	(load-theme): Load the file unconditionally.
+	(enable-theme): Call `load-theme' if theme is undefined.
+	(custom-enabled-themes): Only update value for successful loads.
+	(disable-theme): Complete from enabled themes when interactive.
+	(custom-variable-theme-value): Calculate theme value directly.
+
+	(custom-theme-reset-variables, custom-reset-variables): Mark as
+	XEmacs compatibility functions.  We don't actually use these.
+
+	* cus-edit.el (custom-variable-state-set):
+	Use custom-variable-theme-value instead of custom-theme-value.
+	(custom-face-state-set): Rename `standard' theme to `changed'.
+	(custom-save-variables, custom-save-faces): Delete unneeded
+	references to custom-reset-variables.
+	(custom-save-resets): Delete function.
+	(custom-save-variables, custom-save-faces): MODE argument deleted.
+	(custom-save-variables, custom-save-faces): Ignore theme values.
+
+	* cus-face.el (custom-theme-reset-faces): Mark as XEmacs
+	compatibility function.
+
 2006-01-01  Richard M. Stallman  <rms@gnu.org>
 
 	* cus-edit.el (Custom-set, Custom-save): Ask for confirmation.
--- a/lisp/Makefile.in	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/Makefile.in	Fri Jan 06 16:13:05 2006 +0000
@@ -1,5 +1,5 @@
 # Maintenance productions for the Lisp directory
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -117,7 +117,7 @@
 	   $(srcdir)/update-subdirs $$file; \
 	done;
 
-updates: update-subdirs autoloads mh-autoloads finder-data custom-deps
+updates: update-subdirs autoloads finder-data custom-deps
 
 # This is useful after "cvs up".
 cvs-update: recompile autoloads finder-data custom-deps
@@ -169,7 +169,7 @@
 # unconditionally.  Some files don't actually get compiled because they
 # set the local variable no-byte-compile.
 
-compile-always: $(lisp)/subdirs.el doit
+compile-always: $(lisp)/subdirs.el mh-autoloads doit
 	# `|| true' prevents old Bash versions from getting confused
 	# by an error.
 	find $(lisp) -name "*.elc" -print | xargs chmod +w >/dev/null 2>&1 || true; \
@@ -283,7 +283,7 @@
 
 # Generate/update files for the bootstrap process.
 
-bootstrap: update-subdirs autoloads mh-autoloads compile
+bootstrap: update-subdirs autoloads compile
 
 # Generate/update files after the bootstrap process.
 # custom-deps needs `preloaded-file-list'.
--- a/lisp/cus-edit.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/cus-edit.el	Fri Jan 06 16:13:05 2006 +0000
@@ -619,7 +619,7 @@
 This is used for guessing the type of variables not declared with
 customize."
   :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
-  :group 'customize)
+  :group 'custom-buffer)
 
 (defcustom custom-guess-doc-alist
   '(("\\`\\*?Non-nil " boolean))
@@ -633,7 +633,7 @@
 This is used for guessing the type of variables not declared with
 customize."
   :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
-  :group 'customize)
+  :group 'custom-buffer)
 
 (defun custom-guess-type (symbol)
   "Guess a widget suitable for editing the value of SYMBOL.
@@ -768,8 +768,8 @@
     (message "Aborted")))
 
 (defvar custom-reset-menu
-  '(("Current" . Custom-reset-current)
-    ("Saved" . Custom-reset-saved)
+  '(("Reset to current settings" . Custom-reset-current)
+    ("Reset to saved settings" . Custom-reset-saved)
     ("Erase Customization (use standard values)" . Custom-reset-standard))
   "Alist of actions for the `Reset' button.
 The key is a string containing the name of the action, the value is a
@@ -779,7 +779,7 @@
 (defun custom-reset (event)
   "Select item from reset menu."
   (let* ((completion-ignore-case t)
-	 (answer (widget-choose "Reset to"
+	 (answer (widget-choose "Reset settings"
 				custom-reset-menu
 				event)))
     (if answer
@@ -788,7 +788,7 @@
 (defun Custom-reset-current (&rest ignore)
   "Reset all modified group members to their current value."
   (interactive)
-  (if (y-or-n-p "Update buffer text to show all current settings? ")
+  (if (y-or-n-p "Reset buffer to show current settings? ")
       (let ((children custom-options))
 	(mapc (lambda (widget)
 		(if (memq (widget-get widget :custom-state)
@@ -800,7 +800,7 @@
 (defun Custom-reset-saved (&rest ignore)
   "Reset all modified or set group members to their saved value."
   (interactive)
-  (if (y-or-n-p "Update buffer text to show all saved settings? ")
+  (if (y-or-n-p "Reset all settings to saved values? ")
       (let ((children custom-options))
 	(mapc (lambda (widget)
 		(if (memq (widget-get widget :custom-state)
@@ -819,7 +819,7 @@
     (if (or (and (= 1 (length children))
 		 (memq (widget-type (car children))
 		       '(custom-variable custom-face)))
-	    (yes-or-no-p "Really erase all customizations in this buffer? "))
+	    (yes-or-no-p "Erase all customizations in this buffer? "))
 	(mapc (lambda (widget)
 		(and (if (widget-get widget :custom-standard-value)
 			 (widget-apply widget :custom-standard-value)
@@ -1456,12 +1456,16 @@
 				 "Square brackets indicate")))
 	(widget-create 'info-link
 		       :tag "Custom file"
+		       :button-face 'custom-link
+		       :mouse-face 'highlight
 		       "(emacs)Saving Customizations")
 	(widget-insert
 	 " for information on how to save in a different file.\n
 See ")
 	(widget-create 'info-link
 		       :tag "Help"
+		       :button-face 'custom-link
+		       :mouse-face 'highlight
 		       :help-echo "Read the online help."
 		       "(emacs)Easy Customization")
 	(widget-insert " for more information.\n\n")
@@ -1473,6 +1477,15 @@
 Make your editing in this buffer take effect for this session."
 		 :action (lambda (widget &optional event)
 			   (Custom-set)))
+  (if (not custom-buffer-verbose-help)
+      (progn
+	(widget-insert " ")
+	(widget-create 'info-link
+		       :tag "Help"
+		       :button-face 'custom-link
+		       :mouse-face 'highlight
+		       :help-echo "Read the online help."
+		       "(emacs)Easy Customization")))
   (when (or custom-file user-init-file)
     (widget-insert " ")
     (widget-create 'push-button
@@ -1486,18 +1499,11 @@
       (progn
 	(widget-insert " ")
 	(widget-create 'push-button
-		       :tag "Reset"
+		       :tag "Reset buffer"
 		       :help-echo "Show a menu with reset operations."
 		       :mouse-down-action (lambda (&rest junk) t)
 		       :action (lambda (widget &optional event)
 				 (custom-reset event))))
-    (widget-insert " ")
-    (when (or custom-file user-init-file)
-      (widget-create 'push-button
-		     :tag "Erase Customization"
-		     :help-echo "\
-Un-customize all settings in this buffer--save them with standard values."
-		     :action 'Custom-reset-standard)))
     (widget-insert "\n ")
     (widget-create 'push-button
 		   :tag "Reset to Current"
@@ -1510,13 +1516,13 @@
 		   :help-echo "\
 Reset all settings in this buffer to their saved values."
 		   :action 'Custom-reset-saved)
-  (if (not custom-buffer-verbose-help)
-      (progn
-	(widget-insert " ")
-	(widget-create 'info-link
-		       :tag "Help"
-		       :help-echo "Read the online help."
-		       "(emacs)Easy Customization")))
+    (widget-insert " ")
+    (when (or custom-file user-init-file)
+      (widget-create 'push-button
+		     :tag "Erase Customization"
+		     :help-echo "\
+Un-customize all settings in this buffer and save them with standard values."
+		     :action 'Custom-reset-standard)))
   (widget-insert "   ")
   (widget-create 'push-button
 		 :tag "Finish"
@@ -1701,6 +1707,8 @@
 (define-widget 'custom-manual 'info-link
   "Link to the manual entry for this customization option."
   :help-echo "Read the manual entry for this option."
+  :button-face 'custom-link
+  :mouse-face 'highlight
   :tag "Manual")
 
 ;;; The `custom-magic' Widget.
@@ -2045,6 +2053,17 @@
 ;; backward-compatibility alias
 (put 'custom-state-face 'face-alias 'custom-state)
 
+(defface custom-link
+  '((((min-colors 88)
+      (class color) (background light)) :foreground "blue1" :underline t)
+    (((class color) (background light)) :foreground "blue" :underline t)
+    (((min-colors 88)
+      (class color) (background dark)) :foreground "cyan1" :underline t)
+    (((class color) (background dark)) :foreground "cyan" :underline t)
+    (t :underline t))
+  "Face for Info links in customization buffers."
+  :group 'info)
+
 (define-widget 'custom 'default
   "Customize a user option."
   :format "%v"
@@ -2207,6 +2226,8 @@
 		  (insert " ")
 		  (push (widget-create-child-and-convert
 			 widget 'custom-group-link
+			 :button-face 'custom-link
+			 :mouse-face 'highlight
 			 :tag (custom-unlispify-tag-name symbol)
 			 symbol)
 			buttons)
@@ -2578,15 +2599,13 @@
 		       (if (condition-case nil
 			       (and (equal comment temp)
 				    (equal value
-					   (eval (car
-						  (custom-theme-value
-						   (caar tmp) tmp)))))
+					   (eval
+					    (car (custom-variable-theme-value
+						  symbol)))))
 			     (error nil))
 			   (cond
-			    ((eq 'user (caar (get symbol 'theme-value)))
-			     'saved)
-			    ((eq 'standard (caar (get symbol 'theme-value)))
-			     'changed)
+			    ((eq (caar tmp) 'user) 'saved)
+			    ((eq (caar tmp) 'changed) 'changed)
 			    (t 'themed))
 			 'changed))
 		      ((setq tmp (get symbol 'standard-value))
@@ -2603,39 +2622,40 @@
   (get (widget-value widget) 'standard-value))
 
 (defvar custom-variable-menu
-  `(("Set for Current Session" custom-variable-set
+  `(("Set for current session" custom-variable-set
      (lambda (widget)
        (eq (widget-get widget :custom-state) 'modified)))
     ,@(when (or custom-file user-init-file)
-	'(("Save for Future Sessions" custom-variable-save
+	'(("Save for future sessions" custom-variable-save
 	   (lambda (widget)
-	     (memq (widget-get widget :custom-state) '(modified set changed rogue))))))
-    ("Reset to Current" custom-redraw
+	     (memq (widget-get widget :custom-state)
+		   '(modified set changed rogue))))))
+    ("---" ignore ignore)
+    ("Reset to current value" custom-redraw
      (lambda (widget)
        (and (default-boundp (widget-value widget))
 	    (memq (widget-get widget :custom-state) '(modified changed)))))
-    ("Reset to Saved" custom-variable-reset-saved
+    ("Reset to saved value" custom-variable-reset-saved
      (lambda (widget)
        (and (or (get (widget-value widget) 'saved-value)
 		(get (widget-value widget) 'saved-variable-comment))
 	    (memq (widget-get widget :custom-state)
 		  '(modified set changed rogue)))))
+    ("Reset to backup value" custom-variable-reset-backup
+     (lambda (widget)
+       (get (widget-value widget) 'backup-value)))
     ,@(when (or custom-file user-init-file)
-	'(("Erase Customization" custom-variable-reset-standard
+	'(("Erase customization" custom-variable-reset-standard
 	   (lambda (widget)
 	     (and (get (widget-value widget) 'standard-value)
 		  (memq (widget-get widget :custom-state)
 			'(modified set changed saved rogue)))))))
-    ("Use Backup Value" custom-variable-reset-backup
-     (lambda (widget)
-       (get (widget-value widget) 'backup-value)))
     ("---" ignore ignore)
-    ("Add Comment" custom-comment-show custom-comment-invisible-p)
-    ("---" ignore ignore)
-    ("Don't show as Lisp expression" custom-variable-edit
+    ("Add comment" custom-comment-show custom-comment-invisible-p)
+    ("Show value widget" custom-variable-edit
      (lambda (widget)
        (eq (widget-get widget :custom-form) 'lisp)))
-    ("Show initial Lisp expression" custom-variable-edit-lisp
+    ("Show Lisp expression" custom-variable-edit-lisp
      (lambda (widget)
        (eq (widget-get widget :custom-form) 'edit))))
   "Alist of actions for the `custom-variable' widget.
@@ -2772,7 +2792,7 @@
     (cond ((or value comment)
 	   (put symbol 'variable-comment comment)
 	   (custom-variable-backup-value widget)
-	   (custom-push-theme 'theme-value symbol 'user 'set value)
+	   (custom-push-theme 'theme-value symbol 'user 'set (car-safe value))
 	   (condition-case nil
 	       (funcall set symbol (eval (car value)))
 	     (error nil)))
@@ -2790,15 +2810,14 @@
 restoring it to the state of a variable that has never been customized.
 The value that was current before this operation
 becomes the backup value, so you can get it again."
-  (let* ((symbol (widget-value widget))
-	 (set (or (get symbol 'custom-set) 'set-default)))
+  (let* ((symbol (widget-value widget)))
     (if (get symbol 'standard-value)
 	(custom-variable-backup-value widget)
       (error "No standard setting known for %S" symbol))
     (put symbol 'variable-comment nil)
     (put symbol 'customized-value nil)
     (put symbol 'customized-variable-comment nil)
-    (custom-push-theme 'theme-value symbol 'user 'reset nil)
+    (custom-push-theme 'theme-value symbol 'user 'reset)
     (custom-theme-recalc-variable symbol)
     (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
       (put symbol 'saved-value nil)
@@ -3276,27 +3295,27 @@
 	     (message "Creating face editor...done"))))))
 
 (defvar custom-face-menu
-  `(("Set for Current Session" custom-face-set)
+  `(("Set for current session" custom-face-set)
     ,@(when (or custom-file user-init-file)
-	'(("Save for Future Sessions" custom-face-save-command)))
-    ("Reset to Saved" custom-face-reset-saved
+	'(("Save for future sessions" custom-face-save-command)))
+    ("---" ignore ignore)
+    ("Reset to saved face" custom-face-reset-saved
      (lambda (widget)
        (or (get (widget-value widget) 'saved-face)
 	   (get (widget-value widget) 'saved-face-comment))))
     ,@(when (or custom-file user-init-file)
-	'(("Erase Customization" custom-face-reset-standard
+	'(("Erase customization" custom-face-reset-standard
 	   (lambda (widget)
 	     (get (widget-value widget) 'face-defface-spec)))))
     ("---" ignore ignore)
-    ("Add Comment" custom-comment-show custom-comment-invisible-p)
-    ("---" ignore ignore)
-    ("Show all display specs" custom-face-edit-all
+    ("Add comment" custom-comment-show custom-comment-invisible-p)
+    ("Show all attributes" custom-face-edit-all
      (lambda (widget)
        (not (eq (widget-get widget :custom-form) 'all))))
-    ("Just current attributes" custom-face-edit-selected
+    ("Show current attributes" custom-face-edit-selected
      (lambda (widget)
        (not (eq (widget-get widget :custom-form) 'selected))))
-    ("Show as Lisp expression" custom-face-edit-lisp
+    ("Show Lisp expression" custom-face-edit-lisp
      (lambda (widget)
        (not (eq (widget-get widget :custom-form) 'lisp)))))
   "Alist of actions for the `custom-face' widget.
@@ -3345,7 +3364,7 @@
 		     (cond
 		      ((eq 'user (caar (get symbol 'theme-face)))
 		       'saved)
-		      ((eq 'standard (caar (get symbol 'theme-face)))
+		      ((eq 'changed (caar (get symbol 'theme-face)))
 		       'changed)
 		      (t 'themed))
 		   'changed))
@@ -3416,6 +3435,7 @@
       (setq comment nil)
       ;; Make the comment invisible by hand if it's empty
       (custom-comment-hide comment-widget))
+    (custom-push-theme 'theme-face symbol 'user 'set value)
     (if (face-spec-choose value)
 	(face-spec-set symbol value)
       ;; face-set-spec ignores empty attribute lists, so just give it
@@ -3423,7 +3443,6 @@
       (face-spec-set symbol '((t :foreground unspecified))))
     (unless (eq (widget-get widget :custom-state) 'standard)
       (put symbol 'saved-face value))
-    (custom-push-theme 'theme-face symbol 'user 'set value)
     (put symbol 'customized-face nil)
     (put symbol 'face-comment comment)
     (put symbol 'customized-face-comment nil)
@@ -3467,7 +3486,7 @@
       (error "No standard setting for this face"))
     (put symbol 'customized-face nil)
     (put symbol 'customized-face-comment nil)
-    (custom-push-theme 'theme-face symbol 'user 'reset nil)
+    (custom-push-theme 'theme-face symbol 'user 'reset)
     (custom-theme-recalc-face symbol)
     (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
       (put symbol 'saved-face nil)
@@ -3757,6 +3776,8 @@
 	   (if (eq custom-buffer-style 'links)
 	       (push (widget-create-child-and-convert
 		      widget 'custom-group-link
+		      :button-face 'custom-link
+		      :mouse-face 'highlight
 		      :tag "Go to Group"
 		      symbol)
 		     buttons)
@@ -3872,21 +3893,22 @@
 	   (insert "/\n")))))
 
 (defvar custom-group-menu
-  `(("Set for Current Session" custom-group-set
+  `(("Set for current session" custom-group-set
      (lambda (widget)
        (eq (widget-get widget :custom-state) 'modified)))
     ,@(when (or custom-file user-init-file)
-	'(("Save for Future Sessions" custom-group-save
+	'(("Save for future sessions" custom-group-save
 	   (lambda (widget)
 	     (memq (widget-get widget :custom-state) '(modified set))))))
-    ("Reset to Current" custom-group-reset-current
+    ("---" ignore ignore)
+    ("Reset to current settings" custom-group-reset-current
      (lambda (widget)
        (memq (widget-get widget :custom-state) '(modified))))
-    ("Reset to Saved" custom-group-reset-saved
+    ("Reset to saved settings" custom-group-reset-saved
      (lambda (widget)
        (memq (widget-get widget :custom-state) '(modified set))))
     ,@(when (or custom-file user-init-file)
-	'(("Reset to standard setting" custom-group-reset-standard
+	'(("Reset to standard settings" custom-group-reset-standard
 	   (lambda (widget)
 	     (memq (widget-get widget :custom-state) '(modified set saved)))))))
   "Alist of actions for the `custom-group' widget.
@@ -4123,16 +4145,15 @@
 (defun custom-save-variables ()
   "Save all customized variables in `custom-file'."
   (save-excursion
-    (custom-save-delete 'custom-reset-variables)
     (custom-save-delete 'custom-set-variables)
-    (custom-save-resets 'theme-value 'custom-reset-variables nil)
     (let ((standard-output (current-buffer))
 	  (saved-list (make-list 1 0))
 	  sort-fold-case)
       ;; First create a sorted list of saved variables.
       (mapatoms
        (lambda (symbol)
-	 (if (get symbol 'saved-value)
+	 (if (and (get symbol 'saved-value)
+		  (eq 'user (car (car-safe (get symbol 'theme-value)))))
 	     (nconc saved-list (list symbol)))))
       (setq saved-list (sort (cdr saved-list) 'string<))
       (unless (bolp)
@@ -4156,9 +4177,7 @@
 	    (when (and (symbolp request) (not (featurep request)))
 	      (message "Unknown requested feature: %s" request)
 	      (setq requests (delq request requests))))
-	  (when (or (and spec
-			 (eq (nth 0 spec) 'user)
-			 (eq (nth 1 spec) 'set))
+	  (when (or (and spec (eq (car spec) 'user))
 		    comment
 		    (and (null spec) (get symbol 'saved-value)))
 	    (unless (bolp)
@@ -4183,46 +4202,19 @@
       (unless (looking-at "\n")
 	(princ "\n")))))
 
-(defun custom-save-resets (property setter special)
-  (let (started-writing ignored-special)
-    ;; (custom-save-delete setter) Done by caller
-    (let ((standard-output (current-buffer))
-	  (mapper `(lambda (object)
-		    (let ((spec (car-safe (get object (quote ,property)))))
-		      (when (and (not (memq object ignored-special))
-				 (eq (nth 0 spec) 'user)
-				 (eq (nth 1 spec) 'reset))
-			;; Do not write reset statements unless necessary.
-			(unless started-writing
-			  (setq started-writing t)
-			  (unless (bolp)
-			    (princ "\n"))
-			(princ "(")
-			(princ (quote ,setter))
-			(princ "\n '(")
-			(prin1 object)
-			(princ " ")
-			(prin1 (nth 3 spec))
-			(princ ")")))))))
-      (mapc mapper special)
-      (setq ignored-special special)
-      (mapatoms mapper)
-      (when started-writing
-	(princ ")\n")))))
-
 (defun custom-save-faces ()
   "Save all customized faces in `custom-file'."
   (save-excursion
     (custom-save-delete 'custom-reset-faces)
     (custom-save-delete 'custom-set-faces)
-    (custom-save-resets 'theme-face 'custom-reset-faces '(default))
     (let ((standard-output (current-buffer))
 	  (saved-list (make-list 1 0))
 	  sort-fold-case)
       ;; First create a sorted list of saved faces.
       (mapatoms
        (lambda (symbol)
-	 (if (get symbol 'saved-face)
+	 (if (and (get symbol 'saved-face)
+		  (eq 'user (car (car-safe (get symbol 'theme-face)))))
 	     (nconc saved-list (list symbol)))))
       (setq saved-list (sort (cdr saved-list) 'string<))
       ;; The default face must be first, since it affects the others.
@@ -4242,9 +4234,7 @@
 			    (and (not (custom-facep symbol))
 				 (not (get symbol 'force-face))))))
 	      (comment (get symbol 'saved-face-comment)))
-	  (when (or (and spec
-			 (eq (nth 0 spec) 'user)
-			 (eq (nth 1 spec) 'set))
+	  (when (or (and spec (eq (nth 0 spec) 'user))
 		    comment
 		    (and (null spec) (get symbol 'saved-face)))
 	    ;; Don't print default face here.
@@ -4377,9 +4367,9 @@
     ,(customize-menu-create 'customize)
     ["Set" Custom-set t]
     ["Save" Custom-save t]
-    ["Reset to Current" Custom-reset-current t]
-    ["Reset to Saved" Custom-reset-saved t]
-    ["Reset to Standard Values" Custom-reset-standard t]
+    ["Reset to current settings" Custom-reset-current t]
+    ["Reset to saved settings" Custom-reset-saved t]
+    ["Erase customizations" Custom-reset-standard t]
     ["Info" (info "(emacs)Easy Customization") t]))
 
 (defun Custom-goto-parent ()
--- a/lisp/cus-face.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/cus-face.el	Fri Jan 06 16:13:05 2006 +0000
@@ -353,17 +353,20 @@
 	  (custom-push-theme 'theme-face face theme 'set spec))
 	(setq args (cdr (cdr args))))))))
 
+;; XEmacs compability function.  In XEmacs, when you reset a Custom
+;; Theme, you have to specify the theme to reset it to.  We just apply
+;; the next theme.
 ;;;###autoload
 (defun custom-theme-reset-faces (theme &rest args)
   "Reset the specs in THEME of some faces to their specs in other themes.
 Each of the arguments ARGS has this form:
 
-    (FACE FROM-THEME)
+    (FACE IGNORED)
 
-This means reset FACE to its value in FROM-THEME."
+This means reset FACE.  The argument IGNORED is ignored."
   (custom-check-theme theme)
   (dolist (arg args)
-    (custom-push-theme 'theme-face (car arg) theme 'reset (cadr arg))))
+    (custom-push-theme 'theme-face (car arg) theme 'reset)))
 
 ;;;###autoload
 (defun custom-reset-faces (&rest args)
--- a/lisp/cus-theme.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/cus-theme.el	Fri Jan 06 16:13:05 2006 +0000
@@ -58,18 +58,18 @@
     (set (make-local-variable 'widget-link-suffix) "")))
 (put 'custom-new-theme-mode 'mode-class 'special)
 
-(defvar custom-theme-name)
-(defvar custom-theme-variables)
-(defvar custom-theme-faces)
+(defvar custom-theme-name nil)
+(defvar custom-theme-variables nil)
+(defvar custom-theme-faces nil)
 (defvar custom-theme-description)
+(defvar custom-theme-insert-variable-marker)
+(defvar custom-theme-insert-face-marker)
 
 ;;;###autoload
 (defun customize-create-theme ()
   "Create a custom theme."
   (interactive)
-  (if (get-buffer "*New Custom Theme*")
-      (kill-buffer "*New Custom Theme*"))
-  (switch-to-buffer "*New Custom Theme*")
+  (switch-to-buffer (generate-new-buffer "*New Custom Theme*"))
   (let ((inhibit-read-only t))
     (erase-buffer))
   (custom-new-theme-mode)
@@ -77,17 +77,39 @@
   (make-local-variable 'custom-theme-variables)
   (make-local-variable 'custom-theme-faces)
   (make-local-variable 'custom-theme-description)
+  (make-local-variable 'custom-theme-insert-variable-marker)
+  (make-local-variable 'custom-theme-insert-face-marker)
   (widget-insert "This buffer helps you write a custom theme elisp file.
 This will help you share your customizations with other people.
 
-Just insert the names of all variables and faces you want the theme
-to include.  Then clicking mouse-2 or pressing RET on the [Done] button
-will write a theme file that sets all these variables and faces to their
-current global values.  It will write that file into the directory given
-by the variable `custom-theme-directory', usually \"~/.emacs.d/\".
+Insert the names of all variables and faces you want the theme to include.
+Invoke \"Save Theme\" to save the theme.  The theme file will be saved to
+the directory " custom-theme-directory "\n\n")
+  (widget-create 'push-button
+		 :tag "Visit Theme"
+		 :help-echo "Insert the settings of a pre-defined theme."
+		 :action (lambda (widget &optional event)
+			   (call-interactively 'custom-theme-visit-theme)))
+  (widget-insert "  ")
+  (widget-create 'push-button
+		 :tag "Merge Theme"
+		 :help-echo "Merge in the settings of a pre-defined theme."
+		 :action (lambda (widget &optional event)
+			   (call-interactively 'custom-theme-merge-theme)))
+  (widget-insert "  ")
+  (widget-create 'push-button
+     		 :notify (lambda (&rest ignore)
+			   (when (y-or-n-p "Discard current changes?")
+			     (kill-buffer (current-buffer))
+			     (customize-create-theme)))
+     		 "Reset Buffer")
+  (widget-insert "  ")
+  (widget-create 'push-button
+     		 :notify (function custom-theme-write)
+     		 "Save Theme")
+  (widget-insert "\n")
 
-To undo all your edits to the buffer, use the [Reset] button.\n\n")
-  (widget-insert "Theme name: ")
+  (widget-insert "\n\nTheme name: ")
   (setq custom-theme-name
 	(widget-create 'editable-field
 		       :size 10
@@ -96,76 +118,254 @@
   (setq custom-theme-description
 	(widget-create 'text
 		       :value (format-time-string "Created %Y-%m-%d.")))
-  (widget-insert "\nVariables:\n\n")
-  (setq custom-theme-variables
-     	(widget-create 'editable-list
-     		       :entry-format "%i %d %v"
-		       'variable))
-  (widget-insert "\nFaces:\n\n")
-  (setq custom-theme-faces
-     	(widget-create 'editable-list
-     		       :entry-format "%i %d %v"
-		       'face))
   (widget-insert "\n")
   (widget-create 'push-button
-     		 :notify (function custom-theme-write)
-     		 "Done")
-  (widget-insert " ")
+		 :tag "Insert Variable"
+		 :help-echo "Add another variable to this theme."
+		 :action (lambda (widget &optional event)
+			   (call-interactively 'custom-theme-add-variable)))
+  (widget-insert "\n")
+  (setq custom-theme-insert-variable-marker (point-marker))
+  (widget-insert "\n")
   (widget-create 'push-button
-     		 :notify (lambda (&rest ignore)
-     			   (customize-create-theme))
-     		 "Reset")
-  (widget-insert " ")
+		 :tag "Insert Face"
+		 :help-echo "Add another face to this theme."
+		 :action (lambda (widget &optional event)
+			   (call-interactively 'custom-theme-add-face)))
+  (widget-insert "\n")
+  (setq custom-theme-insert-face-marker (point-marker))
+  (widget-insert "\n")
   (widget-create 'push-button
      		 :notify (lambda (&rest ignore)
-     			   (bury-buffer))
-     		 "Bury Buffer")
+			   (when (y-or-n-p "Discard current changes?")
+			     (kill-buffer (current-buffer))
+			     (customize-create-theme)))
+     		 "Reset Buffer")
+  (widget-insert "  ")
+  (widget-create 'push-button
+     		 :notify (function custom-theme-write)
+     		 "Save Theme")
   (widget-insert "\n")
+  (widget-setup)
+  (goto-char (point-min))
+  (message ""))
+
+;;; Theme variables
+
+(defun custom-theme-add-variable (symbol)
+  (interactive "vVariable name: ")
+  (save-excursion
+    (goto-char custom-theme-insert-variable-marker)
+    (if (assq symbol custom-theme-variables)
+	(message "%s is already in the theme" (symbol-name symbol))
+      (widget-insert "\n")
+      (let ((widget (widget-create 'custom-variable
+				   :tag (custom-unlispify-tag-name symbol)
+				   :custom-level 0
+				   :action 'custom-theme-variable-action
+				   :custom-state 'unknown
+				   :value symbol)))
+	(push (cons symbol widget) custom-theme-variables)
+	(custom-magic-reset widget))
+      (widget-setup))))
+
+(defvar custom-theme-variable-menu
+  `(("Reset to Current" custom-redraw
+     (lambda (widget)
+       (and (boundp (widget-value widget))
+	    (memq (widget-get widget :custom-state)
+		  '(themed modified changed)))))
+    ("Reset to Theme Value" custom-variable-reset-theme
+     (lambda (widget)
+       (let ((theme  (intern (widget-value custom-theme-name)))
+	     (symbol (widget-value widget))
+	     found)
+	 (and (custom-theme-p theme)
+	      (dolist (setting (get theme 'theme-settings) found)
+	 	(if (and (eq (cadr setting) symbol)
+	 		 (eq (car  setting) 'theme-value))
+	 	    (setq found t)))))))
+    ("---" ignore ignore)
+    ("Delete" custom-theme-delete-variable nil))
+  "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
+See the documentation for `custom-variable'.")
+
+(defun custom-theme-variable-action (widget &optional event)
+  "Show the Custom Theme Mode menu for a `custom-variable' widget.
+Optional EVENT is the location for the menu."
+  (let ((custom-variable-menu custom-theme-variable-menu))
+    (custom-variable-action widget event)))
+
+(defun custom-variable-reset-theme (widget)
+  "Reset WIDGET to its value for the currently edited theme."
+  (let ((theme  (intern (widget-value custom-theme-name)))
+	(symbol (widget-value widget))
+	found)
+    (dolist (setting (get theme 'theme-settings))
+      (if (and (eq (cadr setting) symbol)
+	       (eq (car  setting) 'theme-value))
+	  (setq found setting)))
+    (widget-value-set (car (widget-get widget :children))
+		      (nth 3 found)))
+  (widget-put widget :custom-state 'themed)
+  (custom-redraw-magic widget)
   (widget-setup))
 
+(defun custom-theme-delete-variable (widget)
+  (setq custom-theme-variables
+	(assq-delete-all (widget-value widget) custom-theme-variables))
+  (widget-delete widget))
+
+;;; Theme faces
+
+(defun custom-theme-add-face (symbol)
+  (interactive (list (read-face-name "Face name" nil nil)))
+  (save-excursion
+    (goto-char custom-theme-insert-face-marker)
+    (if (assq symbol custom-theme-faces)
+	(message "%s is already in the theme" (symbol-name symbol))
+      (widget-insert "\n")
+      (let ((widget (widget-create 'custom-face
+				   :tag (custom-unlispify-tag-name symbol)
+				   :custom-level 0
+				   :action 'custom-theme-face-action
+				   :custom-state 'unknown
+				   :value symbol)))
+	(push (cons symbol widget) custom-theme-faces)
+	(custom-magic-reset widget)
+	(widget-setup)))))
+
+(defvar custom-theme-face-menu
+  `(("Reset to Theme Value" custom-face-reset-theme
+     (lambda (widget)
+       (let ((theme  (intern (widget-value custom-theme-name)))
+	     (symbol (widget-value widget))
+	     found)
+	 (and (custom-theme-p theme)
+	      (dolist (setting (get theme 'theme-settings) found)
+	 	(if (and (eq (cadr setting) symbol)
+	 		 (eq (car  setting) 'theme-face))
+	 	    (setq found t)))))))
+    ("---" ignore ignore)
+    ("Delete" custom-theme-delete-face nil))
+  "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
+See the documentation for `custom-variable'.")
+
+(defun custom-theme-face-action (widget &optional event)
+  "Show the Custom Theme Mode menu for a `custom-face' widget.
+Optional EVENT is the location for the menu."
+  (let ((custom-face-menu custom-theme-face-menu))
+    (custom-face-action widget event)))
+
+(defun custom-face-reset-theme (widget)
+  "Reset WIDGET to its value for the currently edited theme."
+  (let ((theme  (intern (widget-value custom-theme-name)))
+	(symbol (widget-value widget))
+	found)
+    (dolist (setting (get theme 'theme-settings))
+      (if (and (eq (cadr setting) symbol)
+	       (eq (car  setting) 'theme-face))
+	  (setq found setting)))
+    (widget-value-set (car (widget-get widget :children))
+		      (nth 3 found)))
+  (widget-put widget :custom-state 'themed)
+  (custom-redraw-magic widget)
+  (widget-setup))
+
+(defun custom-theme-delete-face (widget)
+  (setq custom-theme-faces
+	(assq-delete-all (widget-value widget) custom-theme-faces))
+  (widget-delete widget))
+
+;;; Reading and writing
+
+(defun custom-theme-visit-theme ()
+  (interactive)
+  (when (or (null custom-theme-variables)
+	    (if (y-or-n-p "Discard current changes?")
+		(progn (customize-create-theme) t)))
+    (let ((theme (call-interactively 'custom-theme-merge-theme)))
+      (unless (eq theme 'user)
+	(widget-value-set custom-theme-name (symbol-name theme)))
+      (widget-value-set custom-theme-description
+			(or (get theme 'theme-documentation)
+			    (format-time-string "Created %Y-%m-%d.")))
+      (widget-setup))))
+
+(defun custom-theme-merge-theme (theme)
+  (interactive "SCustom theme name: ")
+  (unless (eq theme 'user)
+    (load-theme theme))
+  (let ((settings (get theme 'theme-settings)))
+    (dolist (setting settings)
+      (if (eq (car setting) 'theme-value)
+	  (custom-theme-add-variable (cadr setting))
+	(custom-theme-add-face (cadr setting)))))
+  (disable-theme theme)
+  theme)
+
 (defun custom-theme-write (&rest ignore)
-  (let ((name (widget-value custom-theme-name))
-	(doc (widget-value custom-theme-description))
-	(variables (widget-value custom-theme-variables))
-	(faces (widget-value custom-theme-faces)))
-    (switch-to-buffer (concat name "-theme.el"))
-    (emacs-lisp-mode)
-    (unless (file-exists-p custom-theme-directory)
-      (make-directory (file-name-as-directory custom-theme-directory) t))
-    (setq default-directory custom-theme-directory)
-    (setq buffer-file-name (expand-file-name (concat name "-theme.el")))
-    (let ((inhibit-read-only t))
-      (erase-buffer))
-    (insert "(deftheme " name)
-    (when doc
-      (newline)
-      (insert "  \"" doc "\""))
-    (insert  ")\n")
-    (custom-theme-write-variables name variables)
-    (custom-theme-write-faces name faces)
-    (insert "\n(provide-theme '" name ")\n")
-    (save-buffer)))
+  (let* ((name (widget-value custom-theme-name))
+	 (filename (expand-file-name (concat name "-theme.el")
+				     custom-theme-directory))
+	 (doc (widget-value custom-theme-description))
+	 (vars custom-theme-variables)
+	 (faces custom-theme-faces))
+    (cond ((or (string-equal name "")
+	      (string-equal name "user")
+	      (string-equal name "changed"))
+	   (error "Custom themes cannot be named `%s'" name))
+	  ((string-match " " name)
+	   (error "Custom theme names should not contain spaces"))
+	  ((if (file-exists-p filename)
+	       (not (y-or-n-p
+		     (format "File %s exists.  Overwrite? " filename))))
+	   (error "Aborted")))
+    (with-temp-buffer
+      (emacs-lisp-mode)
+      (unless (file-exists-p custom-theme-directory)
+	(make-directory (file-name-as-directory custom-theme-directory) t))
+      (setq buffer-file-name filename)
+      (erase-buffer)
+      (insert "(deftheme " name)
+      (if doc (insert "\n  \"" doc "\""))
+      (insert  ")\n")
+      (custom-theme-write-variables name vars)
+      (custom-theme-write-faces name faces)
+      (insert "\n(provide-theme '" name ")\n")
+      (save-buffer))
+    (dolist (var vars)
+      (widget-put (cdr var) :custom-state 'saved)
+      (custom-redraw-magic (cdr var)))
+    (dolist (face faces)
+      (widget-put (cdr face) :custom-state 'saved)
+      (custom-redraw-magic (cdr face)))))
 
 (defun custom-theme-write-variables (theme vars)
   "Write a `custom-theme-set-variables' command for THEME.
 It includes all variables in list VARS."
-  ;; Most code is stolen from `custom-save-variables'.
   (when vars
     (let ((standard-output (current-buffer)))
       (princ "\n(custom-theme-set-variables\n")
       (princ " '")
       (princ theme)
       (princ "\n")
-      (mapc (lambda (symbol)
-	      (when (boundp symbol)
-		(unless (bolp)
-		  (princ "\n"))
-		(princ " '(")
-		(prin1 symbol)
-		(princ " ")
-		(prin1 (custom-quote (symbol-value symbol)))
-		(princ ")")))
-	      vars)
+      (mapc (lambda (spec)
+	      (let* ((symbol (car spec))
+		     (child (car-safe (widget-get (cdr spec) :children)))
+		     (value (if child
+				(widget-value child)
+			      ;; For hidden widgets, use the standard value
+			      (get symbol 'standard-value))))
+		(when (boundp symbol)
+		  (unless (bolp)
+		    (princ "\n"))
+		  (princ " '(")
+		  (prin1 symbol)
+		  (princ " ")
+		  (prin1 (custom-quote value))
+		  (princ ")"))))
+	    vars)
       (if (bolp)
 	  (princ " "))
       (princ ")")
@@ -181,18 +381,19 @@
       (princ " '")
       (princ theme)
       (princ "\n")
-      (mapc (lambda (symbol)
-	      (when (facep symbol)
-		(unless (bolp)
-		  (princ "\n"))
-		(princ " '(")
-		(prin1 symbol)
-		(princ " ")
-		(prin1 (list (append '(t)
-				     (custom-face-attributes-get
-				      'font-lock-comment-face nil))))
-		(princ ")")))
-	      faces)
+      (mapc (lambda (spec)
+	      (let* ((symbol (car spec))
+		     (child (car-safe (widget-get (cdr spec) :children)))
+		     (value (if child (widget-value child))))
+		(when (and (facep symbol) child)
+		  (unless (bolp)
+		    (princ "\n"))
+		  (princ " '(")
+		  (prin1 symbol)
+		  (princ " ")
+		  (prin1 value)
+		  (princ ")"))))
+	    faces)
       (if (bolp)
 	  (princ " "))
       (princ ")")
--- a/lisp/custom.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/custom.el	Fri Jan 06 16:13:05 2006 +0000
@@ -599,102 +599,6 @@
 	      ((equal load "cus-edit"))
 	      (t (condition-case nil (load load) (error nil))))))))
 
-(defvar custom-known-themes '(user standard)
-   "Themes that have been defined with `deftheme'.
-The default value is the list (user standard).  The theme `standard'
-contains the settings before custom themes are applied.  The
-theme `user' contains all the settings the user customized and saved.
-Additional themes declared with the `deftheme' macro will be added to
-the front of this list.")
-
-(defsubst custom-theme-p (theme)
-  "Non-nil when THEME has been defined."
-  (memq theme custom-known-themes))
-
-(defsubst custom-check-theme (theme)
-  "Check whether THEME is valid, and signal an error if it is not."
-  (unless (custom-theme-p theme)
-    (error "Unknown theme `%s'" theme)))
-
-;;; Initializing.
-
-(defun custom-push-theme (prop symbol theme mode value)
-  "Record a value for face or variable SYMBOL in custom theme THEME.
-PROP is`theme-face' for a face, `theme-value' for a variable.
-The value is specified by (THEME MODE VALUE), which is interpreted
-by `custom-theme-value'.
-
-MODE can be either the symbol `set' or the symbol `reset'.  If it is the
-symbol `set', then VALUE is the value to use.  If it is the symbol
-`reset', then VALUE is either another theme, which means to use the
-value defined by that theme; or nil, which means to remove SYMBOL from
-THEME entirely.
-
-In the following example, the variable `goto-address-url-face' has been
-set by three different themes.  Its `theme-value' property is:
-
-  \((subtle-hacker reset gnome2)
-   \(jonadab set underline)
-   \(gnome2 set info-xref)
-
-The theme value defined by `subtle-hacker' is in effect, because
-that theme currently has the highest precedence.  The theme
-`subtle-hacker' says to use the same value for the variable as
-the theme `gnome2'.  Therefore, the theme value of the variable
-is `info-xref'.  To change the precedence of the themes, use
-`enable-theme'.
-
-The user has not customized the variable; had he done that, the
-list would contain an entry for the `user' theme, too.
-
-See `custom-known-themes' for a list of known themes."
-  (unless (memq prop '(theme-value theme-face))
-    (error "Unknown theme property"))
-  (let* ((old (get symbol prop))
-	 (setting (assq theme old))
-	 (theme-settings (get theme 'theme-settings)))
-    (if (and (eq mode 'reset) (null value))
-	;; Remove a setting.
-	(when setting
-	  (let (res)
-	    (dolist (theme-setting theme-settings)
-	      (if (and (eq (car  theme-setting) prop)
-		       (eq (cadr theme-setting) symbol))
-		  (setq res theme-setting)))
-	    (put theme 'theme-settings (delq res theme-settings)))
-	  (put symbol prop (delq setting old)))
-      (if setting
-	  ;; Alter an existing setting.
-	  (let (res)
-	    (dolist (theme-setting theme-settings)
-	      (if (and (eq (car  theme-setting) prop)
-		       (eq (cadr theme-setting) symbol))
-		  (setq res theme-setting)))
-	    (put theme 'theme-settings
-		 (cons (list prop symbol theme mode value)
-		       (delq res theme-settings)))
-	    (setcar (cdr setting) mode)
-	    (setcar (cddr setting) value))
-	;; Add a new setting.
-	;; If the user changed the value outside of Customize, we
-	;; first save the current value to a fake theme, `standard'.
-	;; This ensures that the user-set value comes back if the
-	;; theme is later disabled.
-	(if (null old)
-	    (if (and (eq prop 'theme-value)
-		     (boundp symbol)
-		     (or (null (get symbol 'standard-value))
-			 (not (equal (eval (car (get symbol 'standard-value)))
-				     (symbol-value symbol)))))
-		(setq old (list (list 'standard 'set (symbol-value symbol))))
-	      (if (facep symbol)
-		  (setq old (list (list 'standard 'set (list
-		    (append '(t) (custom-face-attributes-get symbol nil)))))))))
-	(put symbol prop (cons (list theme mode value) old))
-	(put theme 'theme-settings
-	     (cons (list prop symbol theme mode value)
-		   theme-settings))))))
-
 (defvar custom-local-buffer nil
   "Non-nil, in a Customization buffer, means customize a specific buffer.
 If this variable is non-nil, it should be a buffer,
@@ -703,117 +607,6 @@
 in every Customization buffer.")
 (put 'custom-local-buffer 'permanent-local t)
 
-(defun custom-set-variables (&rest args)
-  "Install user customizations of variable values specified in ARGS.
-These settings are registered as theme `user'.
-The arguments should each be a list of the form:
-
-  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
-
-This stores EXP (without evaluating it) as the saved value for SYMBOL.
-If NOW is present and non-nil, then also evaluate EXP and set
-the default value for the SYMBOL to the value of EXP.
-
-REQUEST is a list of features we must require in order to
-handle SYMBOL properly.
-COMMENT is a comment string about SYMBOL."
-  (apply 'custom-theme-set-variables 'user args))
-
-(defun custom-reevaluate-setting (symbol)
-  "Reset the value of SYMBOL by re-evaluating its saved or standard value.
-Use the :set function to do so.  This is useful for customizable options
-that are defined before their standard value can really be computed.
-E.g. dumped variables whose default depends on run-time information."
-  (funcall (or (get symbol 'custom-set) 'set-default)
-	   symbol
-	   (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
-
-(defun custom-theme-set-variables (theme &rest args)
-  "Initialize variables for theme THEME according to settings in ARGS.
-Each of the arguments in ARGS should be a list of this form:
-
-  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
-
-This stores EXP (without evaluating it) as the saved value for SYMBOL.
-If NOW is present and non-nil, then also evaluate EXP and set
-the default value for the SYMBOL to the value of EXP.
-
-REQUEST is a list of features we must require in order to
-handle SYMBOL properly.
-COMMENT is a comment string about SYMBOL.
-
-Several properties of THEME and SYMBOL are used in the process:
-
-If THEME's property `theme-immediate' is non-nil, this is equivalent of
-providing the NOW argument to all symbols in the argument list:
-evaluate each EXP and set the corresponding SYMBOL.  However,
-there's a difference in the handling of SYMBOL's property
-`force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to
-the symbol `rogue', else if THEME's property `theme-immediate' is non-nil,
-SYMBOL's property `force-value' is set to the symbol `immediate'.
-
-EXP itself is saved unevaluated as SYMBOL property `saved-value' and
-in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
-  (custom-check-theme theme)
-  (setq args
-	(sort args
-	      (lambda (a1 a2)
-		(let* ((sym1 (car a1))
-		       (sym2 (car a2))
-		       (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
-		       (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
-		  (cond ((and 1-then-2 2-then-1)
-			 (error "Circular custom dependency between `%s' and `%s'"
-				sym1 sym2))
-			(2-then-1 nil)
-			;; Put minor modes and symbols with :require last.
-			;; Putting minor modes last ensures that the mode
-			;; function will see other customized values rather
-			;; than default values.
-			(t (or (nth 3 a2)
-                               (eq (get sym2 'custom-set)
-                                   'custom-set-minor-mode))))))))
-  (while args
-    (let ((entry (car args)))
-      (if (listp entry)
-	  (let* ((symbol (indirect-variable (nth 0 entry)))
-		 (value (nth 1 entry))
-		 (now (nth 2 entry))
-		 (requests (nth 3 entry))
-		 (comment (nth 4 entry))
-		 set)
-	    (when requests
-	      (put symbol 'custom-requests requests)
-	      (mapc 'require requests))
-	    (setq set (or (get symbol 'custom-set) 'custom-set-default))
-	    (put symbol 'saved-value (list value))
-	    (put symbol 'saved-variable-comment comment)
-	    (custom-push-theme 'theme-value symbol theme 'set value)
-	    ;; Allow for errors in the case where the setter has
-	    ;; changed between versions, say, but let the user know.
-	    (condition-case data
-		(cond (now
-		       ;; Rogue variable, set it now.
-		       (put symbol 'force-value t)
-		       (funcall set symbol (eval value)))
-		      ((default-boundp symbol)
-		       ;; Something already set this, overwrite it.
-		       (funcall set symbol (eval value))))
-	      (error
-	       (message "Error setting %s: %s" symbol data)))
-	    (setq args (cdr args))
-	    (and (or now (default-boundp symbol))
-		 (put symbol 'variable-comment comment)))
-	;; Old format, a plist of SYMBOL VALUE pairs.
-	(message "Warning: old format `custom-set-variables'")
-	(ding)
-	(sit-for 2)
-	(let ((symbol (indirect-variable (nth 0 args)))
-	      (value (nth 1 args)))
-	  (put symbol 'saved-value (list value))
-	  (custom-push-theme 'theme-value symbol theme 'set value))
-	(setq args (cdr (cdr args)))))))
-
 (defun custom-set-default (variable value)
   "Default :set function for a customizable variable.
 Normally, this sets the default value of VARIABLE to VALUE,
@@ -901,46 +694,256 @@
       (put symbol 'customized-value nil))
     ;; Changed?
     (not (equal customized (get symbol 'customized-value)))))
+
+(defun custom-reevaluate-setting (symbol)
+  "Reset the value of SYMBOL by re-evaluating its saved or standard value.
+Use the :set function to do so.  This is useful for customizable options
+that are defined before their standard value can really be computed.
+E.g. dumped variables whose default depends on run-time information."
+  (funcall (or (get symbol 'custom-set) 'set-default)
+	   symbol
+	   (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
+
+
+;;; Custom Themes
+
+;; Custom themes are collections of settings that can be enabled or
+;; disabled as a unit.
+
+;; Each Custom theme is defined by a symbol, called the theme name.
+;; The `theme-settings' property of the theme name records the
+;; variable and face settings of the theme.  This property is a list
+;; of elements, each of the form
+;;
+;;     (PROP SYMBOL THEME VALUE)
+;;
+;;  - PROP is either `theme-value' or `theme-face'
+;;  - SYMBOL is the face or variable name
+;;  - THEME is the theme name (redundant, but simplifies the code)
+;;  - VALUE is an expression that gives the theme's setting for SYMBOL.
+;;
+;; The theme name also has a `theme-feature' property, whose value is
+;; specified when the theme is defined (see `custom-declare-theme').
+;; Usually, this is just a symbol named THEME-theme.  This lets
+;; external libraries call (require 'foo-theme).
+
+;; In addition, each symbol (either a variable or a face) affected by
+;; an *enabled* theme has a `theme-value' or `theme-face' property,
+;; which is a list of elements each of the form
+;;
+;;     (THEME VALUE)
+;;
+;; which have the same meanings as in `theme-settings'.
+;;
+;; The `theme-value' and `theme-face' lists are ordered by decreasing
+;; theme precedence.  Thus, the first element is always the one that
+;; is in effect.
+
+;; Each theme is stored in a theme file, with filename THEME-theme.el.
+;; Loading a theme basically involves calling (load "THEME-theme")
+;; This is done by the function `load-theme'.  Loading a theme
+;; automatically enables it.
+;;
+;; When a theme is enabled, the `theme-value' and `theme-face'
+;; properties for the affected symbols are set.  When a theme is
+;; disabled, its settings are removed from the `theme-value' and
+;; `theme-face' properties, but the theme's own `theme-settings'
+;; property remains unchanged.
+
+(defvar custom-known-themes '(user changed)
+   "Themes that have been defined with `deftheme'.
+The default value is the list (user changed).  The theme `changed'
+contains the settings before custom themes are applied.  The
+theme `user' contains all the settings the user customized and saved.
+Additional themes declared with the `deftheme' macro will be added to
+the front of this list.")
+
+(defsubst custom-theme-p (theme)
+  "Non-nil when THEME has been defined."
+  (memq theme custom-known-themes))
+
+(defsubst custom-check-theme (theme)
+  "Check whether THEME is valid, and signal an error if it is not."
+  (unless (custom-theme-p theme)
+    (error "Unknown theme `%s'" theme)))
+
+(defun custom-push-theme (prop symbol theme mode &optional value)
+  "Record VALUE for face or variable SYMBOL in custom theme THEME.
+PROP is `theme-face' for a face, `theme-value' for a variable.
+
+MODE can be either the symbol `set' or the symbol `reset'.  If it is the
+symbol `set', then VALUE is the value to use.  If it is the symbol
+`reset', then SYMBOL will be removed from THEME (VALUE is ignored).
+
+See `custom-known-themes' for a list of known themes."
+  (unless (memq prop '(theme-value theme-face))
+    (error "Unknown theme property"))
+  (let* ((old (get symbol prop))
+	 (setting (assq theme old))  ; '(theme value)
+	 (theme-settings             ; '(prop symbol theme value)
+	  (get theme 'theme-settings)))
+    (if (eq mode 'reset)
+	;; Remove a setting.
+	(when setting
+	  (let (res)
+	    (dolist (theme-setting theme-settings)
+	      (if (and (eq (car  theme-setting) prop)
+		       (eq (cadr theme-setting) symbol))
+		  (setq res theme-setting)))
+	    (put theme 'theme-settings (delq res theme-settings)))
+	  (put symbol prop (delq setting old)))
+      (if setting
+	  ;; Alter an existing setting.
+	  (let (res)
+	    (dolist (theme-setting theme-settings)
+	      (if (and (eq (car  theme-setting) prop)
+		       (eq (cadr theme-setting) symbol))
+		  (setq res theme-setting)))
+	    (put theme 'theme-settings
+		 (cons (list prop symbol theme value)
+		       (delq res theme-settings)))
+	    (setcar (cdr setting) value))
+	;; Add a new setting.
+	;; If the user changed the value outside of Customize, we
+	;; first save the current value to a fake theme, `changed'.
+	;; This ensures that the user-set value comes back if the
+	;; theme is later disabled.
+	(if (null old)
+	    (if (and (eq prop 'theme-value)
+		     (boundp symbol)
+		     (or (null (get symbol 'standard-value))
+			 (not (equal (eval (car (get symbol 'standard-value)))
+				     (symbol-value symbol)))))
+		(setq old (list (list 'changed (symbol-value symbol))))
+	      (if (facep symbol)
+		  (setq old (list (list 'changed (list
+		    (append '(t) (custom-face-attributes-get symbol nil)))))))))
+	(put symbol prop (cons (list theme value) old))
+	(put theme 'theme-settings
+	     (cons (list prop symbol theme value)
+		   theme-settings))))))
+
+
+(defun custom-set-variables (&rest args)
+  "Install user customizations of variable values specified in ARGS.
+These settings are registered as theme `user'.
+The arguments should each be a list of the form:
+
+  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
+
+This stores EXP (without evaluating it) as the saved value for SYMBOL.
+If NOW is present and non-nil, then also evaluate EXP and set
+the default value for the SYMBOL to the value of EXP.
+
+REQUEST is a list of features we must require in order to
+handle SYMBOL properly.
+COMMENT is a comment string about SYMBOL."
+  (apply 'custom-theme-set-variables 'user args))
+
+(defun custom-theme-set-variables (theme &rest args)
+  "Initialize variables for theme THEME according to settings in ARGS.
+Each of the arguments in ARGS should be a list of this form:
+
+  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
+
+This stores EXP (without evaluating it) as the saved value for SYMBOL.
+If NOW is present and non-nil, then also evaluate EXP and set
+the default value for the SYMBOL to the value of EXP.
+
+REQUEST is a list of features we must require in order to
+handle SYMBOL properly.
+COMMENT is a comment string about SYMBOL.
+
+EXP itself is saved unevaluated as SYMBOL property `saved-value' and
+in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
+  (custom-check-theme theme)
+  (setq args
+	(sort args
+	      (lambda (a1 a2)
+		(let* ((sym1 (car a1))
+		       (sym2 (car a2))
+		       (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
+		       (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
+		  (cond ((and 1-then-2 2-then-1)
+			 (error "Circular custom dependency between `%s' and `%s'"
+				sym1 sym2))
+			(2-then-1 nil)
+			;; Put minor modes and symbols with :require last.
+			;; Putting minor modes last ensures that the mode
+			;; function will see other customized values rather
+			;; than default values.
+			(t (or (nth 3 a2)
+                               (eq (get sym2 'custom-set)
+                                   'custom-set-minor-mode))))))))
+  (while args
+    (let ((entry (car args)))
+      (if (listp entry)
+	  (let* ((symbol (indirect-variable (nth 0 entry)))
+		 (value (nth 1 entry))
+		 (now (nth 2 entry))
+		 (requests (nth 3 entry))
+		 (comment (nth 4 entry))
+		 set)
+	    (when requests
+	      (put symbol 'custom-requests requests)
+	      (mapc 'require requests))
+	    (setq set (or (get symbol 'custom-set) 'custom-set-default))
+	    (put symbol 'saved-value (list value))
+	    (put symbol 'saved-variable-comment comment)
+	    (custom-push-theme 'theme-value symbol theme 'set value)
+	    ;; Allow for errors in the case where the setter has
+	    ;; changed between versions, say, but let the user know.
+	    (condition-case data
+		(cond (now
+		       ;; Rogue variable, set it now.
+		       (put symbol 'force-value t)
+		       (funcall set symbol (eval value)))
+		      ((default-boundp symbol)
+		       ;; Something already set this, overwrite it.
+		       (funcall set symbol (eval value))))
+	      (error
+	       (message "Error setting %s: %s" symbol data)))
+	    (setq args (cdr args))
+	    (and (or now (default-boundp symbol))
+		 (put symbol 'variable-comment comment)))
+	;; Old format, a plist of SYMBOL VALUE pairs.
+	(message "Warning: old format `custom-set-variables'")
+	(ding)
+	(sit-for 2)
+	(let ((symbol (indirect-variable (nth 0 args)))
+	      (value (nth 1 args)))
+	  (put symbol 'saved-value (list value))
+	  (custom-push-theme 'theme-value symbol theme 'set value))
+	(setq args (cdr (cdr args)))))))
+
 
 ;;; Defining themes.
 
-;; deftheme is used at the beginning of the file that records a theme.
-
-(defmacro deftheme (theme &optional doc &rest args)
-  "Declare custom theme THEME.
-The optional argument DOC is a doc string describing the theme.
-The remaining arguments should have the form
-
-   [KEYWORD VALUE]...
-
-The following KEYWORD's are defined:
+;; A theme file should be named `THEME-theme.el' (where THEME is the theme
+;; name), and found in either `custom-theme-directory' or the load path.
+;; It has the following format:
+;;
+;;   (deftheme THEME
+;;     DOCSTRING)
+;;
+;;   (custom-theme-set-variables
+;;    'THEME
+;;    [THEME-VARIABLES])
+;;
+;;   (custom-theme-set-faces
+;;    'THEME
+;;    [THEME-FACES])
+;;
+;;   (provide-theme 'THEME)
 
-:short-description
-	VALUE is a short (one line) description of the theme.  If not
-	given, DOC is used.
-:immediate
-	If VALUE is non-nil, variables specified in this theme are set
-	immediately when loading the theme.
-:variable-set-string
-	VALUE is a string used to indicate that a variable takes its
-	setting from this theme.  It is passed to FORMAT with the name
-	of the theme as an additional argument.  If not given, a
-	generic description is used.
-:variable-reset-string
-	VALUE is a string used in the case a variable has been forced
-	to its value in this theme.  It is passed to FORMAT with the
-	name of the theme as an additional argument.  If not given, a
-	generic description is used.
-:face-set-string
-	VALUE is a string used to indicate that a face takes its
-	setting from this theme.  It is passed to FORMAT with the name
-	of the theme as an additional argument.  If not given, a
-	generic description is used.
-:face-reset-string
-	VALUE is a string used in the case a face has been forced to
-	its value in this theme.  It is passed to FORMAT with the name
-	of the theme as an additional argument.  If not given, a
-	generic description is used.
+
+;; The IGNORED arguments to deftheme come from the XEmacs theme code, where
+;; they were used to supply keyword-value pairs like `:immediate',
+;; `:variable-reset-string', etc.  We don't use any of these, so ignore them.
+
+(defmacro deftheme (theme &optional doc &rest ignored)
+  "Declare THEME to be a Custom theme.
+The optional argument DOC is a doc string describing the theme.
 
 Any theme `foo' should be defined in a file called `foo-theme.el';
 see `custom-make-theme-feature' for more information."
@@ -948,42 +951,17 @@
     ;; It is better not to use backquote in this file,
     ;; because that makes a bootstrapping problem
     ;; if you need to recompile all the Lisp files using interpreted code.
-    (nconc (list 'custom-declare-theme
-		 (list 'quote theme)
-		 (list 'quote feature)
-		 doc)
-	   args)))
+    (list 'custom-declare-theme (list 'quote theme) (list 'quote feature) doc)))
 
-(defun custom-declare-theme (theme feature &optional doc &rest args)
+(defun custom-declare-theme (theme feature &optional doc &rest ignored)
   "Like `deftheme', but THEME is evaluated as a normal argument.
-FEATURE is the feature this theme provides.  This symbol is created
-from THEME by `custom-make-theme-feature'."
+FEATURE is the feature this theme provides.  Normally, this is a symbol
+created from THEME by `custom-make-theme-feature'."
+  (if (memq theme '(user changed))
+      (error "Custom theme cannot be named %S" theme))
   (add-to-list 'custom-known-themes theme)
   (put theme 'theme-feature feature)
-  (when doc
-    (put theme 'theme-documentation doc))
-  (while args
-    (let ((arg (car args)))
-      (setq args (cdr args))
-      (unless (symbolp arg)
-	(error "Junk in args %S" args))
-      (let ((keyword arg)
-	    (value (car args)))
-	(unless args
-	  (error "Keyword %s is missing an argument" keyword))
-	(setq args (cdr args))
-	(cond ((eq keyword :short-description)
-	       (put theme 'theme-short-description value))
-	      ((eq keyword :immediate)
-	       (put theme 'theme-immediate value))
-	      ((eq keyword :variable-set-string)
-	       (put theme 'theme-variable-set-string value))
-	      ((eq keyword :variable-reset-string)
-	       (put theme 'theme-variable-reset-string value))
-	      ((eq keyword :face-set-string)
-	       (put theme 'theme-face-set-string value))
-	      ((eq keyword :face-reset-string)
-	       (put theme 'theme-face-reset-string value)))))))
+  (when doc (put theme 'theme-documentation doc)))
 
 (defun custom-make-theme-feature (theme)
   "Given a symbol THEME, create a new symbol by appending \"-theme\".
@@ -998,38 +976,6 @@
 
 ;;; Loading themes.
 
-;; The variable and face settings of a theme are recorded in
-;; the `theme-settings' property of the theme name.
-;; This property's value is a list of elements, each of the form
-;; (PROP SYMBOL THEME MODE VALUE), where PROP is `theme-value' or `theme-face'
-;; and SYMBOL is the face or variable name.
-;; THEME is the theme name itself; that's redundant, but simplifies things.
-;; MODE is `set' or `reset'.
-;; If MODE is `set', then VALUE is an expression that specifies the
-;; theme's setting for SYMBOL.
-;; If MODE is `reset', then VALUE is another theme,
-;; and it means to use the value from that theme.
-
-;; Each variable has a `theme-value' property that describes all the
-;; settings of enabled themes that apply to it.
-;; Each face name has a `theme-face' property that describes all the
-;; settings of enabled themes that apply to it.
-;; The property value is a list of settings, each with the form
-;; (THEME MODE VALUE).  THEME, MODE and VALUE are as above.
-;; Each of these lists is ordered by decreasing theme precedence.
-;; Thus, the first element is always the one that is in effect.
-
-;; Disabling a theme removes its settings from the `theme-value' and
-;; `theme-face' properties, but the theme's own `theme-settings'
-;; property remains unchanged.
-
-;; Loading a theme implicitly enables it.  Enabling a theme adds its
-;; settings to the symbols' `theme-value' and `theme-face' properties,
-;; or moves them to the front of those lists if they're already present.
-
-(defvar custom-loaded-themes nil
-  "Custom themes that have been loaded.")
-
 (defcustom custom-theme-directory
   (if (eq system-type 'ms-dos)
 	 ;; MS-DOS cannot have initial dot.
@@ -1043,76 +989,39 @@
   :group 'customize
   :version "22.1")
 
-(defun custom-theme-loaded-p (theme)
-  "Return non-nil if THEME has been loaded."
-  (memq theme custom-loaded-themes))
-
 (defun provide-theme (theme)
-  "Indicate that this file provides THEME, and mark it as enabled.
-Add THEME to `custom-loaded-themes' and `custom-enabled-themes',
-and `provide' the feature name stored in THEME's property `theme-feature'.
-
-Usually the `theme-feature' property contains a symbol created
-by `custom-make-theme-feature'."
-  (if (eq theme 'user)
-      (error "Custom theme cannot be named `user'"))
+  "Indicate that this file provides THEME.
+This calls `provide' to provide the feature name stored in THEME's
+property `theme-feature' (which is usually a symbol created by
+`custom-make-theme-feature')."
+  (if (memq theme '(user changed))
+      (error "Custom theme cannot be named %S" theme))
   (custom-check-theme theme)
   (provide (get theme 'theme-feature))
-  (push theme custom-loaded-themes)
-  ;; Loading a theme also installs its settings,
-  ;; so mark it as "enabled".
+  ;; Loading a theme also enables it.
   (push theme custom-enabled-themes)
   ;; `user' must always be the highest-precedence enabled theme.
   ;; Make that remain true.  (This has the effect of making user settings
   ;; override the ones just loaded, too.)
-  (enable-theme 'user))
+  (let ((custom-enabling-themes t))
+    (enable-theme 'user)))
 
 (defun load-theme (theme)
-  "Try to load a theme's settings from its file.
+  "Load a theme's settings from its file.
 This also enables the theme; use `disable-theme' to disable it."
-
-  ;; THEME's feature is stored in THEME's `theme-feature' property.
-  ;; Usually the `theme-feature' property contains a symbol created
-  ;; by `custom-make-theme-feature'.
-
   ;; Note we do no check for validity of the theme here.
   ;; This allows to pull in themes by a file-name convention
   (interactive "SCustom theme name: ")
+  ;; If reloading, clear out the old theme settings.
+  (when (custom-theme-p theme)
+    (disable-theme theme)
+    (put theme 'theme-settings nil)
+    (put theme 'theme-feature nil)
+    (put theme 'theme-documentation nil))
   (let ((load-path (if (file-directory-p custom-theme-directory)
 		       (cons custom-theme-directory load-path)
 		     load-path)))
-    (require (or (get theme 'theme-feature)
-		 (custom-make-theme-feature theme)))))
-
-;;; How to load and enable various themes as part of `user'.
-
-(defun custom-theme-load-themes (by-theme &rest body)
-  "Load the themes specified by BODY.
-Record them as required by theme BY-THEME.
-
-BODY is a sequence of either
-
-THEME
-        Load THEME and enable it.
-\(reset THEME)
-	Undo all the settings made by THEME
-\(hidden THEME)
-	Load THEME but do not enable it.
-
-All the themes loaded for BY-THEME are recorded in BY-THEME's property
-`theme-loads-themes'."
-  (custom-check-theme by-theme)
-  (let ((themes-loaded (get by-theme 'theme-loads-themes)))
-    (dolist (theme body)
-      (cond ((and (consp theme) (eq (car theme) 'reset))
-	     (disable-theme (cadr theme)))
-	    ((and (consp theme) (eq (car theme) 'hidden))
-	     (load-theme (cadr theme))
-	     (disable-theme (cadr theme)))
-	    (t
-	     (load-theme theme)))
-      (push theme themes-loaded))
-    (put by-theme 'theme-loads-themes themes-loaded)))
+    (load (symbol-name (custom-make-theme-feature theme)))))
 
 ;;; Enabling and disabling loaded themes.
 
@@ -1123,25 +1032,26 @@
 The newly enabled theme gets the highest precedence (after `user').
 If it is already enabled, just give it highest precedence (after `user').
 
-This signals an error if THEME does not specify any theme
-settings.  Theme settings are set using `load-theme'."
+If THEME does not specify any theme settings, this tries to load
+the theme from its theme file, by calling `load-theme'."
   (interactive "SEnable Custom theme: ")
-  (unless (or (eq theme 'user) (memq theme custom-loaded-themes))
-    (error "Theme %s not defined" (symbol-name theme)))
-  (let ((settings (get theme 'theme-settings)))
-    (dolist (s settings)
-      (let* ((prop (car s))
-	     (symbol (cadr s))
-	     (spec-list (get symbol prop)))
-	(put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
-	(if (eq prop 'theme-value)
-	    (custom-theme-recalc-variable symbol)
-	  (custom-theme-recalc-face symbol)))))
-  (unless (eq theme 'user)
-    (setq custom-enabled-themes
-	  (cons theme (delq theme custom-enabled-themes)))
-    (unless custom-enabling-themes
-      (enable-theme 'user))))
+  (if (not (custom-theme-p theme))
+      (load-theme theme)
+    ;; This could use a bit of optimization -- cyd
+    (let ((settings (get theme 'theme-settings)))
+      (dolist (s settings)
+	(let* ((prop (car s))
+	       (symbol (cadr s))
+	       (spec-list (get symbol prop)))
+	  (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
+	  (if (eq prop 'theme-value)
+	      (custom-theme-recalc-variable symbol)
+	    (custom-theme-recalc-face symbol)))))
+    (unless (eq theme 'user)
+      (setq custom-enabled-themes
+	    (cons theme (delq theme custom-enabled-themes)))
+      (unless custom-enabling-themes
+	(enable-theme 'user)))))
 
 (defcustom custom-enabled-themes nil
   "List of enabled Custom Themes, highest precedence first.
@@ -1155,28 +1065,36 @@
 	 ;; defined in a theme (e.g. `user').  Enabling the theme sets
 	 ;; custom-enabled-themes, which enables the theme...
 	 (unless custom-enabling-themes
-	   (let ((custom-enabling-themes t))
+	   (let ((custom-enabling-themes t) failures)
 	     (setq themes (delq 'user (delete-dups themes)))
 	     (if (boundp symbol)
 		 (dolist (theme (symbol-value symbol))
 		   (if (not (memq theme themes))
 		       (disable-theme theme))))
 	     (dolist (theme (reverse themes))
-	       (if (or (custom-theme-loaded-p theme) (eq theme 'user))
+	       (condition-case nil
 		   (enable-theme theme)
-		 (load-theme theme)))
+		 (error (progn (push theme failures)
+			       (setq themes (delq theme themes))))))
 	     (enable-theme 'user)
-	     (custom-set-default symbol themes)))))
+	     (custom-set-default symbol themes)
+	     (if failures
+		 (message "Failed to enable themes: %s"
+			  (mapconcat 'symbol-name failures " ")))))))
 
-(defun custom-theme-enabled-p (theme)
+(defsubst custom-theme-enabled-p (theme)
   "Return non-nil if THEME is enabled."
   (memq theme custom-enabled-themes))
 
 (defun disable-theme (theme)
   "Disable all variable and face settings defined by THEME.
 See `custom-enabled-themes' for a list of enabled themes."
-  (interactive "SDisable Custom theme: ")
-  (when (memq theme custom-enabled-themes)
+  (interactive (list (intern
+		      (completing-read
+		       "Disable Custom theme: "
+		       (mapcar 'symbol-name custom-enabled-themes)
+		       nil t))))
+  (when (custom-theme-enabled-p theme)
     (let ((settings (get theme 'theme-settings)))
       (dolist (s settings)
 	(let* ((prop (car s))
@@ -1189,28 +1107,6 @@
     (setq custom-enabled-themes
 	  (delq theme custom-enabled-themes))))
 
-(defun custom-theme-value (theme setting-list)
-  "Determine the value specified for THEME according to SETTING-LIST.
-Returns a list whose car is the specified value, if we
-find one; nil otherwise.
-
-SETTING-LIST is an alist with themes as its key.
-Each element has the form:
-
-  \(THEME MODE VALUE)
-
-MODE is either the symbol `set' or the symbol `reset'.  See
-`custom-push-theme' for more information on the format of
-SETTING-LIST."
-  ;; Note we do _NOT_ signal an error if the theme is unknown
-  ;; it might have gone away without the user knowing.
-  (let ((elt (cdr (assoc theme setting-list))))
-    (if elt
-        (if (eq (car elt) 'set)
-            (cdr elt)
-	  ;; `reset' means refer to another theme's value in the same alist.
-          (custom-theme-value (cadr elt) setting-list)))))
-
 (defun custom-variable-theme-value (variable)
   "Return (list VALUE) indicating the custom theme value of VARIABLE.
 That is to say, it specifies what the value should be according to
@@ -1219,47 +1115,53 @@
 This function returns nil if no custom theme specifies a value for VARIABLE."
   (let* ((theme-value (get variable 'theme-value)))
     (if theme-value
-	(custom-theme-value (car (car theme-value)) theme-value))))
+	(cdr (car theme-value)))))
 
 (defun custom-theme-recalc-variable (variable)
   "Set VARIABLE according to currently enabled custom themes."
   (let ((valspec (custom-variable-theme-value variable)))
-    (when valspec
-      (put variable 'saved-value valspec))
-    (unless valspec
+    (if valspec
+	(put variable 'saved-value valspec)
       (setq valspec (get variable 'standard-value)))
-    (when valspec
-      (if (or (get 'force-value variable) (default-boundp variable))
-          (funcall (or (get variable 'custom-set) 'set-default) variable
-                   (eval (car valspec)))))))
+    (if (and valspec
+	     (or (get variable 'force-value)
+		 (default-boundp variable)))
+	(funcall (or (get variable 'custom-set) 'set-default) variable
+		 (eval (car valspec))))))
 
 (defun custom-theme-recalc-face (face)
   "Set FACE according to currently enabled custom themes."
   (if (facep face)
       (let ((theme-faces (reverse (get face 'theme-face))))
 	(dolist (spec theme-faces)
-	  (face-spec-set face (car (cddr spec)))))))
+	  (face-spec-set face (cadr spec))))))
 
+;;; XEmacs compability functions
+
+;; In XEmacs, when you reset a Custom Theme, you have to specify the
+;; theme to reset it to.  We just apply the next available theme, so
+;; just ignore the IGNORED arguments.
+
 (defun custom-theme-reset-variables (theme &rest args)
-  "Reset the specs in THEME of some variables to their values in other themes.
+  "Reset some variable settings in THEME to their values in other themes.
 Each of the arguments ARGS has this form:
 
-    (VARIABLE FROM-THEME)
+    (VARIABLE IGNORED)
 
-This means reset VARIABLE to its value in FROM-THEME."
+This means reset VARIABLE.  (The argument IGNORED is ignored)."
   (custom-check-theme theme)
   (dolist (arg args)
-    (custom-push-theme 'theme-value (car arg) theme 'reset (cadr arg))))
+    (custom-push-theme 'theme-value (car arg) theme 'reset)))
 
 (defun custom-reset-variables (&rest args)
-  "Reset the specs of some variables to their values in certain themes.
+  "Reset the specs of some variables to their values in other themes.
 This creates settings in the `user' theme.
 
 Each of the arguments ARGS has this form:
 
-    (VARIABLE FROM-THEME)
+    (VARIABLE IGNORED)
 
-This means reset VARIABLE to its value in FROM-THEME."
+This means reset VARIABLE.  (The argument IGNORED is ignored)."
     (apply 'custom-theme-reset-variables 'user args))
 
 ;;; The End.
--- a/lisp/emacs-lisp/bytecomp.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/emacs-lisp/bytecomp.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; bytecomp.el --- compilation of Lisp code into byte code
 
 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001, 2002,
-;;   2003, 2004, 2005 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
 ;;	Hallvard Furuseth <hbf@ulrik.uio.no>
@@ -3785,7 +3785,15 @@
 	(push (cons (nth 1 (nth 1 form))
 		    (if constant (nth 1 (nth 2 form)) t))
 	      byte-compile-function-environment)))
-  (byte-compile-normal-call form))
+  ;; We used to jus do: (byte-compile-normal-call form)
+  ;; But it turns out that this fails to optimize the code.
+  ;; So instead we now do the same as what other byte-hunk-handlers do,
+  ;; which is to call back byte-compile-file-form and then return nil.
+  ;; Except that we can't just call byte-compile-file-form since it would
+  ;; call us right back.
+  (byte-compile-keep-pending form)
+  ;; Return nil so the form is not output twice.
+  nil)
 
 ;; Turn off warnings about prior calls to the function being defalias'd.
 ;; This could be smarter and compare those calls with
--- a/lisp/font-lock.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/font-lock.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; font-lock.el --- Electric font lock mode
 
 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;;   2000, 2001, 2002, 2003, 2004 2005 Free Software Foundation, Inc.
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 ;; Author: jwz, then rms, then sm
 ;; Maintainer: FSF
@@ -980,6 +980,7 @@
 (defun font-lock-fontify-buffer ()
   "Fontify the current buffer the way the function `font-lock-mode' would."
   (interactive)
+  (font-lock-set-defaults)
   (let ((font-lock-verbose (or font-lock-verbose (interactive-p))))
     (funcall font-lock-fontify-buffer-function)))
 
@@ -987,6 +988,7 @@
   (funcall font-lock-unfontify-buffer-function))
 
 (defun font-lock-fontify-region (beg end &optional loudly)
+  (font-lock-set-defaults)
   (funcall font-lock-fontify-region-function beg end loudly))
 
 (defun font-lock-unfontify-region (beg end)
@@ -1000,8 +1002,6 @@
     (with-temp-message
 	(when verbose
 	  (format "Fontifying %s..." (buffer-name)))
-      ;; Make sure we have the right `font-lock-keywords' etc.
-      (font-lock-set-defaults)
       ;; Make sure we fontify etc. in the whole buffer.
       (save-restriction
 	(widen)
--- a/lisp/info.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/info.el	Fri Jan 06 16:13:05 2006 +0000
@@ -568,8 +568,10 @@
        (if (and (stringp file-or-node) (string-match "(.*)" file-or-node))
            file-or-node
          (concat "(" file-or-node ")")))
-    (if (zerop (buffer-size))
-        (Info-directory))))
+    (if (and (zerop (buffer-size))
+	     (null Info-history))
+	;; If we just created the Info buffer, go to the directory.
+	(Info-directory))))
 
 ;;;###autoload
 (defun info-emacs-manual ()
@@ -688,11 +690,12 @@
   (setq filename (Info-find-file filename))
   ;; Go into Info buffer.
   (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
-  ;; Record the node we are leaving.
-  (if (not no-going-back)
-      (setq Info-history
-            (cons (list Info-current-file Info-current-node (point))
-                  Info-history)))
+  ;; Record the node we are leaving, if we were in one.
+  (and (not no-going-back)
+       Info-current-file
+       (setq Info-history
+	     (cons (list Info-current-file Info-current-node (point))
+		   Info-history)))
   (Info-find-node-2 filename nodename no-going-back))
 
 ;;;###autoload
--- a/lisp/language/ind-util.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/language/ind-util.el	Fri Jan 06 16:13:05 2006 +0000
@@ -821,7 +821,7 @@
 
 ;;;###autoload
 (defun indian-compose-region (from to)
-  "Compose the region according to `composition-function-table'. "
+  "Compose the region according to `composition-function-table'."
   (interactive "r")
   (save-excursion
     (save-restriction
--- a/lisp/language/mlm-util.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/language/mlm-util.el	Fri Jan 06 16:13:05 2006 +0000
@@ -103,7 +103,7 @@
 ;;;###autoload
 (defun malayalam-composition-function (from to pattern  &optional string)
   "Compose Malayalam characters in REGION, or STRING if specified.
-Assume that the REGION or STRING must fully match the composable 
+Assume that the REGION or STRING must fully match the composable
 PATTERN regexp."
   (if string (malayalam-compose-syllable-string string)
     (malayalam-compose-syllable-region from to))
@@ -239,7 +239,7 @@
     ("$,1@H@m@E(B" . "$,47Y(B")
     ("$,1@H@m@Q(B" . "$,47b(B")
     ("$,1@H@a(B" . "$,47k(B")
-    ("$,1@H@m@H@a(B" . "$,47l(B") 
+    ("$,1@H@m@H@a(B" . "$,47l(B")
 
     ("$,1@J(B" . "$,46=(B")
     ("$,1@J@m@J(B" . "$,478(B") ;; duplicate
@@ -401,7 +401,7 @@
                (apply
                 'nconc
                 (mapcar
-                 (function 
+                 (function
                   (lambda (x) (list '(5 . 3) x))) ;; default ref. point.
                  glyph-str))))
         (compose-region from to glyph-str)))))
--- a/lisp/mh-e/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,118 @@
+2006-01-03  Mark D. Baushke  <mdb@gnu.org>
+
+	* mh-e.el (mh-delete-a-msg): Fix whitespace nit.
+	* mh-index.el (mh-mairix-execute-search): Fix symbol quote.
+
+2006-01-03  Bill Wohler  <wohler@newt.com>
+
+	* mh-alias.el (mh-alias-add-alias): Grand message and error string
+	unification. Use single sentence if possible by using semicolon.
+	Don't end message with punctuation. Don't need format with
+	message. Quote messages as in docstrings: use `' around symbols,
+	\" for option choices. Don't use quotes around %s.
+	
+	* mh-comp.el (mh-complete-word): Ditto.
+
+	* mh-customize.el (mh-adaptive-cmd-note-flag-check)
+	(mh-scan-format-file-check): Ditto.
+
+	* mh-e.el (mh-refile-or-write-again, mh-previous-unread-msg)
+	(mh-delete-a-msg, mh-refile-a-msg, mh-next-unread-msg)
+	(mh-msg-num-width-to-column): Ditto.
+
+	* mh-identity.el (mh-identity-field-handler): Ditto.
+
+	* mh-index.el (mh-mairix-execute-search)
+	(mh-swish-execute-search, mh-swish++-execute-search)
+	(mh-namazu-execute-search): Ditto.
+
+	* mh-init.el (mh-variant-set): Ditto.
+
+	* mh-mime.el (mh-mh-to-mime-undo, mh-mml-forward-message)
+	(mh-secure-message, mh-mime-display): Ditto.
+
+	* mh-pick.el (mh-search-folder, mh-pick-construct-regexp): Ditto.
+
+	* mh-seq.el (mh-narrow-to-seq, mh-put-msg-in-seq, mh-read-seq)
+	(mh-read-range, mh-thread-container-subject): Ditto.
+
+	* mh-utils.el (mh-x-image-scale-and-display)
+	(mh-prompt-for-folder, mh-handle-process-error)
+	(mh-list-to-string-1): Ditto.
+
+	* mh-comp.el (mh-reply): Use standard default notation in
+	prompts (closes SF #1275933).
+
+	* mh-mime.el (mh-mime-save-parts): Ditto.
+
+	* mh-seq.el (mh-read-seq, mh-read-range): Ditto.
+
+	* mh-customize.el (mh-folder-msg-number): Snow is actually
+	off-white on low color displays which turns to white when bold.
+	This is unreadable on white backgrounds. Use snow with min-colors
+	requirement. Use cyan on low-color displays.
+
+	* mh-init.el (mh-defface-compat): On low-color displays, delete
+	the high-color display rather than simply strip the min-colors
+	requirement since the existing algorithm shadowed the desired
+	display on low-color displays.
+
+	* mh-alias.el (mh-alias-add-alias): Remove leading * from
+	docstring.
+
+2006-01-02  Bill Wohler  <wohler@newt.com>
+
+	* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
+	docstring. Does this mean something in a defun?
+
+	* mh-customize.el (bw-new-face-to-old, bw-old-face-to-new):
+	Checkdoc fix.
+
+	* mh-e.el (mh-inc-folder): Rename maildrop-name argument to file
+	so it reads better in docstring and manual. Sync docstring with
+	manual.
+
+	* mh-init.el (mh-defface-compat): Remove trailing space (checkdoc).
+
+	* mh-alias.el (mh-alias-apropos): Sync docstring with manual.
+
+	* mh-comp.el (mh-redistribute, mh-to-field, mh-to-fcc)
+	(mh-insert-auto-fields, mh-send-letter, mh-yank-cur-msg)
+	(mh-fully-kill-draft, mh-open-line, mh-letter-complete)
+	(mh-letter-complete-or-space, mh-letter-confirm-address)
+	(mh-letter-next-header-field-or-indent)
+	(mh-letter-previous-header-field): Ditto.
+
+	* mh-customize.el (mh-alias-completion-ignore-case-flag)
+	(mh-default-folder-for-message-function, mh-mml-method-default)
+	(mh-signature-file-name, mh-yank-behavior, mh-show-hook)
+	(mh-show-mode-hook) Ditto.
+
+	* mh-e.el (mh-refile-or-write-again, mh-toggle-showing): Ditto.
+
+	* mh-funcs.el (mh-pipe-msg, mh-sort-folder, mh-undo-folder)
+	(mh-store-msg, mh-store-buffer): Ditto
+
+	* mh-index.el (mh-index-search, mh-index-do-search)
+	(mh-index-next-folder, mh-index-sequenced-messages): Ditto.
+
+	* mh-junk.el (mh-spamassassin-blacklist): Ditto.
+
+	* mh-mime.el (mh-mh-compose-external-compressed-tar)
+	(mh-mh-compose-external-type, mh-mh-to-mime, mh-mh-to-mime-undo)
+	(mh-mml-secure-message-sign, mh-mml-secure-message-encrypt)
+	(mh-mml-secure-message-signencrypt): Ditto
+
+	* mh-pick.el (mh-search-folder): Ditto.
+
+	* mh-seq.el (mh-widen): Ditto.
+
+	* mh-utils.el (mh-show, mh-modify): Ditto.
+
+2006-01-02  Mark D. Baushke  <mdb@gnu.org>
+
+	* mh-mime.el (mh-mml-unsecure-message): Remove unused argument.
+
 2006-01-01  Bill Wohler  <wohler@newt.com>
 
 	* mh-customize.el: Sync docstrings with manual for faces and sort
--- a/lisp/mh-e/mh-alias.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-alias.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-alias.el --- MH-E mail alias completion and expansion
 ;;
 ;; Copyright (C) 1994, 1995, 1996, 1997,
-;;  2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <psg@debian.org>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -548,7 +548,8 @@
 
 ;;;###mh-autoload
 (defun mh-alias-add-alias (alias address)
-  "*Add ALIAS for ADDRESS in personal alias file.
+  "Add ALIAS for ADDRESS in personal alias file.
+
 This function prompts you for an alias and address. If the alias
 exists already, you will have the choice of inserting the new
 alias before or after the old alias. In the former case, this
@@ -570,7 +571,7 @@
     (cond
      ((and (equal alias address-alias)
            (equal address alias-address))
-      (message "Already defined as: %s" alias-address))
+      (message "Already defined as %s" alias-address))
      (address-alias
       (if (y-or-n-p (format "Address has alias %s; set new one? "
                             address-alias))
@@ -580,7 +581,7 @@
 
 ;;;###mh-autoload
 (defun mh-alias-grab-from-field ()
-  "*Add alias for the sender of the current message."
+  "Add alias for the sender of the current message."
   (interactive)
   (mh-alias-reload-maybe)
   (save-excursion
@@ -609,7 +610,7 @@
 
 ;;;###mh-autoload
 (defun mh-alias-apropos (regexp)
-  "Show all aliases or addresses that match REGEXP."
+  "Show all aliases or addresses that match a regular expression REGEXP."
   (interactive "sAlias regexp: ")
   (if mh-alias-local-users
       (mh-alias-reload-maybe))
--- a/lisp/mh-e/mh-comp.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-comp.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-comp.el --- MH-E functions for composing messages
 
 ;; Copyright (C) 1993, 1995, 1997,
-;;  2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -462,7 +462,7 @@
 command, you are prompted for the TO and CC recipients. The
 default MESSAGE is the current message.
 
-Also investigate the \\[mh-edit-again] command for another way to
+Also investigate the command \\[mh-edit-again] for another way to
 redistribute messages.
 
 See also `mh-redist-full-contents-flag'."
@@ -582,7 +582,7 @@
                 (let ((minibuffer-help-form
                        "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
                   (or mh-reply-default-reply-to
-                      (completing-read "Reply to whom: [from] "
+                      (completing-read "Reply to whom (default from): "
                                        '(("from") ("to") ("cc") ("all"))
                                        nil
                                        t)))
@@ -1114,10 +1114,12 @@
 ;;;###mh-autoload
 (defun mh-to-field ()
   "Move to specified header field.
-The field is indicated by the previous keystroke (the last keystroke
-of the command) according to the list in the variable
-`mh-to-field-choices'. Create the field if it does not exist. Set the
-mark to point before moving."
+
+The field is indicated by the previous keystroke (the last
+keystroke of the command) according to the list in the variable
+`mh-to-field-choices'.
+Create the field if it does not exist.
+Set the mark to point before moving."
   (interactive)
   (expand-abbrev)
   (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
@@ -1146,8 +1148,9 @@
 ;;;###mh-autoload
 (defun mh-to-fcc (&optional folder)
   "Move to \"Fcc:\" header field.
-This command will prompt you for the FOLDER name in which to file a
-copy of the draft."
+
+This command will prompt you for the FOLDER name in which to file
+a copy of the draft."
   (interactive)
   (or folder
       (setq folder (mh-prompt-for-folder
@@ -1333,10 +1336,9 @@
 (defun mh-insert-auto-fields (&optional non-interactive)
   "Insert custom fields if recipient is found in `mh-auto-fields-list'.
 
-Sets buffer-local `mh-insert-auto-fields-done-local' when done
-and inserted something. If NON-INTERACTIVE is non-nil, do not be
-verbose and only attempt matches if
-`mh-insert-auto-fields-done-local' is nil.
+Sets buffer-local `mh-insert-auto-fields-done-local' if header
+fields were added. If NON-INTERACTIVE is non-nil, perform actions
+quietly and only if `mh-insert-auto-fields-done-local' is nil.
 
 An `identity' entry is skipped if one was already entered
 manually.
@@ -1476,9 +1478,9 @@
 of the delivery\; this output can be found in a buffer called \"*MH-E
 Mail Delivery*\".
 
-The hook `mh-before-send-letter-hook' is run at the beginning of the
-this command. For example, if you want to check your spelling in your
-message before sending, add the `ispell-message' function.
+The hook `mh-before-send-letter-hook' is run at the beginning of
+this command. For example, if you want to check your spelling in
+your message before sending, add the function `ispell-message'.
 
 In case the MH \"send\" program is installed under a different name,
 use `mh-send-prog' to tell MH-E the name."
@@ -1607,12 +1609,13 @@
 `mh-ins-buf-prefix' (`> ') before each line.
 
 The attribution consists of the sender's name and email address
-followed by the content of the `mh-extract-from-attribution-verb'
-option.
+followed by the content of the option
+`mh-extract-from-attribution-verb'.
 
-You can also turn on the `mh-delete-yanked-msg-window-flag'
-option to delete the window containing the original message after
-yanking it to make more room on your screen for your reply.
+You can also turn on the option
+`mh-delete-yanked-msg-window-flag' to delete the window
+containing the original message after yanking it to make more
+room on your screen for your reply.
 
 You can control how the message to which you are replying is
 yanked into your reply using `mh-yank-behavior'.
@@ -1741,9 +1744,10 @@
 ;;;###mh-autoload
 (defun mh-fully-kill-draft ()
   "Quit editing and delete draft message.
+
 If for some reason you are not happy with the draft, you can use
-the this command to kill the draft buffer and delete the draft
-message. Use the \\[kill-buffer] command if you don't want to
+this command to kill the draft buffer and delete the draft
+message. Use the command \\[kill-buffer] if you don't want to
 delete the draft message."
   (interactive)
   (if (y-or-n-p "Kill draft message? ")
@@ -1771,9 +1775,9 @@
 
 ;;;###mh-autoload
 (defun mh-open-line ()
-  "Insert a newline and leave point after it.
+  "Insert a newline and leave point before it.
 
-This command is similar to the \\[open-line] command in that it
+This command is similar to the command \\[open-line] in that it
 inserts a newline after point. It differs in that it also inserts
 the right number of quoting characters and spaces so that the
 next line begins in the same column as it was. This is useful
@@ -1814,7 +1818,7 @@
           ((null completion)
            (ignore-errors
              (kill-buffer completions-buffer))
-           (message "No completion for `%s'" word))
+           (message "No completion for %s" word))
           ((stringp completion)
            (if (equal word completion)
                (with-output-to-temp-buffer completions-buffer
@@ -1865,12 +1869,13 @@
 
 (defun mh-letter-complete (arg)
   "Perform completion on header field or word preceding point.
+
 If the field contains addresses (for example, \"To:\" or \"Cc:\")
-or folders (for example, \"Fcc:\") then this command will
-provide alias completion. In the body of the message, this
-command runs `mh-letter-complete-function' instead, which is set
-to \"'ispell-complete-word\" by default. This command takes a
-prefix argument ARG that is passed to the
+or folders (for example, \"Fcc:\") then this command will provide
+alias completion. In the body of the message, this command runs
+`mh-letter-complete-function' instead, which is set to
+`ispell-complete-word' by default. This command takes a prefix
+argument ARG that is passed to the
 `mh-letter-complete-function'."
   (interactive "P")
   (let ((func nil))
@@ -1883,11 +1888,11 @@
 
 (defun mh-letter-complete-or-space (arg)
   "Perform completion or insert space.
-Turn on the `mh-compose-space-does-completion-flag' option to use
+
+Turn on the option `mh-compose-space-does-completion-flag' to use
 this command to perform completion in the header. Otherwise, a
-space is inserted.
-
-ARG is the number of spaces inserted."
+space is inserted; use a prefix argument ARG to specify more than
+one space."
   (interactive "p")
   (let ((func nil)
         (end-of-prev (save-excursion
@@ -1904,9 +1909,10 @@
 
 (defun mh-letter-confirm-address ()
   "Flash alias expansion.
-Addresses are separated by a comma\; and when you press the
-comma, this command flashes the alias expansion in the minibuffer
-if `mh-alias-flash-on-comma' is turned on."
+
+Addresses are separated by a comma\; when you press the comma,
+this command flashes the alias expansion in the minibuffer if
+`mh-alias-flash-on-comma' is turned on."
   (interactive)
   (cond ((not (mh-in-header-p)) (self-insert-command 1))
         ((eq (cdr (assoc (mh-letter-header-field-at-point)
@@ -1929,9 +1935,11 @@
 
 ;;;###mh-autoload
 (defun mh-letter-next-header-field-or-indent (arg)
-  "Move to next field or indent depending on point.
+  "Cycle to next field.
+
 Within the header of the message, this command moves between
-fields, but skips those fields listed in
+fields that are highlighted with the face
+`mh-letter-header-field', skipping those fields listed in
 `mh-compose-skipped-header-fields'. After the last field, this
 command then moves point to the message body before cycling back
 to the first field. If point is already past the first line of
@@ -1969,10 +1977,11 @@
 ;;;###mh-autoload
 (defun mh-letter-previous-header-field ()
   "Cycle to the previous header field.
+
 This command moves backwards between the fields and cycles to the
-body of the message after the first field. Unlike the
-\\[mh-letter-next-header-field-or-indent] command, it will always
-take point to the last field from anywhere in the body."
+body of the message after the first field. Unlike the command
+\\[mh-letter-next-header-field-or-indent], it will always take
+point to the last field from anywhere in the body."
   (interactive)
   (let ((header-end (mh-mail-header-end)))
     (if (>= (point) header-end)
--- a/lisp/mh-e/mh-customize.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-customize.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-customize.el --- MH-E customization
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -260,7 +260,7 @@
   "*Non-nil means don't consider case significant in MH alias completion.
 
 As MH ignores case in the aliases, so too does MH-E. However, you
-may turn this option off to make case significant which can be
+may turn off this option to make case significant which can be
 used to segregate completion of your aliases. You might use
 lowercase for mailing lists and uppercase for people."
   :type 'boolean
@@ -435,7 +435,7 @@
 ;;; Folder Selection (:group 'mh-folder-selection)
 
 (defcustom mh-default-folder-for-message-function nil
-  "Function to select a default folder for refiling or \"Fcc\".
+  "Function to select a default folder for refiling or \"Fcc:\".
 
 The current buffer is set to the message being refiled with point
 at the start of the message. This function should return the
@@ -898,10 +898,11 @@
 The `pgg' customization group may have some settings which may
 interest you (see Info node `(pgg)').
 
-In particular, I set the option `pgg-encrypt-for-me' to t so that all
-messages I encrypt are encrypted with my public key as well. If you
-keep a copy of all of your outgoing mail with a \"Fcc:\" header field,
-this setting is vital so that you can read the mail you write!"
+In particular, I turn on the option `pgg-encrypt-for-me' so that
+all messages I encrypt are encrypted with my public key as well.
+If you keep a copy of all of your outgoing mail with a \"Fcc:\"
+header field, this setting is vital so that you can read the mail
+you write!"
   :type '(choice (const :tag "PGP (MIME)" "pgpmime")
                  (const :tag "PGP" "pgp")
                  (const :tag "S/MIME" "smime")
@@ -925,8 +926,8 @@
 reports t if the buffer contains a separator, may be useful as well.
 
 The signature is inserted into your message with the command
-\\<mh-letter-mode-map>\\[mh-insert-signature] or with the
-`mh-identity-list' option."
+\\<mh-letter-mode-map>\\[mh-insert-signature] or with the option
+`mh-identity-list'."
   :type 'file
   :group 'mh-letter)
 
@@ -971,33 +972,33 @@
 (defcustom mh-yank-behavior 'attribution
   "*Controls which part of a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
 
-To include the entire message, including the entire header, use \"Body
-and Header\". Use \"Body\" to yank just the body without the header.
-To yank only the portion of the message following the point, set this
-option to \"Below Point\".
+To include the entire message, including the entire header, use
+\"Body and Header\". Use \"Body\" to yank just the body without
+the header. To yank only the portion of the message following the
+point, set this option to \"Below Point\".
 
 Choose \"Invoke supercite\" to pass the entire message and header
 through supercite.
 
-If the \"Body With Attribution\" setting is used, then the message
-minus the header is yanked and a simple attribution line is added at
-the top using the value of the `mh-extract-from-attribution-verb'
-option. This is the default.
-
-If the \"Invoke supercite\" or \"Body With Attribution\" settings are
-used, the \"-noformat\" argument is passed to the \"repl\" program to
-override a \"-filter\" or \"-format\" argument. These settings also
-have \"Automatically\" variants that perform the action automatically
-when you reply so that you don't need to use \\[mh-yank-cur-msg] at
-all. Note that this automatic action is only performed if the show
-buffer matches the message being replied to. People who use the
-automatic variants tend to turn on the
-`mh-delete-yanked-msg-window-flag' option as well so that the show
-window is never displayed.
-
-If the show buffer has a region, the `mh-yank-behavior' option is
-ignored unless its value is one of Attribution variants in which case
-the attribution is added to the yanked region.
+If the \"Body With Attribution\" setting is used, then the
+message minus the header is yanked and a simple attribution line
+is added at the top using the value of the option
+`mh-extract-from-attribution-verb'. This is the default.
+
+If the \"Invoke supercite\" or \"Body With Attribution\" settings
+are used, the \"-noformat\" argument is passed to the \"repl\"
+program to override a \"-filter\" or \"-format\" argument. These
+settings also have \"Automatically\" variants that perform the
+action automatically when you reply so that you don't need to use
+\\[mh-yank-cur-msg] at all. Note that this automatic action is
+only performed if the show buffer matches the message being
+replied to. People who use the automatic variants tend to turn on
+the option `mh-delete-yanked-msg-window-flag' as well so that the
+show window is never displayed.
+
+If the show buffer has a region, the option `mh-yank-behavior' is
+ignored unless its value is one of Attribution variants in which
+case the attribution is added to the yanked region.
 
 If this option is set to one of the supercite flavors, the hook
 `mail-citation-hook' is ignored and `mh-ins-buf-prefix' is not
@@ -1040,7 +1041,7 @@
 Otherwise, set SYMBOL to VALUE."
   (if (and value
            (not (eq mh-scan-format-file t)))
-      (error "%s %s" "Can't turn on unless mh-scan-format-file"
+      (error "%s %s" "Can't turn on unless `mh-scan-format-file'"
              "is set to \"Use MH-E scan Format\"")
     (set-default symbol value)))
 
@@ -1051,7 +1052,7 @@
 set SYMBOL to VALUE."
   (if (and (not (eq value t))
            (eq mh-adaptive-cmd-note-flag t))
-      (error "%s %s" "You must turn off mh-adaptive-cmd-note-flag"
+      (error "%s %s" "You must turn off `mh-adaptive-cmd-note-flag'"
              "unless you use \"Use MH-E scan Format\"")
     (set-default symbol value)))
 
@@ -2460,7 +2461,7 @@
 
 It is the last thing called after messages are displayed. It's
 used to affect the behavior of MH-E in general or when
-`mh-show-mode-hook' is too early."
+`mh-show-mode-hook' is too early. See `mh-show-mode-hook'."
   :type 'hook
   :group 'mh-hooks
   :group 'mh-show)
@@ -2470,7 +2471,7 @@
 
 This hook is called early on in the process of the message
 display. It is usually used to perform some action on the
-message's content."
+message's content. See `mh-show-hook'."
   :type 'hook
   :group 'mh-hooks
   :group 'mh-show)
@@ -2535,10 +2536,14 @@
   :group 'mh-folder)
 
 (defface mh-folder-msg-number
-  '((((class color) (background light))
-     (:foreground "snow4"))
-    (((class color) (background dark))
-     (:foreground "snow3")))
+  (mh-defface-compat
+   '((((class color) (min-colors 88) (background light))
+      (:foreground "snow4"))
+     (((class color) (min-colors 88) (background dark))
+      (:foreground "snow3"))
+     (((class color))
+      (:foreground "cyan"))))
+    
   "Message number face."
   :group 'mh-faces
   :group 'mh-folder)
@@ -2802,7 +2807,7 @@
          (setq bw-face-generation 'new))))
 
 (defun bw-new-face-to-old ()
-  "Sets old faces."
+  "Set old faces."
   (face-spec-set 'mh-folder-body
     (mh-defface-compat
      '((((class color) (min-colors 88) (background light))
@@ -2858,7 +2863,7 @@
        (:bold t)))))
 
 (defun bw-old-face-to-new ()
-  "Sets new faces."
+  "Set new faces."
   (face-spec-set 'mh-folder-body
     '((((class color))
        (:inherit mh-folder-msg-number))
@@ -2875,7 +2880,9 @@
     '((((class color) (background light))
        (:foreground "snow4"))
       (((class color) (background dark))
-       (:foreground "snow3")))))
+       (:foreground "snow3"))
+      (((class color))
+       (:foreground "cyan")))))
 
 
 ;; Local Variables:
--- a/lisp/mh-e/mh-e.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-e.el	Fri Jan 06 16:13:05 2006 +0000
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1985, 1986, 1987, 1988,
 ;;  1990, 1992, 1993, 1994, 1995, 1997, 1999,
-;;  2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -711,21 +711,18 @@
       (mh-recenter 0))
     (setq mh-showing-with-headers t)))
 
-(defun mh-inc-folder (&optional maildrop-name folder)
+(defun mh-inc-folder (&optional file folder)
   "Incorporate new mail into a folder.
 
 You can incorporate mail from any file into the current folder by
 specifying a prefix argument; you'll be prompted for the name of
-the file to use as well as the destination folder
+the FILE to use as well as the destination FOLDER
 
 The hook `mh-inc-folder-hook' is run after incorporating new
-mail. Do not call this function from outside MH-E; use
-\\[mh-rmail] instead.
-
-In a program optional argument MAILDROP-NAME specifies an
-alternate maildrop from the default. The optional argument FOLDER
-specifies where to incorporate mail instead of the default named
-by `mh-inbox'."
+mail.
+
+Do not call this function from outside MH-E; use \\[mh-rmail]
+instead."
   (interactive (list (if current-prefix-arg
                          (expand-file-name
                           (read-file-name "inc mail from file: "
@@ -745,7 +742,7 @@
             ((not (eq (current-buffer) (get-buffer folder)))
              (switch-to-buffer folder)
              (setq mh-previous-window-config config))))
-    (mh-get-new-mail maildrop-name)
+    (mh-get-new-mail file)
     (when (and threading-needed-flag
                (save-excursion
                  (goto-char (point-min))
@@ -892,8 +889,10 @@
 (defun mh-refile-or-write-again (range &optional interactive-flag)
   "Repeat last output command.
 
-If you are refiling several messages into the same folder, you can use
-this command to repeat the last refile or write. You can use a range.
+If you are refiling several messages into the same folder, you
+can use this command to repeat the last
+refile (\\[mh-refile-msg]) or write (\\[mh-write-msg-to-file]).
+You can use a range.
 
 Check the documentation of `mh-interactive-range' to see how RANGE is
 read in interactive use.
@@ -905,8 +904,7 @@
       (error "No previous refile or write"))
   (cond ((eq (car mh-last-destination) 'refile)
          (mh-refile-msg range (cdr mh-last-destination))
-         (message "%s" (format "Destination folder: %s"
-                               (cdr mh-last-destination))))
+         (message "Destination folder: %s" (cdr mh-last-destination)))
         (t
          (mh-iterate-on-range msg range
            (apply 'mh-write-msg-to-file msg (cdr mh-last-destination)))
@@ -1006,7 +1004,7 @@
 many unread messages to skip."
   (interactive "p")
   (unless (> count 0)
-    (error "The function mh-previous-unread-msg expects positive argument"))
+    (error "The function `mh-previous-unread-msg' expects positive argument"))
   (setq count (1- count))
   (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
         (cur-msg (mh-get-msg-num nil)))
@@ -1255,7 +1253,14 @@
       (append-to-file (point) (point-max) output-file))))
 
 (defun mh-toggle-showing ()
-  "Toggle the scanning mode/showing mode of displaying messages."
+  "Toggle between MH-Folder and MH-Folder Show modes.
+
+This command switches between MH-Folder mode and MH-Folder Show
+mode. MH-Folder mode turns off the associated show buffer so that
+you can perform operations on the messages quickly without
+reading them. This is an excellent way to prune out your junk
+mail or to refile a group of messages to another folder for later
+examination."
   (interactive)
   (if mh-showing-mode
       (mh-set-scan-mode)
@@ -1521,7 +1526,7 @@
       (beginning-of-line)
       (setq message (mh-get-msg-num t)))
     (if (looking-at mh-scan-refiled-msg-regexp)
-        (error "Message %d is refiled.  Undo refile before deleting" message))
+        (error "Message %d is refiled; undo refile before deleting" message))
     (if (looking-at mh-scan-deleted-msg-regexp)
         nil
       (mh-set-folder-modified-p t)
@@ -1541,10 +1546,10 @@
       (beginning-of-line)
       (setq message (mh-get-msg-num t)))
     (cond ((looking-at mh-scan-deleted-msg-regexp)
-           (error "Message %d is deleted.  Undo delete before moving" message))
+           (error "Message %d is deleted; undo delete before moving" message))
           ((looking-at mh-scan-refiled-msg-regexp)
            (if (y-or-n-p
-                (format "Message %d already refiled.  Copy to %s as well? "
+                (format "Message %d already refiled; copy to %s as well? "
                         message folder))
                (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
                             "-src" mh-current-folder
@@ -1575,7 +1580,7 @@
 many unread messages to skip."
   (interactive "p")
   (unless (> count 0)
-    (error "The function mh-next-unread-msg expects positive argument"))
+    (error "The function `mh-next-unread-msg' expects positive argument"))
   (setq count (1- count))
   (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
         (cur-msg (mh-get-msg-num nil)))
@@ -1983,8 +1988,8 @@
 comes after that."
   (if (eq mh-scan-format-file t)
       (max (1+ width) 2)
-    (error "%s %s" "Can't call mh-msg-num-width-to-column"
-           "when mh-scan-format-file is not t")))
+    (error "%s %s" "Can't call `mh-msg-num-width-to-column' when"
+           "`mh-scan-format-file' is not set to \"Use MH-E scan Format\"")))
 
 (defun mh-set-cmd-note (column)
   "Set `mh-cmd-note' to COLUMN.
--- a/lisp/mh-e/mh-funcs.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-funcs.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-funcs.el --- MH-E functions not everyone will use right away
 
 ;; Copyright (C) 1993, 1995,
-;;  2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -214,9 +214,9 @@
   "Pipe message through shell command COMMAND.
 
 You are prompted for the Unix command through which you wish to
-run your message. If you give an argument INCLUDE-HEADER to this
-command, the message header is included in the text passed to the
-command."
+run your message. If you give a prefix argument INCLUDE-HEADER to
+this command, the message header is included in the text passed
+to the command."
   (interactive
    (list (read-string "Shell command on message: ") current-prefix-arg))
   (let ((msg-file-to-pipe (mh-msg-filename (mh-get-msg-num t)))
@@ -266,12 +266,11 @@
 
 ;;;###mh-autoload
 (defun mh-sort-folder (&optional extra-args)
-  "Sort the messages in the current folder by date.
+  "Sort folder.
 
-Calls the MH program sortm to do the work.
-
-The arguments in the list `mh-sortm-args' are passed to sortm if
-the optional argument EXTRA-ARGS is given."
+By default, messages are sorted by date. The option
+`mh-sortm-args' holds extra arguments to pass on to the command
+\"sortm\" when a prefix argument EXTRA-ARGS is used."
   (interactive "P")
   (mh-process-or-undo-commands mh-current-folder)
   (setq mh-next-direction 'forward)
@@ -288,7 +287,7 @@
 
 ;;;###mh-autoload
 (defun mh-undo-folder ()
-  "Undo all pending deletes and refiles in current folder."
+  "Undo all refiles and deletes in the current folder."
   (interactive)
   (cond ((or mh-do-not-confirm-flag
              (yes-or-no-p "Undo all commands in folder? "))
@@ -310,7 +309,9 @@
 directory. The next time you use this command, the default
 directory is the last directory you used. If you would like to
 change the initial default directory, customize the option
-`mh-store-default-directory'."
+`mh-store-default-directory', change the value from \"Current\"
+to \"Directory\", and then enter the name of the directory for
+storing the content of these messages."
   (interactive (list (let ((udir (or mh-store-default-directory
                                      default-directory)))
                        (read-file-name "Store message in directory: "
@@ -324,12 +325,9 @@
 
 ;;;###mh-autoload
 (defun mh-store-buffer (directory)
-  "Store the file(s) contained in the current buffer into DIRECTORY.
+  "Unpack buffer created with \"uudecode\" or \"shar\".
 
-The buffer can contain a shar file or uuencoded file.
-
-Default directory is the last directory used, or initially the
-value of `mh-store-default-directory' or the current directory."
+See `mh-store-msg' for a description of DIRECTORY."
   (interactive (list (let ((udir (or mh-store-default-directory
                                      default-directory)))
                        (read-file-name "Store buffer in directory: "
--- a/lisp/mh-e/mh-identity.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-identity.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-identity.el --- Multiple identify support for MH-E.
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <psg@debian.org>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -127,7 +127,7 @@
 valid header field."
   (or (cdr (mh-assoc-ignore-case field mh-identity-handlers))
       (and (eq (aref field 0) ?:)
-           (error "Field %s - unknown mh-identity-handler" field))
+           (error "Field %s not found in `mh-identity-handlers'" field))
       (cdr (assoc ":default" mh-identity-handlers))
       'mh-identity-handler-default))
 
--- a/lisp/mh-e/mh-index.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-index.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-index  --  MH-E interface to indexing programs
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -359,46 +359,52 @@
                         &optional window-config)
   "Perform an indexed search in an MH mail folder.
 
-Use a prefix argument to repeat the search.
+Use a prefix argument to repeat the last search.
 
-Unlike regular searches, the prompt for the folder to search can be
-\"all\" to search all folders; in addition, the search works recursively
-on the listed folder. The search criteria are entered in an MH-Pick
-buffer as described in `mh-search-folder'.
+Unlike regular searches, the prompt for the folder to search can
+be \"all\" to search all folders; in addition, the search works
+recursively on the listed folder. The search criteria are entered
+in an MH-Pick buffer as described in `mh-search-folder'.\\<mh-pick-mode-map>
 
-To perform the search, type \\<mh-pick-mode-map>\\[mh-do-search].
-Another difference from the regular searches is that because the
-search operates on more than one folder, the messages that are found
-are put in a temporary sub-folder of \"+mhe-index\" and are displayed in
-an MH-Folder buffer. This buffer is special because it displays
+To perform the search, type \\[mh-do-search]. Another difference
+from the regular searches is that because the search operates on
+more than one folder, the messages that are found are put in a
+temporary sub-folder of \"+mhe-index\" and are displayed in an
+MH-Folder buffer. This buffer is special because it displays
 messages from multiple folders; each set of messages from a given
-folder has a heading with the folder name.
+folder has a heading with the folder name.\\<mh-folder-mode-map>
+
+The appearance of the heading can be modified by customizing the
+face `mh-index-folder'. You can jump back and forth between the
+headings using the commands \\[mh-index-next-folder] and
+\\[mh-index-previous-folder].
 
-In addition, the \\<mh-folder-mode-map>\\[mh-index-visit-folder]
-command can be used to visit the folder of the message at point.
-Initially, only the messages that matched the search criteria are
-displayed in the folder. While the temporary buffer has its own set of
-message numbers, the actual messages numbers are shown in the visited
-folder. Thus, the \\[mh-index-visit-folder] command is useful to find
-the actual message number of an interesting message, or to view
-surrounding messages with the \\[mh-rescan-folder] command.
+In addition, the command \\[mh-index-visit-folder] can be used to
+visit the folder of the message at point. Initially, only the
+messages that matched the search criteria are displayed in the
+folder. While the temporary buffer has its own set of message
+numbers, the actual messages numbers are shown in the visited
+folder. Thus, the command \\[mh-index-visit-folder] is useful to
+find the actual message number of an interesting message, or to
+view surrounding messages with the command \\[mh-rescan-folder].
 
-Because this folder is temporary, you'll probably get in the habit of
-killing it when you're done with \\[mh-kill-folder].
+Because this folder is temporary, you'll probably get in the
+habit of killing it when you're done with
+\\[mh-kill-folder].
 
-If you have run the \\[mh-search-folder] command, but change your mind
-while entering the search criteria and actually want to run an indexed
-search, then you can use the
-\\<mh-pick-mode-map>\\[mh-index-do-search] command in the MH-Pick
-buffer.
+If you have run the command \\[mh-search-folder], but change your
+mind while entering the search criteria and actually want to run
+an indexed search, then you can use the command
+\\<mh-pick-mode-map>\\[mh-index-do-search] in the MH-Pick
+buffer.\\<mh-folder-mode-map>
 
-The \\<mh-folder-mode-map>\\[mh-index-search] command runs the command
-defined by the `mh-index-program' option. The default value is
-\"Auto-detect\" which means that MH-E will automatically choose one of
+The command \\[mh-index-search] runs the command defined by the
+option `mh-index-program'. The default value is \"Auto-detect\"
+which means that MH-E will automatically choose one of
 \"swish++\", \"swish-e\", \"mairix\", \"namazu\", \"pick\" and
-\"grep\" in that order. If, for example, you have both \"swish++\" and
-\"mairix\" installed and you want to use \"mairix\", then you can set
-this option to \"mairix\".
+\"grep\" in that order. If, for example, you have both
+\"swish++\" and \"mairix\" installed and you want to use
+\"mairix\", then you can set this option to \"mairix\".
 
                                 *NOTE*
 
@@ -621,7 +627,7 @@
 
 ;;;###mh-autoload
 (defun mh-index-do-search ()
-  "Construct appropriate regexp and call `mh-index-search'."
+  "Find messages that match the qualifications in the current pattern buffer."
   (interactive)
   (unless (mh-index-choose) (error "No indexing program found"))
   (let* ((regexp-list (mh-pick-parse-search-buffer))
@@ -736,8 +742,7 @@
 ;;;###mh-autoload
 (defun mh-index-next-folder (&optional backward-flag)
   "Jump to the next folder marker.
-The function is only applicable to folders displaying index search
-results.
+
 With non-nil optional argument BACKWARD-FLAG, jump to the previous
 group of results."
   (interactive "P")
@@ -1163,7 +1168,7 @@
   (set-buffer (get-buffer-create mh-index-temp-buffer))
   (erase-buffer)
   (unless mh-mairix-binary
-    (error "Set mh-mairix-binary appropriately"))
+    (error "Set `mh-mairix-binary' appropriately"))
   (apply #'call-process mh-mairix-binary nil '(t nil) nil
          "-r" "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)
          search-regexp-list)
@@ -1305,11 +1310,12 @@
 
 ;;;###mh-autoload
 (defun mh-index-sequenced-messages (folders sequence)
-  "Display messages from FOLDERS in SEQUENCE.
-All messages in the sequence you provide from the folders in
-`mh-new-messages-folders' are listed. With a prefix argument,
-enter a space-separated list of folders, or nothing to search all
-folders."
+  "Display messages in any sequence.
+
+All messages from the FOLDERS in `mh-new-messages-folders' in the
+SEQUENCE you provide are listed. With a prefix argument, enter a
+space-separated list of folders at the prompt, or nothing to
+search all folders."
   (interactive
    (list (if current-prefix-arg
              (split-string (read-string "Search folder(s) (default all): "))
@@ -1440,7 +1446,7 @@
   (set-buffer (get-buffer-create mh-index-temp-buffer))
   (erase-buffer)
   (unless mh-swish-binary
-    (error "Set mh-swish-binary appropriately"))
+    (error "Set `mh-swish-binary' appropriately"))
   (call-process mh-swish-binary nil '(t nil) nil
                 "-w" search-regexp
                 "-f" (format "%s%s/index" mh-user-path mh-swish-directory))
@@ -1529,7 +1535,7 @@
   (set-buffer (get-buffer-create mh-index-temp-buffer))
   (erase-buffer)
   (unless mh-swish++-binary
-    (error "Set mh-swish++-binary appropriately"))
+    (error "Set `mh-swish++-binary' appropriately"))
   (call-process mh-swish++-binary nil '(t nil) nil
                 "-m" "10000"
                 (format "-i%s%s/swish++.index"
@@ -1608,7 +1614,7 @@
     (unless (file-exists-p namazu-index-directory)
       (error "Namazu directory %s not present" namazu-index-directory))
     (unless (executable-find mh-namazu-binary)
-      (error "Set mh-namazu-binary appropriately"))
+      (error "Set `mh-namazu-binary' appropriately"))
     (set-buffer (get-buffer-create mh-index-temp-buffer))
     (erase-buffer)
     (call-process mh-namazu-binary nil '(t nil) nil
--- a/lisp/mh-e/mh-init.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-init.el	Fri Jan 06 16:13:05 2006 +0000
@@ -127,13 +127,13 @@
        ((mh-variant-set-variant 'mu-mh)
         (message "%s installed as MH variant" mh-variant-in-use))
        (t
-        (message "No MH variant found on the system!"))))
+        (message "No MH variant found on the system"))))
      ((member variant valid-list)
       (when (not (mh-variant-set-variant variant))
-        (message "Warning: %s variant not found.  Autodetecting..." variant)
+        (message "Warning: %s variant not found. Autodetecting..." variant)
         (mh-variant-set 'autodetect)))
      (t
-      (message "Unknown variant.  Use %s"
+      (message "Unknown variant; use %s"
                (mapconcat '(lambda (x) (format "%s" (car x)))
                           mh-variants " or "))))))
 
@@ -334,25 +334,30 @@
 
 (defun mh-defface-compat (spec)
   "Convert SPEC for defface if necessary to run on older platforms.
-Modifies SPEC in place and returns it. See `defface' for the spec definition. 
+Modifies SPEC in place and returns it. See `defface' for the spec definition.
 
-When `mh-min-colors-defined-flag' is nil, this function finds a
-display with a single \"class\" requirement with a \"color\"
-item, renames the requirement to \"tty\" and moves it to the
-beginning of the list. It then strips any \"min-colors\"
-requirements."
-  (when (not mh-min-colors-defined-flag)
-    ;; Insert ((class tty)) display with ((class color)) attributes.
-    (let ((attributes (cdr (assoc '((class color)) spec))))
-      (cons (cons '((class tty)) attributes) spec))
-    ;; Delete ((class color)) display.
-    (delq (assoc '((class color)) spec) spec)
-    ;; Strip min-colors.
-    (loop for entry in spec do
-          (when (not (eq (car entry) t))
-            (if (assoc 'min-colors (car entry))
-                (delq (assoc 'min-colors (car entry)) (car entry))))))
-  spec)
+When `mh-min-colors-defined-flag' is nil, this function finds
+display entries with \"min-colors\" requirements and either
+removes the \"min-colors\" requirement or strips the display
+entirely if the display does not support the number of specified
+colors."
+  (if mh-min-colors-defined-flag
+      spec
+    (let ((cells (display-color-cells))
+          new-spec)
+      ;; Remove entries with min-colors, or delete them if we have fewer colors
+      ;; than they specify.
+      (loop for entry in (reverse spec) do
+            (let ((requirement (if (eq (car entry) t)
+                                   nil
+                                 (assoc 'min-colors (car entry)))))
+              (if requirement
+                  (when (>= cells (nth 1 requirement))
+                    (setq new-spec (cons (cons (delq requirement (car entry))
+                                               (cdr entry))
+                                         new-spec)))
+                (setq new-spec (cons entry new-spec)))))
+      new-spec)))
 
 (provide 'mh-init)
 
--- a/lisp/mh-e/mh-junk.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-junk.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-junk.el --- Interface to anti-spam measures
 
-;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>,
 ;;         Bill Wohler <wohler@newt.com>
@@ -108,10 +108,12 @@
 (defun mh-spamassassin-blacklist (msg)
   "Blacklist MSG with SpamAssassin.
 
-SpamAssassin is one of the more popular spam filtering programs. Get
-it from your local distribution or from http://spamassassin.org/.
+SpamAssassin is one of the more popular spam filtering programs.
+Get it from your local distribution or from
+http://spamassassin.org/.
 
-To use SpamAssassin, add the following recipes to \".procmailrc\":
+To use SpamAssassin, add the following recipes to
+\".procmailrc\":
 
     MAILDIR=$HOME/`mhparam Path`
 
@@ -130,56 +132,59 @@
 
 If you don't use \"spamc\", use \"spamassassin -P -a\".
 
-Note that one of the recipes above throws away messages with a score
-greater than or equal to 10. Here's how you can determine a value that
-works best for you.
+Note that one of the recipes above throws away messages with a
+score greater than or equal to 10. Here's how you can determine a
+value that works best for you.
 
-First, run \"spamassassin -t\" on every mail message in your archive and
-use Gnumeric to verify that the average plus the standard deviation of
-good mail is under 5, the SpamAssassin default for \"spam\".
+First, run \"spamassassin -t\" on every mail message in your
+archive and use Gnumeric to verify that the average plus the
+standard deviation of good mail is under 5, the SpamAssassin
+default for \"spam\".
 
-Using Gnumeric, sort the messages by score and view the messages with
-the highest score. Determine the score which encompasses all of your
-interesting messages and add a couple of points to be conservative.
-Add that many dots to the \"X-Spam-Level:\" header field above to send
-messages with that score down the drain.
+Using Gnumeric, sort the messages by score and view the messages
+with the highest score. Determine the score which encompasses all
+of your interesting messages and add a couple of points to be
+conservative. Add that many dots to the \"X-Spam-Level:\" header
+field above to send messages with that score down the drain.
 
-In the example above, messages with a score of 5-9 are set aside in
-the \"+spam\" folder for later review. The major weakness of rules-based
-filters is a plethora of false positives so it is worthwhile to check.
+In the example above, messages with a score of 5-9 are set aside
+in the \"+spam\" folder for later review. The major weakness of
+rules-based filters is a plethora of false positives so it is
+worthwhile to check.
 
-If SpamAssassin classifies a message incorrectly, or is unsure, you
-can use the MH-E commands \\[mh-junk-blacklist] and
+If SpamAssassin classifies a message incorrectly, or is unsure,
+you can use the MH-E commands \\[mh-junk-blacklist] and
 \\[mh-junk-whitelist].
 
-The \\[mh-junk-blacklist] command adds a \"blacklist_from\" entry to
-\"~/spamassassin/user_prefs\", deletes the message, and sends the
-message to the Razor, so that others might not see this spam. If the
-\"sa-learn\" command is available, the message is also recategorized as
-spam.
+The command \\[mh-junk-blacklist] adds a \"blacklist_from\" entry
+to \"~/spamassassin/user_prefs\", deletes the message, and sends
+the message to the Razor, so that others might not see this spam.
+If the \"sa-learn\" command is available, the message is also
+recategorized as spam.
 
-The \\[mh-junk-whitelist] command adds a \"whitelist_from\" rule to the
-\"~/.spamassassin/user_prefs\" file. If the \"sa-learn\" command is
-available, the message is also recategorized as ham.
+The command \\[mh-junk-whitelist] adds a \"whitelist_from\" rule
+to the \"~/.spamassassin/user_prefs\" file. If the \"sa-learn\"
+command is available, the message is also recategorized as ham.
 
 Over time, you'll observe that the same host or domain occurs
-repeatedly in the \"blacklist_from\" entries, so you might think that
-you could avoid future spam by blacklisting all mail from a particular
-domain. The utility function `mh-spamassassin-identify-spammers' helps
-you do precisely that. This function displays a frequency count of the
-hosts and domains in the \"blacklist_from\" entries from the last blank
-line in \"~/.spamassassin/user_prefs\" to the end of the file. This
+repeatedly in the \"blacklist_from\" entries, so you might think
+that you could avoid future spam by blacklisting all mail from a
+particular domain. The utility function
+`mh-spamassassin-identify-spammers' helps you do precisely that.
+This function displays a frequency count of the hosts and domains
+in the \"blacklist_from\" entries from the last blank line in
+\"~/.spamassassin/user_prefs\" to the end of the file. This
 information can be used so that you can replace multiple
 \"blacklist_from\" entries with a single wildcard entry such as:
 
     blacklist_from *@*amazingoffersdirect2u.com
 
 In versions of SpamAssassin (2.50 and on) that support a Bayesian
-classifier, \\[mh-junk-blacklist] uses the \"sa-learn\" program to
-recategorize the message as spam. Neither MH-E, nor SpamAssassin,
-rebuilds the database after adding words, so you will need to run
-\"sa-learn --rebuild\" periodically. This can be done by adding the
-following to your crontab:
+classifier, \\[mh-junk-blacklist] uses the program \"sa-learn\"
+to recategorize the message as spam. Neither MH-E, nor
+SpamAssassin, rebuilds the database after adding words, so you
+will need to run \"sa-learn --rebuild\" periodically. This can be
+done by adding the following to your crontab:
 
     0 * * * *	sa-learn --rebuild > /dev/null 2>&1"
   (unless mh-spamassassin-executable
--- a/lisp/mh-e/mh-mime.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-mime.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-mime.el --- MH-E support for composing MIME messages
 
 ;; Copyright (C) 1993, 1995,
-;;  2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -318,9 +318,10 @@
 ;;;###mh-autoload
 (defun mh-mh-compose-anon-ftp (host filename type description)
   "Add tag to include anonymous ftp reference to a file.
-You can even have your message initiate an \"ftp\" transfer when
-the recipient reads the message. You are prompted for the remote
-HOST and FILENAME, the media TYPE, and the content DESCRIPTION.
+
+You can have your message initiate an \"ftp\" transfer when the
+recipient reads the message. You are prompted for the remote HOST
+and FILENAME, the media TYPE, and the content DESCRIPTION.
 
 See also \\[mh-mh-to-mime]."
   (interactive (list
@@ -334,8 +335,9 @@
 ;;;###mh-autoload
 (defun mh-mh-compose-external-compressed-tar (host filename description)
   "Add tag to include anonymous ftp reference to a compressed tar file.
+
 In addition to retrieving the file via anonymous \"ftp\" as per
-the \\[mh-mh-compose-anon-ftp] command, the file will also be
+the command \\[mh-mh-compose-anon-ftp], the file will also be
 uncompressed and untarred. You are prompted for the remote HOST
 and FILENAME and the content DESCRIPTION.
 
@@ -356,6 +358,7 @@
                                                 attributes parameters
                                                 comment)
   "Add tag to refer to a remote file.
+
 This command is a general utility for referencing external files.
 In fact, all of the other commands that insert directives to
 access external files call this command. You are prompted for the
@@ -435,14 +438,14 @@
 message. However, you may take a sneak preview of the MIME encoding if
 you wish by running this command.
 
-If you wish to pass additional arguments to \"mhbuild\" (\"mhn\") to
-affect how it builds your message, use the `mh-mh-to-mime-args'
-option. For example, you can build a consistency check into the
-message by setting `mh-mh-to-mime-args' to \"-check\". The recipient
-of your message can then run \"mhbuild -check\" on the
-message--\"mhbuild\" (\"mhn\") will complain if the message has been
-corrupted on the way. This command only consults this option when
-given a prefix argument EXTRA-ARGS.
+If you wish to pass additional arguments to \"mhbuild\" (\"mhn\")
+to affect how it builds your message, use the option
+`mh-mh-to-mime-args'. For example, you can build a consistency
+check into the message by setting `mh-mh-to-mime-args' to
+\"-check\". The recipient of your message can then run \"mhbuild
+-check\" on the message--\"mhbuild\" (\"mhn\") will complain if
+the message has been corrupted on the way. This command only
+consults this option when given a prefix argument EXTRA-ARGS.
 
 The hook `mh-mh-to-mime-hook' is called after the message has been
 formatted.
@@ -484,8 +487,10 @@
 ;;;###mh-autoload
 (defun mh-mh-to-mime-undo (noconfirm)
   "Undo effects of \\[mh-mh-to-mime].
-Optional non-nil argument NOCONFIRM means don't ask for
-confirmation."
+
+It does this by reverting to a backup file. You are prompted to
+confirm this action, but you can avoid the confirmation by adding
+a prefix argument NOCONFIRM."
   (interactive "*P")
   (if (null buffer-file-name)
       (error "Buffer does not seem to be associated with any file"))
@@ -500,7 +505,7 @@
                                     ".orig")))))
       (setq backup-strings (cdr backup-strings)))
     (or backup-strings
-        (error "Backup file for %s no longer exists!" buffer-file-name))
+        (error "Backup file for %s no longer exists" buffer-file-name))
     (or noconfirm
         (yes-or-no-p (format "Revert buffer from file %s? "
                              backup-file))
@@ -580,7 +585,7 @@
                                       mh-user-path (substring folder 1) msg)
                               "message/rfc822"
                               description)))
-          (t (error "The message number, %s is not a integer!" msg)))))
+          (t (error "The message number, %s, is not a integer" msg)))))
 
 (defvar mh-mml-cryptographic-method-history ())
 
@@ -628,9 +633,9 @@
     (let ((valid-methods (list "pgpmime" "pgp" "smime"))
           (valid-modes (list "sign" "encrypt" "signencrypt" "none")))
       (if (not (member method valid-methods))
-          (error "Method \"%s\" is invalid" method))
+          (error "Method %s is invalid" method))
       (if (not (member mode valid-modes))
-          (error "Mode \"%s\" is invalid" mode))
+          (error "Mode %s is invalid" mode))
       (mml-unsecure-message)
       (if (not (string= mode "none"))
         (save-excursion
@@ -642,10 +647,9 @@
             (mml-insert-tag 'secure 'method method 'mode mode)))))))
 
 ;;;###mh-autoload
-(defun mh-mml-unsecure-message (&optional ignore)
-  "Remove any secure message tags.
-The argument IGNORE is not used."
-  (interactive "P")
+(defun mh-mml-unsecure-message ()
+  "Remove any secure message tags."
+  (interactive)
   (if (not mh-pgp-support-flag)
       (error "Your version of Gnus does not support PGP/GPG")
     (mml-unsecure-message)))
@@ -655,7 +659,7 @@
   "Add tag to sign the message.
 
 A proper multipart message is created for you when you send the
-message. Use the \\[mh-mml-unsecure-message] command to remove
+message. Use the command \\[mh-mml-unsecure-message] to remove
 this tag. Use a prefix argument METHOD to be prompted for one of
 the possible security methods (see `mh-mml-method-default')."
   (interactive (list (mh-mml-query-cryptographic-method)))
@@ -666,7 +670,7 @@
   "Add tag to encrypt the message.
 
 A proper multipart message is created for you when you send the
-message. Use the \\[mh-mml-unsecure-message] command to remove
+message. Use the command \\[mh-mml-unsecure-message] to remove
 this tag. Use a prefix argument METHOD to be prompted for one of
 the possible security methods (see `mh-mml-method-default')."
   (interactive (list (mh-mml-query-cryptographic-method)))
@@ -677,7 +681,7 @@
   "Add tag to encrypt and sign the message.
 
 A proper multipart message is created for you when you send the
-message. Use the \\[mh-mml-unsecure-message] command to remove
+message. Use the command \\[mh-mml-unsecure-message] to remove
 this tag. Use a prefix argument METHOD to be prompted for one of
 the possible security methods (see `mh-mml-method-default')."
   (interactive (list (mh-mml-query-cryptographic-method)))
@@ -853,7 +857,7 @@
                     (equal t mh-mime-save-parts-default-directory))
                 mh-mime-save-parts-directory)
            (read-file-name (format
-                            "Store in directory: [%s] "
+                            "Store in directory (default %s): "
                             mh-mime-save-parts-directory)
                            "" mh-mime-save-parts-directory t ""))
           ((stringp mh-mime-save-parts-default-directory)
@@ -963,7 +967,7 @@
                    (mh-mime-display-part handles))
                   (t (mh-signature-highlight))))
         (error
-         (message "Please report this error. The error message is:\n %s"
+         (message "Please report this error:\n %s"
                   (error-message-string err))
          (delete-region (point-min) (point-max))
          (insert raw-message-data))))))
--- a/lisp/mh-e/mh-pick.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-pick.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-pick.el --- make a search pattern and search for a message in MH-E
 
 ;; Copyright (C) 1993, 1995,
-;;  2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -54,13 +54,14 @@
 (defun mh-search-folder (folder window-config)
   "Search FOLDER for messages matching a pattern.
 
-With this command, you can search a folder for messages to or from a
-particular person or about a particular subject. In fact, you can also
-search for messages containing selected strings in any arbitrary
-header field or any string found within the messages.
+With this command, you can search a folder for messages to or
+from a particular person or about a particular subject. In fact,
+you can also search for messages containing selected strings in
+any arbitrary header field or any string found within the
+messages.
 
-You are first prompted for the name of the folder to search and then
-placed in the following buffer in MH-Pick mode:
+You are first prompted for the name of the folder to search and
+then placed in the following buffer in MH-Pick mode:
 
      From:
      To:
@@ -69,26 +70,27 @@
      Subject:
      --------
 
-Edit this template by entering your search criteria in an appropriate
-header field that is already there, or create a new field yourself. If
-the string you're looking for could be anywhere in a message, then
-place the string underneath the row of dashes. The
-\\[mh-search-folder] command uses the MH command \"pick\" to do the
-real work.
+Edit this template by entering your search criteria in an
+appropriate header field that is already there, or create a new
+field yourself. If the string you're looking for could be
+anywhere in a message, then place the string underneath the row
+of dashes. The command \\[mh-search-folder] uses the MH command
+\"pick\" to do the real work.
 
-There are no semantics associated with the search criteria--they are
-simply treated as strings. Case is ignored when all lowercase is used,
-and regular expressions (a la \"ed\") are available. It is all right
-to specify several search criteria. What happens then is that a
-logical _and_ of the various fields is performed. If you prefer a
-logical _or_ operation, run \\[mh-search-folder] multiple times.
+There are no semantics associated with the search criteria--they
+are simply treated as strings. Case is ignored when all lowercase
+is used, and regular expressions (a la \"ed\") are available. It
+is all right to specify several search criteria. What happens
+then is that a logical _and_ of the various fields is performed.
+If you prefer a logical _or_ operation, run \\[mh-search-folder]
+multiple times.
 
-As an example, let's say that we want to find messages from Ginnean
-about horseback riding in the Kosciusko National Park (Australia)
-during January, 1994. Normally we would start with a broad search and
-narrow it down if necessary to produce a manageable amount of data,
-but we'll cut to the chase and create a fairly restrictive set of
-criteria as follows:
+As an example, let's say that we want to find messages from
+Ginnean about horseback riding in the Kosciusko National
+Park (Australia) during January, 1994. Normally we would start
+with a broad search and narrow it down if necessary to produce a
+manageable amount of data, but we'll cut to the chase and create
+a fairly restrictive set of criteria as follows:
 
      From: ginnean
      To:
@@ -98,31 +100,32 @@
      --------
 
 As with MH-Letter mode, MH-Pick provides commands like
-\\<mh-pick-mode-map>\\[mh-to-field] to help you fill in the blanks.
+\\<mh-pick-mode-map>\\[mh-to-field] to help you fill in the
+blanks.
 
-To perform the search, type \\[mh-do-search]. The selected messages
-are placed in the \"search\" sequence, which you can use later in
-forwarding, printing, or narrowing your field of view. Subsequent
-searches are appended to the \"search\" sequence. If, however, you
-wish to start with a clean slate, first delete the \"search\"
-sequence.
+To perform the search, type \\[mh-do-search]. The selected
+messages are placed in the \"search\" sequence, which you can use
+later in forwarding, printing, or narrowing your field of view.
+Subsequent searches are appended to the \"search\" sequence. If,
+however, you wish to start with a clean slate, first delete the
+\"search\" sequence.
 
 If you're searching in a folder that is already displayed in an
-MH-Folder buffer, only those messages contained in the buffer are used
-for the search. Therefore, if you want to search in all messages,
-first kill the folder's buffer with
-\\<mh-folder-mode-map>\\[kill-buffer] or scan the entire folder with
-\\[mh-rescan-folder].
+MH-Folder buffer, only those messages contained in the buffer are
+used for the search. Therefore, if you want to search in all
+messages, first kill the folder's buffer with
+\\<mh-folder-mode-map>\\[kill-buffer] or scan the entire folder
+with \\[mh-rescan-folder].
 
-If you find that you do the same thing over and over when editing the
-search template, you may wish to bind some shortcuts to keys. This can
-be done with the variable `mh-pick-mode-hook', which is called when
-\\[mh-search-folder] is run on a new pattern.
+If you find that you do the same thing over and over when editing
+the search template, you may wish to bind some shortcuts to keys.
+This can be done with the variable `mh-pick-mode-hook', which is
+called when \\[mh-search-folder] is run on a new pattern.
 
-If you have run the \\[mh-index-search] command, but change your mind
-while entering the search criteria and actually want to run a regular
-search, then you can use the \\<mh-pick-mode-map>\\[mh-pick-do-search]
-command.
+If you have run the \\[mh-index-search] command, but change your
+mind while entering the search criteria and actually want to run
+a regular search, then you can use the command
+\\<mh-pick-mode-map>\\[mh-pick-do-search] in the MH-Pick buffer.
 
 In a program, argument WINDOW-CONFIG is the current window
 configuration and is used when the search folder is dismissed."
@@ -140,7 +143,7 @@
                         'mh-previous-window-config window-config)
     (message "%s" (substitute-command-keys
                    (concat "Type \\[mh-do-search] to search messages, "
-                           "\\[mh-help] for help.")))))
+                           "\\[mh-help] for help")))))
 
 (defun mh-make-pick-template ()
   "Initialize the current buffer with a template for a pick pattern."
@@ -332,7 +335,7 @@
         ((eq (car expr) 'not)
          `("-lbrace" "-not" ,@(mh-pick-construct-regexp (cadr expr) component)
            "-rbrace"))
-        (t (error "Unknown operator '%s' seen" (car expr)))))
+        (t (error "Unknown operator %s seen" (car expr)))))
 
 ;; All implementations of pick have special options -cc, -date, -from and
 ;; -subject that allow to search for corresponding components. Any other
--- a/lisp/mh-e/mh-seq.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-seq.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-seq.el --- MH-E sequences support
 
 ;; Copyright (C) 1993, 1995,
-;;  2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -177,6 +177,7 @@
 ;;;###mh-autoload
 (defun mh-list-sequences ()
   "List all sequences in folder.
+
 The list appears in a buffer named \"*MH-E Sequences*\"."
   (interactive)
   (let ((folder mh-current-folder)
@@ -219,6 +220,7 @@
 ;;;###mh-autoload
 (defun mh-msg-is-in-seq (message)
   "Display the sequences in which the current message appears.
+
 Use a prefix argument to display the sequences in which another
 MESSAGE appears."
   (interactive "P")
@@ -282,7 +284,7 @@
                         mh-show-seq-tool-bar-map))))
              (push 'widen mh-view-ops)))
           (t
-           (error "No messages in sequence \"%s\"" (symbol-name sequence))))))
+           (error "No messages in sequence %s" (symbol-name sequence))))))
 
 ;;;###mh-autoload
 (defun mh-put-msg-in-seq (range sequence)
@@ -302,7 +304,7 @@
   (interactive (list (mh-interactive-range "Add messages from")
                      (mh-read-seq-default "Add to" nil)))
   (unless (mh-valid-seq-p sequence)
-    (error "Can't put message in invalid sequence \"%s\"" sequence))
+    (error "Can't put message in invalid sequence %s" sequence))
   (let* ((internal-seq-flag (mh-internal-seq sequence))
          (original-msgs (mh-seq-msgs (mh-find-seq sequence)))
          (folders (list mh-current-folder))
@@ -329,8 +331,10 @@
 ;;;###mh-autoload
 (defun mh-widen (&optional all-flag)
   "Remove last restriction.
-If optional prefix argument ALL-FLAG is non-nil, remove all
-limits."
+
+Each limit or sequence restriction can be undone in turn with
+this command. Give this command a prefix argument ALL-FLAG to
+remove all limits and sequence restrictions."
   (interactive "P")
   (let ((msg (mh-get-msg-num nil)))
     (when mh-folder-view-stack
@@ -416,9 +420,9 @@
 the NOT-EMPTY flag is non-nil, and supply an optional DEFAULT
 sequence. A reply of '%' defaults to the first sequence
 containing the current message."
-  (let* ((input (completing-read (format "%s %s %s" prompt "sequence:"
+  (let* ((input (completing-read (format "%s sequence%s: " prompt
                                          (if default
-                                             (format "[%s] " default)
+                                             (format " (default %s)" default)
                                            ""))
                                  (mh-seq-names mh-seq-list)
                                  nil nil nil 'mh-sequence-history))
@@ -428,7 +432,7 @@
                     (t (intern input))))
          (msgs (mh-seq-to-msgs seq)))
     (if (and (null msgs) not-empty)
-        (error "No messages in sequence \"%s\"" seq))
+        (error "No messages in sequence %s" seq))
     seq))
 
 
@@ -509,20 +513,22 @@
                     (car (mh-seq-containing-msg (mh-get-msg-num nil) t)))
         prompt (format "%s range" prompt))
   (let* ((folder (or folder mh-current-folder))
-         (default (cond ((or (eq default t) (stringp default)) default)
-                        ((symbolp default) (symbol-name default))))
          (guess (eq default t))
          (counts (and guess (mh-folder-size folder)))
          (unseen (and counts (> (cadr counts) 0)))
          (large (and counts mh-large-folder (> (car counts) mh-large-folder)))
-         (str (cond ((and guess large
-                          (setq default (format "last:%s" mh-large-folder)
-                                prompt (format "%s (folder has %s messages)"
-                                               prompt (car counts)))
-                          nil))
-                    ((and guess (not large) (setq default "all") nil))
-                    ((eq default nil) "")
-                    (t (format "[%s] " default))))
+         (default (cond ((and guess large) (format "last:%s" mh-large-folder))
+                        ((and guess (not large)) "all")
+                        ((stringp default) default)
+                        ((symbolp default) (symbol-name default))))
+         (prompt (cond ((and guess large default)
+                        (format "%s (folder has %s messages, default %s)"
+                                prompt (car counts) default))
+                       ((and guess large)
+                        (format "%s (folder has %s messages)"
+                                prompt (car counts)))
+                       (default
+                         (format "%s (default %s)" prompt default))))
          (minibuffer-local-completion-map mh-range-completion-map)
          (seq-list (if (eq folder mh-current-folder)
                        mh-seq-list
@@ -532,7 +538,7 @@
                   (mh-seq-names seq-list)))
          (input (cond ((and (not ask-flag) unseen) (symbol-name mh-unseen-seq))
                       ((and (not ask-flag) (not large)) "all")
-                      (t (completing-read (format "%s: %s" prompt str)
+                      (t (completing-read (format "%s: " prompt)
                                           'mh-range-completion-function nil nil
                                           nil 'mh-range-history default))))
          msg-list)
@@ -543,7 +549,7 @@
           ((assoc (intern input) seq-list)
            (cdr (assoc (intern input) seq-list)))
           ((setq msg-list (mh-translate-range folder input)) msg-list)
-          (t (error "No messages in range \"%s\"" input)))))
+          (t (error "No messages in range %s" input)))))
 
 ;;;###mh-autoload
 (defun mh-translate-range (folder expr)
@@ -1170,7 +1176,7 @@
                           (mh-message-id (mh-container-message kid)))
                  (let ((kid-message (mh-container-message kid)))
                    (return (mh-message-subject kid-message)))))
-             (error "This can't happen!")))))
+             (error "This can't happen")))))
 
 (defun mh-thread-rewind-pruning ()
   "Restore the thread tree to its state before pruning."
--- a/lisp/mh-e/mh-utils.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mh-e/mh-utils.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-utils.el --- MH-E code needed for both sending and reading
 
 ;; Copyright (C) 1993, 1995, 1997,
-;;  2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -1582,7 +1582,7 @@
       (cond
        ;; Check if we have `convert'
        ((eq mh-x-image-scaling-function 'ignore)
-        (message "The `convert' program is needed to display X-Image-URL")
+        (message "The \"convert\" program is needed to display X-Image-URL")
         (mh-x-image-set-download-state cache-filename 'try-again))
        ;; Scale fetched image
        ((and (funcall mh-x-image-scaling-function temp-file cache-filename)
@@ -1647,6 +1647,14 @@
 the superfluous header fields that mailers add to a message, but if
 you wish to see all of them, use the command \\[mh-header-display].
 
+Two hooks can be used to control how messages are displayed. The
+first hook, `mh-show-mode-hook', is called early on in the
+process of the message display. It is usually used to perform
+some action on the message's content. The second hook,
+`mh-show-hook', is the last thing called after messages are
+displayed. It's used to affect the behavior of MH-E in general or
+when `mh-show-mode-hook' is too early.
+
 From a program, optional argument MESSAGE can be used to display an
 alternative message. The optional argument REDISPLAY-FLAG forces the
 redisplay of the message even if the show buffer was already
@@ -1728,7 +1736,7 @@
 editable buffer. When you are done editing, save and kill the
 buffer as you would any other.
 
-From a program, edit MESSAGE instead if it is non-nil."
+From a program, edit MESSAGE; nil means edit current message."
   (interactive)
   (let* ((message (or message (mh-get-msg-num t)))
          (msg-filename (mh-msg-filename message))
@@ -2471,7 +2479,7 @@
             (new-file-flag
              (error "Folder %s does not exist" folder-name))
             ((not (file-directory-p (mh-expand-file-name folder-name)))
-             (error "\"%s\" is not a directory"
+             (error "%s is not a directory"
                     (mh-expand-file-name folder-name)))))
     folder-name))
 
@@ -2655,7 +2663,7 @@
         (set-buffer (get-buffer-create mh-log-buffer))
         (mh-truncate-log-buffer)
         (insert error-message)))
-    (error "%s failed, check %s buffer for error message"
+    (error "%s failed, check buffer %s for error message"
            command mh-log-buffer)))
 
 (defun mh-list-to-string (l)
@@ -2676,7 +2684,7 @@
             ((listp (car l))
              (setq new-list (nconc (mh-list-to-string-1 (car l))
                                    new-list)))
-            (t (error "Bad element in mh-list-to-string: %s" (car l))))
+            (t (error "Bad element in `mh-list-to-string': %s" (car l))))
       (setq l (cdr l)))
     new-list))
 
--- a/lisp/mouse.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/mouse.el	Fri Jan 06 16:13:05 2006 +0000
@@ -765,7 +765,7 @@
 	  (display-buffer (current-buffer)))
       ;; Give temporary modes such as isearch a chance to turn off.
       (run-hooks 'mouse-leave-buffer-hook)
-      (mouse-drag-region-1 start-event))))
+      (mouse-drag-track start-event t))))
 
 
 (defun mouse-on-link-p (pos)
@@ -865,7 +865,12 @@
   (let ((range (mouse-start-end start end mode)))
     (move-overlay ol (car range) (nth 1 range))))
 
-(defun mouse-drag-region-1 (start-event)
+(defun mouse-drag-track (start-event  &optional 
+				      do-mouse-drag-region-post-process)
+    "Track mouse drags by highlighting area between point and cursor.
+The region will be defined with mark and point, and the overlay
+will be deleted after return.  DO-MOUSE-DRAG-REGION-POST-PROCESS
+should only be used by mouse-drag-region."
   (mouse-minibuffer-check start-event)
   (setq mouse-selection-click-count-buffer (current-buffer))
   (let* ((original-window (selected-window))
@@ -949,12 +954,15 @@
 		 (integer-or-marker-p end-point))
         (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count))
 
+      ;; Handle the terminating event
       (if (consp event)
 	  (let* ((fun (key-binding (vector (car event))))
 		 (do-multi-click   (and (> (event-click-count event) 0)
 					(functionp fun)
-					(not (memq fun '(mouse-set-point mouse-set-region))))))
-            ;; Run the binding of the terminating up-event, if possible.
+					(not (memq fun 
+						   '(mouse-set-point 
+						     mouse-set-region))))))
+	    ;; Run the binding of the terminating up-event, if possible.
 	    (if (and (not (= (overlay-start mouse-drag-overlay)
 			     (overlay-end mouse-drag-overlay)))
 		     (not do-multi-click))
@@ -965,31 +973,34 @@
 		       ;; The end that comes from where we ended the drag.
 		       ;; Point goes here.
 		       (region-termination
-                        (if (and stop-point (< stop-point start-point))
-                            (overlay-start mouse-drag-overlay)
-                          (overlay-end mouse-drag-overlay)))
-                       ;; The end that comes from where we started the drag.
-                       ;; Mark goes there.
-                       (region-commencement
-                        (- (+ (overlay-end mouse-drag-overlay)
-                              (overlay-start mouse-drag-overlay))
-                           region-termination))
-                       last-command this-command)
-                  (push-mark region-commencement t t)
-                  (goto-char region-termination)
-                  ;; Don't let copy-region-as-kill set deactivate-mark.
-                  (when mouse-drag-copy-region
-                    (let (deactivate-mark)
-                      (copy-region-as-kill (point) (mark t))))
-                  (let ((buffer (current-buffer)))
-                    (mouse-show-mark)
-                    ;; mouse-show-mark can call read-event,
-                    ;; and that means the Emacs server could switch buffers
-                    ;; under us.  If that happened,
-                    ;; avoid trying to use the region.
-                    (and (mark t) mark-active
-                         (eq buffer (current-buffer))
-                         (mouse-set-region-1))))
+			(if (and stop-point (< stop-point start-point))
+			    (overlay-start mouse-drag-overlay)
+			  (overlay-end mouse-drag-overlay)))
+		       ;; The end that comes from where we started the drag.
+		       ;; Mark goes there.
+		       (region-commencement
+			(- (+ (overlay-end mouse-drag-overlay)
+			      (overlay-start mouse-drag-overlay))
+			   region-termination))
+		       last-command this-command)
+		  (push-mark region-commencement t t)
+		  (goto-char region-termination)
+		  (if (not do-mouse-drag-region-post-process)
+		      ;; Skip all post-event handling, return immediately.
+		      (delete-overlay mouse-drag-overlay)
+		    ;; Don't let copy-region-as-kill set deactivate-mark.
+		    (when mouse-drag-copy-region
+		      (let (deactivate-mark)
+			(copy-region-as-kill (point) (mark t))))
+		    (let ((buffer (current-buffer)))
+		      (mouse-show-mark)
+		      ;; mouse-show-mark can call read-event,
+		      ;; and that means the Emacs server could switch buffers
+		      ;; under us.  If that happened,
+		      ;; avoid trying to use the region.
+		      (and (mark t) mark-active
+			   (eq buffer (current-buffer))
+			   (mouse-set-region-1)))))
               ;; Run the binding of the terminating up-event.
 	      ;; If a multiple click is not bound to mouse-set-point,
 	      ;; cancel the effects of mouse-move-drag-overlay to
@@ -997,18 +1008,18 @@
 	      (if do-multi-click (goto-char start-point))
               (delete-overlay mouse-drag-overlay)
               (when (and (functionp fun)
-                         (= start-hscroll (window-hscroll start-window))
-                         ;; Don't run the up-event handler if the
-                         ;; window start changed in a redisplay after
-                         ;; the mouse-set-point for the down-mouse
-                         ;; event at the beginning of this function.
-                         ;; When the window start has changed, the
-                         ;; up-mouse event will contain a different
-                         ;; position due to the new window contents,
-                         ;; and point is set again.
-                         (or end-point
-                             (= (window-start start-window)
-                                start-window-start)))
+	      (= start-hscroll (window-hscroll start-window))
+	      ;; Don't run the up-event handler if the
+	      ;; window start changed in a redisplay after
+	      ;; the mouse-set-point for the down-mouse
+	      ;; event at the beginning of this function.
+	      ;; When the window start has changed, the
+	      ;; up-mouse event will contain a different
+	      ;; position due to the new window contents,
+	      ;; and point is set again.
+	      (or end-point
+		  (= (window-start start-window)
+		     start-window-start)))
                 (when (and on-link
 			   (or (not end-point) (= end-point start-point))
 			   (consp event)
--- a/lisp/progmodes/flymake.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/progmodes/flymake.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 ;;; flymake.el -- a universal on-the-fly syntax checker
 
-;; Copyright (C) 2003, 2004, 2005  Free Software Foundation
+;; Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation
 
 ;; Author:  Pavel Kobiakov <pk_at_work@yahoo.com>
 ;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com>
@@ -32,16 +32,33 @@
 
 ;;; Code:
 
-;;;; [[ Silence the byte-compiler
+(defvar flymake-is-running nil
+  "If t, flymake syntax check process is running for the current buffer.")
+(make-variable-buffer-local 'flymake-is-running)
+
+(defvar flymake-timer nil
+  "Timer for starting syntax check.")
+(make-variable-buffer-local 'flymake-timer)
+
+(defvar flymake-last-change-time nil
+  "Time of last buffer change.")
+(make-variable-buffer-local 'flymake-last-change-time)
 
-(defvar flymake-check-start-time)
-(defvar flymake-check-was-interrupted)
-(defvar flymake-err-info)
-(defvar flymake-is-running)
-(defvar flymake-last-change-time)
-(defvar flymake-new-err-info)
+(defvar flymake-check-start-time nil
+  "Time at which syntax check was started.")
+(make-variable-buffer-local 'flymake-check-start-time)
+
+(defvar flymake-check-was-interrupted nil
+  "Non-nil if syntax check was killed by `flymake-compile'.")
+(make-variable-buffer-local 'flymake-check-was-interrupted)
 
-;;;; ]]
+(defvar flymake-err-info nil
+  "Sorted list of line numbers and lists of err info in the form (file, err-text).")
+(make-variable-buffer-local 'flymake-err-info)
+
+(defvar flymake-new-err-info nil
+  "Same as `flymake-err-info', effective when a syntax check is in progress.")
+(make-variable-buffer-local 'flymake-new-err-info)
 
 ;;;; [[ Xemacs overlay compatibility
 (if (featurep 'xemacs) (progn
@@ -69,25 +86,30 @@
 	  (multiple-value-bind (s0 s1 s2) (current-time)
 	    (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))))
 
-(defsubst flymake-replace-regexp-in-string (regexp rep str)
-  (if (fboundp 'replace-in-string)
-      (replace-in-string str regexp rep)
-    (replace-regexp-in-string regexp rep str)))
+(defalias 'flymake-replace-regexp-in-string
+  (if (eval-when-compile (fboundp 'replace-regexp-in-string))
+      'replace-regexp-in-string
+    (lambda (regexp rep str)
+      (replace-in-string str regexp rep))))
 
-(defun flymake-split-string (str pattern)
-  "Split STR into a list of substrings bounded by PATTERN.
+(defalias 'flymake-split-string
+  (if (condition-case nil (equal (split-string " bc " " " t) '("bc"))
+        (error nil))
+      (lambda (str pattern) (split-string str pattern t))
+    (lambda (str pattern)
+      "Split STR into a list of substrings bounded by PATTERN.
 Zero-length substrings at the beginning and end of the list are omitted."
-  (let* ((splitted (split-string str pattern)))
-    (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0))))
-	(setq splitted (cdr splitted)))
-    (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted))))))
-	(setq splitted (reverse (cdr (reverse splitted)))))
-    splitted))
+      (let ((split (split-string str pattern)))
+        (if (and (> (length split) 0) (= 0 (length (elt split 0))))
+            (setq split (cdr split)))
+        (if (and (> (length split) 0) (= 0 (length (elt split (1- (length split))))))
+            (setq split (nreverse (cdr (nreverse split)))))
+        split))))
 
-(defsubst flymake-get-temp-dir ()
+(defalias 'flymake-get-temp-dir
   (if (fboundp 'temp-directory)
-      (temp-directory)
-    temporary-file-directory))
+      'temp-directory
+    (lambda () temporary-file-directory)))
 
 (defalias 'flymake-line-beginning-position
   (if (fboundp 'line-beginning-position)
@@ -99,20 +121,26 @@
       'line-end-position
     (lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
 
-(defun flymake-popup-menu (pos menu-data)
-  "Pop up the flymake menu at position POS, using the data MENU-DATA.
+
+(defun flymake-popup-menu (menu-data)
+  "Pop up the flymake menu at point, using the data MENU-DATA.
 POS is a list of the form ((X Y) WINDOW), where X and Y are
 pixels positions from the top left corner of WINDOW's frame.
 MENU-DATA is a list of error and warning messages returned by
 `flymake-make-err-menu-data'."
   (if (featurep 'xemacs)
-      (let* ((x-pos       (nth 0 (nth 0 pos)))
-	     (y-pos       (nth 1 (nth 0 pos)))
+      (let* ((pos         (flymake-get-point-pixel-pos))
+             (x-pos       (nth 0 pos))
+	     (y-pos       (nth 1 pos))
 	     (fake-event-props  '(button 1 x 1 y 1)))
 	(setq fake-event-props (plist-put fake-event-props 'x x-pos))
 	(setq fake-event-props (plist-put fake-event-props 'y y-pos))
-	(popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props)))
-    (x-popup-menu pos (flymake-make-emacs-menu menu-data))))
+	(popup-menu (flymake-make-xemacs-menu menu-data)
+                    (make-event 'button-press fake-event-props)))
+    (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
+                      (posn-at-point)
+                    (list (flymake-get-point-pixel-pos) (selected-window)))
+                  (flymake-make-emacs-menu menu-data))))
 
 (defun flymake-make-emacs-menu (menu-data)
   "Return a menu specifier using MENU-DATA.
@@ -121,10 +149,9 @@
 See `x-popup-menu' for the menu specifier format."
   (let* ((menu-title     (nth 0 menu-data))
 	 (menu-items     (nth 1 menu-data))
-	 (menu-commands  nil))
-    (setq menu-commands (mapcar (lambda (foo)
-				  (cons (nth 0 foo) (nth 1 foo)))
-				menu-items))
+	 (menu-commands  (mapcar (lambda (foo)
+                                   (cons (nth 0 foo) (nth 1 foo)))
+                                 menu-items)))
     (list menu-title (cons "" menu-commands))))
 
 (if (featurep 'xemacs) (progn
@@ -141,20 +168,9 @@
 				menu-items))
     (cons menu-title menu-commands)))
 
-(defun flymake-xemacs-window-edges (&optional window)
-  (let ((edges  (window-pixel-edges window))
-	tmp)
-    (setq tmp edges)
-    (setcar tmp (/ (car tmp) (face-width 'default)))
-    (setq tmp (cdr tmp))
-    (setcar tmp (/ (car tmp) (face-height 'default)))
-    (setq tmp (cdr tmp))
-    (setcar tmp (/ (car tmp) (face-width 'default)))
-    (setq tmp (cdr tmp))
-    (setcar tmp (/ (car tmp) (face-height 'default)))
-    edges))
+)) ;; xemacs
 
-)) ;; xemacs
+(unless (eval-when-compile (fboundp 'posn-at-point))
 
 (defun flymake-current-row ()
   "Return current row number in current frame."
@@ -167,6 +183,24 @@
       (selected-frame)
     (selected-window)))
 
+(defun flymake-get-point-pixel-pos ()
+  "Return point position in pixels: (x, y)."
+  (let ((mouse-pos  (mouse-position))
+	(pixel-pos  nil)
+	(ret        nil))
+    (if (car (cdr mouse-pos))
+	(progn
+	  (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
+	  (setq pixel-pos (mouse-pixel-position))
+	  (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
+	  (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
+      (progn
+	(setq ret '(0 0))))
+    (flymake-log 3 "mouse pos is %s" ret)
+    ret))
+
+) ;; End of (unless (fboundp 'posn-at-point)
+
 ;;;; ]]
 
 (defcustom flymake-log-level -1
@@ -187,7 +221,7 @@
 	;;(with-temp-buffer
 	;;    (insert msg)
 	;;   (insert "\n")
-	;;   (flymake-save-buffer-in-file (current-buffer) "d:/flymake.log" t)  ; make log file name customizable
+	;;   (flymake-save-buffer-in-file "d:/flymake.log" t)  ; make log file name customizable
 	;;)
 	)))
 
@@ -203,59 +237,34 @@
     (setcar (nthcdr pos tmp) val)
     tmp))
 
-(defvar flymake-pid-to-names (flymake-makehash)
-  "Hash table mapping PIDs to source buffer names and output files.")
-
-(defun flymake-reg-names (pid source-buffer-name)
-  "Associate PID with SOURCE-BUFFER-NAME in `flymake-pid-to-names'."
-  (unless (stringp source-buffer-name)
-    (error "Invalid buffer name"))
-  (puthash pid (list source-buffer-name) flymake-pid-to-names))
-
-(defun flymake-get-source-buffer-name (pid)
-  "Return buffer name associated with PID in `flymake-pid-to-names'."
-  (nth 0 (gethash pid flymake-pid-to-names)))
-
-(defun flymake-unreg-names (pid)
-  "Remove the entry associated with PID from `flymake-pid-to-names'."
-  (remhash pid flymake-pid-to-names))
-
-(defvar flymake-buffer-data (flymake-makehash)
-  "Data specific to syntax check tool, in name-value pairs.")
-
-(make-variable-buffer-local 'flymake-buffer-data)
-
-(defun flymake-get-buffer-value (buffer name)
-  (gethash name (with-current-buffer buffer flymake-buffer-data)))
-
-(defun flymake-set-buffer-value (buffer name value)
-  (puthash name value (with-current-buffer buffer flymake-buffer-data)))
+(defvar flymake-processes nil
+  "List of currently active flymake processes.")
 
 (defvar flymake-output-residual nil)
 
 (make-variable-buffer-local 'flymake-output-residual)
 
 (defcustom flymake-allowed-file-name-masks
-  '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.xml$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.html?$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.cs$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.pl$" flymake-perl-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.h$" flymake-master-make-header-init flymake-master-cleanup flymake-get-real-file-name)
-    (".+\\.java$" flymake-simple-make-java-init flymake-simple-java-cleanup flymake-get-real-file-name)
-    (".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name)
-    (".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name)
-    (".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
-    ;; (".+\\.cpp$" 1)
-    ;; (".+\\.java$" 3)
-    ;; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$")
+  '(("\\.c\\'" flymake-simple-make-init)
+    ("\\.cpp\\'" flymake-simple-make-init)
+    ("\\.xml\\'" flymake-xml-init)
+    ("\\.html?\\'" flymake-xml-init)
+    ("\\.cs\\'" flymake-simple-make-init)
+    ("\\.pl\\'" flymake-perl-init)
+    ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
+    ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
+    ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
+    ("\\.tex\\'" flymake-simple-tex-init)
+    ("\\.idl\\'" flymake-simple-make-init)
+    ;; ("\\.cpp\\'" 1)
+    ;; ("\\.java\\'" 3)
+    ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
     ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
-    ;; (".+\\.idl$" 1)
-    ;; (".+\\.odl$" 1)
-    ;; (".+[0-9]+\\.tex$" 2 (".+\\.tex$")
+    ;; ("\\.idl\\'" 1)
+    ;; ("\\.odl\\'" 1)
+    ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
     ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
-    ;; (".+\\.tex$" 1)
+    ;; ("\\.tex\\'" 1)
     )
   "*Files syntax checking is allowed for."
   :group 'flymake
@@ -288,10 +297,12 @@
 
 (defun flymake-get-cleanup-function (file-name)
   "Return cleanup function to be used for the file."
-  (nth 1 (flymake-get-file-name-mode-and-masks file-name)))
+  (or (nth 1 (flymake-get-file-name-mode-and-masks file-name))
+      'flymake-simple-cleanup))
 
 (defun flymake-get-real-file-name-function (file-name)
-  (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 'flymake-get-real-file-name))
+  (or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
+      'flymake-get-real-file-name))
 
 (defcustom flymake-buildfile-dirs '("." ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." "../../../../../../.." "../../../../../../../.." "../../../../../../../../.." "../../../../../../../../../.." "../../../../../../../../../../..")
   "Dirs to look for buildfile."
@@ -491,7 +502,7 @@
 					    (file-name-nondirectory patched-source-file-name))))
 		(forward-line 1)))
 	    (when found
-	      (flymake-save-buffer-in-file (current-buffer) patched-master-file-name)))
+	      (flymake-save-buffer-in-file patched-master-file-name)))
 	;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer))
 	(kill-buffer master-file-temp-buffer)))
     ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
@@ -581,15 +592,12 @@
 		     (file-name-nondirectory source-file-name))
 	nil))))
 
-(defun flymake-save-buffer-in-file (buffer file-name)
-  (or buffer
-      (error "Invalid buffer"))
-  (with-current-buffer buffer
-    (save-restriction
-      (widen)
-      (make-directory (file-name-directory file-name) 1)
-      (write-region (point-min) (point-max) file-name nil 566)))
-  (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name))
+(defun flymake-save-buffer-in-file (file-name)
+  (save-restriction
+    (widen)
+    (make-directory (file-name-directory file-name) 1)
+    (write-region (point-min) (point-max) file-name nil 566))
+  (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
 
 (defun flymake-save-string-to-file (file-name data)
   "Save string DATA to file FILE-NAME."
@@ -604,44 +612,46 @@
 (defun flymake-process-filter (process output)
   "Parse OUTPUT and highlight error lines.
 It's flymake process filter."
-  (let* ((pid               (process-id process))
-	 (source-buffer     (get-buffer (flymake-get-source-buffer-name pid))))
+  (let ((source-buffer (process-buffer process)))
 
-    (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid)
+    (flymake-log 3 "received %d byte(s) of output from process %d"
+                 (length output) (process-id process))
     (when source-buffer
       (with-current-buffer source-buffer
         (flymake-parse-output-and-residual output)))))
 
 (defun flymake-process-sentinel (process event)
   "Sentinel for syntax check buffers."
-  (if (memq (process-status process) '(signal exit))
-      (let*((exit-status       (process-exit-status process))
-	    (command           (process-command process))
-	    (pid               (process-id process))
-	    (source-buffer     (get-buffer (flymake-get-source-buffer-name pid)))
-	    (cleanup-f         (flymake-get-cleanup-function (buffer-file-name source-buffer))))
+  (when (memq (process-status process) '(signal exit))
+    (let* ((exit-status       (process-exit-status process))
+           (command           (process-command process))
+           (source-buffer     (process-buffer process))
+           (cleanup-f         (flymake-get-cleanup-function (buffer-file-name source-buffer))))
 
-	(flymake-log 2 "process %d exited with code %d" pid exit-status)
-	(condition-case err
-	    (progn
-	      (flymake-log 3 "cleaning up using %s" cleanup-f)
-	      (funcall cleanup-f source-buffer)
+      (flymake-log 2 "process %d exited with code %d"
+                   (process-id process) exit-status)
+      (condition-case err
+          (progn
+            (flymake-log 3 "cleaning up using %s" cleanup-f)
+            (when (buffer-live-p source-buffer)
+              (with-current-buffer source-buffer
+                (funcall cleanup-f)))
 
-	      (flymake-unreg-names pid)
-	      (delete-process process)
+            (delete-process process)
+            (setq flymake-processes (delq process flymake-processes))
 
-	      (when source-buffer
-		(with-current-buffer source-buffer
+            (when (buffer-live-p source-buffer)
+              (with-current-buffer source-buffer
 
-		  (flymake-parse-residual)
-		  (flymake-post-syntax-check exit-status command)
-		  (setq flymake-is-running nil))))
-	  (error
-	   (let ((err-str (format "Error in process sentinel for buffer %s: %s"
-				  source-buffer (error-message-string err))))
-	     (flymake-log 0 err-str)
-	     (with-current-buffer source-buffer
-	       (setq flymake-is-running nil))))))))
+                (flymake-parse-residual)
+                (flymake-post-syntax-check exit-status command)
+                (setq flymake-is-running nil))))
+        (error
+         (let ((err-str (format "Error in process sentinel for buffer %s: %s"
+                                source-buffer (error-message-string err))))
+           (flymake-log 0 err-str)
+           (with-current-buffer source-buffer
+             (setq flymake-is-running nil))))))))
 
 (defun flymake-post-syntax-check (exit-status command)
   (setq flymake-err-info flymake-new-err-info)
@@ -689,11 +699,6 @@
            (list flymake-output-residual)))
     (setq flymake-output-residual nil)))
 
-(defvar flymake-err-info nil
-  "Sorted list of line numbers and lists of err info in the form (file, err-text).")
-
-(make-variable-buffer-local 'flymake-err-info)
-
 (defun flymake-er-make-er (line-no line-err-info-list)
   (list line-no line-err-info-list))
 
@@ -703,11 +708,6 @@
 (defun flymake-er-get-line-err-info-list (err-info)
   (nth 1 err-info))
 
-(defvar flymake-new-err-info nil
-  "Same as `flymake-err-info', effective when a syntax check is in progress.")
-
-(make-variable-buffer-local 'flymake-new-err-info)
-
 ;; getters/setters for line-err-info: (file, line, type, text).
 (defun flymake-ler-make-ler (file line type text &optional full-file)
   (list file line type text full-file))
@@ -897,7 +897,8 @@
     (while (< idx count)
       (setq line-err-info (flymake-parse-line (nth idx lines)))
       (when line-err-info
-	(setq real-file-name (funcall get-real-file-name-f (current-buffer) (flymake-ler-get-file line-err-info)))
+	(setq real-file-name (funcall get-real-file-name-f
+                                      (flymake-ler-get-file line-err-info)))
 	(setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
 
 	(if (flymake-same-files real-file-name source-file-name)
@@ -1131,12 +1132,12 @@
 ;;   "Remove any formatting made by flymake."
 ;;   )
 
-(defun flymake-get-program-dir (buffer)
-  "Get dir to start program in."
-  (unless (bufferp buffer)
-    (error "Invalid buffer"))
-  (with-current-buffer buffer
-    default-directory))
+;; (defun flymake-get-program-dir (buffer)
+;;   "Get dir to start program in."
+;;   (unless (bufferp buffer)
+;;     (error "Invalid buffer"))
+;;   (with-current-buffer buffer
+;;     default-directory))
 
 (defun flymake-safe-delete-file (file-name)
   (when (and file-name (file-exists-p file-name))
@@ -1168,19 +1169,18 @@
       (flymake-clear-project-include-dirs-cache)
 
       (setq flymake-check-was-interrupted nil)
-      (setq flymake-buffer-data (flymake-makehash 'equal))
 
       (let* ((source-file-name  buffer-file-name)
              (init-f (flymake-get-init-function source-file-name))
              (cleanup-f (flymake-get-cleanup-function source-file-name))
-             (cmd-and-args (funcall init-f (current-buffer)))
+             (cmd-and-args (funcall init-f))
              (cmd          (nth 0 cmd-and-args))
              (args         (nth 1 cmd-and-args))
              (dir          (nth 2 cmd-and-args)))
         (if (not cmd-and-args)
             (progn
               (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
-              (funcall cleanup-f (current-buffer)))
+              (funcall cleanup-f))
           (progn
             (setq flymake-last-change-time nil)
             (flymake-start-syntax-check-process cmd args dir)))))))
@@ -1193,11 +1193,10 @@
 	  (when dir
 	    (let ((default-directory dir))
 	      (flymake-log 3 "starting process on dir %s" default-directory)))
-	  (setq process (get-process (apply 'start-process "flymake-proc" nil cmd args)))
+	  (setq process (apply 'start-process "flymake-proc" (current-buffer) cmd args))
 	  (set-process-sentinel process 'flymake-process-sentinel)
 	  (set-process-filter process 'flymake-process-filter)
-
-	  (flymake-reg-names (process-id process) (buffer-name))
+          (push process flymake-processes)
 
           (setq flymake-is-running t)
           (setq flymake-last-change-time nil)
@@ -1205,7 +1204,8 @@
 
 	  (flymake-report-status nil "*")
 	  (flymake-log 2 "started process %d, command=%s, dir=%s"
-		       (process-id process) (process-command process) default-directory)
+		       (process-id process) (process-command process)
+                       default-directory)
 	  process)
       (error
        (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
@@ -1213,23 +1213,23 @@
 	      (source-file-name buffer-file-name)
 	      (cleanup-f        (flymake-get-cleanup-function source-file-name)))
 	 (flymake-log 0 err-str)
-	 (funcall cleanup-f (current-buffer))
+	 (funcall cleanup-f)
 	 (flymake-report-fatal-status "PROCERR" err-str))))))
 
-(defun flymake-kill-process (pid &optional rest)
-  "Kill process PID."
-  (signal-process pid 9)
-  (let* ((buffer-name (flymake-get-source-buffer-name pid)))
-    (when (and buffer-name (get-buffer buffer-name))
-      (with-current-buffer (get-buffer buffer-name)
+(defun flymake-kill-process (proc)
+  "Kill process PROC."
+  (kill-process proc)
+  (let* ((buf (process-buffer proc)))
+    (when (buffer-live-p buf)
+      (with-current-buffer buf
 	(setq flymake-check-was-interrupted t))))
-  (flymake-log 1 "killed process %d" pid))
+  (flymake-log 1 "killed process %d" (process-id proc)))
 
 (defun flymake-stop-all-syntax-checks ()
   "Kill all syntax check processes."
   (interactive)
-  (let ((pids  (copy-hash-table flymake-pid-to-names)))
-    (maphash 'flymake-kill-process pids)))
+  (while flymake-processes
+    (flymake-kill-process (pop flymake-processes))))
 
 (defun flymake-compilation-is-running ()
   (and (boundp 'compilation-in-progress)
@@ -1241,31 +1241,6 @@
   (flymake-stop-all-syntax-checks)
   (call-interactively 'compile))
 
-(defvar flymake-is-running nil
-  "If t, flymake syntax check process is running for the current buffer.")
-
-(make-variable-buffer-local 'flymake-is-running)
-
-(defvar flymake-timer nil
-  "Timer for starting syntax check.")
-
-(make-variable-buffer-local 'flymake-timer)
-
-(defvar flymake-last-change-time nil
-  "Time of last buffer change.")
-
-(make-variable-buffer-local 'flymake-last-change-time)
-
-(defvar flymake-check-start-time nil
-  "Time at which syntax check was started.")
-
-(make-variable-buffer-local 'flymake-check-start-time)
-
-(defvar flymake-check-was-interrupted nil
-  "Non-nil if syntax check was killed by `flymake-compile'.")
-
-(make-variable-buffer-local 'flymake-check-was-interrupted)
-
 (defcustom flymake-no-changes-timeout 0.5
   "Time to wait after last change before starting compilation."
   :group 'flymake
@@ -1294,33 +1269,16 @@
   "Return number of lines in buffer BUFFER."
   (count-lines (point-min) (point-max)))
 
-(defun flymake-get-point-pixel-pos ()
-  "Return point position in pixels: (x, y)."
-  (let ((mouse-pos  (mouse-position))
-	(pixel-pos  nil)
-	(ret        nil))
-    (if (car (cdr mouse-pos))
-	(progn
-	  (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
-	  (setq pixel-pos (mouse-pixel-position))
-	  (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
-	  (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
-      (progn
-	(setq ret '(0 0))))
-    (flymake-log 3 "mouse pos is %s" ret)
-    ret))
-
 (defun flymake-display-err-menu-for-current-line ()
   "Display a menu with errors/warnings for current line if it has errors and/or warnings."
   (interactive)
   (let* ((line-no             (flymake-current-line-no))
 	 (line-err-info-list  (nth 0 (flymake-find-err-info flymake-err-info line-no)))
 	 (menu-data           (flymake-make-err-menu-data line-no line-err-info-list))
-	 (choice              nil)
-	 (menu-pos            (list (flymake-get-point-pixel-pos) (selected-window))))
+	 (choice              nil))
     (if menu-data
 	(progn
-	  (setq choice (flymake-popup-menu menu-pos menu-data))
+	  (setq choice (flymake-popup-menu menu-data))
 	  (flymake-log 3 "choice=%s" choice)
 	  (when choice
 	    (eval choice)))
@@ -1579,20 +1537,14 @@
     (error "Invalid file-name"))
 
   (let* ((dir       (file-name-directory file-name))
+         ;; Not sure what this slash-pos is all about, but I guess it's just
+         ;; trying to remove the leading / of absolute file names.
 	 (slash-pos (string-match "/" dir))
-	 (temp-dir  (concat (file-name-as-directory (flymake-get-temp-dir)) (substring dir (1+ slash-pos)))))
-
-    (file-truename (concat (file-name-as-directory temp-dir)
-			   (file-name-nondirectory file-name)))))
+	 (temp-dir  (expand-file-name (substring dir (1+ slash-pos))
+                                      (flymake-get-temp-dir))))
 
-(defun flymake-strrchr (str ch)
-  (let* ((count  (length str))
-	 (pos    nil))
-    (while (and (not pos) (> count 0))
-      (if (= ch (elt str (1- count)))
-	  (setq pos (1- count)))
-      (setq count (1- count)))
-    pos))
+    (file-truename (expand-file-name (file-name-nondirectory file-name)
+                                     temp-dir))))
 
 (defun flymake-delete-temp-directory (dir-name)
   "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error."
@@ -1601,45 +1553,55 @@
 	 (slash-pos   nil))
 
     (while (> (length suffix) 0)
+      (setq suffix (directory-file-name suffix))
       ;;+(flymake-log 0 "suffix=%s" suffix)
-      (flymake-safe-delete-directory (file-truename (concat (file-name-as-directory temp-dir) suffix)))
-      (setq slash-pos (flymake-strrchr suffix (string-to-char "/")))
-      (if slash-pos
-	  (setq suffix (substring suffix 0 slash-pos))
-	(setq suffix "")))))
+      (flymake-safe-delete-directory
+       (file-truename (expand-file-name suffix temp-dir)))
+      (setq suffix (file-name-directory suffix)))))
+
+(defvar flymake-temp-source-file-name nil)
+(make-variable-buffer-local 'flymake-temp-source-file-name)
+
+(defvar flymake-master-file-name nil)
+(make-variable-buffer-local 'flymake-master-file-name)
 
-(defun flymake-init-create-temp-buffer-copy (buffer create-temp-f)
+(defvar flymake-temp-master-file-name nil)
+(make-variable-buffer-local 'flymake-temp-master-file-name)
+
+(defvar flymake-base-dir nil)
+(make-variable-buffer-local 'flymake-base-dir)
+
+(defun flymake-init-create-temp-buffer-copy (create-temp-f)
   "Make a temporary copy of the current buffer, save its name in buffer data and return the name."
-  (let*  ((source-file-name       (buffer-file-name buffer))
+  (let*  ((source-file-name       buffer-file-name)
 	  (temp-source-file-name  (funcall create-temp-f source-file-name "flymake")))
 
-    (flymake-save-buffer-in-file buffer temp-source-file-name)
-    (flymake-set-buffer-value buffer "temp-source-file-name" temp-source-file-name)
+    (flymake-save-buffer-in-file temp-source-file-name)
+    (setq flymake-temp-source-file-name temp-source-file-name)
     temp-source-file-name))
 
-(defun flymake-simple-cleanup (buffer)
+(defun flymake-simple-cleanup ()
   "Do cleanup after `flymake-init-create-temp-buffer-copy'.
 Delete temp file."
-  (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")))
-    (flymake-safe-delete-file temp-source-file-name)
-    (with-current-buffer buffer
-      (setq flymake-last-change-time nil))))
+  (flymake-safe-delete-file flymake-temp-source-file-name)
+  (setq flymake-last-change-time nil))
 
-(defun flymake-get-real-file-name (buffer file-name-from-err-msg)
+(defun flymake-get-real-file-name (file-name-from-err-msg)
   "Translate file name from error message to \"real\" file name.
 Return full-name.  Names are real, not patched."
-  (let* ((real-name              nil)
-	 (source-file-name       (buffer-file-name buffer))
-	 (master-file-name       (flymake-get-buffer-value buffer "master-file-name"))
-	 (temp-source-file-name  (flymake-get-buffer-value buffer "temp-source-file-name"))
-	 (temp-master-file-name  (flymake-get-buffer-value buffer "temp-master-file-name"))
-	 (base-dirs              (list (flymake-get-buffer-value buffer "base-dir")
-				       (file-name-directory source-file-name)
-				       (if master-file-name (file-name-directory master-file-name) nil)))
-	 (files                  (list (list source-file-name       source-file-name)
-				       (list temp-source-file-name  source-file-name)
-				       (list master-file-name       master-file-name)
-				       (list temp-master-file-name  master-file-name))))
+  (let* ((real-name		nil)
+	 (source-file-name	buffer-file-name)
+	 (master-file-name	flymake-master-file-name)
+	 (temp-source-file-name	flymake-temp-source-file-name)
+	 (temp-master-file-name	flymake-temp-master-file-name)
+	 (base-dirs
+          (list flymake-base-dir
+                (file-name-directory source-file-name)
+                (if master-file-name (file-name-directory master-file-name))))
+	 (files (list (list source-file-name       source-file-name)
+                      (list temp-source-file-name  source-file-name)
+                      (list master-file-name       master-file-name)
+                      (list temp-master-file-name  master-file-name))))
 
     (when (equal 0 (length file-name-from-err-msg))
       (setq file-name-from-err-msg source-file-name))
@@ -1687,27 +1649,23 @@
 	    (setq base-dirs-count (1- base-dirs-count))))))
     real-name))
 
-(defun flymake-init-find-buildfile-dir (buffer source-file-name buildfile-name)
+(defun flymake-init-find-buildfile-dir (source-file-name buildfile-name)
   "Find buildfile, store its dir in buffer data and return its dir, if found."
-  (let* ((buildfile-dir  (flymake-find-buildfile buildfile-name
-						 (file-name-directory source-file-name)
-						 flymake-buildfile-dirs)))
-    (if (not buildfile-dir)
-	(progn
-	  (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
-          (with-current-buffer buffer
-            (flymake-report-fatal-status "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name)))
-	  )
-      (progn
-	(flymake-set-buffer-value buffer "base-dir" buildfile-dir)))
-    buildfile-dir))
+  (let* ((buildfile-dir
+          (flymake-find-buildfile buildfile-name
+                                  (file-name-directory source-file-name)
+                                  flymake-buildfile-dirs)))
+    (if buildfile-dir
+        (setq flymake-base-dir buildfile-dir)
+      (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
+      (flymake-report-fatal-status
+       "NOMK" (format "No buildfile (%s) found for %s"
+                      buildfile-name source-file-name)))))
 
-(defun flymake-init-create-temp-source-and-master-buffer-copy (buffer get-incl-dirs-f create-temp-f master-file-masks include-regexp-list)
+(defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp-list)
   "Find master file (or buffer), create it's copy along with a copy of the source file."
-  (let* ((source-file-name       (buffer-file-name buffer))
-	 (temp-source-file-name  (flymake-init-create-temp-buffer-copy buffer create-temp-f))
-	 (master-file-name       nil)
-	 (temp-master-file-name  nil)
+  (let* ((source-file-name       buffer-file-name)
+	 (temp-source-file-name  (flymake-init-create-temp-buffer-copy create-temp-f))
 	 (master-and-temp-master (flymake-create-master-file
 				  source-file-name temp-source-file-name
 				  get-incl-dirs-f create-temp-f
@@ -1716,21 +1674,14 @@
     (if (not master-and-temp-master)
 	(progn
 	  (flymake-log 1 "cannot find master file for %s" source-file-name)
-          (when (bufferp buffer)
-            (with-current-buffer buffer
-              (flymake-report-status "!" "")))	; NOMASTER
-	  )
-      (progn
-	(setq master-file-name       (nth 0 master-and-temp-master))
-	(setq temp-master-file-name  (nth 1 master-and-temp-master))
-	(flymake-set-buffer-value buffer "master-file-name"      master-file-name)
-	(flymake-set-buffer-value buffer "temp-master-file-name" temp-master-file-name)
-	))
-    temp-master-file-name))
+          (flymake-report-status "!" "")	; NOMASTER
+          nil)
+      (setq flymake-master-file-name (nth 0 master-and-temp-master))
+      (setq flymake-temp-master-file-name (nth 1 master-and-temp-master)))))
 
-(defun flymake-master-cleanup (buffer)
-  (flymake-simple-cleanup buffer)
-  (flymake-safe-delete-file (flymake-get-buffer-value buffer "temp-master-file-name")))
+(defun flymake-master-cleanup ()
+  (flymake-simple-cleanup)
+  (flymake-safe-delete-file flymake-temp-master-file-name))
 
 ;;;; make-specific init-cleanup routines
 (defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f)
@@ -1762,30 +1713,30 @@
 	      (concat "-DCHK_SOURCES=" source)
 	      "check-syntax")))
 
-(defun flymake-simple-make-init-impl (buffer create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
+(defun flymake-simple-make-init-impl (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
   "Create syntax check command line for a directly checked source file.
 Use CREATE-TEMP-F for creating temp copy."
   (let* ((args nil)
-	 (source-file-name   (buffer-file-name buffer))
-	 (buildfile-dir      (flymake-init-find-buildfile-dir buffer source-file-name build-file-name)))
+	 (source-file-name   buffer-file-name)
+	 (buildfile-dir      (flymake-init-find-buildfile-dir source-file-name build-file-name)))
     (if buildfile-dir
-	(let* ((temp-source-file-name  (flymake-init-create-temp-buffer-copy buffer create-temp-f)))
+	(let* ((temp-source-file-name  (flymake-init-create-temp-buffer-copy create-temp-f)))
 	  (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
 							    use-relative-base-dir use-relative-source
 							    get-cmdline-f))))
     args))
 
-(defun flymake-simple-make-init (buffer)
-  (flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
+(defun flymake-simple-make-init ()
+  (flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
 
-(defun flymake-master-make-init (buffer get-incl-dirs-f master-file-masks include-regexp-list)
+(defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp-list)
   "Create make command line for a source file checked via master file compilation."
   (let* ((make-args nil)
 	 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
-				 buffer get-incl-dirs-f 'flymake-create-temp-inplace
+                                 get-incl-dirs-f 'flymake-create-temp-inplace
 				 master-file-masks include-regexp-list)))
     (when temp-master-file-name
-      (let* ((buildfile-dir (flymake-init-find-buildfile-dir buffer temp-master-file-name "Makefile")))
+      (let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile")))
 	(if  buildfile-dir
 	    (setq make-args (flymake-get-syntax-check-program-args
 			     temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline)))))
@@ -1795,30 +1746,29 @@
   (flymake-find-buildfile "Makefile" source-dir flymake-buildfile-dirs))
 
 ;;;; .h/make specific
-(defun flymake-master-make-header-init (buffer)
-  (flymake-master-make-init buffer
-			    'flymake-get-include-dirs
-			    '(".+\\.cpp$" ".+\\.c$")
+(defun flymake-master-make-header-init ()
+  (flymake-master-make-init 'flymake-get-include-dirs
+			    '("\\.cpp\\'" "\\.c\\'")
 			    '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)))
 
 ;;;; .java/make specific
-(defun flymake-simple-make-java-init (buffer)
-  (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline))
+(defun flymake-simple-make-java-init ()
+  (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline))
 
-(defun flymake-simple-ant-java-init (buffer)
-  (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline))
+(defun flymake-simple-ant-java-init ()
+  (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline))
 
-(defun flymake-simple-java-cleanup (buffer)
+(defun flymake-simple-java-cleanup ()
   "Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs."
-  (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")))
-    (flymake-safe-delete-file temp-source-file-name)
-    (when temp-source-file-name
-      (flymake-delete-temp-directory (file-name-directory temp-source-file-name)))))
+  (flymake-safe-delete-file flymake-temp-source-file-name)
+  (when flymake-temp-source-file-name
+    (flymake-delete-temp-directory
+     (file-name-directory flymake-temp-source-file-name))))
 
 ;;;; perl-specific init-cleanup routines
-(defun flymake-perl-init (buffer)
+(defun flymake-perl-init ()
   (let* ((temp-file   (flymake-init-create-temp-buffer-copy
-		       buffer 'flymake-create-temp-inplace))
+                       'flymake-create-temp-inplace))
 	 (local-file  (concat (flymake-build-relative-filename
 			       (file-name-directory buffer-file-name)
 			       (file-name-directory temp-file))
@@ -1830,13 +1780,13 @@
   ;;(list "latex" (list "-c-style-errors" file-name))
   (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name)))
 
-(defun flymake-simple-tex-init (buffer)
-  (flymake-get-tex-args (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace)))
+(defun flymake-simple-tex-init ()
+  (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)))
 
-(defun flymake-master-tex-init (buffer)
+(defun flymake-master-tex-init ()
   (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
-				 buffer 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
-				 '(".+\\.tex$")
+                                 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
+				 '("\\.tex\\'")
 				 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2))))
     (when temp-master-file-name
       (flymake-get-tex-args temp-master-file-name))))
@@ -1845,8 +1795,8 @@
   '("."))
 
 ;;;; xml-specific init-cleanup routines
-(defun flymake-xml-init (buffer)
-  (list "xml" (list "val" (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace))))
+(defun flymake-xml-init ()
+  (list "xml" (list "val" (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))))
 
 (provide 'flymake)
 
--- a/lisp/simple.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/simple.el	Fri Jan 06 16:13:05 2006 +0000
@@ -3061,10 +3061,12 @@
   "Hook run when the mark becomes inactive.")
 
 (defun mark (&optional force)
-  "Return this buffer's mark value as integer; error if mark inactive.
-If optional argument FORCE is non-nil, access the mark value
-even if the mark is not currently active, and return nil
-if there is no mark at all.
+  "Return this buffer's mark value as integer, or nil if never set.
+
+In Transient Mark mode, this function signals an error if
+the mark is not active.  However, if `mark-even-if-inactive' is non-nil,
+or the argument FORCE is non-nil, it disregards whether the mark
+is active, and returns an integer or nil in the usual way.
 
 If you are using this in an editing command, you are most likely making
 a mistake; see the documentation of `set-mark'."
@@ -3679,15 +3681,13 @@
 	    (goto-char (previous-char-property-change (point) line-beg))))))))
 
 (defun move-end-of-line (arg)
-  "Move point to end of current line.
+  "Move point to end of current line as displayed.
+\(If there's an image in the line, this disregards newlines
+which are part of the text that the image rests on.)
+
 With argument ARG not nil or 1, move forward ARG - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
-To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
-
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; if ARG is nil or 1, and
-point starts at a field boundary, point does not move.  To ignore field
-boundaries bind `inhibit-field-text-motion' to t."
+To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
   (interactive "p")
   (or arg (setq arg 1))
   (let (done)
@@ -3715,15 +3715,13 @@
 	    (setq done t)))))))
 
 (defun move-beginning-of-line (arg)
-  "Move point to beginning of current display line.
+  "Move point to beginning of current line as displayed.
+\(If there's an image in the line, this disregards newlines
+which are part of the text that the image rests on.)
+
 With argument ARG not nil or 1, move forward ARG - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
-To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
-
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; if ARG is nil or 1, and
-point starts at a field boundary, point does not move.  To ignore field
-boundaries bind `inhibit-field-text-motion' to t."
+To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
   (interactive "p")
   (or arg (setq arg 1))
   (if (/= arg 1)
--- a/lisp/startup.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/startup.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; startup.el --- process Emacs shell arguments
 
 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -1250,7 +1250,7 @@
 			 (emacs-version)
 			 "\n"
 			 :face '(variable-pitch :height 0.5)
-			 "Copyright (C) 2005 Free Software Foundation, Inc.")
+			 "Copyright (C) 2006 Free Software Foundation, Inc.")
     (and auto-save-list-file-prefix
 	 ;; Don't signal an error if the
 	 ;; directory for auto-save-list files
@@ -1439,7 +1439,7 @@
 ")
 		  (insert "\n\n" (emacs-version)
 			  "
-Copyright (C) 2005 Free Software Foundation, Inc."))
+Copyright (C) 2006 Free Software Foundation, Inc."))
 
 	      ;; No mouse menus, so give help using kbd commands.
 
@@ -1487,7 +1487,7 @@
 
 	      (insert "\n\n" (emacs-version)
 		      "
-Copyright (C) 2005 Free Software Foundation, Inc.")
+Copyright (C) 2006 Free Software Foundation, Inc.")
 
 	      (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
 		       (eq (key-binding "\C-h\C-d") 'describe-distribution)
--- a/lisp/term/mac-win.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/term/mac-win.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1381,7 +1381,7 @@
 (put 'core-event     'mac-apple-event-class "aevt") ; kCoreEventClass
 (put 'internet-event 'mac-apple-event-class "GURL") ; kAEInternetEventClass
 
-;;; Event IDs 
+;;; Event IDs
 ;; kCoreEventClass
 (put 'open-application   'mac-apple-event-id "oapp") ; kAEOpenApplication
 (put 'reopen-application 'mac-apple-event-id "rapp") ; kAEReopenApplication
@@ -1409,14 +1409,14 @@
       (error "Not an Apple event: %S" ae)
     (let ((type-data (cdr (assoc keyword (cdr ae))))
 	  data)
-      (when (and type type-data)
+      (when (and type type-data (not (equal type (car type-data))))
 	(setq data (mac-coerce-ae-data (car type-data) (cdr type-data) type))
 	(setq type-data (if data (cons type data) nil)))
       type-data)))
 
 (defun mac-ae-list (ae &optional keyword type)
   (or keyword (setq keyword "----")) ;; Direct object.
-  (let ((desc (mac-ae-parameter ae keyword)))
+  (let ((desc (mac-ae-parameter ae keyword "list")))
     (cond ((null desc)
 	   nil)
 	  ((not (equal (car desc) "list"))
@@ -1588,6 +1588,9 @@
       (setq service-message
 	    (intern (decode-coding-string service-message 'utf-8)))
       (setq binding (lookup-key binding (vector service-message))))
+    ;; Replace (cadr event) with a dummy position so that event-start
+    ;; returns it.
+    (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0))
     (call-interactively binding)))
 
 (global-set-key [mac-apple-event] 'mac-dispatch-apple-event)
--- a/lisp/textmodes/flyspell.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/textmodes/flyspell.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; flyspell.el --- on-the-fly spell checker
 
 ;; Copyright (C) 1998, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Manuel Serrano <Manuel.Serrano@sophia.inria.fr>
 ;; Maintainer: FSF
@@ -504,11 +504,11 @@
 (defvar flyspell-last-buffer nil
   "The buffer in which the last flyspell operation took place.")
 
-(defun flyspell-accept-buffer-local-defs ()
+(defun flyspell-accept-buffer-local-defs (&optional force)
   ;; When flyspell-word is used inside a loop (e.g. when processing
   ;; flyspell-changes), the calls to `ispell-accept-buffer-local-defs' end
   ;; up dwarfing everything else, so only do it when the buffer has changed.
-  (unless (eq flyspell-last-buffer (current-buffer))
+  (when (or force (not (eq flyspell-last-buffer (current-buffer))))
     (setq flyspell-last-buffer (current-buffer))
     ;; Strange problem:  If buffer in current window has font-lock turned on,
     ;; but SET-BUFFER was called to point to an invisible buffer, this ispell
@@ -539,7 +539,9 @@
   ;; we have to force ispell to accept the local definition or
   ;; otherwise it could be too late, the local dictionary may
   ;; be forgotten!
-  (flyspell-accept-buffer-local-defs)
+  ;; Pass the `force' argument for the case where flyspell was active already
+  ;; but the buffer's local-defs have been edited.
+  (flyspell-accept-buffer-local-defs 'force)
   ;; we put the `flyspell-delayed' property on some commands
   (flyspell-delay-commands)
   ;; we put the `flyspell-deplacement' property on some commands
--- a/lisp/textmodes/org.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/textmodes/org.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,11 +1,11 @@
 ;;; org.el --- Outline-based notes management and organize
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (c) 2004, 2005 Free Software Foundation
+;; Copyright (c) 2004, 2005, 2006 Free Software Foundation
 ;;
 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
-;; Version: 4.01
+;; Version: 4.02
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -79,8 +79,12 @@
 ;; excellent reference card made by Philip Rooke.  This card can be found
 ;; in the etc/ directory of Emacs 22.
 ;;
-;; Changes:
-;; -------
+;; Changes since version 4.00:
+;; ---------------------------
+;; Version 4.02
+;;    - Minor bug fixes and improvements around tag searches.
+;;    - XEmacs compatibility fixes.
+;;
 ;; Version 4.01
 ;;    - Tags can also be set remotely from agenda buffer.
 ;;    - Boolean logic for tag searches.
@@ -88,178 +92,6 @@
 ;;      `org-agenda-custom-commands'.
 ;;    - Minor bug fixes.
 ;;
-;; Version 4.00
-;;    - Headlines can contain TAGS, and Org-mode can produced a list
-;;      of matching headlines based on a TAG search expression.
-;;    - `org-agenda' has now become a dispatcher that will produce the agenda
-;;      and other views on org-mode data with an additional keypress.
-;;
-;; Version 3.24
-;;    - Switching and item to DONE records a time stamp when the variable
-;;      `org-log-done' is turned on.  Default is off.
-;;
-;; Version 3.23
-;;    - M-RET makes new items as well as new headings.
-;;    - Various small bug fixes
-;;
-;; Version 3.22
-;;    - CamelCase words link to other locations in the same file.
-;;    - File links accept search options, to link to specific locations.
-;;    - Plain list items can be folded with `org-cycle'.  See new option
-;;      `org-cycle-include-plain-lists'.
-;;    - Sparse trees for specific TODO keywords through numeric prefix
-;;      argument to `C-c C-v'.
-;;    - Global TODO list, also for specific keywords.
-;;    - Matches in sparse trees are highlighted (highlights disappear with
-;;      next buffer change due to editing).
-;;
-;; Version 3.21
-;;    - Improved CSS support for the HTML export.  Thanks to Christian Egli.
-;;    - Editing support for hand-formatted lists
-;;      - M-S-cursor keys handle plain list items
-;;      - C-c C-c renumbers ordered plain lists
-;;
-;; Version 3.20
-;;    - There is finally an option to make TAB jump over horizontal lines
-;;      in tables instead of creating a new line before that line.
-;;      The option is `org-table-tab-jumps-over-hlines', default nil.
-;;    - New command for sorting tables, on `C-c ^'.
-;;    - Changes to the HTML exporter
-;;      - hand-formatted lists are exported correctly, similar to
-;;        markdown lists.  Nested lists are possible.  See the docstring
-;;        of the variable `org-export-plain-list-max-depth'.
-;;      - cleaned up to produce valid HTML 4.0 (transitional).
-;;      - support for cascading style sheets.
-;;    - New command to cycle through all agenda files, on C-,
-;;    - C-c [ can now also be used to change the sequence of agenda files.
-;;
-;; Version 3.19
-;;    - Bug fixes
-;;
-;; Version 3.18
-;;    - Export of calendar information in the standard iCalendar format.
-;;    - Some bug fixes.
-;;
-;; Version 3.17
-;;    - HTML export specifies character set depending on coding-system.
-;;
-;; Version 3.16
-;;    - In tables, directly after the field motion commands like TAB and RET,
-;;      typing a character will blank the field.  Can be turned off with
-;;      variable `org-table-auto-blank-field'.
-;;    - Inactive timestamps with `C-c !'.  These do not trigger the agenda
-;;      and are not linked to the calendar.
-;;    - Additional key bindings to allow Org-mode to function on a tty emacs.
-;;    - `C-c C-h' prefix key replaced by `C-c C-x', and `C-c C-x C-h' replaced
-;;      by `C-c C-x b' (b=Browser).  This was necessary to recover the
-;;      standard meaning of C-h after a prefix key (show prefix bindings).
-;;
-;; Version 3.15
-;;    - QUOTE keyword at the beginning of an entry causes fixed-width export
-;;      of unmodified entry text. `C-c :' toggles this keyword.
-;;    - New face `org-special-keyword' which is used for COMMENT, QUOTE,
-;;      DEADLINE and SCHEDULED, and priority cookies.  Default is only a weak
-;;      color, to reduce the amount of aggressive color in the buffer.
-;;
-;; Version 3.14
-;;    - Formulas for individual fields in table.
-;;    - Automatic recalculation in calculating tables.
-;;    - Named fields and columns in tables.
-;;    - Fixed bug with calling `org-archive' several times in a row.
-;;
-;; Version 3.13
-;;    - Efficiency improvements:  Fewer table re-alignments needed.
-;;    - New special lines in tables, for defining names for individual cells.
-;;
-;; Version 3.12
-;;    - Tables can store formulas (one per column) and compute fields.
-;;      Not quite like a full spreadsheet, but very powerful.
-;;    - table.el keybinding is now `C-c ~'.
-;;    - Numeric argument to org-cycle does `show-subtree' above on level ARG.
-;;    - Small changes to keys in agenda buffer.  Affected keys:
-;;      [w] weekly view; [d] daily view; [D] toggle diary inclusion.
-;;    - Bug fixes.
-;;
-;; Version 3.11
-;;    - Links inserted with C-c C-l are now by default enclosed in angle
-;;      brackets.  See the new variable `org-link-format'.
-;;    - ">" terminates a link, this is a way to have several links in a line.
-;;      Both "<" and ">" are no longer allowed as characters in a link.
-;;    - Archiving of finished tasks.
-;;    - C-<up>/<down> bindings removed, to allow access to paragraph commands.
-;;    - Compatibility with CUA-mode (see variable `org-CUA-compatible').
-;;    - Compatibility problems with viper-mode fixed.
-;;    - Improved html export of tables.
-;;    - Various clean-up changes.
-;;
-;; Version 3.10
-;;    - Using `define-derived-mode' to derive `org-mode' from `outline-mode'.
-;;
-;; Version 3.09
-;;    - Time-of-day specifications in agenda are extracted and placed
-;;      into the prefix.  Timed entries can be placed into a time grid for
-;;      day.
-;;
-;; Version 3.08
-;;    - "|" no longer allowed as part of a link, to allow links in tables.
-;;    - The prefix of items in the agenda buffer can be configured.
-;;    - Cleanup.
-;;
-;; Version 3.07
-;;    - Some folding inconsistencies removed.
-;;    - BBDB links to company-only entries.
-;;    - Bug fixes and global cleanup.
-;;
-;; Version 3.06
-;;    - M-S-RET inserts a new TODO heading.
-;;    - New startup option `content'.
-;;    - Better visual response when TODO items in agenda change status.
-;;    - Window positioning after visibility state changes optimized and made
-;;      configurable.  See `org-cycle-hook' and `org-occur-hook'.
-;;
-;; Version 3.05
-;;    - Agenda entries from the diary are linked to the diary file, so
-;;      adding and editing diary entries can be done directly from the agenda.
-;;    - Many calendar/diary commands available directly from agenda.
-;;    - Field copying in tables with S-RET does increment.
-;;    - C-c C-x C-v extracts the visible part of the buffer for printing.
-;;    - Moving subtrees up and down preserves the whitespace at the tree end.
-;;
-;; Version 3.04
-;;    - Table editor optimized to need fewer realignments, and to keep
-;;      table shape when typing in fields.
-;;    - A new minor mode, orgtbl-mode, introduces the Org-mode table editor
-;;      into arbitrary major modes.
-;;    - Fixed bug with realignment in XEmacs.
-;;    - Startup options can be set with special #+STARTUP line.
-;;    - Heading following a match in org-occur can be suppressed.
-;;
-;; Version 3.03
-;;    - Copyright transfer to the FSF.
-;;    - Effect of C-u and C-u C-u in org-timeline swapped.
-;;    - Timeline now always contains today, and `.' jumps to it.
-;;    - Table editor:
-;;      - cut and paste of rectangular regions in tables
-;;      - command to convert org-mode table to table.el table and back
-;;      - command to treat several cells like a paragraph and fill it
-;;      - command to convert a buffer region to a table
-;;      - import/export tables as tab-separated files (exchange with Excel)
-;;    - Agenda:
-;;      - Sorting mechanism for agenda items rewritten from scratch.
-;;      - Sorting fully configurable.
-;;      - Entries specifying a time are sorted together.
-;;    - Completion also covers option keywords after `#-'.
-;;    - Bug fixes.
-;;
-;; Version 3.01
-;;    - New reference card, thanks to Philip Rooke for creating it.
-;;    - Single file agenda renamed to "Timeline".  It no longer shows
-;;      warnings about upcoming deadlines/overdue scheduled items.
-;;      That functionality is now limited to the (multifile) agenda.
-;;    - When reading a date, the calendar can be manipulated with keys.
-;;    - Link support for RMAIL and Wanderlust (from planner.el, untested).
-;;    - Minor bug fixes and documentation improvements.
-
 ;;; Code:
 
 (eval-when-compile (require 'cl) (require 'calendar))
@@ -601,21 +433,31 @@
   :group 'org-agenda
   :type '(repeat file))
 
-(defcustom org-agenda-custom-commands
-  '(("w" todo "WAITING")
-    ("u" tags "+WORK+URGENT-BOSS"))
+(defcustom org-agenda-custom-commands '(("w" todo "WAITING"))
   "Custom commands for the agenda.
 These commands will be offered on the splash screen displayed by the
 agenda dispatcher \\[org-agenda].  Each entry is a list of 3 items:
 
-key    The key (as a string) to be associated with the command.
-type   The command type, either `todo' for a todo list with a specific
-       todo keyword, or `tags' for a tags search.
-match  What to search for.  Either a TODO keyword, or a tags match query."
+key    The key (a single char as a string) to be associated with the command.
+type   The command type, any of the following symbols:
+        todo        Entries with a specific TODO keyword, in all agenda files.
+        tags        Tags match in all agenda files.
+        todo-tree   Sparse tree of specific TODO keyword in *current* file.
+        tags-tree   Sparse tree with all tags matches in *current* file.
+        occur-tree  Occur sparse tree for current file.
+match  What to search for:
+        - a single keyword for TODO keyword searches
+        - a tags match expression for tags searches
+        - a regular expression for occur searches"
   :group 'org-agenda
   :type '(repeat
 	  (list (string :tag "Key")
-		(choice :tag "Type" (const tags) (const todo))
+		(choice :tag "Type"
+			(const :tag "Tags search in all agenda files" tags)
+			(const :tag "TODO keyword search in all agenda files" todo)
+			(const :tag "Tags sparse tree in current buffer" tags-tree)
+			(const :tag "TODO keyword tree in current buffer" todo-tree)
+			(const :tag "Occur tree in current buffer" occur-tree))
 		(string :tag "Match"))))
 
 (defcustom org-select-timeline-window t
@@ -1036,7 +878,11 @@
 the same search.  Listing all of them can create very long lists.
 Setting this variable to nil causes subtrees to be skipped.
 This option is off by default, because inheritance in on.  If you turn
-inheritance off, you very likely want to turn this option on."
+inheritance off, you very likely want to turn this option on.
+
+As a special case, if the tag search is restricted to TODO items, the
+value of this variable is ignored and sublevels are always checked, to
+make sure all corresponding TODO items find their way into the list."
   :group 'org-tags
   :type 'boolean)
 
@@ -2137,6 +1983,12 @@
   (make-local-hook 'before-change-functions)  ;; needed for XEmacs
   (add-hook 'before-change-functions 'org-before-change-function nil
 	    'local)
+  ;; FIXME: The following does not work because isearch-mode-end-hook
+  ;; is called *before* the visibility overlays as removed.
+  ;; There should be another hook then for me to be used.
+;;  (make-local-hook 'isearch-mode-end-hook)  ;; needed for XEmacs
+;;  (add-hook 'isearch-mode-end-hook 'org-show-hierarchy-above nil
+;;	    'local)
   ;; Paragraphs and auto-filling
   (org-set-autofill-regexps)
   ;; Settings for Calc embedded mode
@@ -2173,6 +2025,13 @@
 (defsubst org-current-line (&optional pos)
   (+ (if (bolp) 1 0) (count-lines (point-min) (or pos (point)))))
 
+
+;; FIXME: Do we need to copy?
+(defun org-string-props (string &rest properties)
+  "Add PROPERTIES to string."
+  (add-text-properties 0 (length string) properties string)
+  string)
+
 ;;; Font-Lock stuff
 
 (defvar org-mouse-map (make-sparse-keymap))
@@ -2452,7 +2311,7 @@
 			(get-char-property (1- (point)) 'invisible))
 	      (beginning-of-line 2)) (setq eol (point)))
 	  (outline-end-of-heading)   (setq eoh (point))
-	  (outline-end-of-subtree)   (setq eos (point))
+	  (org-end-of-subtree t)     (setq eos (point))
 	  (outline-next-heading))
 	;; Find out what to do next and set `this-command'
 	(cond
@@ -2513,7 +2372,7 @@
 (defun org-subtree-end-visible-p ()
   "Is the end of the current subtree visible?"
   (pos-visible-in-window-p
-   (save-excursion (outline-end-of-subtree) (point))))
+   (save-excursion (org-end-of-subtree t) (point))))
 
 (defun org-first-headline-recenter (&optional N)
   "Move cursor to the first headline and recenter the headline.
@@ -3626,25 +3485,43 @@
 
 (defun org-show-hierarchy-above ()
   "Make sure point and the headings hierarchy above is visible."
-  (if (org-on-heading-p t)
-      (org-flag-heading nil)    ; only show the heading
-    (and (org-invisible-p) (org-show-hidden-entry)))    ; show entire entry
-  (save-excursion
-    (and org-show-following-heading
-	 (outline-next-heading)
-	 (org-flag-heading nil)))  ; show the next heading
-  (when org-show-hierarchy-above
-    (save-excursion                  ; show all higher headings
-      (while (condition-case nil
-		 (progn (org-up-heading-all 1) t)
-	       (error nil))
-	(org-flag-heading nil)))))
+  (catch 'exit
+    (if (org-on-heading-p t)
+	(org-flag-heading nil)    ; only show the heading
+      (and (org-invisible-p) (org-show-hidden-entry)))    ; show entire entry
+    (save-excursion
+      (and org-show-following-heading
+	   (outline-next-heading)
+	   (org-flag-heading nil)))  ; show the next heading
+    (when org-show-hierarchy-above
+      (save-excursion                  ; show all higher headings
+	(while (and (condition-case nil
+			(progn (org-up-heading-all 1) t)
+		      (error nil))
+		    (not (bobp)))
+	  (org-flag-heading nil))))))
+
+;; Overlay compatibility functions
+(defun org-make-overlay (beg end &optional buffer)
+  (if org-xemacs-p (make-extent beg end buffer) (make-overlay beg end buffer)))
+(defun org-delete-overlay (ovl)
+  (if org-xemacs-p (delete-extent ovl) (delete-overlay ovl)))
+(defun org-detatch-overlay (ovl) 
+  (if org-xemacs-p (detach-extent ovl) (delete-overlay ovl)))
+(defun org-move-overlay (ovl beg end &optional buffer)
+  (if org-xemacs-p
+      (set-extent-endpoints ovl beg end buffer)
+    (move-overlay ovl beg end buffer)))
+(defun org-overlay-put (ovl prop value)
+  (if org-xemacs-p
+      (set-extent-property ovl prop value)
+    (overlay-put ovl prop value)))
 
 (defvar org-occur-highlights nil)
 (defun org-highlight-new-match (beg end)
   "Highlight from BEG to END and mark the highlight is an occur headline."
-  (let ((ov (make-overlay beg end)))
-    (overlay-put ov 'face 'secondary-selection)
+  (let ((ov (org-make-overlay beg end)))
+    (org-overlay-put ov 'face 'secondary-selection)
     (push ov org-occur-highlights)))
 
 (defun org-remove-occur-highlights (&optional beg end noremove)
@@ -3652,7 +3529,7 @@
 BEG and END are ignored.  If NOREMOVE is nil, remove this function
 from the before-change-functions in the current buffer."
   (interactive)
-  (mapc 'delete-overlay org-occur-highlights)
+  (mapc 'org-delete-overlay org-occur-highlights)
   (setq org-occur-highlights nil)
   (unless noremove
     (remove-hook 'before-change-functions
@@ -3786,6 +3663,10 @@
     (setq fmt (concat "[" (substring fmt 1 -1) "]"))
     (insert (format-time-string fmt time))))
 
+(defvar org-date-ovl (org-make-overlay 1 1))
+(org-overlay-put org-date-ovl 'face 'org-warning)
+(org-detatch-overlay org-date-ovl)
+
 ;;; FIXME: Make the function take "Fri" as "next friday"
 ;;; because these are mostly being used to record the current time.
 (defun org-read-date (&optional with-time to-time)
@@ -3847,12 +3728,15 @@
 	    (calendar-forward-day (- (time-to-days default-time)
 				     (calendar-absolute-from-gregorian
 				      (calendar-current-date))))
+            (org-eval-in-calendar nil)
 	    (let* ((old-map (current-local-map))
 		   (map (copy-keymap calendar-mode-map))
 		   (minibuffer-local-map (copy-keymap minibuffer-local-map)))
 	      (define-key map (kbd "RET") 'org-calendar-select)
 	      (define-key map (if org-xemacs-p [button1] [mouse-1])
-		'org-calendar-select)
+		'org-calendar-select-mouse)
+	      (define-key map (if org-xemacs-p [button2] [mouse-2])
+		'org-calendar-select-mouse)
 	      (define-key minibuffer-local-map [(meta shift left)]
 		(lambda () (interactive)
 		  (org-eval-in-calendar '(calendar-backward-month 1))))
@@ -3885,6 +3769,7 @@
 		(use-local-map old-map)))))
       ;; Naked prompt only
       (setq ans (read-string prompt "" nil timestr)))
+    (org-detatch-overlay org-date-ovl)
 
     (if (string-match
 	 "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans)
@@ -3924,7 +3809,7 @@
       (let* ((date (calendar-cursor-to-date))
 	     (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
 	(setq ans2 (format-time-string "%Y-%m-%d" time))))
-    (and org-xemacs-p (sit-for .2))
+    (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
     (select-window sw)))
 
 (defun org-calendar-select ()
@@ -3937,6 +3822,17 @@
       (setq ans1 (format-time-string "%Y-%m-%d" time)))
     (if (active-minibuffer-window) (exit-minibuffer))))
 
+(defun org-calendar-select-mouse (ev)
+  "Return to `org-read-date' with the date currently selected.
+This is used by `org-read-date' in a temporary keymap for the calendar buffer."
+  (interactive "e")
+  (mouse-set-point ev)
+  (when (calendar-cursor-to-date)
+    (let* ((date (calendar-cursor-to-date))
+	   (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
+      (setq ans1 (format-time-string "%Y-%m-%d" time)))
+    (if (active-minibuffer-window) (exit-minibuffer))))
+
 (defun org-check-deadlines (ndays)
   "Check if there are any deadlines due or past due.
 A deadline is considered due if it happens within `org-deadline-warning-days'
@@ -4220,7 +4116,7 @@
 (defvar org-agenda-buffer-name "*Org Agenda*")
 (defvar org-agenda-redo-command nil)
 (defvar org-agenda-mode-hook nil)
-
+(defvar org-agenda-type nil)
 (defvar org-agenda-force-single-file nil)
 
 ;;;###autoload
@@ -4338,40 +4234,42 @@
     ["Cycle TODO" org-agenda-todo t]
     ["Set Tags" org-agenda-set-tags t]
     ("Reschedule"
-     ["Reschedule +1 day" org-agenda-date-later t]
-     ["Reschedule -1 day" org-agenda-date-earlier t]
+     ["Reschedule +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Reschedule -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
      "--"
-     ["Reschedule to ..." org-agenda-date-prompt t])
+     ["Reschedule to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
     ("Priority"
      ["Set Priority" org-agenda-priority t]
      ["Increase Priority" org-agenda-priority-up t]
      ["Decrease Priority" org-agenda-priority-down t]
      ["Show Priority" org-agenda-show-priority t])
     "--"
+    ;; ["New agenda command" org-agenda t]
     ["Rebuild buffer" org-agenda-redo t]
-    ["Goto Today" org-agenda-goto-today t]
-    ["Next Dates" org-agenda-later (local-variable-p 'starting-day (current-buffer))]
-    ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day (current-buffer))]
     "--"
-    ["Day View" org-agenda-day-view :active (local-variable-p 'starting-day (current-buffer))
+    ["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
+    ["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
+    ["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
+    "--"
+    ["Day View" org-agenda-day-view :active (org-agenda-check-type nil 'agenda)
      :style radio :selected (equal org-agenda-ndays 1)]
-    ["Week View" org-agenda-week-view :active (local-variable-p 'starting-day (current-buffer))
+    ["Week View" org-agenda-week-view :active (org-agenda-check-type nil 'agenda)
      :style radio :selected (equal org-agenda-ndays 7)]
     "--"
     ["Show Logbook entries" org-agenda-log-mode
-     :style toggle :selected org-agenda-show-log :active t]
+     :style toggle :selected org-agenda-show-log :active (org-agenda-check-type nil 'agenda 'timeline)]
     ["Include Diary" org-agenda-toggle-diary
-     :style toggle :selected org-agenda-include-diary :active t]
+     :style toggle :selected org-agenda-include-diary :active (org-agenda-check-type nil 'agenda)]
     ["Use Time Grid" org-agenda-toggle-time-grid
-     :style toggle :selected org-agenda-use-time-grid :active t]
+     :style toggle :selected org-agenda-use-time-grid :active (org-agenda-check-type nil 'agenda)]
     "--"
-    ["New Diary Entry" org-agenda-diary-entry t]
+    ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
     ("Calendar Commands"
-     ["Goto Calendar" org-agenda-goto-calendar t]
-     ["Phases of the Moon" org-agenda-phases-of-moon t]
-     ["Sunrise/Sunset" org-agenda-sunrise-sunset t]
-     ["Holidays" org-agenda-holidays t]
-     ["Convert" org-agenda-convert-date t])
+     ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)])
     ["Create iCalendar file" org-export-icalendar-combine-agenda-files t]
     "--"
     ["Quit" org-agenda-quit t]
@@ -4386,19 +4284,19 @@
 
 a     Call `org-agenda' to display the agenda for the current day or week.
 t     Call `org-todo-list' to display the global todo list.
-T     Call `org-todo-list' to display the global todo list, put
-      select only entries with a specific TODO keyword.
+T     Call `org-todo-list' to display the global todo list, select only
+      entries with a specific TODO keyword (the user get a prompt).
 m     Call `org-tags-view' to display headlines with tags matching
-      a condition.  The tags condition is a list of positive and negative
-      selections, like `+WORK+URGENT-WITHBOSS'.
+      a condition  (the user is prompted for the condition).
 M     like `m', but select only TODO entries, no ordinary headlines.
 
 More commands can be added by configuring the variable
-`org-agenda-custom-commands'.
+`org-agenda-custom-commands'.  In particular, specific tags and TODO keyword
+searches can be pre-defined in this way.
 
 If the current buffer is in Org-mode and visiting a file, you can also
-first press `1' to indicate that the agenda should be temporarily
-restricted to the current file."
+first press `1' to indicate that the agenda should be temporarily (until the
+next use of \\[org-agenda]) restricted to the current file."
   (interactive "P")
   (catch 'exit
     (let ((restrict-ok (and (buffer-file-name) (eq major-mode 'org-mode)))
@@ -4418,14 +4316,20 @@
 C   Configure your own agenda commands")
 	(while (setq entry (pop custom))
 	  (setq key (car entry) type (nth 1 entry) string (nth 2 entry))
-	  (insert (format "\n%-4s%-12s: %s"
+	  (insert (format "\n%-4s%-14s: %s"
 			  key
-			  (if (eq type 'tags) "Tags query" "TODO keyword")
-			  string)))
+			  (cond
+			   ((eq type 'tags) "Tags query")
+			   ((eq type 'todo) "TODO keyword")
+			   ((eq type 'tags-tree) "Tags tree")
+			   ((eq type 'todo-tree) "TODO kwd tree")
+			   ((eq type 'occur-tree) "Occur tree")
+			   (t "???"))
+			  (org-string-props string 'face 'org-link))))
 	(goto-char (point-min))
-	(fit-window-to-buffer)
+	(if (fboundp 'fit-window-to-buffer) (fit-window-to-buffer))
 	(message "Press key for agenda command%s"
-		(if restrict-ok ", or [1] to restrict to current file" ""))
+		 (if restrict-ok ", or [1] to restrict to current file" ""))
 	(setq c (read-char-exclusive))
 	(message "")
 	(when (equal c ?1)
@@ -4437,6 +4341,7 @@
 	  (setq c (read-char-exclusive))
 	  (message "")))
       (require 'calendar)  ; FIXME: can we avoid this for some commands?
+      ;; For example the todo list should not need it (but does...)
       (cond
        ((equal c ?C) (customize-variable 'org-agenda-custom-commands))
        ((equal c ?a) (call-interactively 'org-agenda-list))
@@ -4455,9 +4360,25 @@
 	  (org-tags-view current-prefix-arg string))
 	 ((eq type 'todo)
 	  (org-todo-list string))
+	 ((eq type 'tags-tree)
+	  (org-check-for-org-mode)
+	  (org-tags-sparse-tree current-prefix-arg string))
+	 ((eq type 'todo-tree)
+	  (org-check-for-org-mode)
+	  (org-occur (concat "^" outline-regexp "[ \t]*"
+			     (regexp-quote string) "\\>")))
+	 ((eq type 'occur-tree)
+	  (org-check-for-org-mode)
+	  (org-occur string))
 	 (t (error "Invalid custom agenda command type %s" type))))
        (t (error "Invalid key"))))))
 
+(defun org-check-for-org-mode ()
+  "Make sure current buffer is in org-mode.  Error if not."
+  (or (eq major-mode 'org-mode)
+      (error "Cannot execute org-mode agenda command on buffer in %s."
+	     major-mode)))
+
 (defun org-fit-agenda-window ()
   "Fit the window to the buffer size."
   (and org-fit-agenda-window
@@ -4565,6 +4486,7 @@
     (setq buffer-read-only nil)
     (erase-buffer)
     (org-agenda-mode) (setq buffer-read-only nil)
+    (set (make-local-variable 'org-agenda-type) 'timeline)
     (if doclosed (push :closed args))
     (push :timestamp args)
     (if dotodo (push :todo args))
@@ -4653,6 +4575,7 @@
     (setq buffer-read-only nil)
     (erase-buffer)
     (org-agenda-mode) (setq buffer-read-only nil)
+    (set (make-local-variable 'org-agenda-type) 'agenda)
     (set (make-local-variable 'starting-day) (car day-numbers))
     (set (make-local-variable 'include-all-loc) include-all)
     (when (and (or include-all org-agenda-include-all-todo)
@@ -4762,6 +4685,7 @@
     (setq buffer-read-only nil)
     (erase-buffer)
     (org-agenda-mode) (setq buffer-read-only nil)
+    (set (make-local-variable 'org-agenda-type) 'todo)
     (set (make-local-variable 'last-arg) arg)
     (set (make-local-variable 'org-todo-keywords) kwds)
     (set (make-local-variable 'org-agenda-redo-command)
@@ -4798,7 +4722,8 @@
 (defun org-check-agenda-file (file)
   "Make sure FILE exists.  If not, ask user what to do."
   ;; FIXME:  this does not correctly change the menus
-  ;; Could probably be fixed by explicitly going to the buffer.
+  ;; Could probably be fixed by explicitly going to the buffer where
+  ;; the call originated.
   (when (not (file-exists-p file))
     (message "non-existent file %s.  [R]emove from agenda-files or [A]bort?"
 	     file)
@@ -4809,6 +4734,15 @@
 	(throw 'nextfile t))
        (t (error "Abort"))))))
 
+(defun org-agenda-check-type (error &rest types)
+  "Check if agenda buffer is of allowed type.
+If ERROR is non-nil, throw an error, otherwise just return nil."
+  (if (memq org-agenda-type types)
+      t
+    (if error
+	(error "Now allowed in %s-type agenda buffers" org-agenda-type)
+      nil)))
+
 (defun org-agenda-quit ()
   "Exit agenda by removing the window or the buffer."
   (interactive)
@@ -4830,11 +4764,14 @@
   "Rebuild Agenda.
 When this is the global TODO list, a prefix argument will be interpreted."
   (interactive)
-  (eval org-agenda-redo-command))
+  (message "Rebuilding agenda buffer...")
+  (eval org-agenda-redo-command)
+  (message "Rebuilding agenda buffer...done"))
 
 (defun org-agenda-goto-today ()
   "Go to today."
   (interactive)
+  (org-agenda-check-type t 'timeline 'agenda)
   (if (boundp 'starting-day)
       (let ((cmd (car org-agenda-redo-command))
 	    (iall (nth 1 org-agenda-redo-command))
@@ -4848,8 +4785,7 @@
   "Go forward in time by `org-agenda-ndays' days.
 With prefix ARG, go forward that many times `org-agenda-ndays'."
   (interactive "p")
-  (unless (boundp 'starting-day)
-    (error "Not allowed"))
+  (org-agenda-check-type t 'agenda)
   (org-agenda-list (if (boundp 'include-all-loc) include-all-loc nil)
 		   (+ starting-day (* arg org-agenda-ndays)) nil t))
 
@@ -4857,16 +4793,14 @@
   "Go back in time by `org-agenda-ndays' days.
 With prefix ARG, go back that many times `org-agenda-ndays'."
   (interactive "p")
-  (unless (boundp 'starting-day)
-    (error "Not allowed"))
+  (org-agenda-check-type t 'agenda)
   (org-agenda-list (if (boundp 'include-all-loc) include-all-loc nil)
 		   (- starting-day (* arg org-agenda-ndays)) nil t))
 
 (defun org-agenda-week-view ()
   "Switch to weekly view for agenda."
   (interactive)
-  (unless (boundp 'starting-day)
-    (error "Not allowed"))
+  (org-agenda-check-type t 'agenda)
   (setq org-agenda-ndays 7)
   (org-agenda-list include-all-loc
 		   (or (get-text-property (point) 'day)
@@ -4878,8 +4812,7 @@
 (defun org-agenda-day-view ()
   "Switch to weekly view for agenda."
   (interactive)
-  (unless (boundp 'starting-day)
-    (error "Not allowed"))
+  (org-agenda-check-type t 'agenda)
   (setq org-agenda-ndays 1)
   (org-agenda-list include-all-loc
 		   (or (get-text-property (point) 'day)
@@ -4891,6 +4824,7 @@
 (defun org-agenda-next-date-line (&optional arg)
   "Jump to the next line indicating a date in agenda buffer."
   (interactive "p")
+  (org-agenda-check-type t 'agenda 'timeline)
   (beginning-of-line 1)
   (if (looking-at "^\\S-") (forward-char 1))
   (if (not (re-search-forward "^\\S-" nil t arg))
@@ -4902,14 +4836,14 @@
 (defun org-agenda-previous-date-line (&optional arg)
   "Jump to the next line indicating a date in agenda buffer."
   (interactive "p")
+  (org-agenda-check-type t 'agenda 'timeline)
   (beginning-of-line 1)
   (if (not (re-search-backward "^\\S-" nil t arg))
       (error "No previous date before this line in this buffer")))
 
 ;; Initialize the highlight
-(defvar org-hl (funcall (if org-xemacs-p 'make-extent 'make-overlay) 1 1))
-(funcall (if org-xemacs-p 'set-extent-property 'overlay-put) org-hl
-	 'face 'highlight)
+(defvar org-hl (org-make-overlay 1 1))
+(org-overlay-put org-hl 'face 'highlight)
 
 (defun org-highlight (begin end &optional buffer)
   "Highlight a region with overlay."
@@ -4932,6 +4866,7 @@
 (defun org-agenda-log-mode ()
   "Toggle follow mode in an agenda buffer."
   (interactive)
+  (org-agenda-check-type t 'agenda 'timeline)
   (setq org-agenda-show-log (not org-agenda-show-log))
   (org-agenda-set-mode-name)
   (org-agenda-redo)
@@ -4941,6 +4876,7 @@
 (defun org-agenda-toggle-diary ()
   "Toggle follow mode in an agenda buffer."
   (interactive)
+  (org-agenda-check-type t 'agenda)
   (setq org-agenda-include-diary (not org-agenda-include-diary))
   (org-agenda-redo)
   (org-agenda-set-mode-name)
@@ -4950,6 +4886,7 @@
 (defun org-agenda-toggle-time-grid ()
   "Toggle follow mode in an agenda buffer."
   (interactive)
+  (org-agenda-check-type t 'agenda)
   (setq org-agenda-use-time-grid (not org-agenda-use-time-grid))
   (org-agenda-redo)
   (org-agenda-set-mode-name)
@@ -5365,16 +5302,16 @@
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (goto-char (match-beginning 1))
-      (setq marker (org-agenda-new-marker (point-at-bol))
+      (setq marker (org-agenda-new-marker (1+ (match-beginning 0)))
 	    category (org-get-category)
 	    txt (org-format-agenda-item "" (match-string 1) category)
 	    priority
 	    (+ (org-get-priority txt)
 	       (if org-todo-kwd-priority-p
-			 (- org-todo-kwd-max-priority -2
-			    (length
-			     (member (match-string 2) org-todo-keywords)))
-		       1)))
+                   (- org-todo-kwd-max-priority -2
+                      (length
+                       (member (match-string 2) org-todo-keywords)))
+                 1)))
       (add-text-properties
        0 (length txt) (append (list 'org-marker marker 'org-hd-marker marker
 				    'priority priority 'category category)
@@ -6089,9 +6026,9 @@
   "Set tags for the current headline."
   (interactive)
   (org-agenda-check-no-diary)
-  (let* ((marker (or (get-text-property (point) 'org-marker)
-		     (org-agenda-error)))
-	 (hdmarker (get-text-property (point) 'org-hd-marker))
+  (org-agenda-show)   ;;; FIXME This is a stupid hack and should not be needed
+  (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
+                       (org-agenda-error)))
 	 (buffer (marker-buffer hdmarker))
 	 (pos (marker-position hdmarker))
 	 (buffer-read-only nil)
@@ -6112,6 +6049,7 @@
 (defun org-agenda-date-later (arg &optional what)
   "Change the date of this item to one day later."
   (interactive "p")
+  (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-no-diary)
   (let* ((marker (or (get-text-property (point) 'org-marker)
 		     (org-agenda-error)))
@@ -6135,6 +6073,7 @@
 The prefix ARG is passed to the `org-time-stamp' command and can therefore
 be used to request time specification in the time stamp."
   (interactive "P")
+  (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-no-diary)
   (let* ((marker (or (get-text-property (point) 'org-marker)
 		     (org-agenda-error)))
@@ -6151,9 +6090,10 @@
 (defun org-get-heading ()
   "Return the heading of the current entry, without the stars."
   (save-excursion
-    (and (bolp) (end-of-line 1))
+    (and (memq (char-before) '(?\n ?\r)) (skip-chars-forward "^\n\r"))
+;;FIXME????????    (and (bolp) (end-of-line 1))
     (if (and (re-search-backward "[\r\n]\\*" nil t)
-	     (looking-at "[\r\n]\\*+[ \t]+\\(.*\\)"))
+	     (looking-at "[\r\n]\\*+[ \t]+\\([^\r\n]*\\)"))
 	(match-string 1)
       "")))
 
@@ -6161,6 +6101,7 @@
   "Make a diary entry, like the `i' command from the calendar.
 All the standard commands work: block, weekly etc"
   (interactive)
+  (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (let* ((char (progn
 		 (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic")
@@ -6201,6 +6142,7 @@
 (defun org-agenda-execute-calendar-command (cmd)
   "Execute a calendar command from the agenda, with the date associated to
 the cursor position."
+  (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (unless (get-text-property (point) 'day)
     (error "Don't know which date to use for calendar command"))
@@ -6245,6 +6187,7 @@
 (defun org-agenda-goto-calendar ()
   "Open the Emacs calendar with the date at the cursor."
   (interactive)
+  (org-agenda-check-type t 'agenda 'timeline)
   (let* ((day (or (get-text-property (point) 'day)
 		  (error "Don't know which date to open in calendar")))
 	 (date (calendar-gregorian-from-absolute day))
@@ -6263,6 +6206,7 @@
 
 (defun org-agenda-convert-date ()
   (interactive)
+  (org-agenda-check-type t 'agenda 'timeline)
   (let ((day (get-text-property (point) 'day))
 	date s)
     (unless day
@@ -6285,7 +6229,8 @@
 	     "Chinese:    " (calendar-chinese-date-string date) "\n"))
     (with-output-to-temp-buffer "*Dates*"
       (princ s))
-    (fit-window-to-buffer (get-buffer-window "*Dates*"))))
+    (if (fboundp 'fit-window-to-buffer)
+	(fit-window-to-buffer (get-buffer-window "*Dates*")))))
 
 ;;; Tags
 
@@ -6308,6 +6253,7 @@
 		      'help-echo
 		      (format "mouse-2 or RET jump to org file %s"
 			      (abbreviate-file-name (buffer-file-name)))))
+         lspos
 	 tags tags-list tags-alist (llast 0) rtn level category i txt
 	 todo marker)
 
@@ -6317,7 +6263,7 @@
       (while (re-search-forward re nil t)
 	(setq todo (if (match-end 1) (match-string 2))
 	      tags (if (match-end 4) (match-string 4)))
-	(goto-char (1+ (match-beginning 0)))
+	(goto-char (setq lspos (1+ (match-beginning 0))))
 	(setq level (outline-level)
 	      category (org-get-category))
 	(setq i llast llast level)
@@ -6349,6 +6295,7 @@
 			    (make-string (1- level) ?.) "")
 			(org-get-heading))
 		       category))
+            (goto-char lspos)
 	    (setq marker (org-agenda-new-marker))
 	    (add-text-properties
 	     0 (length txt) 
@@ -6358,7 +6305,8 @@
 	     txt)
 	    (push txt rtn))
 	  ;; if we are to skip sublevels, jump to end of subtree
-	  (or org-tags-match-list-sublevels (outline-end-of-subtree)))))
+          (point)
+	  (or org-tags-match-list-sublevels (org-end-of-subtree)))))
     (nreverse rtn)))
 
 (defun org-tags-sparse-tree (&optional arg match)
@@ -6399,9 +6347,6 @@
     ;; Return the string and lisp forms of the matcher
     (cons match0 matcher)))
 
-;;(org-make-tags-matcher "&hello&-you")
-
-
 ;;;###autoload
 (defun org-tags-view (&optional todo-only match keep-modes)
   "Show all headlines for all `org-agenda-files' matching a TAGS criterions.
@@ -6410,6 +6355,8 @@
   (org-agenda-maybe-reset-markers 'force)
   (org-compile-prefix-format org-agenda-prefix-format)
   (let* ((org-agenda-keep-modes keep-modes)
+	 (org-tags-match-list-sublevels
+	  (if todo-only t org-tags-match-list-sublevels))
 	 (win (selected-window))
 	 (completion-ignore-case t)
 	 rtn rtnall files file pos matcher
@@ -6424,8 +6371,10 @@
     (setq buffer-read-only nil)
     (erase-buffer)
     (org-agenda-mode) (setq buffer-read-only nil)
+    (set (make-local-variable 'org-agenda-type) 'tags)
     (set (make-local-variable 'org-agenda-redo-command)
-	 '(call-interactively 'org-tags-view))
+	 (list 'org-tags-view (list 'quote todo-only) 
+	       (list 'if 'current-prefix-arg nil match) t))
     (setq files (org-agenda-files)
 	  rtnall nil)
     (while (setq file (pop files))
@@ -6459,6 +6408,9 @@
     (setq pos (point))
     (insert match "\n")
     (add-text-properties pos (1- (point)) (list 'face 'org-warning))
+    (setq pos (point))
+    (insert "Press `C-u r' to search again with new search string\n")
+    (add-text-properties pos (1- (point)) (list 'face 'org-link))
     (when rtnall
       (insert (mapconcat 'identity rtnall "\n")))
     (goto-char (point-min))
@@ -6475,7 +6427,7 @@
 	 (re (concat "^" outline-regexp))
 	 (col (current-column))
 	 (current (org-get-tags))
-	 tags hd)
+	 tags hd empty)
     (if arg
 	(save-excursion
 	  (goto-char (point-min))
@@ -6493,15 +6445,18 @@
 				 nil nil current 'org-tags-history)))
 	(while (string-match "[-+&]+" tags)
 	  (setq tags (replace-match ":" t t tags)))
-	(unless (string-match ":$" tags) (setq tags (concat tags ":")))
-	(unless (string-match "^:" tags) (setq tags (concat ":" tags))))
+	(unless (setq empty (string-match "\\`[\t ]*\\'" tags))
+	  (unless (string-match ":$" tags) (setq tags (concat tags ":")))
+	  (unless (string-match "^:" tags) (setq tags (concat ":" tags)))))
       (if (equal current "")
-	  (end-of-line 1)
+	  (progn
+	    (end-of-line 1)
+	    (or empty (insert " ")))
 	(beginning-of-line 1)
 	(looking-at (concat "\\(.*\\)\\(" (regexp-quote current) "\\)[ \t]*"))
 	(setq hd (match-string 1))
 	(delete-region (match-beginning 0) (match-end 0))
-	(insert (org-trim hd) " "))
+	(insert (org-trim hd) (if empty "" " ")))
       (unless (equal tags "")
 	(move-to-column (max (current-column)
 			     (if (> org-tags-column 0)
@@ -6553,7 +6508,7 @@
       (goto-char (point-min))
       (while (re-search-forward "[ \t]:\\([A-Za-z_:]+\\):[ \t\r\n]" nil t)
 	(mapc (lambda (x) (add-to-list 'tags x))
-	      (org-split-string (match-string-no-properties 1) ":"))))
+	      (org-split-string (match-string 1) ":"))))
     (mapcar 'list tags)))
 
 ;;; Link Stuff
@@ -11542,13 +11497,17 @@
       (org-table-paste-rectangle)
     (org-paste-subtree arg)))
 
-;; FIXME: document tags
 (defun org-ctrl-c-ctrl-c (&optional arg)
   "Call realign table, or recognize a table.el table, or update keywords.
 When the cursor is inside a table created by the table.el package,
 activate that table.  Otherwise, if the cursor is at a normal table
 created with org.el, re-align that table.  This command works even if
 the automatic table editor has been turned off.
+
+If the cursor is in a headline, prompt for tags and insert them into
+the current line, aligned to `org-tags-column'.  When in a headline and
+called with prefix arg, realign all tags in the current buffer.
+
 If the cursor is in one of the special #+KEYWORD lines, this triggers
 scanning the buffer for these lines and updating the information.
 If the cursor is on a #+TBLFM line, re-apply the formulae to the table."
@@ -11946,12 +11905,18 @@
 			  t)
 	      "\\'"))))
 
-;; Functions needed for compatibility with old outline.el
+;; Functions needed for compatibility with old outline.el.
+
+;; Programming for the old outline.el (that uses selective display
+;; instead of `invisible' text properties) is a nightmare, mostly
+;; because regular expressions can no longer be anchored at
+;; beginning/end of line.  Therefore a number of function need special
+;; treatment when the old outline.el is being used.
 
 ;; The following functions capture almost the entire compatibility code
-;; between the different versions of outline-mode.  The only other place
-;; where this is important are the font-lock-keywords.  Search for
-;; `org-noutline-p' to find it.
+;; between the different versions of outline-mode.  The only other
+;; places where this is important are the font-lock-keywords, and in
+;; `org-export-copy-visible'.  Search for `org-noutline-p' to find them.
 
 ;; C-a should go to the beginning of a *visible* line, also in the
 ;; new outline.el.  I guess this should be patched into Emacs?
@@ -11968,8 +11933,11 @@
 	  (backward-char 1)
 	  (beginning-of-line 1))
       (forward-char 1))))
+
 (when org-noutline-p
   (define-key org-mode-map "\C-a" 'org-beginning-of-line))
+;; FIXME: should I use substitute-key-definition to reach other bindings
+;; of beginning-of-line?
 
 (defun org-invisible-p ()
   "Check if point is at a character currently not visible."
@@ -11987,7 +11955,8 @@
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
   (if org-noutline-p
       (outline-back-to-heading invisible-ok)
-    (if (looking-at outline-regexp)
+    (if (and (memq (char-before) '(?\n ?\r))
+             (looking-at outline-regexp))
 	t
       (if (re-search-backward (concat (if invisible-ok "\\([\r\n]\\|^\\)" "^")
 				      outline-regexp)
@@ -12068,6 +12037,27 @@
 			       flag
 			     (if flag ?\r ?\n))))))
 
+(defun org-end-of-subtree (&optional invisible-OK)
+  ;; This is an exact copy of the original function, but it uses
+  ;; `org-back-to-heading', to make it work also in invisible
+  ;; trees.  And is uses an invisible-OK argument.
+  ;; Under Emacs this is not needed, but the old outline.el needs this fix.
+  (org-back-to-heading invisible-OK)
+  (let ((opoint (point))
+	(first t)
+	(level (funcall outline-level)))
+    (while (and (not (eobp))
+		(or first (> (funcall outline-level) level)))
+      (setq first nil)
+      (outline-next-heading))
+    (if (memq (preceding-char) '(?\n ?\^M))
+	(progn
+	  ;; Go to end of line before heading
+	  (forward-char -1)
+	  (if (memq (preceding-char) '(?\n ?\^M))
+	      ;; leave blank line before heading
+	      (forward-char -1))))))
+
 (defun org-show-subtree ()
   "Show everything after this heading at deeper levels."
   (outline-flag-region
@@ -12125,3 +12115,4 @@
 
 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
 ;;; org.el ends here
+
--- a/lisp/url/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/url/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,25 @@
+2006-01-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* url-history.el (url-history-hash-table): Initialize in declaration.
+	(url-history-parse-history): Don't reset the history.
+	(url-history-save-history): Create parent dir if necessary.
+	(url-history-save-history): Don't write the initialization of
+	url-history-hash-table into the history file.
+	(url-have-visited-url): Simplify since url-history-hash-table is non-nil.
+	(url-completion-function): Simplify.
+
+	* url-cookie.el (url-cookie-parse-file): Don't complain of missing file.
+	(url-cookie-parse-file, url-cookie-write-file, url-cookie-retrieve)
+	(url-cookie-generate-header-lines, url-cookie-handle-set-cookie)
+	(url-cookie-setup-save-timer): Remove autoload cookies.
+	They're only called from files that require url-cookie anyway.
+
+	* url-history.el (url-history-setup-save-timer)
+	(url-history-parse-history, url-history-save-history):
+	Remove autoload cookies.  They're only called from url.el which requires
+	url-history anyway.
+	(url-history-parse-history): Don't complain if the file is missing.
+
 2006-01-02  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* url-handlers.el (url-retrieve-synchronously): Don't autoload.
--- a/lisp/url/url-cookie.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/url/url-cookie.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; url-cookie.el --- Netscape Cookie support
 
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -109,12 +109,14 @@
 (defvar url-cookies-changed-since-last-save nil
   "Whether the cookies list has changed since the last save operation.")
 
-;;;###autoload
 (defun url-cookie-parse-file (&optional fname)
   (setq fname (or fname url-cookie-file))
   (condition-case ()
       (load fname nil t)
-    (error (message "Could not load cookie file %s" fname))))
+    (error
+     ;; It's completely normal for the cookies file not to exist yet.
+     ;; (message "Could not load cookie file %s" fname)
+     )))
 
 (defun url-cookie-clean-up (&optional secure)
   (let* (
@@ -145,7 +147,6 @@
 	(setq new (cons cur new))))
     (set var new)))
 
-;;;###autoload
 (defun url-cookie-write-file (&optional fname)
   (setq fname (or fname url-cookie-file))
   (unless (file-directory-p (file-name-directory fname))
@@ -250,7 +251,6 @@
 			  (*   1 (string-to-number (aref exp-time 0))))))
 	(> (- cur-norm exp-norm) 1))))))
 
-;;;###autoload
 (defun url-cookie-retrieve (host localpart &optional secure)
   "Retrieve all the netscape-style cookies for a specified HOST and LOCALPART."
   (let ((storage (if secure
@@ -278,7 +278,6 @@
 		(setq retval (cons cur retval))))))
     retval))
 
-;;;###autoload
 (defun url-cookie-generate-header-lines (host localpart secure)
   (let* ((cookies (url-cookie-retrieve host localpart secure))
 	 (retval nil)
@@ -344,7 +343,6 @@
      (t
       nil))))
 
-;;;###autoload
 (defun url-cookie-handle-set-cookie (str)
   (setq url-cookies-changed-since-last-save t)
   (let* ((args (url-parse-args str t))
@@ -457,7 +455,6 @@
   :type 'integer
   :group 'url)
 
-;;;###autoload
 (defun url-cookie-setup-save-timer ()
   "Reset the cookie saver timer."
   (interactive)
--- a/lisp/url/url-history.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/url/url-history.el	Fri Jan 06 16:13:05 2006 +0000
@@ -1,7 +1,7 @@
 ;;; url-history.el --- Global history tracking for URL package
 
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -75,12 +75,11 @@
 (defvar url-history-changed-since-last-save nil
   "Whether the history list has changed since the last save operation.")
 
-(defvar url-history-hash-table nil
+(defvar url-history-hash-table (make-hash-table :size 31 :test 'equal)
   "Hash table for global history completion.")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;;;###autoload
 (defun url-history-setup-save-timer ()
   "Reset the history list timer."
   (interactive)
@@ -92,28 +91,27 @@
 					   url-history-save-interval
 					   'url-history-save-history))))
 
-;;;###autoload
 (defun url-history-parse-history (&optional fname)
   "Parse a history file stored in FNAME."
   ;; Parse out the mosaic global history file for completions, etc.
   (or fname (setq fname (expand-file-name url-history-file)))
   (cond
    ((not (file-exists-p fname))
-    (message "%s does not exist." fname))
+    ;; It's completely normal for this file not to exist, so don't complain.
+    ;; (message "%s does not exist." fname)
+    )
    ((not (file-readable-p fname))
     (message "%s is unreadable." fname))
    (t
     (condition-case nil
 	(load fname nil t)
-      (error (message "Could not load %s" fname)))))
-  (if (not url-history-hash-table)
-      (setq url-history-hash-table (make-hash-table :size 31 :test 'equal))))
+      (error (message "Could not load %s" fname))))))
 
 (defun url-history-update-url (url time)
   (setq url-history-changed-since-last-save t)
-  (puthash (if (vectorp url) (url-recreate-url url) url) time url-history-hash-table))
+  (puthash (if (vectorp url) (url-recreate-url url) url) time
+           url-history-hash-table))
 
-;;;###autoload
 (defun url-history-save-history (&optional fname)
   "Write the global history file into `url-history-file'.
 The type of data written is determined by what is in the file to begin
@@ -121,6 +119,8 @@
 user for what type to save as."
   (interactive)
   (or fname (setq fname (expand-file-name url-history-file)))
+  (unless (file-directory-p (file-name-directory fname))
+    (ignore-errors (make-directory (file-name-directory fname))))
   (cond
    ((not url-history-changed-since-last-save) nil)
    ((not (file-writable-p fname))
@@ -129,26 +129,27 @@
     (let ((make-backup-files nil)
 	  (version-control nil)
 	  (require-final-newline t))
-      (save-excursion
-	(set-buffer (get-buffer-create " *url-tmp*"))
+      (with-current-buffer (get-buffer-create " *url-tmp*")
 	(erase-buffer)
 	(let ((count 0))
-	  (maphash (function
-		       (lambda (key value)
-			 (while (string-match "[\r\n]+" key)
-			   (setq key (concat (substring key 0 (match-beginning 0))
-					     (substring key (match-end 0) nil))))
-			 (setq count (1+ count))
-			 (insert "(puthash \"" key "\""
-				 (if (not (stringp value)) " '" "")
-				 (prin1-to-string value)
-				 " url-history-hash-table)\n")))
-		      url-history-hash-table)
-	  (goto-char (point-min))
-	  (insert (format
-		   "(setq url-history-hash-table (make-hash-table :size %d :test 'equal))\n"
-		   (/ count 4)))
-	  (goto-char (point-max))
+	  (maphash (lambda (key value)
+                     (while (string-match "[\r\n]+" key)
+                       (setq key (concat (substring key 0 (match-beginning 0))
+                                         (substring key (match-end 0) nil))))
+                     (setq count (1+ count))
+                     (insert "(puthash \"" key "\""
+                             (if (not (stringp value)) " '" "")
+                             (prin1-to-string value)
+                             " url-history-hash-table)\n"))
+                   url-history-hash-table)
+          ;; We used to add this in the file, but it just makes the code
+          ;; more complex with no benefit.  Worse: it makes it harder to
+          ;; preserve preexisting history when loading the history file.
+	  ;; (goto-char (point-min))
+	  ;; (insert (format
+	  ;;          "(setq url-history-hash-table (make-hash-table :size %d :test 'equal))\n"
+	  ;;          (/ count 4)))
+	  ;; (goto-char (point-max))
 	  (insert "\n")
 	  (write-file fname))
 	(kill-buffer (current-buffer))))))
@@ -156,33 +157,30 @@
 
 (defun url-have-visited-url (url)
   (url-do-setup)
-  (and url-history-hash-table
-       (gethash url url-history-hash-table nil)))
+  (gethash url url-history-hash-table nil))
 
 (defun url-completion-function (string predicate function)
+  ;; Completion function to complete urls from the history.
+  ;; This is obsolete since we can now pass the hash-table directly as a
+  ;; completion table.
   (url-do-setup)
   (cond
    ((eq function nil)
     (let ((list nil))
-      (maphash (function (lambda (key val)
-			      (setq list (cons (cons key val)
-					       list))))
-		  url-history-hash-table)
+      (maphash (lambda (key val) (push key list))
+               url-history-hash-table)
+      ;; Not sure why we bother reversing the list.  --Stef
       (try-completion string (nreverse list) predicate)))
    ((eq function t)
-    (let ((stub (concat "^" (regexp-quote string)))
+    (let ((stub (concat "\\`" (regexp-quote string)))
 	  (retval nil))
       (maphash
-       (function
-	(lambda (url time)
-	  (if (string-match stub url)
-	      (setq retval (cons url retval)))))
+       (lambda (url time)
+         (if (string-match stub url) (push url retval)))
        url-history-hash-table)
       retval))
    ((eq function 'lambda)
-    (and url-history-hash-table
-	 (gethash string url-history-hash-table)
-	 t))
+    (and (gethash string url-history-hash-table) t))
    (t
     (error "url-completion-function very confused"))))
 
--- a/lisp/wid-edit.el	Thu Jan 05 14:02:59 2006 +0000
+++ b/lisp/wid-edit.el	Fri Jan 06 16:13:05 2006 +0000
@@ -403,7 +403,8 @@
     ;; We want to avoid the face with image buttons.
     (unless (widget-get widget :suppress-face)
       (overlay-put overlay 'face (widget-apply widget :button-face-get))
-      (overlay-put overlay 'mouse-face widget-mouse-face))
+      (overlay-put overlay 'mouse-face 
+		   (widget-apply widget :mouse-face-get)))
     (overlay-put overlay 'pointer 'hand)
     (overlay-put overlay 'follow-link follow-link)
     (overlay-put overlay 'help-echo help-echo)))
@@ -1391,6 +1392,7 @@
   :offset 0
   :format-handler 'widget-default-format-handler
   :button-face-get 'widget-default-button-face-get
+  :mouse-face-get 'widget-default-mouse-face-get
   :sample-face-get 'widget-default-sample-face-get
   :delete 'widget-default-delete
   :copy 'identity
@@ -1535,6 +1537,14 @@
 	    (widget-apply parent :button-face-get)
 	  widget-button-face))))
 
+(defun widget-default-mouse-face-get (widget)
+  ;; Use :mouse-face or widget-mouse-face
+  (or (widget-get widget :mouse-face)
+      (let ((parent (widget-get widget :parent)))
+	(if parent
+	    (widget-apply parent :mouse-face-get)
+	  widget-mouse-face))))
+
 (defun widget-default-sample-face-get (widget)
   ;; Use :sample-face.
   (widget-get widget :sample-face))
@@ -3161,28 +3171,83 @@
     (widget-apply widget :notify widget event)
     (widget-setup)))
 
+;;; I'm not sure about what this is good for?  KFS.
 (defvar widget-key-sequence-prompt-value-history nil
   "History of input to `widget-key-sequence-prompt-value'.")
 
-;; This mostly works, but I am pretty sure it needs more change
-;; to be 100% correct.  I don't know what the change should be -- rms.
+(defvar widget-key-sequence-default-value [ignore]
+  "Default value for an empty key sequence.")
+
+(defvar widget-key-sequence-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map widget-field-keymap)
+    (define-key map [(control ?q)] 'widget-key-sequence-read-event)
+    map))
 
 (define-widget 'key-sequence 'restricted-sexp
-  "A Lisp function."
+  "A key sequence."
   :prompt-value 'widget-field-prompt-value
   :prompt-internal 'widget-symbol-prompt-internal
-  :prompt-match 'fboundp
+; :prompt-match 'fboundp   ;; What was this good for?  KFS
   :prompt-history 'widget-key-sequence-prompt-value-history
   :action 'widget-field-action
   :match-alternatives '(stringp vectorp)
-  :validate (lambda (widget)
-	      (unless (or (stringp (widget-value widget))
-			  (vectorp (widget-value widget)))
-		(widget-put widget :error (format "Invalid key sequence: %S"
-						  (widget-value widget)))
-		widget))
-  :value 'ignore
+  :format "%{%t%}: %v"
+  :validate 'widget-key-sequence-validate
+  :value-to-internal 'widget-key-sequence-value-to-internal
+  :value-to-external 'widget-key-sequence-value-to-external
+  :value widget-key-sequence-default-value
+  :keymap widget-key-sequence-map
+  :help-echo "C-q: insert KEY, EVENT, or CODE; RET: enter value"
   :tag "Key sequence")
+
+(defun widget-key-sequence-read-event (ev)
+  (interactive (list
+		(let ((inhibit-quit t) quit-flag)
+		  (read-event "Insert KEY, EVENT, or CODE: "))))
+  (let ((ev2 (and (memq 'down (event-modifiers ev))
+		  (read-event)))
+	(tr (and (keymapp function-key-map)
+		 (lookup-key function-key-map (vector ev)))))
+    (when (and (integerp ev)
+	       (or (and (<= ?0 ev) (< ev (+ ?0 (min 10 read-quoted-char-radix))))
+		   (and (<= ?a (downcase ev))
+			(< (downcase ev) (+ ?a -10 (min 36 read-quoted-char-radix))))))
+      (setq unread-command-events (cons ev unread-command-events)
+	    ev (read-quoted-char (format "Enter code (radix %d)" read-quoted-char-radix))
+	    tr nil)
+      (if (and (integerp ev) (not (char-valid-p ev)))
+	  (insert (char-to-string ev))))  ;; throw invalid char error
+    (setq ev (key-description (list ev)))
+    (when (arrayp tr)
+      (setq tr (key-description (list (aref tr 0))))
+      (if (y-or-n-p (format "Key %s is translated to %s -- use %s? " ev tr tr))
+	  (setq ev tr ev2 nil)))
+    (insert (if (= (char-before) ?\s)  "" " ") ev " ")
+    (if ev2
+	(insert (key-description (list ev2)) " "))))
+
+(defun widget-key-sequence-validate (widget)
+  (unless (or (stringp (widget-value widget))
+	      (vectorp (widget-value widget)))
+    (widget-put widget :error (format "Invalid key sequence: %S"
+				      (widget-value widget)))
+    widget))
+
+(defun widget-key-sequence-value-to-internal (widget value)
+  (if (widget-apply widget :match value)
+      (if (equal value widget-key-sequence-default-value)
+	  ""
+	(key-description value))
+    value))
+
+(defun widget-key-sequence-value-to-external (widget value)
+  (if (stringp value)
+      (if (string-match "\\`[[:space:]]*\\'" value)
+	  widget-key-sequence-default-value
+	(read-kbd-macro value))
+    value))
+
 
 (define-widget 'sexp 'editable-field
   "An arbitrary Lisp expression."
--- a/lispref/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/lispref/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,17 @@
+2006-01-05  Richard M. Stallman  <rms@gnu.org>
+
+	* markers.texi (The Mark): Fix in `mark'.
+
+2006-01-04  Richard M. Stallman  <rms@gnu.org>
+
+	* processes.texi (Misc Network, Make Network): Minor cleanups.
+
+2006-01-04  Kim F. Storm  <storm@cua.dk>
+
+	* processes.texi (Make Network): Add IPv6 addresses and handling.
+	(Network Feature Testing): Mention (:family ipv6).
+	(Misc Network): Add IPv6 formats to format-network-address.
+
 2005-12-30  Richard M. Stallman  <rms@gnu.org>
 
 	* text.texi (Changing Properties):
--- a/lispref/markers.texi	Thu Jan 05 14:02:59 2006 +0000
+++ b/lispref/markers.texi	Fri Jan 06 16:13:05 2006 +0000
@@ -441,13 +441,14 @@
 
 @defun mark &optional force
 @cindex current buffer mark
-This function returns the current buffer's mark position as an integer.
+This function returns the current buffer's mark position as an integer,
+or @code{nil} if no mark has ever been set in this buffer.
 
-If Transient Mark mode is enabled, @code{mark-even-if-inactive} is
-@code{nil} and the mark is inactive, @code{mark} normally signals
-an error.  However, if @var{force} is non-@code{nil}, then @code{mark}
-returns the mark position anyway---or @code{nil}, if the mark is not
-yet set for this buffer.
+If Transient Mark mode is enabled, and @code{mark-even-if-inactive} is
+@code{nil}, @code{mark} signals an error if the mark is inactive.
+However, if @var{force} is non-@code{nil}, then @code{mark} disregards
+inactivity of the mark, and returns the mark position anyway (or
+@code{nil}).
 @end defun
 
 @defun mark-marker
--- a/lispref/processes.texi	Thu Jan 05 14:02:59 2006 +0000
+++ b/lispref/processes.texi	Fri Jan 06 16:13:05 2006 +0000
@@ -1782,8 +1782,11 @@
 
 @item :family @var{family}
 @var{family} specifies the address (and protocol) family for
-communication.  @code{nil} stands for IPv4.  @code{local} specifies a
-Unix socket, in which case @var{host} is ignored.
+communication.  @code{nil} means determine the proper address family
+automatically for the given @var{host} and @var{service}.
+@code{local} specifies a Unix socket, in which case @var{host} is
+ignored.  @code{ipv4} and @code{ipv6} specify to use IPv4 and IPv6
+respectively.
 
 @item :local @var{local-address}
 For a server process, @var{local-address} is the address to listen on.
@@ -1803,9 +1806,18 @@
 
 @itemize -
 @item
-An IPv4 address is represented as a vector of integers @code{[@var{a}
-@var{b} @var{c} @var{d} @var{p}]} corresponding to numeric IP address
-@var{a}.@var{b}.@var{c}.@var{d} and port number @var{p}.
+An IPv4 address is represented as a five-element vector of four 8-bit
+integers and one 16-bit integer
+@code{[@var{a} @var{b} @var{c} @var{d} @var{p}]} corresponding to
+numeric IPv4 address @var{a}.@var{b}.@var{c}.@var{d} and port number
+@var{p}.
+
+@item
+An IPv6 address is represented as a nine-element vector of 16-bit
+integers @code{[@var{a} @var{b} @var{c} @var{d} @var{e} @var{f}
+@var{g} @var{h} @var{p}]} corresponding to numeric IPv6 address
+@var{a}:@var{b}:@var{c}:@var{d}:@var{e}:@var{f}:@var{g}:@var{h} and
+port number @var{p}.
 
 @item
 A local address is represented as a string which specifies the address
@@ -1979,6 +1991,8 @@
 Non-@code{nil} if datagrams are supported.
 @item (:family local)
 Non-@code{nil} if local (aka ``UNIX domain'') sockets are supported.
+@item (:family ipv6)
+Non-@code{nil} if IPv6 is supported.
 @item (:service t)
 Non-@code{nil} if the system can select the port for a server.
 @end table
@@ -2041,14 +2055,21 @@
 
 @defun format-network-address address &optional omit-port
 This function converts the Lisp representation of a network address to
-a string.  For example, a five-element vector @code{[@var{a} @var{b}
-@var{c} @var{d} @var{p}]} represents an IP address
-@var{a}.@var{b}.@var{c}.@var{d} and port number @var{p}.
-@code{format-network-address} converts that to the string
-@code{"@var{a}.@var{b}.@var{c}.@var{d}:@var{p}"}.
-
-If @var{omit-port} is non-@code{nil}, the value does not include
-the port number.
+a string.
+
+A five-element vector @code{[@var{a} @var{b} @var{c} @var{d} @var{p}]}
+represents an IPv4 address @var{a}.@var{b}.@var{c}.@var{d} and port
+number @var{p}.  @code{format-network-address} converts that to the
+string @code{"@var{a}.@var{b}.@var{c}.@var{d}:@var{p}"}.
+
+A nine-element vector @code{[@var{a} @var{b} @var{c} @var{d} @var{e}
+@var{f} @var{g} @var{h} @var{p}]} represents an IPv6 address and port
+number.  @code{format-network-address} converts that to the string
+@code{"[@var{a}:@var{b}:@var{c}:@var{d}:@var{e}:@var{f}:@var{g}:@var{h}]:@var{p}"}.
+
+If the vector does not include the port number, @var{p}, or if
+@var{omit-port} is non-@code{nil}, the result does not include the
+@code{:@var{p}} suffix.
 @end defun
 
 @node Byte Packing
--- a/man/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/man/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,16 @@
+2006-01-05  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macos.texi (Mac International): Undo last change.
+
+2006-01-05  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.texi: (Agenda Views): Chapter reorganized.
+
+2006-01-02  Chong Yidong  <cyd@stupidchicken.com>
+
+	* custom.texi (Custom Themes): Describe the new
+	customize-create-theme interface.
+
 2005-12-30  Juri Linkov  <juri@jurta.org>
 
 	* basic.texi (Position Info): Update example.
--- a/man/custom.texi	Thu Jan 05 14:02:59 2006 +0000
+++ b/man/custom.texi	Fri Jan 06 16:13:05 2006 +0000
@@ -687,47 +687,56 @@
 such collections from one computer to another.
 
 @findex customize-create-theme
-  To define a Custom theme, use the command @kbd{M-x
-customize-create-theme}, which brings up a buffer named @samp{*New
-Custom Theme*}.  At the top of the buffer is an editable field where
-you can specify the name of the theme.  To add a customization option
-to the theme, click on the @samp{INS} button to open up a field where
-you can insert the name of the option.  The current value of that
-option is applied to the theme.  After adding as many options as you
-like, click on @samp{Done} to save the Custom theme.
+  To define a Custom theme, use @kbd{M-x customize-create-theme},
+which brings up a buffer named @samp{*New Custom Theme*}.  At the top
+of the buffer is an editable field where you can specify the name of
+the theme.  Click on the button labelled @samp{Insert Variable} to add
+a variable to the theme, and click on @samp{Insert Face} to add a
+face.  You can edit these values in the @samp{*New Custom Theme*}
+buffer like in an ordinary Customize buffer.  To remove an option from
+the theme, click on its @samp{State} button and select @samp{Delete}.
 
 @vindex custom-theme-directory
-  Saving a Custom theme named @var{foo} writes its definition into the
-file @file{@var{foo}-theme.el}, in the directory @file{~/.emacs.d/}
-(you can specify the directory by setting
-@code{custom-theme-directory}).
+  After adding the desired options, click on @samp{Save Theme} to save
+the Custom theme.  This writes the theme definition to a file
+@file{@var{foo}-theme.el} (where @var{foo} is the theme name you
+supplied), in the directory @file{~/.emacs.d/}.  You can specify the
+directory by setting @code{custom-theme-directory}.
+
+  You can view and edit the settings of a previously-defined theme by
+clicking on @samp{Visit Theme} and specifying the theme name.  You can
+also import the variables and faces that you have set using Customize
+by visiting the ``special'' theme named @samp{user}.  This theme, which
+records all the options that you set in the ordinary customization
+buffer, is always enabled, and always takes precedence over all other
+enabled Custom themes.  Additionally, the @samp{user} theme is
+recorded in your @file{.emacs} file, rather than a
+@file{user-theme.el} file.
+
+@vindex custom-enabled-themes
+  Once you have defined a Custom theme, you can use it by customizing
+the variable @code{custom-enabled-themes}.  This is a list of Custom
+themes that are @dfn{enabled}, or put into effect.  If you set
+@code{custom-enabled-themes} using the Customize interface, the theme
+definitions are automatically loaded from the theme files, if they
+aren't already.  If you save the value of @code{custom-enabled-themes}
+for future Emacs sessions, those Custom themes will be enabled
+whenever Emacs is started up.
+
+  If two enabled themes specify different values for an option, the
+theme occurring earlier in @code{custom-enabled-themes} takes effect.
 
 @findex load-theme
 @findex enable-theme
 @findex disable-theme
-You can load the themes you've previously defined with the command
-@code{load-theme}.  It prompts for a theme name in the minibuffer, and
-loads that theme from the theme file.  It also @dfn{enables} the
-theme, which means putting its settings into effect.  An enabled theme
+  You can also enable a Custom theme with @kbd{M-x enable-theme}.
+This prompts for a theme name in the minibuffer, loads the theme from
+the theme file if necessary, and enables the theme.  An enabled theme
 can be @dfn{disabled} with the command @kbd{M-x disable-theme}; this
 returns the options specified in the theme to their original values.
-To re-enable the theme, use the command @kbd{M-x enable-theme}.
-
-To enable a Custom theme named @var{foo} whenever Emacs is started up,
-add the line @code{(load-theme '@var{foo})} to your @file{.emacs} file
-(@pxref{Init File}).
-
-Enabling a custom theme does not disable the themes already enabled;
-instead, they are all enabled together.  If two enabled Custom themes
-specify different values for an option, the last theme to be enabled
-takes effect.
-
-The options that you set in the ordinary customization buffer
-(@pxref{Easy Customization}) are also considered part of a Custom
-theme, called @samp{user}.  The @samp{user} theme is always enabled,
-and always takes precedence over all other enabled Custom themes.
-Additionally, the @samp{user} theme is recorded in your @file{.emacs}
-file, rather than a @file{user-theme.el} file.
+To re-enable the theme, call @kbd{M-x enable-theme} again.  If a theme
+file is changed during your Emacs session, you can reload it by
+calling @kbd{M-x load-theme}.  This also enables the theme.
 
 @node Variables
 @section Variables
--- a/man/macos.texi	Thu Jan 05 14:02:59 2006 +0000
+++ b/man/macos.texi	Fri Jan 06 16:13:05 2006 +0000
@@ -141,18 +141,18 @@
 converted to the encoding specified by the selection coding system
 using the converter in the Mac OS system, and then decoded into the
 Emacs internal encoding using the converter in Emacs.  If the first
-conversion failed, then the UTF-16 data is converted similarly but via
-UTF-8.  Copying UTF-16 text to the clipboard goes through the inverse
-path.  The reason for this two-pass decoding is to avoid subtle
-differences in Unicode mappings between the Mac OS system and Emacs
-such as various kinds of hyphens, to deal with UTF-16 data in native
-byte order with no byte order mark, and to minimize users'
-customization.  For example, users that mainly use Latin characters
-would prefer Greek characters to be decoded into the
-@code{mule-unicode-0100-24ff} charset, but Japanese users would prefer
-them to be decoded into the @code{japanese-jisx0208} charset.  Since
-the coding system for selection is automatically set according to the
-system locale setting, users usually don't have to set it manually.
+conversion failed, then the UTF-16 data is directly converted to Emacs
+internal encoding using the converter in Emacs.  Copying UTF-16 text
+to the clipboard goes through the inverse path.  The reason for this
+two-pass decoding is to avoid subtle differences in Unicode mappings
+between the Mac OS system and Emacs such as various kinds of hyphens,
+and to minimize users' customization.  For example, users that mainly
+use Latin characters would prefer Greek characters to be decoded into
+the @code{mule-unicode-0100-24ff} charset, but Japanese users would
+prefer them to be decoded into the @code{japanese-jisx0208} charset.
+Since the coding system for selection is automatically set according
+to the system locale setting, users usually don't have to set it
+manually.
 
   The default language environment (@pxref{Language Environments}) is
 set according to the locale setting at the startup time.  On Mac OS,
--- a/man/org.texi	Thu Jan 05 14:02:59 2006 +0000
+++ b/man/org.texi	Fri Jan 06 16:13:05 2006 +0000
@@ -4,12 +4,13 @@
 @setfilename ../info/org
 @settitle Org Mode Manual
 
-@set VERSION 4.01
-@set DATE December 2005
+@set VERSION 4.02
+@set DATE January 2006
 
 @dircategory Emacs
 @direntry
-* Org Mode: (org).	outline-based notes management and organizer.
+* Org Mode: (org).	outline-based notes management and organizer
+
 @end direntry
 
 @c Version and Contact Info
@@ -35,7 +36,7 @@
 @copying
 This manual is for Org-mode (version @value{VERSION}).
 
-Copyright @copyright{} 2004, 2005 Free Software Foundation
+Copyright @copyright{} 2004, 2005, 2006 Free Software Foundation
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -105,7 +106,7 @@
 * Structure editing::           Changing sequence and level of headlines
 * Archiving::                   Move done task trees to a different place
 * Sparse trees::                Matches embedded in context
-* Tags::                        
+* Tags::                        Tagging headlines and matching sets of tags
 * Plain Lists::                 Editing hand-formatted lists
 
 Tables
@@ -152,17 +153,20 @@
 
 Agenda Views
 
-* Agenda::                      Your weekly planner
-* Global TODO list::            Overview over all things to do
-* Matching headline tags::      Select information based on tags
+* Agenda files::                Files being searched for agenda information
+* Agenda dispatcher::           Keyboard access to agenda views
+* Weekly/Daily Agenda::         The calendar page with current tasks
+* Global TODO list::            All infinished action items
+* Matching headline tags::      Structured information with fine-tuned search
 * Timeline::                    Time-sorted view for single file
 * Agenda commands::             Remote editing of org trees
+
+Weekly/Daily Agenda
+
+* Categories::                  Not all tasks are equal
+* Time-of-day specifications::  How the agenda knows the time
 * Calendar/Diary integration::  Integrating Anniversaries and more
-
-Calendar/Diary integration
-
-* Diary to agenda::             Agenda incorporates the diary
-* Agenda to diary::             Diary incorporates the agenda
+* Sorting of agenda items::     The order of things
 
 Exporting
 
@@ -333,7 +337,7 @@
 * Structure editing::           Changing sequence and level of headlines
 * Archiving::                   Move done task trees to a different place
 * Sparse trees::                Matches embedded in context
-* Tags::                        
+* Tags::                        Tagging headlines and matching sets of tags
 * Plain Lists::                 Editing hand-formatted lists
 @end menu
 
@@ -563,7 +567,8 @@
 @emph{sparse trees} for selected information in an outline tree.  A
 sparse tree means that the entire document is folded as much as
 possible, but the selected information is made visible along with the
-headline structure above it@footnote{See also the variable
+headline structure above it@footnote{See also the variables
+@code{org-show-hierarchy-above} and
 @code{org-show-following-heading}.}.  Just try it out and you will see
 immediately how it works.
 
@@ -581,8 +586,20 @@
 the match.  Each match is also highlighted, the highlights disappear
 when the buffer is changed with an editing command.
 @end table
-
-Other commands are using this feature as well.  For example @kbd{C-c
+@noindent
+For frequently used sparse trees of specific search strings, you can
+use the variable @code{org-agenda-custom-commands} to define fast
+keyboard access to specific sparse trees.  These commands will then be
+accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
+For example
+@lisp
+(setq org-agenda-custom-commands
+      '(("f" occur-tree "FIXME")))
+@end lisp
+@noindent will define the key @kbd{C-c a f} as a shortcut for creating
+a sparse tree matching the string @samp{FIXME}.
+
+Other commands are using sparse trees as well.  For example @kbd{C-c
 C-v} creates a sparse TODO tree (@pxref{TODO basics}).
 
 @kindex C-c C-x v
@@ -655,6 +672,11 @@
 @item C-c a m
 Create a global list of tag matches from all agenda files.
 @xref{Matching headline tags}.
+@kindex C-c a M
+@item C-c a M
+Create a global list of tag matches from all agenda files, but check
+only TODO items and force checking subitems (see variable
+@code{org-tags-match-list-sublevels}).
 @end table
 
 A tags search string can use Boolean operators @samp{&} for AND and
@@ -1650,7 +1672,7 @@
 @kindex C-c a t
 @item C-c a t
 Show the global TODO list.  This collects the TODO items from all
-agenda files (@pxref{Agenda}) into a single buffer.  The buffer is in
+agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
 @code{agenda-mode}, so there are commands to examine and manipulate
 the TODO entries directly from that buffer (@pxref{Agenda commands}).
 @xref{Global TODO list}, for more information.
@@ -1674,9 +1696,9 @@
 @samp{CLOSED: [timestamp]} will be inserted just after the headline.
 If you turn the entry back into a TODO item again through further
 state cycling, that line will be removed again.  In the timeline
-(@pxref{Timeline}) and in the agenda (@pxref{Agenda}), you can then
-use the @kbd{L} key to display the TODO items closed on each day,
-giving you an overview of what has been done on a day.
+(@pxref{Timeline}) and in the agenda (@pxref{Weekly/Daily Agenda}),
+you can then use the @kbd{L} key to display the TODO items closed on
+each day, giving you an overview of what has been done on a day.
 
 @node TODO extensions, Priorities, Progress Logging, TODO items
 @section Extended use of TODO keywords
@@ -1814,7 +1836,7 @@
 With its standard setup, Org-mode supports priorities @samp{A},
 @samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
 without a cookie is treated as priority @samp{B}.  Priorities make a
-difference only in the agenda (@pxref{Agenda}).
+difference only in the agenda (@pxref{Weekly/Daily Agenda}).
 
 @table @kbd
 @kindex @kbd{C-c ,}
@@ -1859,7 +1881,7 @@
 special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16
 Tue 09:39>}.  A time stamp can appear anywhere in the headline or body
 of an org-tree entry.  Its presence allows to show entries on specific
-dates in the agenda (@pxref{Agenda}).  We distinguish:
+dates in the agenda (@pxref{Weekly/Daily Agenda}).  We distinguish:
 
 @table @var
 @cindex timestamp
@@ -1944,7 +1966,7 @@
 @kindex C-c C-o
 @item C-c C-o
 Access the agenda for the date given by the time stamp at point
-(@pxref{Agenda}).
+(@pxref{Weekly/Daily Agenda}).
 
 @kindex C-c C-d
 @item C-c C-d
@@ -2035,16 +2057,52 @@
 @chapter Agenda Views
 @cindex agenda views
 
-Org-mode can select items based of various criteria, and display them
-in a separate buffer.  The information to be shown is collected from
-all @emph{agenda files}, the files listed in the variable
-@code{org-agenda-files}.  Thus even if you only work with a single
-Org-mode file, this file must be put into that list@footnote{When
-using the dispatcher pressing @kbd{1} before selecting a command will
-actually limit the command to the current file, and ignore
-@code{org-agenda-files} until the next dispatcher command.}.  You can
-customize @code{org-agenda-files}, but the easiest way to maintain it
-is through the following commands
+Due to the way Org-mode works, TODO items and time-stamped items can
+be scattered throughout a file or even a number of files.  To get an
+overview over open action items, or over events that are important for
+a particular date, this information must be collected, sorted and
+displayed in an organized way.
+
+Org-mode can select items based on various criteria, and display them
+in a separate buffer.  Three different views are provided:
+@itemize @bullet
+@item
+an @emph{agenda} that is like a calendar and shows information
+for specific dates
+@item
+a @emph{TODO list} that covers all unfinished
+action items, and
+@item
+a @emph{tags view} that shows information based on
+the tags associated with headlines in the outline tree.
+@end itemize
+@noindent
+The extracted information is displayed in a special @emph{agenda
+buffer}.  This buffer is read-only, but provides commands to visit the
+corresponding locations in the original Org-mode files, and even to
+edit these files remotely.
+
+@menu
+* Agenda files::                Files being searched for agenda information
+* Agenda dispatcher::           Keyboard access to agenda views
+* Weekly/Daily Agenda::         The calendar page with current tasks
+* Global TODO list::            All unfinished action items
+* Matching headline tags::      Structured information with fine-tuned search
+* Timeline::                    Time-sorted view for single file
+* Agenda commands::             Remote editing of org trees
+@end menu
+
+@node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
+@section Agenda files
+
+The information to be shown is collected from all @emph{agenda files},
+the files listed in the variable @code{org-agenda-files}.  Thus even
+if you only work with a single Org-mode file, this file should be put
+into that list@footnote{When using the dispatcher pressing @kbd{1}
+before selecting a command will actually limit the command to the
+current file, and ignore @code{org-agenda-files} until the next
+dispatcher command.}.  You can customize @code{org-agenda-files}, but
+the easiest way to maintain it is through the following commands
 
 @cindex files, adding to agenda list
 @table @kbd
@@ -2061,59 +2119,66 @@
 Cycle through agenda file list.
 @end table
 @noindent
-The Org menu always contains the current list of files and can be used
-to quickly visit any of them.
-
-Org-mode provides three different views on the information in these
-files: 
-@itemize @bullet
-@item
-an @emph{agenda} that is like a calendar and shows information
-for specific dates
-@item
-a @emph{TODO list} that covers all unfinished
-action items, and
-@item
-a @emph{tags view} that show information based on
-the tags associated with headlines in the outline tree.
-@end itemize
-@noindent
-The extracted information is displayed in a special @emph{agenda
-buffer}.  This buffer is read-only, but provides commands to visit the
-corresponding locations in the original Org-mode files, and even to
-edit these files remotely.
-
+The Org menu contains the current list of files and can be used
+to visit any of them.
+
+@node Agenda dispatcher, Weekly/Daily Agenda, Agenda files, Agenda Views
+@section The agenda dispatcher
+@cindex agenda dispatcher
+@cindex dispatching agenda commands
 @cindex custom agenda commands
 @cindex agenda commands, custom
 The views are created through a dispatcher that should be bound to a
 global key, for example @kbd{C-c a} (@pxref{Installation and
 Activation}).  In the following we will assume that @kbd{C-c a} is
 indeed how the dispatcher is accessed and list keyboard access to
-commands accordingly.  The dispatcher offers a number of default
-commands, for example to create a TODO list or a the calendar-like
-agenda.  You can also define a number of custom searches for tags and
-specific TODO keywords through the variable
-@code{org-agenda-custom-commands}.
+commands accordingly.  After pressing @kbd{C-c a}, an additional
+letter is required to execute a command.  The dispatcher offers the
+following default commands:
+@table @kbd
+@item a
+Create the calendar-like agenda (@pxref{Weekly/Daily Agenda}).
+@item t / T
+Create a list of all TODO items (@pxref{Global TODO list}).
+@item m / M
+Create a list of headline matching a TAGS expression (@pxref{Matching
+headline tags}).
+@end table
+
+You can also define custom commands that will be accessible through
+the dispatcher, just like the default commands.  Custom commands are
+global searches for tags and specific TODO keywords, or a variety of
+sparse tree creating commands (@pxref{Sparse trees}).  As sparse trees
+are only defined for a single org-mode file, these latter commands act
+on the current buffer instead of the list of agenda files.
+
 @kindex C-c a C
-These commands will be offered by the dispatcher just like the default
-commands.  If you press @kbd{C-c a C}, you will get a customization
-buffer for this variable.
-
-@menu
-* Agenda::                      Your weekly planner
-* Global TODO list::            Overview over all things to do
-* Matching headline tags::      Select information based on tags
-* Timeline::                    Time-sorted view for single file
-* Agenda commands::             Remote editing of org trees
-* Calendar/Diary integration::  Integrating Anniversaries and more
-@end menu
-
-@node Agenda, Global TODO list, Agenda Views, Agenda Views
-@section Agenda
+Custom commands are configured in the variable
+@code{org-agenda-custom-commands}.  You can customize this variable,
+for example by pressing @kbd{C-c a C}.  You can also directly set it
+with Emacs Lisp in @file{.emacs}.  For example:
+@lisp
+(setq org-agenda-custom-commands
+      '(("w" todo "WAITING")
+        ("u" tags "+BOSS-URGENT")
+        ("U" tags-tree "+BOSS-URGENT")
+        ("f" occur-tree "\\<FIXME\\>")))
+@end lisp
+@noindent will define @kbd{C-c a w} as a global search for
+TODO entries with @samp{WAITING} as todo keyword, @kbd{C-c a u} as a
+global tags search for headlines marked @samp{:BOSS:} but not
+@samp{:URGENT:}, @kbd{C-c a U} to do the same search but only in the
+current buffer and display the result as a sparse tree, and @kbd{C-c a
+f} to create a sparse tree with all entries containing the word
+@samp{FIXME}.  For more information, look at the documentation string
+of the variable @code{org-agenda-custom-commands}.
+
+@node Weekly/Daily Agenda, Global TODO list, Agenda dispatcher, Agenda Views
+@section The weekly/daily agenda
 @cindex agenda
 
-The purpose of the @emph{agenda} is to act like a week/day page of a
-paper agenda, showing you all the tasks for the current week or day.
+The purpose of the weekly/daily @emph{agenda} is to act like a page of
+a paper agenda, showing all the tasks for the current week or day.
 
 @table @kbd
 @cindex org-agenda, command
@@ -2124,8 +2189,6 @@
 when the variable @code{org-agenda-include-all-todo} is @code{t}), all
 unfinished TODO items (also those without a date) are also listed at
 the beginning of the buffer, before the first date.@*
-The key binding @kbd{C-c a a} is only a suggestion - see
-@ref{Installation and Activation}.
 @end table
 
 Remote editing from the agenda buffer means for example that you can
@@ -2133,7 +2196,14 @@
 The commands available in the Agenda buffer are listed in @ref{Agenda
 commands}.
 
-
+@menu
+* Categories::                  Not all tasks are equal
+* Time-of-day specifications::  How the agenda knows the time
+* Calendar/Diary integration::  Integrating Anniversaries and more
+* Sorting of agenda items::     The order of things
+@end menu
+
+@node Categories, Time-of-day specifications, Weekly/Daily Agenda, Weekly/Daily Agenda
 @subsection Categories
 
 @cindex category
@@ -2147,6 +2217,7 @@
 for the text below it.  The display in the agenda buffer looks best if
 the category is not longer than 10 characters.
 
+@node Time-of-day specifications, Calendar/Diary integration, Categories, Weekly/Daily Agenda
 @subsection Time-of-Day Specifications
 
 Org-mode checks each agenda item for a time-of-day specification.  The
@@ -2194,6 +2265,39 @@
 @code{org-agenda-time-grid}.
 
 
+@node Calendar/Diary integration, Sorting of agenda items, Time-of-day specifications, Weekly/Daily Agenda
+@subsection Calendar/Diary integration
+@cindex calendar integration
+@cindex diary integration
+
+Emacs contains the calendar and diary by Edward M. Reingold.  The
+calendar displays a three-month calendar with holidays from different
+countries and cultures.  The diary allows to keep track of
+anniversaries, lunar phases, sunrise/set, recurrent appointments
+(weekly, monthly) and more.  In this way, it is quite complementary to
+Org-mode.  It can be very useful to combine output from Org-mode with
+the diary.
+
+In order to include entries from the Emacs diary into Org-mode's
+agenda, you only need to customize the variable
+
+@lisp
+(setq org-agenda-include-diary t)
+@end lisp
+@noindent
+
+@noindent After that, everything will happen automatically.  All diary
+entries including holidays, anniversaries etc will be included in the
+agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
+@key{RET} can be used from the agenda buffer to jump to the diary
+file, in order to edit existing diary entries.  The @kbd{i} command to
+insert new entries for the current date works in the agenda buffer, as
+well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
+Sunrise/Sunset times, show lunar phases and to convert to other
+calendars, respectively.  @kbd{c} can be used to switch back and forth
+between calendar and agenda.
+
+@node Sorting of agenda items,  , Calendar/Diary integration, Weekly/Daily Agenda
 @subsection Sorting of agenda items
 @cindex sorting, of agenda items
 @cindex priorities, of agenda items
@@ -2211,7 +2315,8 @@
 Sorting can be customized using the variable
 @code{org-agenda-sorting-strategy}.
 
-@node Global TODO list, Matching headline tags, Agenda, Agenda Views
+
+@node Global TODO list, Matching headline tags, Weekly/Daily Agenda, Agenda Views
 @section The global TODO list
 @cindex global TODO list
 @cindex TODO list, global
@@ -2223,20 +2328,21 @@
 @kindex C-c a t
 @item C-c a t
 Show the global TODO list.  This collects the TODO items from all
-agenda files (@pxref{Agenda}) into a single buffer.  The buffer is in
+agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
 @code{agenda-mode}, so there are commands to examine and manipulate
 the TODO entries directly from that buffer (@pxref{Agenda commands}).
 @xref{Global TODO list}, for more information.
 @kindex C-c a T
 @item C-c a T
 Like the above, but allow to select a specific TODO keyword.  You can
-also do this by specifying a prefix argument.  With a @kbd{C-u} prefix
-you are prompted for a keyword.  With a numeric prefix, the Nth
-keyword in @code{org-todo-keywords} is selected.
+also do this by specifying a prefix argument to @kbd{C-c a t}.  With a
+@kbd{C-u} prefix you are prompted for a keyword.  With a numeric
+prefix, the Nth keyword in @code{org-todo-keywords} is selected.
 @kindex r
 The @kbd{r} key in the agenda buffer regenerates it, and you can give
 a prefix argument to this command to change the selected TODO keyword,
-for example @kbd{3 r}.
+for example @kbd{3 r}.  If you often need a search for a specific
+keyword, define a custom command for it (@pxref{Agenda dispatcher}).
 @end table
 
 Remote editing of TODO items means that you can change the state of a
@@ -2258,11 +2364,13 @@
 Produce a list of all headlines that match a given set of tags.  The
 command prompts for a selection criterion, which is a boolean logic
 expression with tags, like @samp{+WORK+URGENT-WITHBOSS} or
-@samp{WORK|HOME} (@pxref{Tags}).
+@samp{WORK|HOME} (@pxref{Tags}).  If you often need a specific search,
+define a custom command for it (@pxref{Agenda dispatcher}).
 @kindex C-c a M
 @item C-c a M
-Like @kbd{C-c a m}, but only select headlines that are also TODO
-items.
+Like @kbd{C-c a m}, but only select headlines that are also TODO items
+and force checking subitems (see variable
+@code{org-tags-match-list-sublevels}.
 @end table
 
 The commands available in the tags list are described in @ref{Agenda
@@ -2294,7 +2402,7 @@
 The commands available in the timeline buffer are listed in
 @ref{Agenda commands}.
 
-@node Agenda commands, Calendar/Diary integration, Timeline, Agenda Views
+@node Agenda commands,  , Timeline, Agenda Views
 @section Commands in the agenda buffer
 @cindex commands, in agenda buffer
 
@@ -2306,9 +2414,7 @@
 and you don't risk that your agenda and note files diverge.
 
 Some commands can be executed with mouse clicks on agenda lines.  For
-the other commands, the cursor needs to be in the desired line.  Most
-commands are available for both timelines and the agenda.  The
-exceptions are marked.
+the other commands, the cursor needs to be in the desired line.
 
 @table @kbd
 @tsubheading{Motion}
@@ -2384,12 +2490,11 @@
 @item @key{right}
 Display the following @code{org-agenda-ndays} days.  For example, if
 the display covers a week, switch to the following week.  With prefix
-arg, go forward that many times @code{org-agenda-ndays} days.  Not
-available in timelines.
+arg, go forward that many times @code{org-agenda-ndays} days.
 
 @kindex @key{left}
 @item @key{left}
-Display the previous dates.  Not available in timelines.
+Display the previous dates.
 
 @kindex .
 @item .
@@ -2491,7 +2596,6 @@
 @kindex C-c C-x C-c
 @item C-c C-x C-c
 Export a single iCalendar file containing entries from all agenda files.
-Not available in timelines.
 
 @tsubheading{Quit and Exit}
 @kindex q
@@ -2507,88 +2611,6 @@
 
 @end table
 
-@node Calendar/Diary integration,  , Agenda commands, Agenda Views
-@section Calendar/Diary integration
-@cindex calendar integration
-@cindex diary integration
-
-Emacs contains the calendar and diary by Edward M. Reingold.  The
-calendar displays a three-month calendar with holidays from different
-countries and cultures.  The diary allows to keep track of
-anniversaries, lunar phases, sunrise/set, recurrent appointments
-(weekly, monthly) and more.  In this way, it is quite complementary to
-Org-mode.  It can be very useful to combine output from Org-mode with
-the diary.
-
-The interaction between Org-mode and diary works both ways: You can
-list entries from the diary in the Org-mode agenda, from which many
-calendar and diary commands are directly accessible.  Or you can
-display entries from the org agenda in the Emacs diary.
-
-@menu
-* Diary to agenda::             Agenda incorporates the diary
-* Agenda to diary::             Diary incorporates the agenda
-@end menu
-
-@node Diary to agenda, Agenda to diary, Calendar/Diary integration, Calendar/Diary integration
-@subsection Including the diary into the agenda
-@cindex diary to agenda
-
-In order to include entries from the Emacs diary into Org-mode's
-agenda, you only need to customize the variable
-
-@lisp
-(setq org-agenda-include-diary t)
-@end lisp
-@noindent
-
-@noindent After that, everything will happen automatically.  All diary
-entries including holidays, anniversaries etc will be included in the
-agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
-@key{RET} can be used from the agenda buffer to jump to the diary
-file, in order to edit existing diary entries.  The @kbd{i} command to
-insert new entries for the current date works in the agenda buffer, as
-well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
-Sunrise/Sunset times, show lunar phases and to convert to other
-calendars, respectively.  @kbd{c} can be used to switch back and forth
-between calendar and agenda.
-
-@node Agenda to diary,  , Diary to agenda, Calendar/Diary integration
-@subsection Including the agenda into the diary
-@cindex agenda to diary
-
-If you prefer to use the Emacs diary as your main instrument and if
-you wish to include the Org-mode agenda into it, the following steps
-are necessary: Autoload the function @command{org-diary} as shown
-above under @ref{Installation and Activation}.  You also need to use
-@emph{fancy diary display} by setting in @file{.emacs}:
-
-@lisp
-(add-hook 'diary-display-hook 'fancy-diary-display)
-@end lisp
-
-Then include the following line into your @file{~/diary} file, in
-order to get the entries from all files listed in the variable
-@code{org-agenda-files}:
-
-@example
-&%%(org-diary)
-@end example
-@noindent
-You may also select specific files with
-
-@example
-&%%(org-diary) ~/path/to/some/org-file.org
-&%%(org-diary) ~/path/to/another/org-file.org
-@end example
-
-If you now launch the calendar and press @kbd{d} to display a diary,
-the headlines of entries containing a timestamp, date range, schedule,
-or deadline referring to the selected date will be listed.  Just like
-in Org-mode's agenda view, the diary for @emph{today} contains
-additional entries for overdue deadlines and scheduled items.  See
-also the documentation of the @command{org-diary} function.
-
 @node Exporting, Miscellaneous, Agenda Views, Top
 @chapter Exporting
 @cindex exporting
@@ -3021,6 +3043,42 @@
 The indentation of a table is set by the first line.  So just fix the
 indentation of the first line and realign with @key{TAB}.
 
+@item @b{Is it possible to include entries from org-mode files into my
+emacs diary?}@* 
+Since the org-mode agenda is much more powerful and can contain the
+diary (@pxref{Calendar/Diary integration}), you should think twice
+before deciding to do this.  Inegrating org-mode information into the
+diary is, however, possible.  The following steps are necessary:
+Autoload the function @command{org-diary} as shown above under
+@ref{Installation and Activation}.  You also need to use @emph{fancy
+diary display} by setting in @file{.emacs}:
+
+@lisp
+(add-hook 'diary-display-hook 'fancy-diary-display)
+@end lisp
+
+Then include the following line into your @file{~/diary} file, in
+order to get the entries from all files listed in the variable
+@code{org-agenda-files}:
+
+@example
+&%%(org-diary)
+@end example
+@noindent
+You may also select specific files with
+
+@example
+&%%(org-diary) ~/path/to/some/org-file.org
+&%%(org-diary) ~/path/to/another/org-file.org
+@end example
+
+If you now launch the calendar and press @kbd{d} to display a diary,
+the headlines of entries containing a timestamp, date range, schedule,
+or deadline referring to the selected date will be listed.  Just like
+in Org-mode's agenda view, the diary for @emph{today} contains
+additional entries for overdue deadlines and scheduled items.  See
+also the documentation of the @command{org-diary} function.
+
 @end enumerate
 
 
--- a/src/.gdbinit	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/.gdbinit	Fri Jan 06 16:13:05 2006 +0000
@@ -765,21 +765,39 @@
 #set args -geometry 80x40+0+0
 
 # People get bothered when they see messages about non-existent functions...
-echo \n
-echo  If you see messages below about functions not being defined,\n
-echo  don\'t worry about them.  Nothing is wrong.\n
-echo \n
+xgetptr Vsystem_type
+set $tem = (struct Lisp_Symbol *) $ptr
+xgetptr $tem->xname
+set $tem = (struct Lisp_String *) $ptr
+set $tem = (char *) $tem->data
 
-# Don't let abort actually run, as it will make
-# stdio stop working and therefore the `pr' command above as well.
-break abort
+# Don't let abort actually run, as it will make stdio stop working and
+# therefore the `pr' command above as well.
+if $tem[0] == 'w' && $tem[1] == 'i' && $tem[2] == 'n' && $tem[3] == 'd'
+  # The windows-nt build replaces abort with its own function.
+  break w32_abort
+else
+  break abort
+end
 
-# The MS-Windows build replaces abort with its own function.
-break w32_abort
-
-# If we are running in synchronous mode, we want a chance to look around
-# before Emacs exits.  Perhaps we should put the break somewhere else
-# instead...
-break x_error_quitter
-
+# x_error_quitter is defined only on X.  But window-system is set up
+# only at run time, during Emacs startup, so we need to defer setting
+# the breakpoint.  init_sys_modes is the first function called on
+# every platform after init_display, where window-system is set.
+tbreak init_sys_modes
+commands
+  silent
+  xgetptr Vwindow_system
+  set $tem = (struct Lisp_Symbol *) $ptr
+  xgetptr $tem->xname
+  set $tem = (struct Lisp_String *) $ptr
+  set $tem = (char *) $tem->data
+  # If we are running in synchronous mode, we want a chance to look
+  # around before Emacs exits.  Perhaps we should put the break
+  # somewhere else instead...
+  if $tem[0] == 'x' && $tem[1] == '\0'
+    break x_error_quitter
+  end
+  continue
+end
 # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe
--- a/src/ChangeLog	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/ChangeLog	Fri Jan 06 16:13:05 2006 +0000
@@ -1,3 +1,74 @@
+2006-01-06  Nick Roberts  <nickrob@snap.net.nz>
+
+	* .gdbinit: Fix typo.
+
+2006-01-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* .gdbinit: Fix last change.
+
+2006-01-05  Kim F. Storm  <storm@cua.dk>
+
+	* process.c (Fmake_network_process): Use AF_INET instead of
+	AF_UNSPEC when AF_INET6	is not defined.
+
+2006-01-05  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
+	Don't check that the other type is known file-related one.
+
+	* macfns.c (Fx_server_version): Use gestaltSystemVersionMajor,
+	gestaltSystemVersionMinor, and gestaltSystemVersionBugFix on Mac
+	OS X 10.4 and later.
+
+2006-01-04  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
+	let GTK do all image processing.  Importing Emacs own pixmaps to GTK
+	looks bad for inactive tool bar items with some Gnome themes.
+
+2006-01-04  Eli Zaretskii  <eliz@gnu.org>
+
+	* .gdbinit: Avoid a warning message when x_error_quitter is not
+	compiled in.
+
+	* process.c [WINDOWSNT]: Undef AF_INET6 to disable IPv6 support
+	for w32.
+
+2006-01-04  Kim F. Storm  <storm@cua.dk>
+
+	* process.c: Add IPv6 support.
+	(Qipv4, Qipv6): New vars.
+	(syms_of_process): Intern and staticpro them.
+	(Fformat_network_address): Handle 9 or 8 element vector as IPv6 address
+	with or without port number.  Handle 4 element vector as IPv4 address
+	without port number.
+	(conv_sockaddr_to_lisp, get_lisp_to_sockaddr_size)
+	(conv_lisp_to_sockaddr): Handle IPv6 addresses.
+	(Fmake_network_process): Use :family 'ipv4 and 'ipv6 to explicitly
+	request that address family only.  :family nil or omitted means to
+	determine address family from the specified :host and :service.
+	(ifflag_table): Add missing OpenBSD IFF_ flags.
+	(server_accept_connection): Handle IPv6 addresses.
+	(init_process): Add (:family ipv4) and (:family ipv6) sub-features.
+
+	* .gdbinit: Undo last change.  Instead, look at Vsystem_type to
+	determine which breakpoints to set.
+
+2006-01-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* keymap.c (describe_map_compare): Yet another int/Lisp_Object mixup.
+
+	* window.h (Fwindow_minibuffer_p): Declare (for use in minibuf.c).
+
+2006-01-03  Romain Francoise  <romain@orebokech.com>
+
+	* emacs.c (main): Update copyright year.
+
+2006-01-03  Ken Raeburn  <raeburn@gnu.org>
+
+	* callproc.c (delete_temp_file): Bind file-name-handler-alist to
+	nil for the call to internal_delete_file.
+
 2006-01-01  Ken Raeburn  <raeburn@gnu.org>
 
 	* callproc.c (Fcall_process_region): Bind file-name-handler-alist
@@ -48,7 +119,7 @@
 
 2005-12-28  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
-	* gtkutil.c (xg_get_file_with_chooser): Changed message shown
+	* gtkutil.c (xg_get_file_with_chooser): Change message shown
 	in file chooser.
 
 2005-12-27  Richard M. Stallman  <rms@gnu.org>
@@ -122,8 +193,8 @@
 	* macterm.h (TYPE_FILE_NAME): New define.
 	(posix_pathname_to_fsspec, fsspec_to_posix_pathname): Remove externs.
 
-	* mac.c (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
-	prototypes.  Make static.
+	* mac.c (posix_pathname_to_fsspec, fsspec_to_posix_pathname):
+	Add prototypes.  Make static.
 	(mac_aedesc_to_lisp): Initialize err to noErr.
 	(mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
 	(init_coercion_handler): New functions.
@@ -167,8 +238,8 @@
 	* macgui.h (XCharStruct): Remove member `valid_p'.
 	(STORE_XCHARSTRUCT): Don't set member `valid_p'.
 	(XCharStructRow): New typedef.
-	(XCHARSTRUCTROW_CHAR_VALID_P, XCHARSTRUCTROW_SET_CHAR_VALID): New
-	macros.
+	(XCHARSTRUCTROW_CHAR_VALID_P, XCHARSTRUCTROW_SET_CHAR_VALID):
+	New macros.
 	(struct MacFontStruct): Add member `bounds'.  Remove member
 	`per_char'.  All uses for QuichDraw Text fonts are changed to
 	`bounds.per_char'.  ATSUI font bounds are represented as an array
@@ -180,8 +251,8 @@
 	(mac_query_char_extents): New function.
 	(x_per_char_metric): Use it.
 	(XLoadQueryFont): Likewise.  Consolidate min/max_bounds calculations.
-	[USE_CG_TEXT_DRAWING] (mac_draw_string_cg): Use
-	mac_per_char_metric instead of x_per_char_metric.
+	[USE_CG_TEXT_DRAWING] (mac_draw_string_cg):
+	Use mac_per_char_metric instead of x_per_char_metric.
 	(mac_text_extents_16): New function.
 	(mac_compute_glyph_string_overhangs): Use it.
 	(mac_unload_font): Free member `bounds' in struct MacFontStruct.
@@ -435,11 +506,11 @@
 	[MAC_OS8] (main): Call init_apple_event_handler instead of
 	init_required_apple_events.
 	(mac_initialize) [MAC_OSX]: Likewise.
-	[!USE_CARBON_EVENTS] (mac_wait_next_event): Use
-	mac_ready_for_apple_events instead of Qmac_ready_for_drag_n_drop.
-
-	* macterm.h (mac_make_lispy_event_code, mac_aedesc_to_lisp): Add
-	externs.
+	[!USE_CARBON_EVENTS] (mac_wait_next_event):
+	Use mac_ready_for_apple_events instead of Qmac_ready_for_drag_n_drop.
+
+	* macterm.h (mac_make_lispy_event_code, mac_aedesc_to_lisp):
+	Add externs.
 	(create_apple_event_from_event_ref) [TARGET_API_MAC_CARBON]: Likewise.
 	(Fmac_get_preference): Add EXFUN.
 
@@ -479,11 +550,9 @@
 
 2005-12-06  Ken Raeburn  <raeburn@gnu.org>
 
-	* buffer.c (Fkill_buffer): Avoid dangerous side effects in NILP
-	argument.
+	* buffer.c (Fkill_buffer): Avoid dangerous side effects in NILP args.
 	* bytecode.c (Fbyte_code): Likewise.
-	* fileio.c (internal_delete_file, Fread_file_name_internal):
-	Likewise.
+	* fileio.c (internal_delete_file, Fread_file_name_internal): Likewise.
 	* minibuf.c (Fminibuffer_complete_and_exit): Likewise.
 	* undo.c (truncate_undo_list): Likewise.
 
--- a/src/callproc.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/callproc.c	Fri Jan 06 16:13:05 2006 +0000
@@ -1020,9 +1020,11 @@
 delete_temp_file (name)
      Lisp_Object name;
 {
-  /* Use Fdelete_file (indirectly) because that runs a file name handler.
-     We did that when writing the file, so we should do so when deleting.  */
+  /* Suppress jka-compr handling, etc.  */
+  int count = SPECPDL_INDEX ();
+  specbind (intern ("file-name-handler-alist"), Qnil);
   internal_delete_file (name);
+  unbind_to (count, Qnil);
   return Qnil;
 }
 
--- a/src/emacs.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/emacs.c	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 /* Fully extensible Emacs, running on Unix, intended for GNU.
    Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999,
-                 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+                 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -900,7 +900,7 @@
       else
 	{
 	  printf ("GNU Emacs %s\n", SDATA (tem));
-	  printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
+	  printf ("Copyright (C) 2006 Free Software Foundation, Inc.\n");
 	  printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
 	  printf ("You may redistribute copies of Emacs\n");
 	  printf ("under the terms of the GNU General Public License.\n");
--- a/src/gtkutil.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/gtkutil.c	Fri Jan 06 16:13:05 2006 +0000
@@ -322,43 +322,43 @@
   GdkPixmap *gmask;
   GdkDisplay *gdpy;
 
-  /* If we are on a one bit display, let GTK do all the image handling.
+  /* If we have a file, let GTK do all the image handling.
      This seems to be the only way to make insensitive and activated icons
-     look good.  */
-  if (x_screen_planes (f) == 1)
+     look good in all cases.  */
+  Lisp_Object specified_file = Qnil;
+  Lisp_Object tail;
+  extern Lisp_Object QCfile;
+
+  for (tail = XCDR (img->spec);
+       NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
+       tail = XCDR (XCDR (tail)))
+    if (EQ (XCAR (tail), QCfile))
+      specified_file = XCAR (XCDR (tail));
+
+  if (STRINGP (specified_file))
     {
-      Lisp_Object specified_file = Qnil;
-      Lisp_Object tail;
-      extern Lisp_Object QCfile;
-
-      for (tail = XCDR (img->spec);
-	   NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
-	   tail = XCDR (XCDR (tail)))
-	if (EQ (XCAR (tail), QCfile))
-	  specified_file = XCAR (XCDR (tail));
-
-	if (STRINGP (specified_file))
-	  {
-
-	    Lisp_Object file = Qnil;
-	    struct gcpro gcpro1;
-	    GCPRO1 (file);
-
-	    file = x_find_image_file (specified_file);
-	    /* We already loaded the image once before calling this
-	       function, so this should not fail.  */
-	    xassert (STRINGP (file) != 0);
-
-	    if (! old_widget)
-	      old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file)));
-	    else
-	      gtk_image_set_from_file (old_widget, SSDATA (file));
-
-	    UNGCPRO;
-	    return GTK_WIDGET (old_widget);
-	  }
+      Lisp_Object file = Qnil;
+      struct gcpro gcpro1;
+      GCPRO1 (file);
+
+      file = x_find_image_file (specified_file);
+      /* We already loaded the image once before calling this
+         function, so this should not fail.  */
+      xassert (STRINGP (file) != 0);
+
+      if (! old_widget)
+        old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file)));
+      else
+        gtk_image_set_from_file (old_widget, SSDATA (file));
+
+      UNGCPRO;
+      return GTK_WIDGET (old_widget);
     }
 
+  /* No file, do the image handling ourselves.  This will look very bad
+     on a monochrome display, and sometimes bad on all displays with
+     certain themes.  */
+
   gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
   gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
   gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
--- a/src/keymap.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/keymap.c	Fri Jan 06 16:13:05 2006 +0000
@@ -3189,8 +3189,8 @@
   if (INTEGERP (a->event) && !INTEGERP (b->event))
     return -1;
   if (SYMBOLP (a->event) && SYMBOLP (b->event))
-    return (Fstring_lessp (a->event, b->event) ? -1
-	    : Fstring_lessp (b->event, a->event) ? 1
+    return (!NILP (Fstring_lessp (a->event, b->event)) ? -1
+	    : !NILP (Fstring_lessp (b->event, a->event)) ? 1
 	    : 0);
   return 0;
 }
--- a/src/mac.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/mac.c	Fri Jan 06 16:13:05 2006 +0000
@@ -411,91 +411,73 @@
 {
   OSErr err;
 
-  if (type_code == TYPE_FILE_NAME)
+  if (type_code == typeNull)
+    err = errAECoercionFail;
+  else if (type_code == to_type || to_type == typeWildCard)
+    err = AECreateDesc (TYPE_FILE_NAME, data_ptr, data_size, result);
+  else if (type_code == TYPE_FILE_NAME)
     /* Coercion from undecoded file name.  */
-    switch (to_type)
-      {
-      case typeAlias:
-      case typeFSS:
-      case typeFSRef:
-#ifdef MAC_OSX
-      case typeFileURL:
-#endif
-	{
+    {
 #ifdef MAC_OSX
-	  CFStringRef str;
-	  CFURLRef url = NULL;
-	  CFDataRef data = NULL;
-
-	  str = CFStringCreateWithBytes (NULL, data_ptr, data_size,
-					 kCFStringEncodingUTF8, false);
-	  if (str)
-	    {
-	      url = CFURLCreateWithFileSystemPath (NULL, str,
-						   kCFURLPOSIXPathStyle, false);
-	      CFRelease (str);
-	    }
-	  if (url)
-	    {
-	      data = CFURLCreateData (NULL, url, kCFStringEncodingUTF8, true);
-	      CFRelease (url);
-	    }
-	  if (data)
-	    {
-	      err = AECoercePtr (typeFileURL, CFDataGetBytePtr (data),
-				 CFDataGetLength (data), to_type, result);
-	      CFRelease (data);
-	    }
-	else
-	  err = memFullErr;
+      CFStringRef str;
+      CFURLRef url = NULL;
+      CFDataRef data = NULL;
+
+      str = CFStringCreateWithBytes (NULL, data_ptr, data_size,
+				     kCFStringEncodingUTF8, false);
+      if (str)
+	{
+	  url = CFURLCreateWithFileSystemPath (NULL, str,
+					       kCFURLPOSIXPathStyle, false);
+	  CFRelease (str);
+	}
+      if (url)
+	{
+	  data = CFURLCreateData (NULL, url, kCFStringEncodingUTF8, true);
+	  CFRelease (url);
+	}
+      if (data)
+	{
+	  err = AECoercePtr (typeFileURL, CFDataGetBytePtr (data),
+			     CFDataGetLength (data), to_type, result);
+	  CFRelease (data);
+	}
+      else
+	err = memFullErr;
 #else
-	  FSSpec fs;
-	  char *buf;
-
-	  buf = xmalloc (data_size + 1);
-	  if (buf)
-	    {
-	      memcpy (buf, data_ptr, data_size);
-	      buf[data_size] = '\0';
-	      err = posix_pathname_to_fsspec (buf, &fs);
-	      xfree (buf);
-	    }
-	  else
-	    err = memFullErr;
-	  if (err == noErr)
-	    err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec),
-			       to_type, result);
+      FSSpec fs;
+      char *buf;
+
+      buf = xmalloc (data_size + 1);
+      if (buf)
+	{
+	  memcpy (buf, data_ptr, data_size);
+	  buf[data_size] = '\0';
+	  err = posix_pathname_to_fsspec (buf, &fs);
+	  xfree (buf);
+	}
+      else
+	err = memFullErr;
+      if (err == noErr)
+	err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
 #endif
-	}
-	break;
-
-      case TYPE_FILE_NAME:
-      case typeWildCard:
-	err = AECreateDesc (TYPE_FILE_NAME, data_ptr, data_size, result);
-	break;
-
-      default:
-	err = errAECoercionFail;
-	break;
-      }
+    }
   else if (to_type == TYPE_FILE_NAME)
     /* Coercion to undecoded file name.  */
-    switch (type_code)
-      {
-      case typeAlias:
-      case typeFSS:
-      case typeFSRef:
+    {
 #ifdef MAC_OSX
-      case typeFileURL:
-#endif
+      CFURLRef url = NULL;
+      CFStringRef str = NULL;
+      CFDataRef data = NULL;
+
+      if (type_code == typeFileURL)
+	url = CFURLCreateWithBytes (NULL, data_ptr, data_size,
+				    kCFStringEncodingUTF8, NULL);
+      else
 	{
 	  AEDesc desc;
-#ifdef MAC_OSX
 	  Size size;
 	  char *buf;
-	  CFURLRef url = NULL;
-	  CFStringRef str = NULL;
-	  CFDataRef data = NULL;
 
 	  err = AECoercePtr (type_code, data_ptr, data_size,
 			     typeFileURL, &desc);
@@ -513,33 +495,37 @@
 		}
 	      AEDisposeDesc (&desc);
 	    }
-	  if (url)
-	    {
-	      str = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
-	      CFRelease (url);
-	    }
-	  if (str)
-	    {
-	      data =
-		CFStringCreateExternalRepresentation (NULL, str,
-						      kCFStringEncodingUTF8,
-						      '\0');
-	      CFRelease (str);
-	    }
-	  if (data)
-	    {
-	      err = AECreateDesc (TYPE_FILE_NAME, CFDataGetBytePtr (data),
-				  CFDataGetLength (data), result);
-	      CFRelease (data);
-	    }
-	  else
-	    err = memFullErr;
+	}
+      if (url)
+	{
+	  str = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
+	  CFRelease (url);
+	}
+      if (str)
+	{
+	  data = CFStringCreateExternalRepresentation (NULL, str,
+						       kCFStringEncodingUTF8,
+						       '\0');
+	  CFRelease (str);
+	}
+      if (data)
+	{
+	  err = AECreateDesc (TYPE_FILE_NAME, CFDataGetBytePtr (data),
+			      CFDataGetLength (data), result);
+	  CFRelease (data);
+	}
 #else
+      char file_name[MAXPATHLEN];
+
+      if (type_code == typeFSS && data_size == sizeof (FSSpec))
+	err = fsspec_to_posix_pathname (data_ptr, file_name,
+					sizeof (file_name) - 1);
+      else
+	{
+	  AEDesc desc;
 	  FSSpec fs;
-	  char file_name[MAXPATHLEN];
-
-	  err = AECoercePtr (type_code, data_ptr, data_size,
-			     typeFSS, &desc);
+
+	  err = AECoercePtr (type_code, data_ptr, data_size, typeFSS, &desc);
 	  if (err == noErr)
 	    {
 #if TARGET_API_MAC_CARBON
@@ -550,19 +536,14 @@
 	      if (err == noErr)
 		err = fsspec_to_posix_pathname (&fs, file_name,
 						sizeof (file_name) - 1);
-	      if (err == noErr)
-		err = AECreateDesc (TYPE_FILE_NAME, file_name,
-				    strlen (file_name), result);
 	      AEDisposeDesc (&desc);
 	    }
+	}
+      if (err == noErr)
+	err = AECreateDesc (TYPE_FILE_NAME, file_name,
+			    strlen (file_name), result);
 #endif
-	}
-	break;
-
-      default:
-	err = errAECoercionFail;
-	break;
-      }
+    }
   else
     abort ();
 
@@ -581,31 +562,9 @@
   OSErr err = noErr;
   DescType from_type = from_desc->descriptorType;
 
-  if (from_type == TYPE_FILE_NAME)
-    {
-      if (to_type != TYPE_FILE_NAME && to_type != typeWildCard
-	  && to_type != typeAlias && to_type != typeFSS
-	  && to_type != typeFSRef
-#ifdef MAC_OSX
-	  && to_type != typeFileURL
-#endif
-	  )
-	return errAECoercionFail;
-    }
-  else if (to_type == TYPE_FILE_NAME)
-    {
-      if (from_type != typeAlias && from_type != typeFSS
-	  && from_type != typeFSRef
-#ifdef MAC_OSX
-	  && from_type != typeFileURL
-#endif
-	  )
-	return errAECoercionFail;
-    }
-  else
-    abort ();
-
-  if (from_type == to_type || to_type == typeWildCard)
+  if (from_type == typeNull)
+    err = errAECoercionFail;
+  else if (from_type == to_type || to_type == typeWildCard)
     err = AEDuplicateDesc (from_desc, result);
   else
     {
--- a/src/macfns.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/macfns.c	Fri Jan 06 16:13:05 2006 +0000
@@ -2880,24 +2880,37 @@
      (display)
      Lisp_Object display;
 {
-  int mac_major_version;
-  SInt32 response;
+  UInt32 response, major, minor, bugfix;
   OSErr err;
 
   BLOCK_INPUT;
   err = Gestalt (gestaltSystemVersion, &response);
+  if (err == noErr)
+    if (response >= 0x00001040)
+      {
+	err = Gestalt ('sys1', &major); /* gestaltSystemVersionMajor */
+	if (err == noErr)
+	  err = Gestalt ('sys2', &minor); /* gestaltSystemVersionMinor */
+	if (err == noErr)
+	  err = Gestalt ('sys3', &bugfix); /* gestaltSystemVersionBugFix */
+      }
+    else
+      {
+	bugfix = response & 0xf;
+	response >>= 4;
+	minor = response & 0xf;
+	response >>= 4;
+	/* convert BCD to int */
+	major = response - (response >> 4) * 6;
+      }
   UNBLOCK_INPUT;
 
   if (err != noErr)
     error ("Cannot get Mac OS version");
 
-  mac_major_version = (response >> 8) & 0xff;
-  /* convert BCD to int */
-  mac_major_version -= (mac_major_version >> 4) * 6;
-
-  return Fcons (make_number (mac_major_version),
-		Fcons (make_number ((response >> 4) & 0xf),
-		       Fcons (make_number (response & 0xf),
+  return Fcons (make_number (major),
+		Fcons (make_number (minor),
+		       Fcons (make_number (bugfix),
 			      Qnil)));
 }
 
--- a/src/process.c	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/process.c	Fri Jan 06 16:13:05 2006 +0000
@@ -118,6 +118,14 @@
 #include <sys/wait.h>
 #endif
 
+/* Disable IPv6 support for w32 until someone figures out how to do it
+   properly.  */
+#ifdef WINDOWSNT
+# ifdef AF_INET6
+#  undef AF_INET6
+# endif
+#endif
+
 #include "lisp.h"
 #include "systime.h"
 #include "systty.h"
@@ -140,7 +148,10 @@
 Lisp_Object Qprocessp;
 Lisp_Object Qrun, Qstop, Qsignal;
 Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten;
-Lisp_Object Qlocal, Qdatagram;
+Lisp_Object Qlocal, Qipv4, Qdatagram;
+#ifdef AF_INET6
+Lisp_Object Qipv6;
+#endif
 Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype;
 Lisp_Object QClocal, QCremote, QCcoding;
 Lisp_Object QCserver, QCnowait, QCnoquery, QCstop;
@@ -1195,9 +1206,11 @@
 DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
        1, 2, 0,
        doc: /* Convert network ADDRESS from internal format to a string.
+A 4 or 5 element vector represents an IPv4 address (with port number).
+An 8 or 9 element vector represents an IPv6 address (with port number).
 If optional second argument OMIT-PORT is non-nil, don't include a port
-number in the string; in this case, interpret a 4 element vector as an
-IP address.  Returns nil if format of ADDRESS is invalid.  */)
+number in the string, even when present in ADDRESS.
+Returns nil if format of ADDRESS is invalid.  */)
      (address, omit_port)
      Lisp_Object address, omit_port;
 {
@@ -1207,13 +1220,13 @@
   if (STRINGP (address))  /* AF_LOCAL */
     return address;
 
-  if (VECTORP (address))  /* AF_INET */
+  if (VECTORP (address))  /* AF_INET or AF_INET6 */
     {
       register struct Lisp_Vector *p = XVECTOR (address);
       Lisp_Object args[6];
       int nargs, i;
 
-      if (!NILP (omit_port) && (p->size == 4 || p->size == 5))
+      if (p->size == 4 || (p->size == 5 && !NILP (omit_port)))
 	{
 	  args[0] = build_string ("%d.%d.%d.%d");
 	  nargs = 4;
@@ -1223,6 +1236,16 @@
 	  args[0] = build_string ("%d.%d.%d.%d:%d");
 	  nargs = 5;
 	}
+      else if (p->size == 8 || (p->size == 9 && !NILP (omit_port)))
+	{
+	  args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x");
+	  nargs = 8;
+	}
+      else if (p->size == 9)
+	{
+	  args[0] = build_string ("[%x:%x:%x:%x:%x:%x:%x:%x]:%d");
+	  nargs = 9;
+	}
       else
 	return Qnil;
 
@@ -2212,6 +2235,20 @@
 	cp = (unsigned char *)&sin->sin_addr;
 	break;
       }
+#ifdef AF_INET6
+    case AF_INET6:
+      {
+	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
+	uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr;
+	len = sizeof (sin6->sin6_addr)/2 + 1;
+	address = Fmake_vector (make_number (len), Qnil);
+	p = XVECTOR (address);
+	p->contents[--len] = make_number (ntohs (sin6->sin6_port));
+	for (i = 0; i < len; i++)
+	  p->contents[i] = make_number (ntohs (ip6[i]));
+	return address;
+      }
+#endif
 #ifdef HAVE_LOCAL_SOCKETS
     case AF_LOCAL:
       {
@@ -2256,6 +2293,13 @@
 	  *familyp = AF_INET;
 	  return sizeof (struct sockaddr_in);
 	}
+#ifdef AF_INET6
+      else if (p->size == 9)
+	{
+	  *familyp = AF_INET6;
+	  return sizeof (struct sockaddr_in6);
+	}
+#endif
     }
 #ifdef HAVE_LOCAL_SOCKETS
   else if (STRINGP (address))
@@ -2302,6 +2346,23 @@
 	  sin->sin_port = htons (i);
 	  cp = (unsigned char *)&sin->sin_addr;
 	}
+#ifdef AF_INET6
+      else if (family == AF_INET6)
+	{
+	  struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
+	  uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr;
+	  len = sizeof (sin6->sin6_addr) + 1;
+	  i = XINT (p->contents[--len]);
+	  sin6->sin6_port = htons (i);
+	  for (i = 0; i < len; i++)
+	    if (INTEGERP (p->contents[i]))
+	      {
+		int j = XFASTINT (p->contents[i]) & 0xffff;
+		ip6[i] = ntohs (j);
+	      }
+	  return;
+	}
+#endif
     }
   else if (STRINGP (address))
     {
@@ -2595,10 +2656,13 @@
 stream type connection, `datagram' creates a datagram type connection.
 
 :family FAMILY -- FAMILY is the address (and protocol) family for the
-service specified by HOST and SERVICE.  The default address family is
-Inet (or IPv4) for the host and port number specified by HOST and
-SERVICE.  Other address families supported are:
+service specified by HOST and SERVICE.  The default (nil) is to use
+whatever address family (IPv4 or IPv6) that is defined for the host
+and port number specified by HOST and SERVICE.  Other address families
+supported are:
   local -- for a local (i.e. UNIX) address specified by SERVICE.
+  ipv4  -- use IPv4 address family only.
+  ipv6  -- use IPv6 address family only.
 
 :local ADDRESS -- ADDRESS is the local address used for the connection.
 This parameter is ignored when opening a client process. When specified
@@ -2715,8 +2779,8 @@
   struct Lisp_Process *p;
 #ifdef HAVE_GETADDRINFO
   struct addrinfo ai, *res, *lres;
-      struct addrinfo hints;
-      char *portstring, portbuf[128];
+  struct addrinfo hints;
+  char *portstring, portbuf[128];
 #else /* HAVE_GETADDRINFO */
   struct _emacs_addrinfo
   {
@@ -2855,19 +2919,29 @@
 
   /* :family FAMILY -- nil (for Inet), local, or integer.  */
   tem = Fplist_get (contact, QCfamily);
-  if (INTEGERP (tem))
+  if (NILP (tem))
+    {
+#if defined(HAVE_GETADDRINFO) && defined(AF_INET6)
+      family = AF_UNSPEC;
+#else
+      family = AF_INET;
+#endif
+    }
+#ifdef HAVE_LOCAL_SOCKETS
+  else if (EQ (tem, Qlocal))
+    family = AF_LOCAL;
+#endif
+#ifdef AF_INET6
+  else if (EQ (tem, Qipv6))
+    family = AF_INET6;
+#endif
+  else if (EQ (tem, Qipv4))
+    family = AF_INET;
+  else if (INTEGERP (tem))
     family = XINT (tem);
   else
-    {
-      if (NILP (tem))
-	family = AF_INET;
-#ifdef HAVE_LOCAL_SOCKETS
-      else if (EQ (tem, Qlocal))
-	family = AF_LOCAL;
-#endif
-    }
-  if (family < 0)
     error ("Unknown address family");
+
   ai.ai_family = family;
 
   /* :service SERVICE -- string, integer (port number), or t (random port).  */
@@ -2933,7 +3007,7 @@
       QUIT;
       memset (&hints, 0, sizeof (hints));
       hints.ai_flags = 0;
-      hints.ai_family = NILP (Fplist_member (contact, QCfamily)) ? AF_UNSPEC : family;
+      hints.ai_family = family;
       hints.ai_socktype = socktype;
       hints.ai_protocol = 0;
       ret = getaddrinfo (SDATA (host), portstring, &hints, &res);
@@ -3522,6 +3596,21 @@
 #ifdef IFF_DYNAMIC
   { IFF_DYNAMIC,	"dynamic" },
 #endif
+#ifdef IFF_OACTIV
+  { IFF_OACTIV,		"oactiv" },	/* OpenBSD: transmission in progress */
+#endif
+#ifdef IFF_SIMPLEX
+  { IFF_SIMPLEX,	"simplex" },	/* OpenBSD: can't hear own transmissions */
+#endif
+#ifdef IFF_LINK0
+  { IFF_LINK0,		"link0" },	/* OpenBSD: per link layer defined bit */
+#endif
+#ifdef IFF_LINK1
+  { IFF_LINK1,		"link1" },	/* OpenBSD: per link layer defined bit */
+#endif
+#ifdef IFF_LINK2
+  { IFF_LINK2,		"link2" },	/* OpenBSD: per link layer defined bit */
+#endif
   { 0, 0 }
 };
 
@@ -3816,6 +3905,9 @@
   union u_sockaddr {
     struct sockaddr sa;
     struct sockaddr_in in;
+#ifdef AF_INET6
+    struct sockaddr_in6 in6;
+#endif
 #ifdef HAVE_LOCAL_SOCKETS
     struct sockaddr_un un;
 #endif
@@ -3872,6 +3964,26 @@
       }
       break;
 
+#ifdef AF_INET6
+    case AF_INET6:
+      {
+	Lisp_Object args[9];
+	uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr;
+	int i;
+	args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x");
+	for (i = 0; i < 8; i++)
+	  args[i+1] = make_number (ntohs(ip6[i]));
+	host = Fformat (9, args);
+	service = make_number (ntohs (saddr.in.sin_port));
+
+	args[0] = build_string (" <[%s]:%d>");
+	args[1] = host;
+	args[2] = service;
+	caller = Fformat (3, args);
+      }
+      break;
+#endif
+
 #ifdef HAVE_LOCAL_SOCKETS
     case AF_LOCAL:
 #endif
@@ -6721,6 +6833,10 @@
 #ifdef HAVE_LOCAL_SOCKETS
    ADD_SUBFEATURE (QCfamily, Qlocal);
 #endif
+   ADD_SUBFEATURE (QCfamily, Qipv4);
+#ifdef AF_INET6
+   ADD_SUBFEATURE (QCfamily, Qipv6);
+#endif
 #ifdef HAVE_GETSOCKNAME
    ADD_SUBFEATURE (QCservice, Qt);
 #endif
@@ -6779,6 +6895,12 @@
   staticpro (&Qlisten);
   Qlocal = intern ("local");
   staticpro (&Qlocal);
+  Qipv4 = intern ("ipv4");
+  staticpro (&Qipv4);
+#ifdef AF_INET6
+  Qipv6 = intern ("ipv6");
+  staticpro (&Qipv6);
+#endif
   Qdatagram = intern ("datagram");
   staticpro (&Qdatagram);
 
--- a/src/window.h	Thu Jan 05 14:02:59 2006 +0000
+++ b/src/window.h	Fri Jan 06 16:13:05 2006 +0000
@@ -1,6 +1,6 @@
 /* Window definitions for GNU Emacs.
    Copyright (C) 1985, 1986, 1993, 1995, 1997, 1998, 1999, 2000, 2001,
-                 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+                 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -865,6 +865,7 @@
 
 EXFUN (Fwindow_end, 2);
 EXFUN (Fselected_window, 0);
+EXFUN (Fwindow_minibuffer_p, 1);
 EXFUN (Fdelete_window, 1);
 EXFUN (Fwindow_buffer, 1);
 EXFUN (Fget_buffer_window, 2);