changeset 91367:c70e45a7acfd

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-324
author Miles Bader <miles@gnu.org>
date Wed, 30 Jan 2008 07:57:28 +0000
parents 86f3a8f0a3a6 (current diff) eda73292b257 (diff)
children 928f0831d88b
files ChangeLog Makefile.in admin/FOR-RELEASE admin/make-tarball.txt configure configure.in doc/misc/cc-mode.texi etc/ChangeLog etc/MACHINES etc/NEWS etc/NEWS.22 etc/TODO leim/ChangeLog leim/quail/latin-ltx.el lib-src/ChangeLog lib-src/emacsclient.c lib-src/make-docfile.c lib-src/movemail.c lib-src/pop.c lisp/ChangeLog lisp/ChangeLog.12 lisp/ChangeLog.6 lisp/ChangeLog.unicode lisp/abbrev.el lisp/add-log.el lisp/allout.el lisp/ansi-color.el lisp/arc-mode.el lisp/button.el lisp/calendar/cal-menu.el lisp/comint.el lisp/cus-edit.el lisp/cus-start.el lisp/custom.el lisp/delsel.el lisp/diff-mode.el lisp/ediff-diff.el lisp/ediff-util.el lisp/ediff-wind.el lisp/ediff.el lisp/emacs-lisp/cl-loaddefs.el lisp/emacs-lisp/cl-macs.el lisp/emacs-lisp/easymenu.el lisp/emacs-lisp/find-func.el lisp/emulation/crisp.el lisp/emulation/tpu-edt.el lisp/emulation/viper-cmd.el lisp/emulation/viper-ex.el lisp/emulation/viper-keym.el lisp/emulation/viper-util.el lisp/emulation/viper.el lisp/ffap.el lisp/files.el lisp/frame.el lisp/fringe.el lisp/gnus/ChangeLog lisp/gnus/gnus-art.el lisp/gnus/gnus-group.el lisp/gnus/gnus-sum.el lisp/gnus/mail-source.el lisp/gnus/message.el lisp/gnus/mm-decode.el lisp/gnus/mml.el lisp/gnus/nnmail.el lisp/help.el lisp/ibuf-ext.el lisp/ibuffer.el lisp/icomplete.el lisp/ldefs-boot.el lisp/loadhist.el lisp/log-edit.el lisp/lpr.el lisp/ls-lisp.el lisp/mail/rmail.el lisp/mh-e/ChangeLog lisp/mh-e/mh-mime.el lisp/net/tramp.el lisp/net/trampver.el lisp/outline.el lisp/pcvs-defs.el lisp/pcvs.el lisp/play/blackbox.el lisp/progmodes/ada-mode.el lisp/progmodes/ada-xref.el lisp/progmodes/cc-awk.el lisp/progmodes/cc-cmds.el lisp/progmodes/cc-defs.el lisp/progmodes/cc-engine.el lisp/progmodes/cc-langs.el lisp/progmodes/cc-styles.el lisp/progmodes/cc-vars.el lisp/progmodes/compile.el lisp/progmodes/ebrowse.el lisp/progmodes/etags.el lisp/progmodes/f90.el lisp/progmodes/gdb-ui.el lisp/progmodes/hideif.el lisp/progmodes/pascal.el lisp/progmodes/python.el lisp/progmodes/sh-script.el lisp/progmodes/vhdl-mode.el lisp/repeat.el lisp/replace.el lisp/server.el lisp/smerge-mode.el lisp/subr.el lisp/tar-mode.el lisp/textmodes/bibtex.el lisp/textmodes/ispell.el lisp/textmodes/org-publish.el lisp/textmodes/org.el lisp/textmodes/reftex-index.el lisp/textmodes/reftex-toc.el lisp/textmodes/sgml-mode.el lisp/vc-arch.el lisp/vc-cvs.el lisp/vc-svn.el lisp/vc.el lisp/view.el lisp/whitespace.el lisp/winner.el lisp/woman.el make-dist nt/ChangeLog nt/gmake.defs src/.gdbinit src/ChangeLog src/ChangeLog.10 src/Makefile.in src/alloc.c src/buffer.c src/callproc.c src/coding.c src/config.in src/dispnew.c src/ecrt0.c src/emacs.c src/fileio.c src/fns.c src/frame.c src/getpagesize.h src/keyboard.c src/lisp.h src/lread.c src/m/amdx86-64.h src/m/intel386.h src/m/mips.h src/m/sequent-ptx.h src/m/sequent.h src/mac.c src/macterm.c src/macterm.h src/process.c src/puresize.h src/s/386-ix.h src/s/domain.h src/s/hpux9-x11r4.h src/s/hpux9shxr4.h src/s/irix3-3.h src/s/irix4-0.h src/s/ptx.h src/s/ptx4-2.h src/s/ptx4.h src/sysdep.c src/systty.h src/syswait.h src/terminal.c src/undo.c src/unexec.c src/unexsunos4.c src/w32.c src/window.c src/window.h src/xdisp.c src/xterm.c
diffstat 392 files changed, 17984 insertions(+), 10044 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,67 @@
+2008-01-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in (xtensa): Match more configurations.
+
+	* configure: Regenerate.
+
+2008-01-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in: Update comment.
+
+2008-01-26  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (--without-gcc): By default, neither off nor on.
+	(--with-carbon): Tone down rhetoric in help text.
+
+2008-01-25  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in: Correct usage of OPTION_DEFAULT_ON,
+	OPTION_DEFAULT_OFF so that the defaults are as they used to be.
+	Default `Carbon' to off (it's unsupported).
+
+2008-01-24  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in: Standardize dbus-related messages.
+
+2008-01-23  Michael Olson  <mwolson@gnu.org>
+
+	* configure.in (pkg-config-prog): Remove initial whitespace.
+
+2008-01-23  Tom Tromey  <tromey@redhat.com>
+
+	* configure.in (OPTION_DEFAULT_ON, OPTION_DEFAULT_OFF): New macros.
+	(EMACS_ARG_Y, EMACS_ARG_N): Remove.
+	Update all users.
+
+2008-01-21  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* config.guess, config.sub: Updated from master source.
+
+2008-01-17  Andreas Schwab  <schwab@suse.de>
+
+	* configure.in (HAVE_LIB64_DIR): Rename from HAVE_X86_64_LIB64_DIR.
+
+2008-01-17  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (HAVE_X86_64_LIB64_DIR): Also set on s390x systems.
+
+2008-01-16  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in: Remove more references to unsupported systems.
+
+2008-01-16  Sven Joachim  <svenjoac@gmx.de>
+
+	* make-dist: Add --lzma.
+
+2008-01-16  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (maybe_bootstrap): Remove texinfo message, since
+	configure checks for this.
+
+2008-01-13  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure.in: Remove more references to unsupported systems.
+
 2008-01-06  Romain Francoise  <romain@orebokech.com>
 
 	* configure.in: Delete extra semicolons.
--- a/Makefile.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/Makefile.in	Wed Jan 30 07:57:28 2008 +0000
@@ -802,7 +802,6 @@
 	if [ \( "$$bar" = '$(srcdir)/lisp/*.elc' \) -o \( "$$bar" = '' \) ]; then \
 	  echo "Your tree does not include the compiled Lisp files."; \
 	  echo "You need to do \`make bootstrap' to build Emacs."; \
-	  echo "Emacs now requires Texinfo version 4.2."; \
 	  exit 1;\
 	fi
 
--- a/admin/CPP-DEFINES	Wed Jan 30 06:40:42 2008 +0000
+++ b/admin/CPP-DEFINES	Wed Jan 30 07:57:28 2008 +0000
@@ -3,10 +3,9 @@
 
 ** Distinguishing OSes **
 
-MAC_OS		Compiling for some version of Mac OS?
-MAC_OS8		Compiling for Mac OS version 8.  Requires MAC_OS?
-MAC_OSX		Compiling for Mac OS X?  Is that also valid for Darwin?
-MAC_OS_X	??  Apparently only used once in mac.c.
+MAC_OS		Compiling for the `mac' window-system.
+MAC_OS8		Compiling for Mac OS Classic (v8 or v9).
+MAC_OSX		Compiling for Mac OS X.  Not bare Darwin.
 CYGWIN		Compiling the Cygwin port.
 __CYGWIN__	Ditto
 MSDOS		Compiling the MS-DOS port.
@@ -44,25 +43,9 @@
 SYSTEM_MALLOC	Use the system library's malloc.
 
 ** All references to these symbols should be removed, all their definitions are gone **
-ALLIANT
-ALLIANT_2800
-ALTOS
-APOLLO
-APOLLO_SR10
-RTU
-STRIDE
-UNIPLUS
-GOULD
+
 NU
-pyramid
-sps7
-tahoe
-tek4300
-__DGUX
-DGUX
 romp
-ibmrt 
-NEWSOS5
 
 ** Temporarily put defines from removed files here, check if these macros need to be documented or removed because they are not used anymore.  ** 
 
@@ -77,7 +60,6 @@
 BROKEN_FIONREAD
 BROKEN_SELECT_NON_X
 BROKEN_SIGIO
-BROKEN_START
 BROKEN_TIOCGETC
 BROKEN_TIOCGWINSZ
 BSD4_2
@@ -110,9 +92,6 @@
 DUMMIES
 EEOF
 ELF
-ERROR0
-ERROR1
-ERROR2
 EXEC_HDR_TYPE
 EXEC_MAGIC
 EXEC_PAGESIZE
@@ -122,6 +101,7 @@
 FREE_RETURN_TYPE
 FSCALE
 F_SETOWN_BUG
+F_SETOWN_SOCK_NEG
 GC_MARK_STACK
 GC_SETJMP_WORKS
 GETPGRP_NO_ARG
@@ -166,8 +146,6 @@
 IRIS_4D
 IRIX6_5
 IRIX_FORCE_32_BITS
-ISC4_0
-ISI68K
 KEEP_OLD_PADDR
 KEEP_OLD_TEXT_SCNPTR
 KERNEL_FILE
@@ -190,19 +168,15 @@
 LINKER
 LOAD_AVE_CVT
 LOAD_AVE_TYPE
-LONG_ALIGN
 L_SET
 MAIL_PROGRAM_NAME
 MAIL_USE_FLOCK
-MAKE_PARALLEL
 MAXNAMLEN
 MEMMOVE_MISSING
 MEMORY_IN_STRING_H
 MKDIR_PROTOTYPE
 MOTIF
-M_TERMINFO
 NARROWPROTO
-NBPC
 NEED_ERRNO
 NEED_NET_ERRNO_H
 NEED_PTEM_H
@@ -221,14 +195,13 @@
 NO_REMAP
 NO_SIOCTL_H
 NO_SOCKETS_IN_FILE_SYSTEM
+NO_SOCK_SIGIO
 NO_TERMIO
 NO_UNION_TYPE
+NO_UNION_TYPE
 NSIG
 NSIG_MINIMUM
 OBJECTS_MACHINE
-OLDXMENU_OPTIONS
-OLD_PROGRAM_H
-OLD_SECTION_H
 ORDINARY_LINK
 OSF1
 O_NDELAY
@@ -239,16 +212,12 @@
 POSIX_SIGNALS
 PREFER_VSUSP
 PTY_ITERATION
-PTY_MAJOR
-PTY_MINOR
 PTY_NAME_SPRINTF
 PTY_OPEN
 PTY_TTY_NAME_SPRINTF
 PURESIZE
 READ
 REL_ALLOC
-RISCiX
-RISCiX_1_1
 RUN_TIME_REMAP
 SECTION_ALIGNMENT
 SEEK
@@ -266,7 +235,6 @@
 SMAIL
 START_FILES
 SUNOS4
-SUNOS4_SHARED_LIBRARIES
 SUNOS_LOCALTIME_BUG
 SVR4
 SWITCH_ENUM_BUG
@@ -281,7 +249,6 @@
 S_IFMT
 S_IREAD
 S_IWRITE
-TAHOE_REGISTER_BUG
 TERMCAP
 TERMINFO
 TEXT_END
@@ -290,8 +257,6 @@
 THIS_IS_MAKEFILE
 TPIX
 ULIMIT_BREAK_VALUE
-UMAX
-UMAX4_2
 UNEXEC
 USE_DL_STUBS
 USE_GETOBAUD
@@ -303,20 +268,17 @@
 USG5_4
 USG_JOBCTRL
 USG_SHARED_LIBRARIES
-V3x
 VIRT_ADDR_VARIES
 WORDS_BIG_ENDIAN
 WORD_MACHINE
 WRITE
 X11R4
-XENIX
 XICCC
 XINT
 XSET
 XUINT
 X_DEFAULT_FONT
 _ABIN32
-_CX_UX
 _MIPS_SZLONG
 _POSIX_SOURCE
 __main
@@ -325,15 +287,10 @@
 _sobuf
 aix386
 alloca
-amdahl_uts
 aouthdr
-celerity
-clipper
-convex
 data_start
 drem
 dsize
-elxsi
 emacs
 entry
 etext
@@ -348,17 +305,12 @@
 longjmp
 m68000
 m68k
-m88k
 magic
 mc68000
 mips
-orion
 sel
 subprocesses
 sun
-sun_68881
-sun_fpa
-sun_soft
 text_start
 
 # arch-tag: bc80061a-1168-4911-9766-46aaf2640250
--- a/admin/FOR-RELEASE	Wed Jan 30 06:40:42 2008 +0000
+++ b/admin/FOR-RELEASE	Wed Jan 30 07:57:28 2008 +0000
@@ -96,29 +96,23 @@
 
 ** sdl.web@gmail.com, 30 Oct: ps-lpr-switches has no effect
 
-** Stephen.Berman@gmx.net: minibuffer and current-local-map
-
 ** timh@insightful.com, 9 Nov: X-coding-system incompatibility, and workaround
 
-** Get rid of old-style backquotes in cc-vars.el.
-ttn has a patch:
-http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg02052.html
-
-** Fix or document the shortcoming of easymenu and :suffix.
-http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01857.html
-
 ** Fix problem with mode-name in SGML mode.
 If mode-name stays non-string, add NEWS entry and doc fix.
 http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg02048.html
 
-** pot@gnu.org, 17 Dec: strange From line maker rmail-reply loop
-
 ** multi-tty does not work correctly.
 If the server is started from a tty frame and emacsclient creates an
 X11 frame, the tty frame gets confused, it thinks it is an X11 frame
 when trying to do a C-z.  This worked with server.el version 1.136, it
 broke after that.
 http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00545.html
+Also emacsclient does not work on Windows, it also worked with
+server.el version 1.136.
+http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg00710.html
+
+
 
 * DOCUMENTATION
 
--- a/admin/make-tarball.txt	Wed Jan 30 06:40:42 2008 +0000
+++ b/admin/make-tarball.txt	Wed Jan 30 07:57:28 2008 +0000
@@ -21,8 +21,8 @@
 
 5.   rm configure; make bootstrap
 
-6.  Commit configure, README, etc/AUTHORS, lisp/finder-inf.el,
-    lisp/version.el, man/emacs.texi, lispref/elisp.texi,
+6.  Commit configure, README, doc/emacs/emacs.texi,
+    doc/lispref/elisp.texi, etc/AUTHORS, lisp/version.el,    
     mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings,
     mac/src/Emacs.r, nt/emacs.rc.  Copy lisp/loaddefs.el to
     lisp/ldefs-boot.el and commit lisp/ldefs-boot.el.  For a release,
@@ -73,9 +73,9 @@
     ftp://alpha.gnu.org/gnu/emacs/pretest/ for a pretest, at
     ftp://ftp.gnu.org/gnu/emacs/ for a release.
 
-14. For a pretest, let Richard Stallman <rms@gnu.org> know about the new pretest and
-    tell him to announce it using the announcement you prepared.  Remind
-    him to set a Reply-to header to <emacs-pretest-bug@gnu.org>.
+14. For a pretest, let Richard Stallman <rms@gnu.org> know about the new
+    pretest and tell him to announce it using the announcement you prepared.
+    Remind him to set a Reply-to header to <emacs-pretest-bug@gnu.org>.
 
 15. Shortly before the release, cut the branch with the following commands:
 
--- a/admin/notes/lel-TODO	Wed Jan 30 06:40:42 2008 +0000
+++ b/admin/notes/lel-TODO	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,7 @@
 Some lisp/emacs-lisp/ Features and Where They Are Documented
-Copyright (C) 2007 Free Software Foundation, Inc.
+
+Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+See the end of the file for license conditions.
 
 
 * Status Key
@@ -102,6 +104,24 @@
 
 
 * Etc
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
   Local variables:
   mode: outline
   End:
--- a/admin/notes/multi-tty	Wed Jan 30 06:40:42 2008 +0000
+++ b/admin/notes/multi-tty	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,8 @@
 -*- coding: utf-8; mode: text; -*-
 
+Copyright (C) 2007, 2008  Free Software Foundation, Inc.
+See the end of the file for license conditions.
+
 From README.multi-tty in the multi-tty branch.
 Some of this information may be out of date.
 
--- a/config.guess	Wed Jan 30 06:40:42 2008 +0000
+++ b/config.guess	Wed Jan 30 07:57:28 2008 +0000
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-#                 2002, 2003, 2004, 2005, 2006, 2007
-#                 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2007-02-26'
+timestamp='2008-01-08'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -56,8 +56,8 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -330,7 +330,7 @@
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
-    i86pc:SunOS:5.*:*)
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
@@ -532,7 +532,7 @@
 		echo rs6000-ibm-aix3.2
 	fi
 	exit ;;
-    *:AIX:*:[45])
+    *:AIX:*:[456])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
@@ -791,12 +791,18 @@
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
-    x86:Interix*:[3456]*)
-	echo i586-pc-interix${UNAME_RELEASE}
-	exit ;;
-    EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*)
-	echo x86_64-unknown-interix${UNAME_RELEASE}
-	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
 	echo i${UNAME_MACHINE}-pc-mks
 	exit ;;
@@ -830,7 +836,14 @@
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
     arm*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
 	exit ;;
     avr32*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -951,8 +964,8 @@
     x86_64:Linux:*:*)
 	echo x86_64-unknown-linux-gnu
 	exit ;;
-    xtensa:Linux:*:*)
-    	echo xtensa-unknown-linux-gnu
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     i*86:Linux:*:*)
 	# The BFD linker knows what the default object file format is, so
--- a/config.sub	Wed Jan 30 06:40:42 2008 +0000
+++ b/config.sub	Wed Jan 30 07:57:28 2008 +0000
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-#                 2002, 2003, 2004, 2005, 2006, 2007
-#                 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2007-02-26'
+timestamp='2008-01-16'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -72,8 +72,8 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -369,10 +369,14 @@
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
-	| xstormy16-* | xtensa-* \
+	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| z8k-*)
 		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
 	386bsd)
@@ -443,6 +447,14 @@
 		basic_machine=ns32k-sequent
 		os=-dynix
 		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	c90)
 		basic_machine=c90-cray
 		os=-unicos
@@ -475,8 +487,8 @@
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16c)
-		basic_machine=cr16c-unknown
+	cr16)
+		basic_machine=cr16-unknown
 		os=-elf
 		;;
 	crds | unos)
@@ -668,6 +680,14 @@
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	m88k-omron*)
 		basic_machine=m88k-omron
 		;;
@@ -683,6 +703,10 @@
 		basic_machine=i386-pc
 		os=-mingw32
 		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
@@ -809,6 +833,14 @@
 		basic_machine=i860-intel
 		os=-osf
 		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	pbd)
 		basic_machine=sparc-tti
 		;;
@@ -1017,6 +1049,10 @@
 		basic_machine=tic6x-unknown
 		os=-coff
 		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
 	tx39)
 		basic_machine=mipstx39-unknown
 		;;
--- a/configure	Wed Jan 30 06:40:42 2008 +0000
+++ b/configure	Wed Jan 30 07:57:28 2008 +0000
@@ -1345,7 +1345,7 @@
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --without-gcc           don't use GCC to compile Emacs if GCC is found
+  --without-gcc           don't use GCC to compile Emacs even if GCC is found
   --without-pop           don't support POP mail retrieval with movemail
   --with-kerberos         support Kerberos-authenticated POP
   --with-kerberos5        support Kerberos version 5 authenticated POP
@@ -1353,25 +1353,27 @@
   --without-sound         don't compile with sound support
   --with-x-toolkit=KIT    use an X toolkit (KIT one of: yes, lucid, athena,
                           motif, gtk, no)
-  --with-xpm              use -lXpm for displaying XPM images
-  --with-jpeg             use -ljpeg for displaying JPEG images
-  --with-tiff             use -ltiff for displaying TIFF images
-  --with-gif              use -lgif (or -lungif) for displaying GIF images
-  --with-png              use -lpng for displaying PNG images
+  --without-xpm           don't compile with XPM image support
+  --without-jpeg          don't compile with JPEG image support
+  --without-tiff          don't compile with TIFF image support
+  --without-gif           don't compile with GIF image support
+  --without-png           don't compile with PNG image support
+  --without-rsvg          don't compile with SVG image support
   --with-freetype         use -lfreetype for local fonts support
   --with-xft              use -lXft for anti aliased fonts
-  --with-gpm              use -lgpm for mouse support on a GNU/Linux console
-  --with-rsvg             use -lrsvg-2 for displaying SVG images
-  --with-gtk              use GTK (same as --with-x-toolkit=gtk)
-  --with-pkg-config-prog  Path to pkg-config for finding GTK and librsvg
+  --without-libotf        don't use libotf for OpenType font support
+  --without-m17n-flt      don't use m17n-flt for text shaping
+  --with-gtk              use GTK toolkit
   --without-toolkit-scroll-bars
                           don't use Motif or Xaw3d scroll bars
   --without-xaw3d         don't use Xaw3d
   --without-xim           don't use X11 XIM
-  --without-carbon        don't use Carbon GUI on Mac OS X
-  --with-dbus             use D-Bus
-  --without-libotf        don't use libotf for OpenType font support
-  --without-m17n-flt      don't use m17n-flt for text shaping
+  --with-carbon           use Carbon GUI on Mac OS X. This is unsupported!
+  --without-gpm           don't use -lgpm for mouse support on a GNU/Linux
+                          console
+  --with-dbus             compile with D-Bus support
+  --with-pkg-config-prog=PATH
+                          Path to pkg-config for finding GTK and librsvg
   --with-x                use the X Window System
 
 Some influential environment variables:
@@ -1849,6 +1851,7 @@
 
 
 
+
 # Check whether --with-gcc was given.
 if test "${with_gcc+set}" = set; then
   withval=$with_gcc;
@@ -1858,40 +1861,45 @@
 
 # Check whether --with-pop was given.
 if test "${with_pop+set}" = set; then
-  withval=$with_pop; if test "$withval" = yes; then
+  withval=$with_pop;
+else
+     with_pop=yes
+fi
+
+if test "$with_pop" = yes; then
    cat >>confdefs.h <<\_ACEOF
 #define MAIL_USE_POP 1
 _ACEOF
 
-else :
-fi
-else
-  cat >>confdefs.h <<\_ACEOF
-#define MAIL_USE_POP 1
-_ACEOF
-
-fi
-
+fi
 
 
 
 # Check whether --with-kerberos was given.
 if test "${with_kerberos+set}" = set; then
-  withval=$with_kerberos; if test "$withval" = yes; then
+  withval=$with_kerberos;
+else
+      with_kerberos=no
+fi
+
+if test "$with_kerberos" = yes; then
    cat >>confdefs.h <<\_ACEOF
 #define KERBEROS 1
 _ACEOF
 
 fi
-fi
-
 
 
 
 # Check whether --with-kerberos5 was given.
 if test "${with_kerberos5+set}" = set; then
-  withval=$with_kerberos5; if test "${with_kerberos5+set}" = set; then
-  if test "${with_kerberos+set}" != set; then
+  withval=$with_kerberos5;
+else
+      with_kerberos5=no
+fi
+
+if test "${with_kerberos5}" = yes; then
+  if test "${with_kerberos}" != yes; then
     with_kerberos=yes
     cat >>confdefs.h <<\_ACEOF
 #define KERBEROS 1
@@ -1904,26 +1912,29 @@
 _ACEOF
 
 fi
-fi
-
 
 
 # Check whether --with-hesiod was given.
 if test "${with_hesiod+set}" = set; then
-  withval=$with_hesiod; if test "$withval" = yes; then
+  withval=$with_hesiod;
+else
+      with_hesiod=no
+fi
+
+if test "$with_hesiod" = yes; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HESIOD 1
 _ACEOF
 
 fi
-fi
-
 
 
 # Check whether --with-sound was given.
 if test "${with_sound+set}" = set; then
   withval=$with_sound;
+else
+     with_sound=yes
 fi
 
 
@@ -1956,110 +1967,153 @@
 # Check whether --with-xpm was given.
 if test "${with_xpm+set}" = set; then
   withval=$with_xpm;
+else
+     with_xpm=yes
 fi
 
 
 # Check whether --with-jpeg was given.
 if test "${with_jpeg+set}" = set; then
   withval=$with_jpeg;
+else
+     with_jpeg=yes
 fi
 
 
 # Check whether --with-tiff was given.
 if test "${with_tiff+set}" = set; then
   withval=$with_tiff;
+else
+     with_tiff=yes
 fi
 
 
 # Check whether --with-gif was given.
 if test "${with_gif+set}" = set; then
   withval=$with_gif;
+else
+     with_gif=yes
 fi
 
 
 # Check whether --with-png was given.
 if test "${with_png+set}" = set; then
   withval=$with_png;
-fi
-
-
-# Check whether --with-freetype was given.
-if test "${with_freetype+set}" = set; then
-  withval=$with_freetype;
-fi
-
-
-# Check whether --with-xft was given.
-if test "${with_xft+set}" = set; then
-  withval=$with_xft;
-fi
-
-
-# Check whether --with-gpm was given.
-if test "${with_gpm+set}" = set; then
-  withval=$with_gpm;
+else
+     with_png=yes
 fi
 
 
 # Check whether --with-rsvg was given.
 if test "${with_rsvg+set}" = set; then
   withval=$with_rsvg;
-fi
+else
+     with_rsvg=yes
+fi
+
+
+
+# Check whether --with-freetype was given.
+if test "${with_freetype+set}" = set; then
+  withval=$with_freetype;
+else
+      with_freetype=no
+fi
+
+
+# Check whether --with-xft was given.
+if test "${with_xft+set}" = set; then
+  withval=$with_xft;
+else
+      with_xft=no
+fi
+
+
+# Check whether --with-libotf was given.
+if test "${with_libotf+set}" = set; then
+  withval=$with_libotf;
+else
+     with_libotf=yes
+fi
+
+
+# Check whether --with-m17n-flt was given.
+if test "${with_m17n_flt+set}" = set; then
+  withval=$with_m17n_flt;
+else
+     with_m17n_flt=yes
+fi
+
 
 
 # Check whether --with-gtk was given.
 if test "${with_gtk+set}" = set; then
   withval=$with_gtk;
-fi
-
-
-# Check whether --with-pkg-config-prog was given.
-if test "${with_pkg_config_prog+set}" = set; then
-  withval=$with_pkg_config_prog;
+else
+      with_gtk=no
 fi
 
 
 # Check whether --with-toolkit-scroll-bars was given.
 if test "${with_toolkit_scroll_bars+set}" = set; then
   withval=$with_toolkit_scroll_bars;
+else
+     with_toolkit_scroll_bars=yes
 fi
 
 
 # Check whether --with-xaw3d was given.
 if test "${with_xaw3d+set}" = set; then
   withval=$with_xaw3d;
+else
+     with_xaw3d=yes
 fi
 
 
 # Check whether --with-xim was given.
 if test "${with_xim+set}" = set; then
   withval=$with_xim;
+else
+     with_xim=yes
 fi
 
 
 # Check whether --with-carbon was given.
 if test "${with_carbon+set}" = set; then
   withval=$with_carbon;
+else
+      with_carbon=no
+fi
+
+
+
+# Check whether --with-gpm was given.
+if test "${with_gpm+set}" = set; then
+  withval=$with_gpm;
+else
+     with_gpm=yes
 fi
 
 
 # Check whether --with-dbus was given.
 if test "${with_dbus+set}" = set; then
   withval=$with_dbus;
-fi
-
-
-# Check whether --with-libotf was given.
-if test "${with_libotf+set}" = set; then
-  withval=$with_libotf;
-fi
-
-
-# Check whether --with-m17n-flt was given.
-if test "${with_m17n_flt+set}" = set; then
-  withval=$with_m17n_flt;
-fi
-
+else
+      with_dbus=no
+fi
+
+
+
+# Check whether --with-pkg-config-prog was given.
+if test "${with_pkg_config_prog+set}" = set; then
+  withval=$with_pkg_config_prog;
+fi
+
+if test "X${with_pkg_config_prog}" != X; then
+   if test "${with_pkg_config_prog}" != yes; then
+      PKG_CONFIG="${with_pkg_config_prog}"
+   fi
+fi
 
 # Check whether --enable-carbon-app was given.
 if test "${enable_carbon_app+set}" = set; then
@@ -2280,8 +2334,8 @@
 ### based on the machine portion of the configuration name, and an s-
 ### file based on the operating system portion.  However, it turns out
 ### that each m/*.h file is pretty manufacturer-specific - for
-### example, apollo.h, hp9000s300.h, mega68k, news.h, and tad68k are
-### all 68000 machines; mips.h, pmax.h, and news-risc are all MIPS
+### example hp9000s300.h is a 68000 machine;
+### mips.h, pmax.h are all MIPS
 ### machines.  So we basically have to have a special case for each
 ### configuration name.
 ###
@@ -2344,14 +2398,12 @@
       mips-*-netbsd*)	machine=pmax ;;
       mipsel-*-netbsd*)	machine=pmax ;;
       mipseb-*-netbsd*)	machine=pmax ;;
-      ns32k-*-netbsd*)	machine=ns32000 ;;
       powerpc-*-netbsd*) machine=macppc ;;
       sparc*-*-netbsd*)	machine=sparc ;;
       vax-*-netbsd*)	machine=vax ;;
       arm-*-netbsd*)	machine=arm ;;
       x86_64-*-netbsd*)	machine=amdx86-64 ;;
       hppa-*-netbsd*)	machine=hp800 ;;
-      shle-*-netbsd*)	machine=sh3el ;;
     esac
   ;;
 
@@ -2364,10 +2416,8 @@
       hppa-*-openbsd*)         machine=hp9000s300 ;;
       i386-*-openbsd*)         machine=intel386 ;;
       m68k-*-openbsd*)         machine=hp9000s300 ;;
-      m88k-*-openbsd*)         machine=aviion ;;
       mips64-*-openbsd*)       machine=mips64 ;;
       powerpc-*-openbsd*)      machine=macppc ;;
-      sh-*-openbsd*)           machine=sh3el ;;
       sparc*-*-openbsd*)       machine=sparc ;;
       vax-*-openbsd*)          machine=vax ;;
       x86_64-*-openbsd*)       machine=amdx86-64 ;;
@@ -2383,16 +2433,6 @@
     esac
   ;;
 
-  ## Acorn RISCiX:
-  arm-acorn-riscix1.1* )
-    machine=acorn opsys=riscix1-1
-  ;;
-  arm-acorn-riscix1.2* | arm-acorn-riscix )
-    ## This name is riscix12 instead of riscix1.2
-    ## to avoid a file name conflict on MSDOS.
-    machine=acorn opsys=riscix12
-  ;;
-
   ## BSDI ports
   *-*-bsdi* )
     opsys=bsdi
@@ -2410,19 +2450,6 @@
     esac
   ;;
 
-  ## Alliant machines
-  ## Strictly speaking, we need the version of the alliant operating
-  ## system to choose the right machine file, but currently the
-  ## configuration name doesn't tell us enough to choose the right
-  ## one; we need to give alliants their own operating system name to
-  ## do this right.  When someone cares, they can help us.
-  fx80-alliant-* )
-    machine=alliant4 opsys=bsd4-2
-  ;;
-  i860-alliant-* )
-    machine=alliant-2800 opsys=bsd4-3
-  ;;
-
   ## Alpha (DEC) machines.
   alpha*-dec-osf* )
     machine=alpha opsys=osf1
@@ -2448,21 +2475,6 @@
     machine=arm opsys=gnu-linux
   ;;
 
-  ## Altos 3068
-  m68*-altos-sysv* )
-    machine=altos opsys=usg5-2
-  ;;
-
-  ## Amdahl UTS
-  580-amdahl-sysv* )
-    machine=amdahl opsys=usg5-2-2
-  ;;
-
-  ## Apollo, Domain/OS
-  m68*-apollo-* )
-    machine=apollo opsys=bsd4-3
-  ;;
-
   ## Apple Darwin / Mac OS X
   *-apple-darwin* )
     case "${canonical}" in
@@ -2481,101 +2493,16 @@
     fi
   ;;
 
-  ## AT&T 3b2, 3b5, 3b15, 3b20
-  we32k-att-sysv* )
-    machine=att3b opsys=usg5-2-2
-  ;;
-
-  ## AT&T 3b1 - The Mighty Unix PC!
-  m68*-att-sysv* )
-    machine=7300 opsys=usg5-2-2
-  ;;
-
-  ## Bull dpx20
-  rs6000-bull-bosx* )
-    machine=ibmrs6000 opsys=aix3-2
-  ;;
-
-  ## Bull dpx2
-  m68*-bull-sysv3* )
-    machine=dpx2 opsys=usg5-3
-  ;;
-
-  ## Bull sps7
-  m68*-bull-sysv2* )
-    machine=sps7 opsys=usg5-2
-  ;;
-
-  ## CCI 5/32, 6/32 -- see "Tahoe".
-
-  ## Celerity
-  ## I don't know what configuration name to use for this; config.sub
-  ## doesn't seem to know anything about it.  Hey, Celerity users, get
-  ## in touch with us!
-  celerity-celerity-bsd* )
-    machine=celerity opsys=bsd4-2
-  ;;
-
-  ## Clipper
-  ## What operating systems does this chip run that Emacs has been
-  ## tested on?
-  clipper-* )
-    machine=clipper
-    ## We'll use the catch-all code at the bottom to guess the
-    ## operating system.
-  ;;
-
   ## Compaq Nonstop
   mips-compaq-nonstopux* )
     machine=nonstopux opsys=nonstopux
     ;;
 
-  ## Convex
-  *-convex-bsd* | *-convex-convexos* )
-    machine=convex opsys=bsd4-3
-    ## Prevents spurious white space in makefiles - d.m.cooke@larc.nasa.gov
-    NON_GNU_CPP="cc -E -P"
-  ;;
-
   ## Cubix QBx/386
   i[3456]86-cubix-sysv* )
     machine=intel386 opsys=usg5-3
   ;;
 
-  ## Cydra 5
-  cydra*-cydrome-sysv* )
-    machine=cydra5 opsys=usg5-3
-  ;;
-
-  ## Data General AViiON Machines
-  ## DG changed naming conventions with the release of 5.4.4.10, they
-  ## dropped the initial 5.4 but left the intervening R.  Because of the
-  ## R this shouldn't conflict with older versions of the OS (which I
-  ## think were named like dgux4.*). In addition, DG new AViiONs series
-  ## uses either Motorola M88k or Intel Pentium CPUs.
-  m88k-dg-dguxR4.* | m88k-dg-dgux4* )
-    machine=aviion opsys=dgux4
-  ;;
-  m88k-dg-dgux5.4R3* | m88k-dg-dgux5.4.3* )
-    ## This name is dgux5-4-3 instead of dgux5-4r3
-    ## to avoid a file name conflict on MSDOS.
-    machine=aviion opsys=dgux5-4-3
-  ;;
-  m88k-dg-dgux5.4R2* | m88k-dg-dgux5.4.2* )
-    machine=aviion opsys=dgux5-4r2
-  ;;
-  m88k-dg-dgux* )
-    machine=aviion opsys=dgux
-  ;;
-
-  ## Data General AViiON Intel (x86) Machines
-  ## Exists from 5.4.3 (current i586-dg-dguxR4.11)
-  ## Ehud Karni, 1998-may-30, ehud@unix.simonwiesel.co.il
-  i[345]86-dg-dguxR4* )
-    machine=aviion-intel opsys=dgux4
-  ;;
-
-  ## DECstations
   mips-dec-ultrix[0-3].* | mips-dec-ultrix4.0* | mips-dec-bsd4.2* )
     machine=pmax opsys=bsd4-2
   ;;
@@ -2592,96 +2519,6 @@
     machine=pmax opsys=mach-bsd4-3
   ;;
 
-  ## Motorola Delta machines
-  m68k-motorola-sysv* | m68000-motorola-sysv* )
-    machine=delta opsys=usg5-3
-    if test -z "`type gnucc | grep 'not found'`"
-    then
-      if test -s /etc/167config
-      then CC="gnucc -m68040"
-      else CC="gnucc -m68881"
-      fi
-    else
-      if test -z "`type gcc | grep 'not found'`"
-      then CC=gcc
-      else CC=cc
-      fi
-    fi
-  ;;
-  m88k-motorola-sysv4* )
-    # jbotte@bnr.ca says that UNIX_System_V <hostName> 4.0 R40V4.3 m88k mc88110
-    # needs POSIX_SIGNALS and therefore needs usg5-4-2.
-    # I hope there are not other 4.0 versions for this machine
-    # which really need usg5-4 instead.
-    machine=delta88k opsys=usg5-4-2
-  ;;
-  m88k-motorola-sysv* | m88k-motorola-m88kbcs* )
-    machine=delta88k opsys=usg5-3
-  ;;
-
-  ## Dual machines
-  m68*-dual-sysv* )
-    machine=dual opsys=usg5-2
-  ;;
-  m68*-dual-uniplus* )
-    machine=dual opsys=unipl5-2
-  ;;
-
-  ## Elxsi 6400
-  elxsi-elxsi-sysv* )
-    machine=elxsi opsys=usg5-2
-  ;;
-
-  ## Encore machines
-  ns16k-encore-bsd* )
-    machine=ns16000 opsys=umax
-  ;;
-
-  ## The GEC 63 - apparently, this port isn't really finished yet.
-  #  I'm sure we finished off the last of the machines, though.  -- fx
-
-  ## Gould Power Node and NP1
-  pn-gould-bsd4.2* )
-    machine=gould opsys=bsd4-2
-  ;;
-  pn-gould-bsd4.3* )
-    machine=gould opsys=bsd4-3
-  ;;
-  np1-gould-bsd* )
-    machine=gould-np1 opsys=bsd4-3
-  ;;
-
-  ## Harris Night Hawk machines running CX/UX (a 5000 looks just like a 4000
-  ## as far as Emacs is concerned).
-  m88k-harris-cxux* )
-    # Build needs to be different on 7.0 and later releases
-    case "`uname -r`" in
-       [56].[0-9] ) machine=nh4000 opsys=cxux ;;
-       [7].[0-9] ) machine=nh4000 opsys=cxux7 ;;
-    esac
-    NON_GNU_CPP="/lib/cpp"
-  ;;
-  ## Harris ecx or gcx running CX/UX (Series 1200, Series 3000)
-  m68k-harris-cxux* )
-    machine=nh3000 opsys=cxux
-  ;;
-  ## Harris power pc NightHawk running Power UNIX (Series 6000)
-  powerpc-harris-powerunix )
-    machine=nh6000 opsys=powerunix
-    NON_GNU_CPP="cc -Xo -E -P"
-  ;;
-  ## SR2001/SR2201 running HI-UX/MPP
-  hppa1.1-hitachi-hiuxmpp* )
-    machine=sr2k opsys=hiuxmpp
-  ;;
-  hppa1.1-hitachi-hiuxwe2* )
-    machine=sr2k opsys=hiuxwe2
-  ;;
-  ## Honeywell XPS100
-  xps*-honeywell-sysv* )
-    machine=xps100 opsys=usg5-2
-  ;;
-
   ## HP 9000 series 200 or 300
   m68*-hp-bsd* )
     machine=hp9000s300 opsys=bsd4-3
@@ -2743,21 +2580,7 @@
     machine=hp800 opsys=nextstep
   ;;
 
-  ## Orion machines
-  orion-orion-bsd* )
-    machine=orion opsys=bsd4-2
-  ;;
-  clipper-orion-bsd* )
-    machine=orion105 opsys=bsd4-2
-  ;;
-
   ## IBM machines
-  i[3456]86-ibm-aix1.1* )
-    machine=ibmps2-aix opsys=usg5-2-2
-  ;;
-  i[3456]86-ibm-aix1.[23]* | i[3456]86-ibm-aix* )
-    machine=ibmps2-aix opsys=usg5-3
-  ;;
   i370-ibm-aix*)
     machine=ibm370aix opsys=usg5-3
   ;;
@@ -2794,64 +2617,12 @@
   rs6000-ibm-aix* | powerpc-ibm-aix* )
     machine=ibmrs6000 opsys=aix3-2
   ;;
-  romp-ibm-bsd4.3* )
-    machine=ibmrt opsys=bsd4-3
-  ;;
-  romp-ibm-bsd4.2* )
-    machine=ibmrt opsys=bsd4-2
-  ;;
-  romp-ibm-aos4.3* )
-    machine=ibmrt opsys=bsd4-3
-  ;;
-  romp-ibm-aos4.2* )
-    machine=ibmrt opsys=bsd4-2
-  ;;
-  romp-ibm-aos* )
-    machine=ibmrt opsys=bsd4-3
-  ;;
-  romp-ibm-bsd* )
-    machine=ibmrt opsys=bsd4-3
-  ;;
-  romp-ibm-aix* )
-    machine=ibmrt-aix opsys=usg5-2-2
-  ;;
-
-  ## Integrated Solutions `Optimum V'
-  m68*-isi-bsd4.2* )
-    machine=isi-ov opsys=bsd4-2
-  ;;
-  m68*-isi-bsd4.3* )
-    machine=isi-ov opsys=bsd4-3
-  ;;
-
-  ## Intel 386 machines where we do care about the manufacturer
-  i[3456]86-intsys-sysv* )
-    machine=is386 opsys=usg5-2-2
-  ;;
 
   ## Prime EXL
   i[3456]86-prime-sysv* )
     machine=i386 opsys=usg5-3
   ;;
 
-  ## Sequent Symmetry running Dynix
-  i[3456]86-sequent-bsd* )
-    machine=symmetry opsys=bsd4-3
-  ;;
-
-  ## Sequent Symmetry running ptx 4, which is a modified SVR4.
-  i[3456]86-sequent-ptx4* | i[3456]86-sequent-sysv4* )
-    machine=sequent-ptx opsys=ptx4
-    NON_GNU_CPP=/lib/cpp
-  ;;
-
-  ## Sequent Symmetry running DYNIX/ptx
-  ## Use the old cpp rather than the newer ANSI one.
-  i[3456]86-sequent-ptx* )
-    machine=sequent-ptx opsys=ptx
-    NON_GNU_CPP="/lib/cpp"
-  ;;
-
   ## ncr machine running svr4.3.
   i[3456]86-ncr-sysv4.3 )
     machine=ncr386 opsys=usg5-4-3
@@ -2863,33 +2634,11 @@
     machine=ncr386 opsys=usg5-4-2
   ;;
 
-  ## Intel Paragon OSF/1
-  i860-intel-osf1* )
-    machine=paragon opsys=osf1 NON_GNU_CPP=/usr/mach/lib/cpp
-  ;;
-
-  ## Intel 860
-  i860-*-sysv4* )
-    machine=i860 opsys=usg5-4
-    NON_GNU_CC="/bin/cc" # Ie, not the one in /usr/ucb/cc.
-    NON_GNU_CPP="/usr/ccs/lib/cpp" # cc -E tokenizes macro expansion.
-  ;;
-
   ## Macintosh PowerPC
   powerpc*-*-linux-gnu* )
     machine=macppc opsys=gnu-linux
   ;;
 
-  ## Masscomp machines
-  m68*-masscomp-rtu* )
-    machine=masscomp opsys=rtu
-  ;;
-
-  ## Megatest machines
-  m68*-megatest-bsd* )
-    machine=mega68 opsys=bsd4-2
-  ;;
-
   ## Workstations sold by MIPS
   ## This is not necessarily all workstations using the MIPS processor -
   ## Irises are produced by SGI, and DECstations by DEC.
@@ -2927,54 +2676,11 @@
     machine=m68k opsys=nextstep
   ;;
 
-  ## The complete machine from National Semiconductor
-  ns32k-ns-genix* )
-    machine=ns32000 opsys=usg5-2
-  ;;
-
-  ## NCR machines
-  m68*-ncr-sysv2* | m68*-ncr-sysvr2* )
-    machine=tower32 opsys=usg5-2-2
-  ;;
-  m68*-ncr-sysv3* | m68*-ncr-sysvr3* )
-    machine=tower32v3 opsys=usg5-3
-  ;;
-
   ## NEC EWS4800
   mips-nec-sysv4*)
   machine=ews4800 opsys=ux4800
   ;;
 
-  ## Nixdorf Targon 31
-  m68*-nixdorf-sysv* )
-    machine=targon31 opsys=usg5-2-2
-  ;;
-
-  ## Nu (TI or LMI)
-  m68*-nu-sysv* )
-    machine=nu opsys=usg5-2
-  ;;
-
-  ## Plexus
-  m68*-plexus-sysv* )
-    machine=plexus opsys=usg5-2
-  ;;
-
-  ## Pyramid machines
-  ## I don't really have any idea what sort of processor the Pyramid has,
-  ## so I'm assuming it is its own architecture.
-  pyramid-pyramid-bsd* )
-    machine=pyramid opsys=bsd4-2
-  ;;
-
-  ## Sequent Balance
-  ns32k-sequent-bsd4.2* )
-    machine=sequent opsys=bsd4-2
-  ;;
-  ns32k-sequent-bsd4.3* )
-    machine=sequent opsys=bsd4-3
-  ;;
-
   ## Siemens Nixdorf
   mips-siemens-sysv* | mips-sni-sysv*)
     machine=mips-siemens opsys=usg5-4
@@ -2983,20 +2689,7 @@
   ;;
 
   ## Silicon Graphics machines
-  ## Iris 2500 and Iris 2500 Turbo (aka the Iris 3030)
-  m68*-sgi-iris3.5* )
-    machine=irist opsys=iris3-5
-  ;;
-  m68*-sgi-iris3.6* | m68*-sgi-iris*)
-    machine=irist opsys=iris3-6
-  ;;
   ## Iris 4D
-  mips-sgi-irix3* )
-    machine=iris4d opsys=irix3-3
-  ;;
-  mips-sgi-irix4* )
-    machine=iris4d opsys=irix4-0
-  ;;
   mips-sgi-irix6.5 )
     machine=iris4d opsys=irix6-5
     # Without defining _LANGUAGE_C, things get masked out in the headers
@@ -3020,31 +2713,6 @@
     machine=iris4d opsys=irix5-2
   ;;
 
-  ## SONY machines
-  m68*-sony-bsd4.2* )
-    machine=news opsys=bsd4-2
-  ;;
-  m68*-sony-bsd4.3* )
-    machine=news opsys=bsd4-3
-  ;;
-  m68*-sony-newsos3* | m68*-sony-news3*)
-    machine=news opsys=bsd4-3
-  ;;
-  mips-sony-bsd* | mips-sony-newsos4* | mips-sony-news4*)
-    machine=news-risc opsys=bsd4-3
-  ;;
-  mips-sony-newsos6* )
-    machine=news-r6 opsys=newsos6
-  ;;
-  mips-sony-news* )
-    machine=news-risc opsys=newsos5
-  ;;
-
-  ## Stride
-  m68*-stride-sysv* )
-    machine=stride opsys=usg5-2
-  ;;
-
   ## Suns
   sparc-*-linux-gnu* | sparc64-*-linux-gnu* )
     machine=sparc opsys=gnu-linux
@@ -3054,10 +2722,6 @@
     | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* | powerpc*-*-solaris2* \
     | rs6000-*-solaris2*)
     case "${canonical}" in
-      m68*-sunos1* )	machine=sun1 ;;
-      m68*-sunos2* )	machine=sun2 ;;
-      m68* )		machine=sun3 ;;
-      i[3456]86-sun-sunos[34]* )	machine=sun386 ;;
       i[3456]86-*-* )     machine=intel386 ;;
       amd64-*-*|x86_64-*-*)	machine=amdx86-64 ;;
       powerpcle* )      machine=powerpcle ;;
@@ -3066,26 +2730,6 @@
       * )		unported=yes ;;
     esac
     case "${canonical}" in
-      ## The Sun386 didn't get past 4.0.
-      i[3456]86-*-sunos4	  ) opsys=sunos4-0 ;;
-      *-sunos4.0*	  ) opsys=sunos4-0 ;;
-      *-sunos4.1.[3-9]*noshare )
-		## This name is sunos413 instead of sunos4-1-3
-		## to avoid a file name conflict on MSDOS.
-		opsys=sunos413
-		NON_GNU_CPP=/usr/lib/cpp
-		NON_GCC_TEST_OPTIONS=-Bstatic
-		GCC_TEST_OPTIONS=-static
-		;;
-      *-sunos4.1.[3-9]* | *-sunos4shr*)
-		opsys=sunos4shr
-		NON_GNU_CPP=/usr/lib/cpp
-		;;
-      *-sunos4* | *-sunos )
-		opsys=sunos4-1
-		NON_GCC_TEST_OPTIONS=-Bstatic
-		GCC_TEST_OPTIONS=-static
-		;;
       *-sunos5.3* | *-solaris2.3* )
 		opsys=sol2-3
 		NON_GNU_CPP=/usr/ccs/lib/cpp
@@ -3128,50 +2772,11 @@
     machine=sparc opsys=nextstep
   ;;
 
-  ## Tadpole 68k
-  m68*-tadpole-sysv* )
-    machine=tad68k opsys=usg5-3
-  ;;
-
-  ## Tahoe machines
-  tahoe-tahoe-bsd4.2* )
-    machine=tahoe opsys=bsd4-2
-  ;;
-  tahoe-tahoe-bsd4.3* )
-    machine=tahoe opsys=bsd4-3
-  ;;
-
   ## Tandem Integrity S2
   mips-tandem-sysv* )
     machine=tandem-s2 opsys=usg5-3
   ;;
 
-  ## Tektronix XD88
-  m88k-tektronix-sysv3* )
-  machine=tekxd88 opsys=usg5-3
-  ;;
-
-  ## Tektronix 16000 box (6130?)
-  ns16k-tektronix-bsd* )
-    machine=ns16000 opsys=bsd4-2
-  ;;
-  ## Tektronix 4300
-  ## src/m/tek4300.h hints that this is a m68k machine.
-  m68*-tektronix-bsd* )
-    machine=tek4300 opsys=bsd4-3
-  ;;
-
-  ## Titan P2 or P3
-  ## We seem to have lost the machine-description file titan.h!
-  titan-titan-sysv* )
-    machine=titan opsys=usg5-3
-  ;;
-
-  ## Ustation E30 (SS5E)
-  m68*-unisys-uniplus* )
-    machine=ustation opsystem=unipl5-2
-  ;;
-
   ## Vaxen.
   vax-dec-* )
     machine=vax
@@ -3186,18 +2791,6 @@
     esac
   ;;
 
-  ## Whitechapel MG1
-  ns16k-whitechapel-* )
-    machine=mg1
-    ## We don't know what sort of OS runs on these; we'll let the
-    ## operating system guessing code below try.
-  ;;
-
-  ## Wicat
-  m68*-wicat-sysv* )
-    machine=wicat opsys=usg5-2
-  ;;
-
   ## IA-64
   ia64*-*-linux* )
     machine=ia64 opsys=gnu-linux
@@ -3211,25 +2804,8 @@
       *-darwin* )               opsys=darwin
                                 CPP="${CC-cc} -E -no-cpp-precomp"
  				;;
-      *-isc1.* | *-isc2.[01]* )	opsys=386-ix ;;
-      *-isc2.2* )		opsys=isc2-2 ;;
-      *-isc4.0* )		opsys=isc4-0 ;;
-      *-isc4.* )		opsys=isc4-1
-				GCC_TEST_OPTIONS=-posix
-				NON_GCC_TEST_OPTIONS=-Xp
-				;;
-      *-isc* )			opsys=isc3-0 ;;
-      *-esix5* )		opsys=esix5r4; NON_GNU_CPP=/usr/lib/cpp ;;
-      *-esix* )			opsys=esix ;;
       *-xenix* )		opsys=xenix ;;
       *-linux-gnu* )		opsys=gnu-linux ;;
-      *-sco3.2v4* )		opsys=sco4 ; NON_GNU_CPP=/lib/cpp  ;;
-      *-sco3.2v5* )		opsys=sco5
-				NON_GNU_CPP=/lib/cpp
-				# Prevent -belf from being passed to $CPP.
-				# /lib/cpp does not accept it.
-				OVERRIDE_CPPFLAGS=" "
-				;;
       *-sysv4.2uw* )	  	opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
       *-sysv5uw* )	  	opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
       *-sysv5OpenUNIX* )  	opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
@@ -3256,18 +2832,13 @@
     RANLIB="ar -ts"
   ;;
 
-  ## UXP/V
-  f301-fujitsu-uxpv4.1)
-    machine=f301 opsys=uxpv
-  ;;
-
   ## AMD x86-64 Linux-based GNU system
   x86_64-*-linux-gnu* )
     machine=amdx86-64 opsys=gnu-linux
   ;;
 
   ## Tensilica Xtensa Linux-based GNU system
-  xtensa-*-linux-gnu* )
+  xtensa*-*-linux-gnu* )
     machine=xtensa opsys=gnu-linux
     ;;
 
@@ -6038,14 +5609,14 @@
 
 
 
-### The standard library on x86-64 GNU/Linux distributions can
+### The standard library on x86-64 and s390x GNU/Linux distributions can
 ### be located in either /usr/lib64 or /usr/lib.
 case "${canonical}" in
-  x86_64-*-linux-gnu* )
+  x86_64-*-linux-gnu* | s390x-*-linux-gnu* )
     if test -d /usr/lib64; then
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_X86_64_LIB64_DIR 1
+#define HAVE_LIB64_DIR 1
 _ACEOF
 
 fi
@@ -6513,14 +6084,10 @@
 
   ALSA_REQUIRED=1.0.0
   ALSA_MODULES="alsa >= $ALSA_REQUIRED"
-    if test "X${with_pkg_config_prog}" != X; then
-    PKG_CONFIG="${with_pkg_config_prog}"
-  fi
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -6561,7 +6128,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      HAVE_ALSA=no
@@ -9812,22 +9378,6 @@
   yes ) HAVE_MENUS=yes ;;
 esac
 
-if test "${opsys}" = "hpux9"; then
-  case "${x_libraries}" in
-    *X11R4* )
-      opsysfile="s/hpux9-x11r4.h"
-      ;;
-  esac
-fi
-
-if test "${opsys}" = "hpux9shr"; then
-  case "${x_libraries}" in
-    *X11R4* )
-      opsysfile="s/hpux9shxr4.h"
-      ;;
-  esac
-fi
-
 ### Compute the unexec source name from the object name.
 UNEXEC_SRC="`echo ${unexec} | sed 's/\.o/.c/'`"
 
@@ -11162,18 +10712,13 @@
 HAVE_RSVG=no
 if test "${HAVE_X11}" = "yes" || test "${HAVE_CARBON}" = "yes"; then
   if test "${with_rsvg}" != "no"; then
-        if test "X${with_pkg_config_prog}" != X; then
-      PKG_CONFIG="${with_pkg_config_prog}"
-    fi
-
     RSVG_REQUIRED=2.0.0
     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
 
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -11214,7 +10759,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      :
@@ -11297,14 +10841,10 @@
   GTK_REQUIRED=2.6
   GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
 
-    if test "X${with_pkg_config_prog}" != X; then
-    PKG_CONFIG="${with_pkg_config_prog}"
-  fi
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -11345,7 +10885,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      pkg_check_gtk=no
@@ -12063,8 +11602,7 @@
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -12105,7 +11643,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      HAVE_DBUS=no
@@ -12930,8 +12467,7 @@
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -12972,7 +12508,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      HAVE_XFT=no
@@ -13251,10 +12786,10 @@
     PKG_CONFIG="${with_pkg_config_prog}"
   fi
 
+
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -13295,7 +12830,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      HAVE_FREETYPE=no
@@ -13350,8 +12884,7 @@
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -13392,7 +12925,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      HAVE_FC=no
@@ -13463,8 +12995,7 @@
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -13505,7 +13036,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      pkg_check_libotf=no
@@ -13574,8 +13104,7 @@
 
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    # Extract the first word of "pkg-config", so it can be a program name with args.
+  # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
@@ -13616,7 +13145,6 @@
 fi
 
 
-  fi
 
   if test "$PKG_CONFIG" = "no" ; then
      pkg_check_m17n_flt=no
@@ -19104,13 +18632,11 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -19150,13 +18676,11 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -24428,6 +23952,7 @@
 echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
 echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
 echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
+echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
 echo "  Does Emacs use X toolkit scroll bars?                   ${USE_TOOLKIT_SCROLL_BARS}"
 echo
 
--- a/configure.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/configure.in	Wed Jan 30 07:57:28 2008 +0000
@@ -43,48 +43,68 @@
 
 gameuser=games
 
-dnl Autoconf is so much less fun under VMS, maybe
-dnl because everything is less fun under VMS. --ttn
-AC_DEFUN([EMACS_ARG_Y],[dnl
-AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[$3],[$4])dnl
-])dnl
-AC_DEFUN([EMACS_ARG_N],[dnl
-AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[$3],[$4])dnl
+dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
+dnl Create a new --with option that defaults to being disabled.
+dnl NAME is the base name of the option.  The shell variable with_NAME
+dnl   will be set to either the user's value (if the option is
+dnl   specified; 'yes' for a plain --with-NAME) or to 'no' (if the
+dnl   option is not specified).  Note that the shell variable name is
+dnl   constructed as autoconf does, by replacing non-alphanumeric
+dnl   characters with "_".
+dnl HELP-STRING is the help text for the option.
+AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
+  AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
+    m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
 ])dnl
 
-EMACS_ARG_N([gcc],[don't use GCC to compile Emacs if GCC is found])
-
-EMACS_ARG_N([pop],[don't support POP mail retrieval with movemail],
-[if test "$withval" = yes; then
+dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
+dnl Create a new --with option that defaults to being enabled.  NAME
+dnl   is the base name of the option.  The shell variable with_NAME
+dnl   will be set either to 'no' (for a plain --without-NAME) or to
+dnl   'yes' (if the option is not specified).  Note that the shell
+dnl   variable name is constructed as autoconf does, by replacing
+dnl   non-alphanumeric characters with "_".
+dnl HELP-STRING is the help text for the option.
+AC_DEFUN([OPTION_DEFAULT_ON], [dnl
+  AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
+   m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=yes])dnl
+])dnl
+
+dnl By default, neither off nor on.
+AC_ARG_WITH([gcc],
+[AS_HELP_STRING([--without-gcc],
+    [don't use GCC to compile Emacs even if GCC is found])])
+
+OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail])
+if test "$with_pop" = yes; then
    AC_DEFINE(MAIL_USE_POP)
-else :
-fi],
-AC_DEFINE(MAIL_USE_POP))
+fi
 AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
 
-EMACS_ARG_Y([kerberos],[support Kerberos-authenticated POP],
-[if test "$withval" = yes; then
+OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
+if test "$with_kerberos" = yes; then
    AC_DEFINE(KERBEROS)
-fi])
+fi
 AH_TEMPLATE(KERBEROS,
 	    [Define to support Kerberos-authenticated POP mail retrieval.])dnl
 
-EMACS_ARG_Y([kerberos5],[support Kerberos version 5 authenticated POP],
-[if test "${with_kerberos5+set}" = set; then
-  if test "${with_kerberos+set}" != set; then
+OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
+if test "${with_kerberos5}" = yes; then
+  if test "${with_kerberos}" != yes; then
     with_kerberos=yes
     AC_DEFINE(KERBEROS)
   fi
   AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
-fi])
-
-EMACS_ARG_Y([hesiod],[support Hesiod to get the POP server host],
-[if test "$withval" = yes; then
+fi
+
+OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
+if test "$with_hesiod" = yes; then
   AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
-fi])
-
-EMACS_ARG_N([sound],[don't compile with sound support])
-
+fi
+
+OPTION_DEFAULT_ON([sound],[don't compile with sound support])
+
+dnl FIXME currently it is not the last.
 dnl This should be the last --with option, because --with-x is
 dnl added later on when we find the path of X, and it's best to
 dnl keep them together visually.
@@ -106,24 +126,37 @@
 	  with_x_toolkit=$val
 ])
 
-EMACS_ARG_Y([xpm],[use -lXpm for displaying XPM images])
-EMACS_ARG_Y([jpeg],[use -ljpeg for displaying JPEG images])
-EMACS_ARG_Y([tiff],[use -ltiff for displaying TIFF images])
-EMACS_ARG_Y([gif],[use -lgif (or -lungif) for displaying GIF images])
-EMACS_ARG_Y([png],[use -lpng for displaying PNG images])
-EMACS_ARG_Y([freetype],[use -lfreetype for local fonts support])
-EMACS_ARG_Y([xft],[use -lXft for anti aliased fonts])
-EMACS_ARG_Y([gpm],[use -lgpm for mouse support on a GNU/Linux console])
-EMACS_ARG_Y([rsvg],[use -lrsvg-2 for displaying SVG images])
-EMACS_ARG_Y([gtk],[use GTK (same as --with-x-toolkit=gtk)])
-EMACS_ARG_Y([pkg-config-prog],[Path to pkg-config for finding GTK and librsvg])
-EMACS_ARG_N([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
-EMACS_ARG_N([xaw3d],[don't use Xaw3d])
-EMACS_ARG_N([xim],[don't use X11 XIM])
-EMACS_ARG_N([carbon],[don't use Carbon GUI on Mac OS X])
-EMACS_ARG_Y([dbus],[use D-Bus])
-EMACS_ARG_N([libotf],[don't use libotf for OpenType font support])
-EMACS_ARG_N([m17n-flt],[don't use m17n-flt for text shaping])
+dnl _ON results in a '--without' option in the --help output, so
+dnl the help text should refer to "don't compile", etc.
+OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
+OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
+OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
+OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
+OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
+OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
+
+OPTION_DEFAULT_OFF([freetype],[use -lfreetype for local fonts support])
+OPTION_DEFAULT_OFF([xft],[use -lXft for anti aliased fonts])
+OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
+OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
+
+OPTION_DEFAULT_OFF([gtk],[use GTK toolkit])
+OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
+OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
+OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
+OPTION_DEFAULT_OFF([carbon],[use Carbon GUI on Mac OS X.  This is unsupported!])
+
+OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
+OPTION_DEFAULT_OFF([dbus],[compile with D-Bus support])
+
+AC_ARG_WITH([pkg-config-prog],dnl
+[AS_HELP_STRING([--with-pkg-config-prog=PATH],
+                  [Path to pkg-config for finding GTK and librsvg])])
+if test "X${with_pkg_config_prog}" != X; then
+   if test "${with_pkg_config_prog}" != yes; then
+      PKG_CONFIG="${with_pkg_config_prog}"
+   fi
+fi
 
 AC_ARG_ENABLE(carbon-app,
 [AS_HELP_STRING([--enable-carbon-app@<:@=DIR@:>@],
@@ -513,19 +546,6 @@
     machine=i386 opsys=usg5-3
   ;;
 
-  ## Sequent Symmetry running ptx 4, which is a modified SVR4.
-  i[3456]86-sequent-ptx4* | i[3456]86-sequent-sysv4* )
-    machine=sequent-ptx opsys=ptx4
-    NON_GNU_CPP=/lib/cpp
-  ;;
-
-  ## Sequent Symmetry running DYNIX/ptx
-  ## Use the old cpp rather than the newer ANSI one.
-  i[3456]86-sequent-ptx* )
-    machine=sequent-ptx opsys=ptx
-    NON_GNU_CPP="/lib/cpp"
-  ;;
-
   ## ncr machine running svr4.3.
   i[3456]86-ncr-sysv4.3 )
     machine=ncr386 opsys=usg5-4-3
@@ -593,12 +613,6 @@
 
   ## Silicon Graphics machines
   ## Iris 4D
-  mips-sgi-irix3* )
-    machine=iris4d opsys=irix3-3
-  ;;
-  mips-sgi-irix4* )
-    machine=iris4d opsys=irix4-0
-  ;;
   mips-sgi-irix6.5 )
     machine=iris4d opsys=irix6-5
     # Without defining _LANGUAGE_C, things get masked out in the headers
@@ -747,7 +761,7 @@
   ;;
 
   ## Tensilica Xtensa Linux-based GNU system
-  xtensa-*-linux-gnu* )
+  xtensa*-*-linux-gnu* )
     machine=xtensa opsys=gnu-linux
     ;;
 
@@ -1100,13 +1114,13 @@
 AC_SYS_LARGEFILE
 
 
-### The standard library on x86-64 GNU/Linux distributions can
+### The standard library on x86-64 and s390x GNU/Linux distributions can
 ### be located in either /usr/lib64 or /usr/lib.
 case "${canonical}" in
-  x86_64-*-linux-gnu* )
+  x86_64-*-linux-gnu* | s390x-*-linux-gnu* )
     if test -d /usr/lib64; then
-      AC_DEFINE(HAVE_X86_64_LIB64_DIR, 1,
-        [Define to 1 if the file /usr/lib64 exists.])
+      AC_DEFINE(HAVE_LIB64_DIR, 1,
+        [Define to 1 if the directory /usr/lib64 exists.])
 fi
 esac
 
@@ -1117,9 +1131,7 @@
 AC_DEFUN([PKG_CHECK_MODULES], [
   succeeded=no
 
-  if test -z "$PKG_CONFIG"; then
-    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
-  fi
+  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
 
   if test "$PKG_CONFIG" = "no" ; then
      ifelse([$4], , [AC_MSG_ERROR([
@@ -1175,10 +1187,6 @@
 
   ALSA_REQUIRED=1.0.0
   ALSA_MODULES="alsa >= $ALSA_REQUIRED"
-  dnl Check if --with-pkg-config-prog has been given.
-  if test "X${with_pkg_config_prog}" != X; then
-    PKG_CONFIG="${with_pkg_config_prog}"
-  fi
   PKG_CHECK_MODULES(ALSA, $ALSA_MODULES, HAVE_ALSA=yes, HAVE_ALSA=no)
   if test $HAVE_ALSA = yes; then
     SAVE_CFLAGS="$CFLAGS"
@@ -1489,22 +1497,6 @@
   yes ) HAVE_MENUS=yes ;;
 esac
 
-if test "${opsys}" = "hpux9"; then
-  case "${x_libraries}" in
-    *X11R4* )
-      opsysfile="s/hpux9-x11r4.h"
-      ;;
-  esac
-fi
-
-if test "${opsys}" = "hpux9shr"; then
-  case "${x_libraries}" in
-    *X11R4* )
-      opsysfile="s/hpux9shxr4.h"
-      ;;
-  esac
-fi
-
 ### Compute the unexec source name from the object name.
 UNEXEC_SRC="`echo ${unexec} | sed 's/\.o/.c/'`"
 
@@ -1683,11 +1675,6 @@
 HAVE_RSVG=no
 if test "${HAVE_X11}" = "yes" || test "${HAVE_CARBON}" = "yes"; then
   if test "${with_rsvg}" != "no"; then
-    dnl Check if `--with-pkg-config-prog' has been given.
-    if test "X${with_pkg_config_prog}" != X; then
-      PKG_CONFIG="${with_pkg_config_prog}"
-    fi
-
     RSVG_REQUIRED=2.0.0
     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
 
@@ -1718,10 +1705,6 @@
   GTK_REQUIRED=2.6
   GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
 
-  dnl Check if --with-pkg-config-prog has been given.
-  if test "X${with_pkg_config_prog}" != X; then
-    PKG_CONFIG="${with_pkg_config_prog}"
-  fi
   dnl Checks for libraries.
   PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
@@ -1806,7 +1789,7 @@
 fi
 
 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
-dnl other platforms.  Support for higher D-Bus versions but 1.0 is
+dnl other platforms.  Support for higher D-Bus versions than 1.0 is
 dnl also not configured.
 HAVE_DBUS=no
 if test "${with_dbus}" = "yes"; then
@@ -2786,8 +2769,7 @@
 #endif
 
 /* Multi-tty support relies on MULTI_KBOARD.  It seems safe to turn it
-   on unconditionally.  Note that src/s/darwin.h disables this at
-   present.  */
+   on unconditionally. */
 #ifndef MULTI_KBOARD
 #define MULTI_KBOARD
 #endif
@@ -3086,6 +3068,7 @@
 echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
 echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
 echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
+echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
 echo "  Does Emacs use X toolkit scroll bars?                   ${USE_TOOLKIT_SCROLL_BARS}"
 echo
 
--- a/doc/emacs/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,22 @@
+2008-01-26  Richard Stallman  <rms@gnu.org>
+
+	* maintaining.texi (Tags): Delete redundant index entry.
+
+2008-01-26  Eli Zaretskii  <eliz@gnu.org>
+
+	* programs.texi (Imenu): Move "@cindex tags" from here...
+	* maintaining.texi (Tags): ...to here.
+
+2008-01-23  Kevin Ryde  <user42@zip.com.au>
+
+	* custom.texi (Mouse Buttons): Update elisp xref to "Click Events" on
+	click count.
+
+2008-01-21  Juanma Barranquero  <lekktu@gmail.com>
+
+	* entering.texi (Exiting): Fix typo.
+	Reported by D. E. Evans <sinuhe@gnu.org>.
+
 2007-12-31  Martin Rudalics  <rudalics@gmx.at>
 
 	* glossary.texi (Glossary): Fix typo.
@@ -5096,7 +5115,7 @@
 ;; End:
 
     Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
-      2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+      2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
--- a/doc/emacs/Makefile.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/Makefile.in	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,7 @@
 #### Makefile for the Emacs Manual
 
 # Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-#   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+#   2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
--- a/doc/emacs/abbrevs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/abbrevs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002, 2003,
-@c   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Abbrevs
 @chapter Abbrevs
--- a/doc/emacs/ack.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/ack.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-@c   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @node Acknowledgments, Screen, Concept Index, Top
--- a/doc/emacs/anti.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/anti.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 
 @node Antinews, Mac OS, X Resources, Top
--- a/doc/emacs/arevert-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/arevert-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/basic.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/basic.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Basic, Minibuffer, Exiting, Top
 @chapter Basic Editing Commands
--- a/doc/emacs/buffers.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/buffers.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Buffers, Windows, Files, Top
 @chapter Using Multiple Buffers
--- a/doc/emacs/building.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/building.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Building, Maintaining, Programs, Top
 @chapter Compiling and Testing Programs
--- a/doc/emacs/cal-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/cal-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/calendar.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/calendar.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Calendar/Diary, Gnus, Dired, Top
 @chapter The Calendar and the Diary
--- a/doc/emacs/cmdargs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/cmdargs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Emacs Invocation, X Resources, GNU Free Documentation License, Top
 @appendix Command Line Arguments for Emacs Invocation
--- a/doc/emacs/commands.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/commands.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
 @chapter Characters, Keys and Commands
--- a/doc/emacs/custom.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/custom.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Customization, Quitting, Amusements, Top
 @chapter Customization
@@ -1885,7 +1885,7 @@
 types; clicks beyond the third generate additional triple-click events.
 However, the full number of clicks is recorded in the event list, so
 if you know Emacs Lisp you can distinguish if you really want to
-(@pxref{Accessing Events,,, elisp, The Emacs Lisp Reference Manual}).
+(@pxref{Click Events,,, elisp, The Emacs Lisp Reference Manual}).
 We don't recommend distinct meanings for more than three clicks, but
 sometimes it is useful for subsequent clicks to cycle through the same
 set of three meanings, so that four clicks are equivalent to one
--- a/doc/emacs/dired-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/dired-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/dired.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/dired.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Dired, Calendar/Diary, Rmail, Top
 @chapter Dired, the Directory Editor
--- a/doc/emacs/display.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/display.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Display, Search, Registers, Top
 @chapter Controlling the Display
--- a/doc/emacs/emacs-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/emacs-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -10,7 +10,7 @@
 @copying
 This manual describes specialized features of Emacs.
 
-Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/emacs/emacs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/emacs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -12,8 +12,8 @@
 updated for Emacs version @value{EMACSVER}.
 
 Copyright @copyright{} 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997,
-1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-Foundation, Inc.
+1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/emacs/emerge-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/emerge-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/entering.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/entering.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 2001, 2002, 2003,
-@c   2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Entering Emacs, Exiting, Text Characters, Top
 @chapter Entering and Exiting Emacs
@@ -122,7 +122,7 @@
 
 @vindex cannot-suspend
   Suspending can fail if you run Emacs under a shell that doesn't
-support suspendion of its subjobs, even if the system itself does
+support suspension of its subjobs, even if the system itself does
 support it.  In such a case, you can set the variable
 @code{cannot-suspend} to a non-@code{nil} value to force @kbd{C-z} to
 start an inferior shell.
--- a/doc/emacs/files.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/files.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
-@c   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Files, Buffers, Keyboard Macros, Top
 @chapter File Handling
--- a/doc/emacs/fixit.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/fixit.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Fixit, Keyboard Macros, Search, Top
 @chapter Commands for Fixing Typos
--- a/doc/emacs/fortran-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/fortran-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/frames.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/frames.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
-@c   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Frames, International, Windows, Top
 @chapter Frames and Graphical Displays
--- a/doc/emacs/glossary.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/glossary.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Glossary, Key Index, Intro, Top
 @unnumbered Glossary
--- a/doc/emacs/gnu.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/gnu.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,13 +1,13 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1995, 2001, 2002, 2003, 2004,
-@c   2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @ifclear justgnu
 @node Manifesto,, Microsoft Windows, Top
 @unnumbered The GNU Manifesto
 @end ifclear
 @ifset justgnu
 Copyright @copyright{} 1985, 1993, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
--- a/doc/emacs/help.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/help.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Help, Mark, M-x, Top
 @chapter Help
--- a/doc/emacs/indent.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/indent.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Indentation, Text, Major Modes, Top
 @chapter Indentation
--- a/doc/emacs/killing.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/killing.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 
 @node Killing, Yanking, Mark, Top
--- a/doc/emacs/kmacro.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/kmacro.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Keyboard Macros, Files, Fixit, Top
 @chapter Keyboard Macros
--- a/doc/emacs/m-x.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/m-x.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node M-x, Help, Minibuffer, Top
 @chapter Running Commands by Name
--- a/doc/emacs/macos.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/macos.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 2000, 2001, 2002, 2003, 2004,
-@c   2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mac OS, Microsoft Windows, Antinews, Top
 @appendix Emacs and Mac OS
--- a/doc/emacs/maintaining.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/maintaining.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
-@c   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Maintaining, Abbrevs, Building, Top
 @chapter Maintaining Large Programs
@@ -130,7 +130,7 @@
 
 @node Tags
 @section Tags Tables
-@cindex tags table
+@cindex tag tables
 
   A @dfn{tags table} is a description of how a multi-file program is
 broken up into files.  It lists the names of the component files and the
@@ -796,9 +796,10 @@
   It is possible to get through all the files in the tags table with a
 single invocation of @kbd{M-x tags-query-replace}.  But often it is
 useful to exit temporarily, which you can do with any input event that
-has no special query replace meaning.  You can resume the query replace
-subsequently by typing @kbd{M-,}; this command resumes the last tags
-search or replace command that you did.
+has no special query replace meaning.  You can resume the query
+replace subsequently by typing @kbd{M-,}; this command resumes the
+last tags search or replace command that you did.  For instance, to
+skip the rest of the current file, you can type @kbd{M-> M-,}.
 
   The commands in this section carry out much broader searches than the
 @code{find-tag} family.  The @code{find-tag} commands search only for
--- a/doc/emacs/major.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/major.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Major Modes, Indentation, International, Top
 @chapter Major Modes
--- a/doc/emacs/makefile.w32-in	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/makefile.w32-in	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,7 @@
 #### -*- Makefile -*- for the Emacs Manual
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
--- a/doc/emacs/mark.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/mark.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mark, Killing, Help, Top
 @chapter The Mark and the Region
--- a/doc/emacs/mini.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/mini.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Minibuffer, M-x, Basic, Top
 @chapter The Minibuffer
--- a/doc/emacs/misc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/misc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
 @chapter Miscellaneous Commands
--- a/doc/emacs/msdog-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/msdog-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/msdog.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/msdog.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Microsoft Windows, Manifesto, Mac OS, Top
 @appendix Emacs and Microsoft Windows/MS-DOS
--- a/doc/emacs/mule.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/mule.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-@c   2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node International, Major Modes, Frames, Top
 @chapter International Character Set Support
--- a/doc/emacs/picture-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/picture-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
--- a/doc/emacs/programs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/programs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
-@c   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Programs, Building, Text, Top
 @chapter Editing Programs
@@ -279,7 +279,6 @@
 @subsection Imenu
 @cindex index of buffer definitions
 @cindex buffer definitions index
-@cindex tags
 
   The Imenu facility offers a way to find the major definitions in
 a file by name.  It is also useful in text formatter major modes,
--- a/doc/emacs/regs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/regs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Registers, Display, CUA Bindings, Top
 @chapter Registers
--- a/doc/emacs/rmail.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/rmail.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Rmail, Dired, Sending Mail, Top
 @chapter Reading Mail with Rmail
--- a/doc/emacs/screen.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/screen.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Screen, User Input, Acknowledgments, Top
 @chapter The Organization of the Screen
--- a/doc/emacs/search.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/search.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Search, Fixit, Display, Top
 @chapter Searching and Replacement
--- a/doc/emacs/sending.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/sending.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Sending Mail
 @chapter Sending Mail
--- a/doc/emacs/text.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/text.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Text, Programs, Indentation, Top
 @chapter Commands for Human Languages
--- a/doc/emacs/trouble.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/trouble.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
 @chapter Dealing with Common Problems
--- a/doc/emacs/vc-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/vc-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included in emacs-xtra.texi when producing the printed
--- a/doc/emacs/vc1-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/vc1-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in vc-xtra.texi (when producing the
--- a/doc/emacs/vc2-xtra.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/vc2-xtra.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in vc-xtra.texi (when producing the
--- a/doc/emacs/windows.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/windows.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Windows, Frames, Buffers, Top
 @chapter Multiple Windows
--- a/doc/emacs/xresources.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/emacs/xresources.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1987, 1993, 1994, 1995, 1997, 2001, 2002, 2003,
-@c   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node X Resources, Antinews, Emacs Invocation, Top
 @appendix X Options and Resources
--- a/doc/lispref/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/lispref/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,12 @@
+2008-01-27  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* display.texi (Button Types):
+	For define-button-type, clarify type of NAME.
+
+2008-01-19  Martin Rudalics  <rudalics@gmx.at>
+
+	* buffers.texi (Buffer Modification): Fix typo.
+
 2008-01-06  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* os.texi (System Environment): Remove references to OSes that are
--- a/doc/lispref/buffers.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/lispref/buffers.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -584,7 +584,7 @@
 This function returns @var{buffer}'s character-change modification-count.
 Changes to text properties leave this counter unchanged; however, each
 time text is inserted or removed from the buffer, the counter is reset
-to the value that would be returned @code{buffer-modified-tick}.
+to the value that would be returned by @code{buffer-modified-tick}.
 By comparing the values returned by two @code{buffer-chars-modified-tick}
 calls, you can tell whether a character change occurred in that buffer
 in between the calls.  If @var{buffer} is @code{nil} (or omitted), the
@@ -783,7 +783,7 @@
 to the end when they are buried (see @code{bury-buffer}, below).
 There are no functions available to the Lisp programmer which directly
 manipulate the buffer list.
-  
+
   In addition to the fundamental Emacs buffer list, each frame has its
 own version of the buffer list, in which the buffers that have been
 selected in that frame come first, starting with the buffers most
--- a/doc/lispref/display.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/lispref/display.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -4499,7 +4499,8 @@
 specific tasks.
 
 @defun define-button-type name &rest properties
-Define a `button type' called @var{name}.  The remaining arguments
+Define a `button type' called @var{name} (a symbol).
+The remaining arguments
 form a sequence of @var{property value} pairs, specifying default
 property values for buttons with this type (a button's type may be set
 by giving it a @code{type} property when creating the button, using
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/lispref/elisp-covers.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,257 @@
+\input texinfo    @c -*-texinfo-*-
+@c This is part of the GNU Emacs Lisp Reference Manual.
+@c Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+@c   Free Software Foundation, Inc.
+@c See the file elisp.texi for copying conditions.
+@c
+@comment %**start of header
+@setfilename covers.info
+@settitle GNU Emacs Lisp Reference Manual
+@comment %**end of header
+
+@titlepage
+@c ================ Volume 1 ================
+@w{ }
+@sp 2
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 1}
+@sp 2
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+@page
+@c ================ Volume 2 ================
+@w{ }
+@sp 5
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 2}
+@sp 2
+@center by Bil Lewis,
+@center Dan LaLiberte, and
+@center the GNU Manual Group
+
+@page
+@c ================ Volume 1 with baseline skip 16pt ================
+
+@tex
+\global\baselineskip = 16pt
+@end tex
+
+16 pts baseline skip:
+
+@w{ }
+@sp 2
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 1}
+@sp 2
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+@page
+@c ================ Volume 1 with baseline skip 18pt ================
+
+@tex
+\global\baselineskip = 18pt
+@end tex
+
+18 pts baseline skip, with 15pts  between sections
+
+@w{ }
+@sp 2
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@tex
+\global\baselineskip = 15pt
+@end tex
+
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 1}
+@sp 2
+@center by Bil Lewis,
+@center Dan LaLiberte, and
+@center the GNU Manual Group
+
+@page
+@c ================ Volume 1 with more baseline skip 24 pts ================
+
+@tex
+\global\baselineskip = 24pt
+@end tex
+
+24 pts baseline skip:
+
+@w{ }
+@sp 2
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 1}
+@sp 2
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+@page
+@c ================ Volume 2 with more baseline skip 18 pts ================
+
+@tex
+\global\baselineskip = 18pt
+@end tex
+
+18 pts baseline skip:
+
+@w{ }
+@sp 5
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 2}
+@sp 2
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+@page
+@c ================ Volume 2 with more baseline skip 24 pts ================
+
+@tex
+\global\baselineskip = 24pt
+@end tex
+
+24 pts baseline skip:
+
+@w{ }
+@sp 5
+@center @titlefont{The}
+@sp 1
+@center @titlefont{GNU}
+@sp 1
+@center @titlefont{Emacs Lisp}
+@sp 1
+@center @titlefont{Reference}
+@sp 1
+@center @titlefont{Manual}
+@sp 2
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 2
+@center @titlefont{Volume 2}
+@sp 2
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+
+@page
+@c ================  Spine 1 ================
+
+@w{@titlefont{The GNU Emacs Lisp Reference Manual --- Vol. 1}}
+@sp 4
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 4
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+@sp 4
+@author The GNU Emacs Lisp Reference Manual --- Vol. 1
+@sp 3
+@author FSF
+
+@author
+
+@page
+@c ================  Spine 2 ================
+
+@w{@titlefont{The GNU Emacs Lisp Reference Manual --- Vol. 2}}
+@sp 4
+@center GNU Emacs Version 19
+@center for Unix Users
+@center Edition 2.3, June 1994
+@sp 4
+@center by Bil Lewis, Dan LaLiberte,
+@center and the GNU Manual Group
+
+
+@sp 4
+@author The GNU Emacs Lisp Reference Manual --- Vol. 2
+@sp 3
+@author FSF
+
+@end titlepage
+@bye
+
+@ignore
+   arch-tag: 02d65d63-3b64-49bc-a5c0-bfd5eabb6c98
+@end ignore
--- a/doc/lispref/modes.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/lispref/modes.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -77,15 +77,16 @@
 @samp{-hooks}.  If the variable's name ends in @samp{-function}, then
 its value is just a single function, not a list of functions.
 
-  Here's an example that uses a mode hook to turn on Auto Fill mode when
-in Lisp Interaction mode:
-
-@example
-(add-hook 'lisp-interaction-mode-hook 'turn-on-auto-fill)
-@end example
-
-  At the appropriate time, Emacs uses the @code{run-hooks} function to
-run particular hooks.
+@menu
+* Running Hooks::      How to run a hook.
+* Setting Hooks::      How to put functions on a hook, or remove them.
+@end menu
+
+@node Running Hooks
+@subsection Running Hooks
+
+  At the appropriate times, Emacs uses the @code{run-hooks} function
+and the other functions below to run particular hooks.
 
 @defun run-hooks &rest hookvars
 This function takes one or more normal hook variable names as
@@ -125,6 +126,16 @@
 @code{nil}, it returns @code{nil} as well.
 @end defun
 
+@node Setting Hooks
+@subsection Setting Hooks
+
+  Here's an example that uses a mode hook to turn on Auto Fill mode when
+in Lisp Interaction mode:
+
+@example
+(add-hook 'lisp-interaction-mode-hook 'turn-on-auto-fill)
+@end example
+
 @defun add-hook hook function &optional append local
 This function is the handy way to add function @var{function} to hook
 variable @var{hook}.  You can use it for abnormal hooks as well as for
@@ -141,6 +152,11 @@
 If @var{function} is already present in @var{hook} (comparing using
 @code{equal}), then @code{add-hook} does not add it a second time.
 
+If @var{function} has a non-@code{nil} property
+@code{permanent-local-hook}, then @code{kill-all-local-variables} (or
+changing major modes) won't delete it from the hook variable's local
+value.
+
 It is best to design your hook functions so that the order in which they
 are executed does not matter.  Any dependence on the order is ``asking
 for trouble.''  However, the order is predictable: normally,
--- a/doc/man/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/man/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -22,7 +22,7 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2007 Free Software Foundation, Inc.
+    Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
--- a/doc/misc/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,74 @@
+2008-01-28  Michael Sperber  <sperber@deinprogramm.de>
+
+	* gnus.texi (Mail Source Specifiers): Document `group' specifier.
+	(Group Parameters): Document `mail-source' parameter.
+
+2008-01-27  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (Inline methods): The hostname of the su(do)? methods
+	must be a local host.
+
+2008-01-26  Michael Olson  <mwolson@gnu.org>
+
+	* erc.texi: Update version for ERC 5.3 release.
+	(Obtaining ERC): Update extras URLs for 5.3.
+	(Development): Write instructions for git, and remove those for Arch.
+	(History): Mention the switch to git.
+
+2008-01-24  Karl Berry  <karl@gnu.org>
+
+	* info.texi (Search Index),
+	 (Search Text): mention the command character in the section name,
+	 a la the (Go to node) node.
+
+2008-01-21  Michael Albinus  <michael.albinus@gmx.de>
+
+	* dbus.texi (Errors and Events): New macro dbus-ignore-errors.
+
+2008-01-18  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-news.texi: Mention gnus-article-describe-bindings.
+
+2008-01-18  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-news.texi: Mention gnus-article-wide-reply-with-original.
+
+2008-01-18  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.texi (Property inheritance): New section.
+	(Conventions): New section.
+	(Structure editing): Document C-RET, the prefix arg to the cut/copy
+	commands, and the new bindings for refiling.
+	(Sparse trees): Document the new special command for sparse trees.
+	(References): Be more clear about the counting of hilines.
+	(Handling links): Document M-p/n for accessing links.
+	(Fast access to TODO states): New section.
+	(Per file keywords): New section.
+	(Property inheritance): New section.
+	(Column attributes): New summary types.
+	(Capturing Column View): New section.
+	(The date/time prompt): Cover the new features in the date/time prompt.
+	Compactify the table of keys for the calendar remote control.
+	(Clocking work time): Document the new :scope parameter.
+	(Remember): Promoted to chapter.
+	(Quoted examples): New section.
+	(Enhancing text): New verbatim environments.
+
+2008-01-14  Michael Albinus  <michael.albinus@gmx.de>
+
+	* trampver.texi: Update release number.
+
+2008-01-09  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus.texi (Article Keymap): Add
+	gnus-article-wide-reply-with-original; fix descriptions of
+	gnus-article-reply-with-original and
+	gnus-article-followup-with-original.
+
+2008-01-09  Glenn Morris  <rgm@gnu.org>
+
+	* nxml-mode.texi: Add @copying section.
+
 2008-01-05  Reiner Steib  <Reiner.Steib@gmx.de>
 
 	* message.texi (Mail Variables): Add some text from "(gnus)Posting
@@ -4673,7 +4744,7 @@
 ;; End:
 
     Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
-      2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+      2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
--- a/doc/misc/Makefile.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/Makefile.in	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,7 @@
 #### Makefile for documentation other than the Emacs manual.
 
 # Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-#   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+#   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
--- a/doc/misc/ada-mode.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/ada-mode.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -4,7 +4,7 @@
 
 @copying
 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/autotype.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/autotype.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,7 @@
 \input texinfo
 @c This is an annex of the Emacs manual.
 @c Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004,
-@c   2005, 2006, 2007  Free Software Foundation, Inc.
+@c   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 @c Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
 @setfilename ../../info/autotype
 @c @node Autotypist, Picture, Abbrevs, Top
@@ -13,7 +13,7 @@
 
 @copying
 Copyright @copyright{} 1994, 1995, 1999, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/calc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/calc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -84,7 +84,7 @@
 This file documents Calc, the GNU Emacs calculator.
 
 Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -119,7 +119,7 @@
 
 @vskip 0pt plus 1filll
 Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 @insertcopying
 @end titlepage
 
--- a/doc/misc/cc-mode.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/cc-mode.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -160,7 +160,7 @@
 This manual is for CC Mode in Emacs.
 
 Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/cl.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/cl.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 @copying
 This file documents the GNU Emacs Common Lisp emulation package.
 
-Copyright @copyright{} 1993, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 1993, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 
 @quotation
--- a/doc/misc/dbus.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/dbus.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -674,9 +674,15 @@
 @code{D-Bus ARG} is raised.
 
 All errors raised by D-Bus are signaled with the error symbol
-@code{dbus-error}.  As usual, such an error can be trapped with a
-@code{condition-case} form.  If possible, error messages from D-Bus
-are appended to the @code{dbus-error}.
+@code{dbus-error}.  If possible, error messages from D-Bus are
+appended to the @code{dbus-error}.
+
+@defspec dbus-ignore-errors forms@dots{}
+This executes @var{forms} exactly like a @code{progn}, except that
+@code{dbus-error} errors are ignored during the @var{forms}.  These
+errors can be made visible when variable @code{dbus-debug} is set to
+@code{t}.
+@end defspec
 
 Incoming D-Bus messages are handled as Emacs events (see @pxref{Misc
 Events, , , elisp}).  The generated event has this form:
--- a/doc/misc/dired-x.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/dired-x.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -26,7 +26,7 @@
 
 @copying
 Copyright @copyright{} 1994, 1995, 1999, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/ebrowse.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/ebrowse.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -11,7 +11,7 @@
 This file documents Ebrowse, a C++ class browser for GNU Emacs.
 
 Copyright @copyright{} 2000, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/ediff.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/ediff.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -26,7 +26,7 @@
 and patch utilities.
 
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/emacs-mime.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/emacs-mime.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -10,7 +10,7 @@
 This file documents the Emacs MIME interface functionality.
 
 Copyright @copyright{} 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-2006, 2007 Free Software Foundation, Inc.
+2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/erc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/erc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -12,9 +12,9 @@
 @syncodeindex fn cp
 
 @copying
-This manual is for ERC version 5.2.
+This manual is for ERC version 5.3.
 
-Copyright @copyright{} 2005, 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -72,7 +72,7 @@
                                   permission to redistribute ERC on
                                   certain terms; it also explains that
                                   there is no warranty.
-* GNU Free Documentation License:: The license for this documentation.
+* GNU Free Documentation License::  The license for this documentation.
 * Concept Index::               Search for terms.
 
 @detailmenu
@@ -135,8 +135,8 @@
 locations, or from your local GNU mirror.
 
 @itemize @bullet
-@item @uref{http://ftp.gnu.org/gnu/erc/erc-5.2-extras.tar.gz}
-@item @uref{http://ftp.gnu.org/gnu/erc/erc-5.2-extras.zip}
+@item @uref{http://ftp.gnu.org/gnu/erc/erc-5.3-extras.tar.gz}
+@item @uref{http://ftp.gnu.org/gnu/erc/erc-5.3-extras.zip}
 @end itemize
 
 The rest of this chapter may be skipped if you are using the version of
@@ -169,67 +169,100 @@
 Choose the development version if you want to live on the bleeding edge
 of ERC development or try out new features before release.
 
-@subheading GNU Arch
+@cindex git version control system, using
+The git version control system allows you to keep up-to-date with the
+latest changes to the development version of ERC.  It also allows you
+to contribute changes (via commits, if you are have developer access to
+the repository, or via patches, otherwise).  If you would like to
+contribute to ERC development, it is highly recommended that you use
+git.
 
-ERC is developed using GNU Arch.  Downloading ERC with Arch and staying
-up-to-date involves the following steps.
+If you are new to git, you might find this tutorial helpful:
+@uref{http://www.kernel.org/pub/software/scm/git/docs/tutorial.html}.
+
+Downloading ERC with git and staying up-to-date involves the following
+steps.
 
 @enumerate
-@cindex GNU Arch, installing
-@item Install arch
+@item Install git.
 
 @itemize @bullet
-@item Debian: @kbd{apt-get install tla}.
-@item Other distributions: see @uref{ftp://ftp.gnu.org/gnu/gnu-arch/}.
+@item Debian and Ubuntu: @kbd{apt-get install git-core}.
+@item Windows: @uref{http://git.or.cz/gitwiki/WindowsInstall}.
+@item Other operating systems: download, compile, and install the source
+from @uref{http://www.kernel.org/pub/software/scm/git/}, or find a git
+package for your operating system.
 @end itemize
 
-@cindex GNU Arch, downloading ERC
-@item Register the archive.
+@item Download the ERC development branch.
+
+If you have developer access to ERC, do:
+
 @example
-tla register-archive -f http://arch.sv.gnu.org/archives/erc/erc
+git clone ssh://loginname@@git.sv.gnu.org/srv/git/erc.git
 @end example
 
-@item Download the ERC source code.
+otherwise, do:
+
 @example
-# Download ERC into the @file{erc} directory.
-tla get erc@@sv.gnu.org/erc--main--0 erc
+git clone git://git.sv.gnu.org/erc.git
+@end example
+
+If you are behind a restrictive firewall, and do not have developer
+access, then do the following instead:
+
+@example
+git clone http://git.sv.gnu.org/r/erc.git
 @end example
 
 @item List upstream changes that are missing from your local copy.
 Do this whenever you want to see whether new changes have been committed
-to ERC.
+to ERC.  If you wish, you may skip this step and proceed directly to
+the ``update'' step.
 
 @example
 # Change to the source directory you are interested in.
-cd erc/
+cd erc
 
-# Display the summary of changes
-tla missing --summary
+# Fetch new changes from the repository, but don't apply them yet
+git fetch origin
+
+# Display log messages for the new changes
+git log HEAD..origin
 @end example
 
-@cindex GNU Arch, updating ERC
-@item Update to the latest version by replaying missing changes.
+``origin'' is git's name for the location where you originally got ERC
+from.  You can change this location at any time by editing the
+@file{.git/config} file in the directory where the ERC source was
+placed.
+
+@cindex updating ERC with git
+@item Update to the latest version by pulling in any missing changes.
+
 @example
 cd erc
-tla update
+git pull origin
 @end example
 
+git will show how many files changed, and will provide a visual display
+for how many lines were changed in each file.
+
 @end enumerate
 
-If you are new to Arch and want to learn more about developing ERC with
-it, visit @uref{http://emacswiki.org/cgi-bin/wiki/ErcDevelopment} for
-full instructions.
-
-@subheading Development snapshots
+There are other ways to interact with the ERC repository.
 
-@cindex development snapshot
-Alternatively, the latest development snapshot may be downloaded in both
-``.tar.gz'' and ``.zip'' forms.
+@itemize
+@item Browse git repo: @uref{http://git.sv.gnu.org/gitweb/?p=erc.git}
+@item Latest development snapshot: @uref{http://mwolson.org/static/dist/erc-latest.tar.gz}
+@item Latest development snapshot (zip file): @uref{http://mwolson.org/static/dist/erc-latest.zip}
+@end itemize
 
-@itemize @bullet
-@item @uref{http://www.mwolson.org/static/dist/erc-latest.tar.gz}
-@item @uref{http://www.mwolson.org/static/dist/erc-latest.zip}
-@end itemize
+The latest development snapshot can lag behind the git repo by as much
+as 20 minutes, but never more than that.
+
+For further information on committing changes to ERC and performing
+development, please consult
+@uref{http://emacswiki.org/cgi-bin/wiki/ErcDevelopment}.
 
 
 @node Installation, Getting Started, Obtaining ERC, Top
@@ -1009,6 +1042,10 @@
 @uref{http://sv.gnu.org/projects/erc}.  We switched to using GNU Arch as
 our revision control system.  Our mailing list address changed as well.
 
+@item 2007
+
+We switched to using git for our version control system.
+
 @end itemize
 
 @node Copying, GNU Free Documentation License, History, Top
--- a/doc/misc/eshell.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/eshell.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -9,7 +9,7 @@
 This manual is for Eshell, the Emacs shell.
 
 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/eudc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/eudc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -12,7 +12,7 @@
 directory servers using various protocols such as LDAP or the CCSO white
 pages directory system (PH/QI)
 
-Copyright @copyright{} 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 
 @quotation
--- a/doc/misc/faq.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/faq.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -14,7 +14,7 @@
 @c appreciate a notice if you do).
 
 @copying
-Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.@*
 Copyright 1994,1995,1996,1997,1998,1999,2000 Reuven M. Lerner@*
 Copyright 1992,1993 Steven Byrnes@*
--- a/doc/misc/flymake.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/flymake.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -11,7 +11,7 @@
 This manual is for GNU Flymake (version @value{VERSION}, @value{UPDATED}),
 which is a universal on-the-fly syntax checker for GNU Emacs.
 
-Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/forms.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/forms.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -19,7 +19,7 @@
 This file documents Forms mode, a form-editing major mode for GNU Emacs.
 
 Copyright @copyright{} 1989, 1997, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/gnus-coding.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/gnus-coding.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -7,7 +7,7 @@
 @syncodeindex pg cp
 
 @copying
-Copyright (c) 2004, 2005, 2007  Free Software Foundation, Inc.
+Copyright (C) 2004, 2005, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/gnus-faq.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/gnus-faq.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,8 @@
 @c \input texinfo @c -*-texinfo-*-
 @c Uncomment 1st line before texing this file alone.
 @c %**start of header
-@c Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+@c   2008 Free Software Foundation, Inc.
 @c
 @c Do not modify this file, it was generated from gnus-faq.xml, available from
 @c <URL:http://my.gnus.org/FAQ/>.
--- a/doc/misc/gnus-news.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/gnus-news.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
-;; Copyright (C)  2004, 2005, 2006  Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Reiner Steib  <Reiner.Steib@gmx.de>
 ;; Keywords: tools
@@ -29,7 +29,7 @@
 "GNUS NEWS -- history of user-visible changes.
 
 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007 Free Software Foundation, Inc.
+   2006, 2007, 2008  Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Gnus bug reports to bugs@gnus.org.
--- a/doc/misc/gnus-news.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/gnus-news.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 
-@c Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @c    Permission is granted to anyone to make or distribute verbatim copies
 @c    of this document as received, in any medium, provided that the
@@ -140,6 +140,19 @@
 emacs-mime, The Emacs MIME Manual}.  (New in Gnus 5.10.7)
 @c This entry is also present in the node "Oort Gnus".
 
+@item Now the new command @kbd{S W}
+(@code{gnus-article-wide-reply-with-original}) for a wide reply in the
+article buffer yanks a text that is in the active region, if it is set,
+as well as the @kbd{R} (@code{gnus-article-reply-with-original}) command.
+Note that the @kbd{R} command in the article buffer no longer accepts a
+prefix argument, which was used to make it do a wide reply.
+@xref{Article Keymap}.
+
+@item The new command @kbd{C-h b}
+(@code{gnus-article-describe-bindings}) used in the article buffer now
+shows not only the article commands but also the real summary commands
+that are accessible from the article buffer.
+
 @end itemize
 
 @item Changes in Message mode
--- a/doc/misc/gnus.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/gnus.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -3035,6 +3035,12 @@
 If it is set, the value is used as the method for posting message
 instead of @code{gnus-post-method}.
 
+@item mail-source
+@cindex mail-source
+If it is set, and the setting of @code{mail-sources} includes a
+@code{group} mail source (@pxref{Mail Sources}), the value is a
+mail source for this group.
+
 @item banner
 @cindex banner
 An item like @code{(banner . @var{regexp})} causes any part of an article
@@ -11900,17 +11906,22 @@
 @kindex R (Article)
 @findex gnus-article-reply-with-original
 Send a reply to the current article and yank the current article
-(@code{gnus-article-reply-with-original}).  If given a prefix, make a
-wide reply.  If the region is active, only yank the text in the
-region.
+(@code{gnus-article-reply-with-original}).  If the region is active,
+only yank the text in the region.
+
+@item S W
+@kindex S W (Article)
+@findex gnus-article-wide-reply-with-original
+Send a wide reply to the current article and yank the current article
+(@code{gnus-article-wide-reply-with-original}).  If the region is
+active, only yank the text in the region.
 
 @item F
 @kindex F (Article)
 @findex gnus-article-followup-with-original
 Send a followup to the current article and yank the current article
-(@code{gnus-article-followup-with-original}).  If given a prefix, make
-a wide reply.  If the region is active, only yank the text in the
-region.
+(@code{gnus-article-followup-with-original}).  If the region is active,
+only yank the text in the region.
 
 
 @end table
@@ -14140,6 +14151,21 @@
 @dfn{keywords}.  Keywords that are not explicitly specified are given
 default values.
 
+The @code{mail-sources} is global for all mail groups.  You can specify
+an additional mail source for a particular group by including the
+@code{group} mail specifier in @code{mail-sources}, and setting a
+@code{mail-source} group parameter (@pxref{Group Parameters}) specifying
+a single mail source.  When this is used, @code{mail-sources} is
+typically just @code{(group)}; the @code{mail-source} parameter for a
+group might look like this:
+
+@lisp
+(mail-source . (file :path "home/user/spools/foo.spool"))
+@end lisp
+
+This means that the group's (and only this group's) messages will be
+fetched from the spool file @samp{/user/spools/foo.spool}.
+
 The following mail source types are available:
 
 @table @code
@@ -14530,6 +14556,11 @@
          :user "user-name"
          :password "secret")
 @end lisp
+
+@item group
+Get the actual mail source from the @code{mail-source} group parameter,
+@xref{Group Parameters}.
+
 @end table
 
 @table @dfn
--- a/doc/misc/idlwave.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/idlwave.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -27,7 +27,7 @@
 @value{VERSION}
 
 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
-          2006, 2007 Free Software Foundation, Inc.
+          2006, 2007, 2008 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
@@ -58,7 +58,7 @@
 IDLWAVE version @value{VERSION}, @value{DATE}.
 @sp 2
 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
-          2006, 2007 Free Software Foundation, Inc.
+          2006, 2007, 2008 Free Software Foundation, Inc.
 @sp 2
 @cindex Copyright, of IDLWAVE
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/info.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/info.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -15,7 +15,7 @@
 documentation system.
 
 Copyright @copyright{} 1989, 1992, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -970,7 +970,7 @@
 
 @node Search Text, Search Index,  , Advanced
 @comment  node-name,  next,  previous,  up
-@section How to search Info documents
+@section @kbd{s} searches Info documents
 
 @cindex searching Info documents
 @cindex Info document as a reference
@@ -1018,7 +1018,7 @@
 
 @node Search Index, Go to node, Search Text, Advanced
 @comment  node-name,  next,  previous,  up
-@section How to search the indices for specific subjects
+@section @kbd{i} searches the indices for specific subjects
 
 @cindex searching Info indices
 @kindex i @r{(Info mode)}
--- a/doc/misc/makefile.w32-in	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/makefile.w32-in	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 #### -*- Makefile -*- for documentation other than the Emacs manual.
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
--- a/doc/misc/mh-e.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/mh-e.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -24,7 +24,7 @@
 This is version @value{VERSION}@value{EDITION} of @cite{The MH-E
 Manual}, last updated @value{UPDATED}.
 
-Copyright @copyright{} 1995, 2001, 2002, 2003, 2005, 2006, 2007 Free
+Copyright @copyright{} 1995, 2001, 2002, 2003, 2005, 2006, 2007, 2008 Free
 Software Foundation, Inc.
 
 @quotation
--- a/doc/misc/newsticker.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/newsticker.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -13,7 +13,7 @@
 This manual is for Newsticker (version @value{VERSION}, @value{UPDATED}).
 
 @noindent
-Copyright @copyright{} 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+Copyright @copyright{} 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/nxml-mode.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/nxml-mode.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -4,6 +4,33 @@
 @settitle nXML Mode
 @c %**end of header
 
+@copying
+
+This manual documents nxml-mode, an Emacs major mode for editing
+XML with RELAX NG support. 
+
+Copyright @copyright{} 2007, 2008 Free Software Foundation, Inc.
+
+@quotation
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.2 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with the Front-Cover texts being ``A GNU
+Manual,'' and with the Back-Cover Texts as in (a) below.  A copy of the
+license is included in the section entitled ``GNU Free Documentation
+License'' in the Emacs manual.
+
+(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+this GNU Manual, like GNU software.  Copies published by the Free
+Software Foundation raise funds for GNU development.''
+
+This document is part of a collection distributed under the GNU Free
+Documentation License.  If you want to distribute this document
+separately from the collection, you can do so by adding a copy of the
+license to the document, as described in section 6 of the license.
+@end quotation
+@end copying
+
 @dircategory Emacs
 @direntry
 * nXML Mode: (nxml-mode).       XML editing mode with RELAX NG support.
--- a/doc/misc/org.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/org.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -3,8 +3,8 @@
 @setfilename ../../info/org
 @settitle Org Mode Manual
 
-@set VERSION 5.07
-@set DATE August 2007
+@set VERSION 5.19
+@set DATE January 2008
 
 @dircategory Emacs
 @direntry
@@ -12,11 +12,11 @@
 @end direntry
 
 @c Version and Contact Info
-@set MAINTAINERSITE @uref{http://www.astro.uva.nl/~dominik/Tools/org/,maintainers webpage}
+@set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
 @set AUTHOR Carsten Dominik
 @set MAINTAINER Carsten Dominik
-@set MAINTAINEREMAIL @email{dominik at science dot uva dot nl}
-@set MAINTAINERCONTACT @uref{mailto:dominik at science dot uva dot nl,contact the maintainer}
+@set MAINTAINEREMAIL @email{carsten at orgmode dot org}
+@set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
 @c %**end of header
 @finalout
 
@@ -35,7 +35,7 @@
 @copying
 This manual is for Org-mode (version @value{VERSION}).
 
-Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation
+Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -81,8 +81,9 @@
 * Hyperlinks::                  Notes in context
 * TODO items::                  Every tree branch can be a TODO item
 * Tags::                        Tagging headlines and matching sets of tags
-* Properties and columns::      
-* Timestamps::                  Assign date and time to items
+* Properties and columns::      Storing information about an entry
+* Dates and times::             Making items useful for planning
+* Remember::                    Quickly adding nodes to the outline tree
 * Agenda views::                Collecting information into views
 * Embedded LaTeX::              LaTeX fragments and formulas
 * Exporting::                   Sharing and publishing of notes
@@ -90,7 +91,7 @@
 * Miscellaneous::               All the rest which did not fit elsewhere
 * Extensions and Hacking::      It is possible to write add-on code
 * History and Acknowledgments::  How Org-mode came into being 
-* Index::                       The fast road to specific information
+* Main Index::                  
 * Key Index::                   Key bindings and where they are described
 
 @detailmenu
@@ -102,6 +103,7 @@
 * Installation::                How to install a downloaded version of Org-mode
 * Activation::                  How to activate Org-mode for certain buffers.
 * Feedback::                    Bug reports, ideas, patches etc.
+* Conventions::                 Type-setting conventions in the manual
 
 Document Structure
 
@@ -150,22 +152,16 @@
 * Link abbreviations::          Shortcuts for writing complex links
 * Search options::              Linking to a specific location
 * Custom searches::             When the default search is not enough
-* Remember::                    Org-trees store quick notes
 
 Internal links
 
 * Radio targets::               Make targets trigger links in plain text.
 
-Remember
-
-* Setting up remember::         Some code for .emacs to get things going
-* Remember templates::          Define the outline of different note types
-* Storing notes::               Directly get the note to where it belongs
-
 TODO items
 
 * TODO basics::                 Marking and displaying TODO entries
 * TODO extensions::             Workflow and assignments
+* Progress logging::            Dates and notes for progress
 * Priorities::                  Some things are more important than others
 * Breaking down tasks::         Splitting a task into manageable pieces
 * Checkboxes::                  Tick-off lists
@@ -173,9 +169,16 @@
 Extended use of TODO keywords
 
 * Workflow states::             From TODO to DONE in steps
-* TODO types::                  I do this, Fred the rest
+* TODO types::                  I do this, Fred does the rest
 * Multiple sets in one file::   Mixing it all, and still finding your way
-* Per file keywords::           Different files, different requirements
+* Fast access to TODO states::  Single letter selection of a state
+* Per-file keywords::           Different files, different requirements
+* Faces for TODO keywords::     Highlighting states
+
+Progress Logging
+
+* Closing items::               When was this entry marked DONE?
+* Tracking TODO state changes::  When did the status change?
 
 Tags
 
@@ -188,6 +191,7 @@
 * Property syntax::             How properties are spelled out
 * Special properties::          Access to other Org-mode features
 * Property searches::           Matching property values
+* Property inheritance::        Passing values down the tree
 * Column view::                 Tabular viewing and editing
 * Property API::                Properties for Lisp programmers
 
@@ -195,18 +199,19 @@
 
 * Defining columns::            The COLUMNS format property
 * Using column view::           How to create and use column view
+* Capturing Column View::       A dynamic block for column view
 
 Defining Columns
 
 * Scope of column definitions::  Where defined, where valid?
 * Column attributes::           Appearance and content of a column
 
-Timestamps
+Dates and Times
 
 * Time stamps::                 Assigning a time to a tree entry
 * Creating timestamps::         Commands which insert timestamps
 * Deadlines and scheduling::    Planning your work
-* Progress logging::            Documenting when what work was done.
+* Clocking work time::          
 
 Creating timestamps
 
@@ -218,11 +223,12 @@
 * Inserting deadline/schedule::  Planning items
 * Repeated tasks::              Items that show up again and again
 
-Progress Logging
-
-* Closing items::               When was this entry marked DONE?
-* Tracking TODO state changes::  When did the status change?
-* Clocking work time::          When exactly did you work on this item?
+Remember
+
+* Setting up remember::         Some code for .emacs to get things going
+* Remember templates::          Define the outline of different note types
+* Storing notes::               Directly get the note to where it belongs
+* Refiling notes::              Moving a note or task to a project
 
 Agenda Views
 
@@ -284,12 +290,14 @@
 
 * LaTeX export commands::       How to invoke LaTeX export
 * Quoting LaTeX code::          Incorporating literal LaTeX code
+* Sectioning structure::        
 
 Text interpretation by the exporter
 
 * Comment lines::               Some lines will not be exported
 * Initial text::                Text before the first headline
 * Footnotes::                   Numbers like [1]
+* Quoted examples::             Inserting quoted chnuks of text            
 * Enhancing text::              Subscripts, symbols and more
 * Export options::              How to influence the export settings
 
@@ -339,11 +347,12 @@
 * Special agenda views::        Customized views
 * Using the property API::      Writing programs that use entry properties
 
-Tables in arbitrary syntax
+Tables and Lists in arbitrary syntax
 
 * Radio tables::                Sending and receiving
 * A LaTeX example::             Step by step, almost a tutorial
 * Translator functions::        Copy and modify
+* Radio lists::                 Doing the same for lists.
 
 @end detailmenu
 @end menu
@@ -357,6 +366,7 @@
 * Installation::                How to install a downloaded version of Org-mode
 * Activation::                  How to activate Org-mode for certain buffers.
 * Feedback::                    Bug reports, ideas, patches etc.
+* Conventions::                 Type-setting conventions in the manual
 @end menu
 
 @node Summary, Installation, Introduction, Introduction
@@ -377,7 +387,7 @@
 and diary.  Plain text URL-like links connect to websites, emails,
 Usenet messages, BBDB entries, and any files related to the projects.
 For printing and sharing of notes, an Org-mode file can be exported as a
-structured ASCII file, as HTML, or (todo and agenda items only) as an
+structured ASCII file, as HTML, or (TODO and agenda items only) as an
 iCalendar file.  It can also serve as a publishing tool for a set of
 linked webpages.
 
@@ -404,7 +414,7 @@
 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
 @r{@bullet{} environment to implement David Allen's GTD system}
 @r{@bullet{} a basic database application}
-@r{@bullet{} simple hypertext system, with HTML export}
+@r{@bullet{} simple hypertext system, with HTML and LaTeX export}
 @r{@bullet{} publishing tool to create a set of interlinked webpages}
 @end example
 
@@ -419,7 +429,7 @@
 There is a website for Org-mode which provides links to the newest
 version of Org-mode, as well as additional information, frequently asked
 questions (FAQ), links to tutorials etc.  This page is located at
-@uref{http://www.astro.uva.nl/~dominik/Tools/org/}.
+@uref{http://orgmode.org}.
 
 @page
 
@@ -524,7 +534,7 @@
 the file's name is.  See also the variable
 @code{org-insert-mode-line-in-empty-file}.
 
-@node Feedback,  , Activation, Introduction
+@node Feedback, Conventions, Activation, Introduction
 @section Feedback
 @cindex feedback
 @cindex bug reports
@@ -581,6 +591,27 @@
 attach it to your bug report.
 @end enumerate
 
+@node Conventions,  , Feedback, Introduction
+@section Typesetting conventions used in this manual
+
+Org-mode uses three types of keywords: TODO keywords, tags, and property
+names.  In this manual we use the following conventions:
+
+@table @code
+@item TODO
+@itemx WAITING
+TODO keywords are written with all capitals, even if they are
+user-defined.
+@item boss
+@itemx ARCHIVE
+User-defined tags are written in lowercase; built-in tags with special
+meaning are written with all capitals.
+@item Release
+@itemx PRIORITY
+User-defined properties are capitalized; built-in properties with
+special meaning are written with all capitals.
+@end table
+
 @node Document structure, Tables, Introduction, Top
 @chapter Document Structure
 @cindex document structure
@@ -708,8 +739,10 @@
 @item C-c C-r
 Reveal context around point, showing the current entry, the following
 heading and the hierarchy above.  Useful for working near a location
-exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda
-command (@pxref{Agenda commands}).  With prefix arg show, on each
+that has been exposed by a sparse tree command (@pxref{Sparse trees}) or
+an agenda command (@pxref{Agenda commands}).  With prefix arg show, on
+each
+
 level, all sibling headings.
 @kindex C-c C-x b
 @item C-c C-x b
@@ -806,6 +839,10 @@
 new heading.  If the command is used at the end of a folded subtree
 (i.e. behind the ellipses at the end of a headline), then a headline
 like the current one will be inserted after the end of the subtree.
+@kindex C-@key{RET}
+@item C-@key{RET}
+Insert a new heading after the current subtree, same level as the
+current headline.  This command works from anywhere in the entry.
 @kindex M-S-@key{RET}
 @item M-S-@key{RET}
 Insert new TODO entry with same level as current heading.
@@ -833,22 +870,27 @@
 @item C-c C-x C-w
 @itemx C-c C-x C-k
 Kill subtree, i.e. remove it from buffer but save in kill ring.
+With prefix arg, kill N sequential subtrees.
 @kindex C-c C-x M-w
 @item C-c C-x M-w
-Copy subtree to kill ring.
+Copy subtree to kill ring.  With prefix arg, copy N sequential subtrees.
 @kindex C-c C-x C-y
 @item C-c C-x C-y
 Yank subtree from kill ring.  This does modify the level of the subtree to
 make sure the tree fits in nicely at the yank position.  The yank
 level can also be specified with a prefix arg, or by yanking after a
 headline marker like @samp{****}.
+@kindex C-c C-w
+@item C-c C-w
+Refile entry to a different location.  @xref{Refiling notes}.
 @kindex C-c ^
 @item C-c ^
 Sort same-level entries.  When there is an active region, all entries in
 the region will be sorted.  Otherwise the children of the current
 headline are sorted.  The command prompts for the sorting method, which
 can be alphabetically, numerically, by time (using the first time stamp
-in each entry), by priority, and each of these in reverse order.  With a
+in each entry), by priority, and each of these in reverse order.  You
+can also supply your own function to extract the sorting key.  With a
 @kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
 C-u} prefixes, duplicate entries will also be removed.
 @end table
@@ -956,16 +998,22 @@
 current file name.  For information and examples on how to change this,
 see the documentation string of the variable
 @code{org-archive-location}.  There is also an in-buffer option for
-setting this variable, for example
+setting this variable, for example@footnote{For backward compatibility,
+the following also works: If there are several such lines in a file,
+each specifies the archive location for the text below it.  The first
+such line also applies to any text before its definition.  However,
+using this method is @emph{strongly} deprecated as it is incompatible
+with the outline structure of the document.  The correct method for
+setting multiple archive locations in a buffer is using a property.}:
 
 @example
 #+ARCHIVE: %s_done::
 @end example
 
 @noindent
-You may have several such lines in the buffer, they will then be valid
-for the entries following the line (the first will also apply to any
-text before it).
+If you would like to have a special ARCHIVE location for a single entry
+or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
+location as the value (@pxref{Properties and columns}).
 
 @node Sparse trees, Plain lists, Archiving, Document structure
 @section Sparse trees
@@ -975,21 +1023,23 @@
 @cindex occur, command
 
 An important feature of Org-mode is the ability to construct
-@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 variables
-@code{org-show-hierarchy-above}, @code{org-show-following-heading}, and
-@code{org-show-siblings} for detailed control on how much context is
-shown around each match.}.  Just try it out and you will see immediately
-how it works.
-
-Org-mode contains several commands creating such trees.  The most
-basic one is @command{org-occur}:
+@emph{sparse trees} for selected information in an outline tree, so 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 variables @code{org-show-hierarchy-above},
+@code{org-show-following-heading}, and @code{org-show-siblings} for
+detailed control on how much context is shown around each match.}.  Just
+try it out and you will see immediately how it works.
+
+Org-mode contains several commands creating such trees, all these
+commands can be accessed through a dispatcher:
 
 @table @kbd
 @kindex C-c /
 @item C-c /
+This prompts for an extra key to select a sparse-tree creating command.
+@kindex C-c / r
+@item C-c / r
 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
 If the match is in a headline, the headline is made visible.  If the
 match is in the body of an entry, headline and body are made visible.
@@ -1000,6 +1050,7 @@
 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
 highlights are kept, so several calls to this command can be stacked.
 @end table
+
 @noindent
 For frequently used sparse trees of specific search strings, you can
 use the variable @code{org-agenda-custom-commands} to define fast
@@ -1015,8 +1066,8 @@
 @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 use sparse trees as well.  For example @kbd{C-c
-C-v} creates a sparse TODO tree (@pxref{TODO basics}).
+The other sparse tree commands select headings based on TODO keywords,
+tags, or properties and will be discussed later in this manual.
 
 @kindex C-c C-e v
 @cindex printing sparse trees
@@ -1038,7 +1089,7 @@
 Within an entry of the outline tree, hand-formatted lists can provide
 additional structure.  They also provide a way to create lists of
 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
-and the HTML exporter (@pxref{Exporting}) does parse and format them.
+and the HTML exporter (@pxref{Exporting}) parses and formats them.
 
 Org-mode knows ordered and unordered lists.  Unordered list items start
 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
@@ -1046,8 +1097,9 @@
 headlines.  Also, when you are hiding leading stars to get a clean
 outline view, plain list items starting with a star are visually
 indistinguishable from true headlines.  In short: even though @samp{*}
-is supported, it may be better not to use it for plain list items.} as
-bullets.  Ordered list items start with @samp{1.} or @samp{1)}.  Items
+is supported, it may be better to not use it for plain list items.} as
+bullets.  Ordered list items start with a numeral followed by either a
+period or a right parenthesis, such as @samp{1.} or @samp{1)}.  Items
 belonging to the same list must have the same indentation on the first
 line.  In particular, if an ordered list reaches number @samp{10.}, then
 the 2--digit numbers must be written left-aligned with the other numbers
@@ -1131,9 +1183,9 @@
 @kindex C-c C-c
 @item C-c C-c
 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
-state of the checkbox.  If not, make this command makes sure that all
-the items on this list level use the same bullet.  Furthermore, if this
-is an ordered list, make sure the numbering is ok.
+state of the checkbox.  If not, this command makes sure that all the
+items on this list level use the same bullet.  Furthermore, if this is
+an ordered list, make sure the numbering is ok.
 @kindex C-c -
 @item C-c -
 Cycle the entire list level through the different itemize/enumerate
@@ -1148,7 +1200,9 @@
 
 Sometimes you want to keep information associated with an entry, but you
 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
-Drawers need to be configured with the variable @code{org-drawers}, and
+Drawers need to be configured with the variable
+@code{org-drawers}@footnote{You can define drawers on a per-file basis
+with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
 look like this:
 
 @example
@@ -1194,9 +1248,16 @@
 @cindex tables
 @cindex editing tables
 
-Org-mode has a very fast and intuitive table editor built-in.
-Spreadsheet-like calculations are supported in connection with the
-Emacs @file{calc} package.
+Org-mode comes with a fast and intuitive table editor.  Spreadsheet-like
+calculations are supported in connection with the Emacs @file{calc}
+package 
+@ifinfo
+(@pxref{Calc,,,calc,Gnu Emacs Calculator Manual}).
+@end ifinfo
+@ifnotinfo
+(see the Emacs Calculator manual for more information about the Emacs
+calculator).
+@end ifnotinfo
 
 @menu
 * Built-in table editor::       Simple tables
@@ -1254,9 +1315,12 @@
 @item C-c |
 Convert the active region to table. If every line contains at least one
 TAB character, the function assumes that the material is tab separated.
+If every line contains a comma, comma-separated values (CSV) are assumed.
 If not, lines are split at whitespace into fields.  You can use a prefix
-argument to indicate the minimum number of consecutive spaces required
-to identify a field separator (default: just one).@* 
+argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
+C-u} forces TAB, and a numeric argument N indicates that at least N
+consequtive spaces, or alternatively a TAB will be the separator.
+@* 
 If there is no active region, this command creates an empty Org-mode
 table.  But it's easier just to start typing, like
 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
@@ -1388,18 +1452,14 @@
 @kbd{C-u} prefix, just make the full field visible, so that it can be
 edited in place.
 @c
-@kindex C-c @key{TAB}
-@item C-c @key{TAB}
-This is an alias for @kbd{C-u C-c `} to make the current field fully
-visible.
-@c
 @item M-x org-table-import
 Import a file as a table.  The table should be TAB- or whitespace
-separated.  Useful, for example, to import an Excel table or data from a
-database, because these programs generally can write TAB-separated text
-files.  This command works by inserting the file into the buffer and
-then converting the region to a table.  Any prefix argument is passed on
-to the converter, which uses it to determine the separator.
+separated.  Useful, for example, to import a spreadsheet table or data
+from a database, because these programs generally can write
+TAB-separated text files.  This command works by inserting the file into
+the buffer and then converting the region to a table.  Any prefix
+argument is passed on to the converter, which uses it to determine the
+separator.
 @item C-c |
 Tables can also be imported by pasting tabular text into the org-mode
 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
@@ -1407,7 +1467,7 @@
 @c
 @item M-x org-table-export
 Export the table as a TAB-separated file.  Useful for data exchange with,
-for example, Excel or database programs.
+for example, spreadsheet or database programs.
 @end table
 
 If you don't like the automatic table editor because it gets in your
@@ -1583,13 +1643,15 @@
 separator lines (hlines).  You can use absolute row numbers
 @samp{1}...@samp{N}, and row numbers relative to the current row like
 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
-hlines: @samp{I} refers to the first hline, @samp{II} to the second etc.
-@samp{-I} refers to the first such line above the current line,
-@samp{+I} to the first such line below the current line.  You can also
-write @samp{III+2} which is the second data line after the third hline
-in the table.  Relative row numbers like @samp{-3} will not cross hlines
-if the current line is too close to the hline.  Instead, the value
-directly at the hline is used.
+hlines: @samp{I} refers to the first hline@footnote{Note that only
+hlines are counted that @emph{separate} table lines.  If the table
+starts with a hline above the header, it does not count.}, @samp{II} to
+the second etc.  @samp{-I} refers to the first such line above the
+current line, @samp{+I} to the first such line below the current line.
+You can also write @samp{III+2} which is the second data line after the
+third hline in the table.  Relative row numbers like @samp{-3} will not
+cross hlines if the current line is too close to the hline.  Instead,
+the value directly at the hline is used.
 
 @samp{0} refers to the current row and column.  Also, if you omit
 either the column or the row part of the reference, the current
@@ -1656,8 +1718,8 @@
 
 @noindent
 Also properties (@pxref{Properties and columns}) can be used as
-constants in table formulas: For a property @samp{:XYZ:} use the name
-@samp{$PROP_XYZ}, and the property will be searched in the current
+constants in table formulas: For a property @samp{:Xyz:} use the name
+@samp{$PROP_Xyz}, and the property will be searched in the current
 outline entry and in the hierarchy above it.  If you have the
 @file{constants.el} package, it will also be used to resolve constants,
 including natural constants like @samp{$h} for Planck's constant, and
@@ -2087,8 +2149,8 @@
 @chapter Hyperlinks
 @cindex hyperlinks
 
-Just like HTML, Org-mode provides links inside a file, and external
-links to other files, Usenet articles, emails, and much more.
+Like HTML, Org-mode provides links inside a file, external links to
+other files, Usenet articles, emails, and much more.
 
 @menu
 * Link format::                 How links in Org-mode are formatted
@@ -2099,7 +2161,6 @@
 * Link abbreviations::          Shortcuts for writing complex links
 * Search options::              Linking to a specific location
 * Custom searches::             When the default search is not enough
-* Remember::                    Org-trees store quick notes
 @end menu
 
 @node Link format, Internal links, Hyperlinks, Hyperlinks
@@ -2304,20 +2365,21 @@
 You can just type a link, using text for an internal link, or one of the
 link type prefixes mentioned in the examples above.  All links stored
 during the current session are part of the history for this prompt, so
-you can access them with @key{up} and @key{down}.  Completion, on the
-other hand, will help you to insert valid link prefixes like
-@samp{http:} or @samp{ftp:}, including the prefixes defined through link
-abbreviations (@pxref{Link abbreviations}).  The link will be inserted
-into the buffer@footnote{After insertion of a stored link, the link will
-be removed from the list of stored links.  To keep it in the list later
-use, use a triple @kbd{C-u} prefix to @kbd{C-c C-l}, or configure the
-option @code{org-keep-stored-link-after-insertion}.}, along with a
-descriptive text.  If some text was selected when this command is
-called, the selected text becomes the default description.@* Note that
-you don't have to use this command to insert a link.  Links in Org-mode
-are plain text, and you can type or paste them straight into the buffer.
-By using this command, the links are automatically enclosed in double
-brackets, and you will be asked for the optional descriptive text.
+you can access them with @key{up} and @key{down} (or @kbd{M-p/n}).
+Completion, on the other hand, will help you to insert valid link
+prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
+defined through link abbreviations (@pxref{Link abbreviations}).  The
+link will be inserted into the buffer@footnote{After insertion of a
+stored link, the link will be removed from the list of stored links.  To
+keep it in the list later use, use a triple @kbd{C-u} prefix to @kbd{C-c
+C-l}, or configure the option
+@code{org-keep-stored-link-after-insertion}.}, along with a descriptive
+text.  If some text was selected when this command is called, the
+selected text becomes the default description.@* Note that you don't
+have to use this command to insert a link.  Links in Org-mode are plain
+text, and you can type or paste them straight into the buffer.  By using
+this command, the links are automatically enclosed in double brackets,
+and you will be asked for the optional descriptive text.
 @c
 @c  If the link is a @samp{file:} link and
 @c the linked file is located in the same directory as the current file or
@@ -2513,7 +2575,7 @@
 a search for @samp{find me} in the current file, just as
 @samp{[[find me]]} would.
 
-@node Custom searches, Remember, Search options, Hyperlinks
+@node Custom searches,  , Search options, Hyperlinks
 @section Custom Searches
 @cindex custom search strings
 @cindex search strings, custom
@@ -2537,194 +2599,26 @@
 file.
 
 
-@node Remember,  , Custom searches, Hyperlinks
-@section Remember
-@cindex @file{remember.el}
-
-Another way to create org entries with links to other files is through
-the @i{remember} package by John Wiegley.  @i{Remember} lets you store
-quick notes with little interruption of your work flow.  See
-@uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
-information.  The notes produced by @i{Remember} can be stored in
-different ways, and Org-mode files are a good target.  Org-mode
-significantly expands the possibilities of @i{remember}: You may define
-templates for different note types, and to associate target files and
-headlines with specific templates.  It also allows you to select the
-location where a note should be stored interactively, on the fly.
-
-@menu
-* Setting up remember::         Some code for .emacs to get things going
-* Remember templates::          Define the outline of different note types
-* Storing notes::               Directly get the note to where it belongs
-@end menu
-
-@node Setting up remember, Remember templates, Remember, Remember
-@subsection Setting up remember
-
-The following customization will tell @i{remember} to use org files as
-target, and to create annotations compatible with Org-mode links.
-
-@example
-(setq org-directory "~/path/to/my/orgfiles/")
-(setq org-default-notes-file "~/.notes")
-(setq remember-annotation-functions '(org-remember-annotation))
-(setq remember-handler-functions '(org-remember-handler))
-(add-hook 'remember-mode-hook 'org-remember-apply-template)
-@end example
-
-@node Remember templates, Storing notes, Setting up remember, Remember
-@subsection Remember templates
-@cindex templates, for remember
-
-In combination with Org-mode, you can use templates to generate
-different types of @i{remember} notes.  For example, if you would like
-to use one template to create general TODO entries, another one for
-journal entries, and a third one for collecting random ideas, you could
-use:
-
-@example
-(setq org-remember-templates
- '((?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org")
-   (?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
-   (?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
-@end example
-
-@noindent In these entries, the character specifies how to select the
-template.  The first string specifies the template.  Two more (optional)
-strings give the file in which, and the headline under which the new
-note should be stored.  The file defaults (if not present or @code{nil})
-to @code{org-default-notes-file}, the heading to
-@code{org-remember-default-headline}.  Both defaults help to get to the
-storing location quickly, but you can change the location interactively
-while storing the note.
-
-When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
-something, org will prompt for a key to select the template (if you have
-more than one template) and then prepare the buffer like
-@example
-* TODO
-  [[file:link to where you called remember]]
-@end example
-
-@noindent or
-
-@example
-* [2006-03-21 Tue 15:37]
-
-  [[file:link to where you called remember]]
-@end example
-
-@noindent
-During expansion of the template, special @kbd{%}-escapes allow dynamic
-insertion of content:
-@example
-%^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
-%t          @r{time stamp, date only}
-%T          @r{time stamp with date and time}
-%u, %U      @r{like the above, but inactive time stamps}
-%^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
-            @r{You may define a prompt like @code{%^@{Birthday@}t}}
-%n          @r{user name (taken from @code{user-full-name})}
-%a          @r{annotation, normally the link created with @code{org-store-link}}
-%i          @r{initial content, the region when remember is called with C-u.}
-            @r{The entire text will be indented like @code{%i} itself.}
-%^g         @r{prompt for tags, with completion on tags in target file.}
-%^G         @r{prompt for tags, with completion all tags in all agenda files.}
-%:keyword   @r{specific information for certain link types, see below}
-@end example
-
-@noindent
-For specific link types, the following keywords will be defined:
-
-@example
-Link type          |  Available keywords
--------------------+----------------------------------------------
-bbdb               |  %:name %:company
-vm, wl, mh, rmail  |  %:type %:subject %:message-id
-                   |  %:from %:fromname %:fromaddress
-                   |  %:to   %:toname   %:toaddress
-                   |  %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user.  See the variable @code{org-from-is-user-regexp}.}}       
-gnus               |  %:group, @r{for messages also all email fields}
-w3, w3m            |  %:url
-info               |  %:file %:node
-calendar           |  %:date"
-@end example
-
-@noindent
-To place the cursor after template expansion use:
-
-@example
-%?          @r{After completing the template, position cursor here.}
-@end example
-
-@noindent
-If you change you mind about which template to use, call
-@code{org-remember} in the remember buffer.  You may then select a new
-template that will be filled with the previous context information.
-
-@node Storing notes,  , Remember templates, Remember
-@subsection Storing notes
-
-When you are finished preparing a note with @i{remember}, you have to press
-@kbd{C-c C-c} to file the note away.  The handler first prompts for a
-target file - if you press @key{RET}, the value specified for the
-template is used.  Then the command offers the headings tree of the
-selected file, with the cursor position at the default headline (if you
-had specified one in the template).  You can either immediately press
-@key{RET} to get the note placed there.  Or you can use the following
-keys to find a better location:
-@example
-@key{TAB}         @r{Cycle visibility.}
-@key{down} / @key{up}   @r{Next/previous visible headline.}
-n / p        @r{Next/previous visible headline.}
-f / b        @r{Next/previous headline same level.}
-u            @r{One level up.}
-@c 0-9          @r{Digit argument.}
-@end example
-@noindent
-Pressing @key{RET} or @key{left} or @key{right}
-then leads to the following result.
-
-@multitable @columnfractions 0.2 0.15 0.65
-@item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
-@item buffer-start @tab @key{RET} @tab as level 2 heading at end of file
-@item on headline @tab @key{RET} @tab as sublevel of the heading at cursor
-@item             @tab @key{left}/@key{right} @tab as same level, before/after current heading
-@item not on headline @tab @key{RET}
-      @tab at cursor position, level taken from context.
-@end multitable
-
-So a fast way to store the note to its default location is to press
-@kbd{C-c C-c @key{RET} @key{RET}}.  Even shorter would be @kbd{C-u C-c
-C-c}, which does the same without even asking for a file or showing the
-tree.
-
-Before inserting the text into a tree, the function ensures that the
-text has a headline, i.e. a first line that starts with a @samp{*}.
-If not, a headline is constructed from the current date and some
-additional data.  If the variable @code{org-adapt-indentation} is
-non-nil, the entire text is also indented so that it starts in the
-same column as the headline (after the asterisks).
-
 
 @node TODO items, Tags, Hyperlinks, Top
 @chapter TODO items
 @cindex TODO items
 
-Org-mode does not maintain TODO lists as a separate document.  TODO
-items are an integral part of the notes file, because TODO items
-usually come up while taking notes!  With Org-mode, you simply mark
-any entry in a tree as being a TODO item.  In this way, the
-information is not duplicated, and the entire context from which the
-item emerged is always present when you check.
-
-Of course, this technique causes TODO items to be scattered throughout
-your file.  Org-mode provides methods to give you an overview over all
-things you have to do.
+Org-mode does not maintain TODO lists as separate documents.  Instead,
+TODO items are an integral part of the notes file, because TODO items
+usually come up while taking notes!  With Org-mode, simply mark any
+entry in a tree as being a TODO item.  In this way, information is not
+duplicated, and the entire context from which the TODO item emerged is
+always present.
+
+Of course, this technique for managing TODO items scatters them
+throughout your notes file.  Org-mode compensates for this by providing
+methods to give you an overview of all the things that you have to do.
 
 @menu
 * TODO basics::                 Marking and displaying TODO entries
 * TODO extensions::             Workflow and assignments
+* Progress logging::            Dates and notes for progress
 * Priorities::                  Some things are more important than others
 * Breaking down tasks::         Splitting a task into manageable pieces
 * Checkboxes::                  Tick-off lists
@@ -2733,8 +2627,8 @@
 @node TODO basics, TODO extensions, TODO items, TODO items
 @section Basic TODO functionality
 
-Any headline can become a TODO item by starting it with the word TODO,
-for example:
+Any headline becomes a TODO item when it starts with the word
+@samp{TODO}, for example:
 
 @example
 *** TODO Write letter to Sam Fortune
@@ -2756,61 +2650,72 @@
 
 The same rotation can also be done ``remotely'' from the timeline and
 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
+
+@kindex C-u C-c C-t
+@item C-u C-c C-t
+Select a specific keyword using completion or (if it has been set up)
+the fast selection interface.
+
 @kindex S-@key{right}
 @kindex S-@key{left}
 @item S-@key{right}
 @itemx S-@key{left}
-Select the following/preceding TODO state, similar to cycling.  Mostly
-useful if more than two TODO states are possible (@pxref{TODO
+Select the following/preceding TODO state, similar to cycling.  Useful
+mostly if more than two TODO states are possible (@pxref{TODO
 extensions}).
 @kindex C-c C-c
 @item C-c C-c
-Use the fast tag interface to quickly and directly select a specific
-TODO state.  For this you need to assign keys to TODO state, like this:
+Use the fast tag interface to directly select a specific TODO state.
+For this you need to assign keys to TODO states, like this:
 @example
 #+SEQ_TODO: TODO(t) STARTED(s) WAITING(w) | DONE(d)
 @end example
-@noindent See @ref{Per file keywords} and @ref{Setting tags} for more
+@noindent See @ref{Per-file keywords} and @ref{Setting tags} for more
 information.
 @kindex C-c C-v
+@kindex C-c / t
 @cindex sparse tree, for TODO
 @item C-c C-v
+@itemx C-c / t
 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
 the entire buffer, but shows all TODO items and the headings hierarchy
 above them.  With prefix arg, search for a specific TODO.  You will be
 prompted for the keyword, and you can also give a list of keywords like
-@code{kwd1|kwd2|...}.  With numerical prefix N, show the tree for the
+@code{KWD1|KWD2|...}.  With numerical prefix N, show the tree for the
 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
 args, find all TODO and DONE entries.
 @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 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.
+Show the global TODO list.  Collects the TODO items from all agenda
+files (@pxref{Agenda views}) into a single buffer.  The new buffer will
+be in @code{agenda-mode}, which provides commands to examine and
+manipulate the TODO entries from the new buffer (@pxref{Agenda
+commands}).  @xref{Global TODO list}, for more information.
 @kindex S-M-@key{RET}
 @item S-M-@key{RET}
 Insert a new TODO entry below the current one.
 @end table
 
-@node TODO extensions, Priorities, TODO basics, TODO items
+@node TODO extensions, Progress logging, TODO basics, TODO items
 @section Extended use of TODO keywords
 @cindex extended TODO keywords
 
-The default implementation of TODO entries is just two states: TODO and
-DONE.  You can use the TODO feature for more complicated things by
-configuring the variable @code{org-todo-keywords}.  With special setup,
-the TODO keyword system can work differently in different files.
+By default, marked TODO entries have one of only two states: TODO and
+DONE.  Org-mode allows you to classify TODO items in more complex ways
+with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
+special setup, the TODO keyword system can work differently in different
+files.
 
 Note that @i{tags} are another way to classify headlines in general and
 TODO items in particular (@pxref{Tags}).
 
 @menu
 * Workflow states::             From TODO to DONE in steps
-* TODO types::                  I do this, Fred the rest
+* TODO types::                  I do this, Fred does the rest
 * Multiple sets in one file::   Mixing it all, and still finding your way
-* Per file keywords::           Different files, different requirements
+* Fast access to TODO states::  Single letter selection of a state
+* Per-file keywords::           Different files, different requirements
+* Faces for TODO keywords::     Highlighting states
 @end menu
 
 @node Workflow states, TODO types, TODO extensions, TODO extensions
@@ -2875,7 +2780,7 @@
 files into a single buffer, you would use the prefix arg as well when
 creating the global todo list: @kbd{C-3 C-c t}.
 
-@node Multiple sets in one file, Per file keywords, TODO types, TODO extensions
+@node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
 @subsection Multiple keyword sets in one file
 @cindex todo keyword sets
 
@@ -2918,10 +2823,34 @@
 would switch from @code{DONE} to @code{REPORT} in the example above.
 @end table
 
-@node Per file keywords,  , Multiple sets in one file, TODO extensions
+@node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
+@subsection Fast access to TODO states
+
+If you would like to quickly change an entry to an arbitrary TODO state
+instead of cycling through the states, you can set up keys for
+single-letter access to the states.  This is done by adding the section
+key after each keyword, in parenthesis.  For example:
+
+@lisp
+(setq org-todo-keywords
+      '((sequence "TODO(t)" "|" "DONE(d)")
+        (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
+        (sequence "|" "CANCELED(c)")))
+@end lisp
+
+If you then press @code{C-u C-c C-t} followed by the selection key, the
+entry will be switched to this state.  @key{SPC} can be used to remove
+any TODO keyword from an entry.  Should you like this way of selecting
+TODO states a lot, you might want to set the variable
+@code{org-use-fast-todo-selection} to @code{t} and make this behavior
+the default.  Check also the variable
+@code{org-fast-tag-selection-include-todo}, it allows to change the TODO
+state through the tags interface (@pxref{Setting tags}).
+
+@node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
 @subsection Setting up keywords for individual files
 @cindex keyword options
-@cindex per file keywords
+@cindex per-file keywords
 
 It can be very useful to use different aspects of the TODO mechanism in
 different files.  For file-local settings, you need to add special lines
@@ -2961,24 +2890,124 @@
 cursor in a line starting with @samp{#+} is simply restarting Org-mode
 for the current buffer.}.
 
-@node Priorities, Breaking down tasks, TODO extensions, TODO items
+@node Faces for TODO keywords,  , Per-file keywords, TODO extensions
+@subsection Faces for TODO keywords
+@cindex faces, for TODO keywords
+
+Org-mode highlights TODO keywords with special faces: @code{org-todo}
+for keywords indicating that an item still has to be acted upon, and
+@code{org-done} for keywords indicating that an item is finished.  If
+you are using more than 2 different states, you might want to use
+special faces for some of them.  This can be done using the variable
+@code{org-todo-keyword-faces}.  For example:
+
+@lisp
+(setq org-todo-keyword-faces
+      '(("TODO"      . org-warning)
+        ("DEFERRED"  . shadow)
+        ("CANCELED"  . (:foreground "blue" :weight bold))))
+@end lisp
+
+@page
+@node Progress logging, Priorities, TODO extensions, TODO items
+@section Progress Logging
+@cindex progress logging
+@cindex logging, of progress
+
+Org-mode can automatically record a time stamp and even a note when you
+mark a TODO item as DONE, or even each time you change the state of
+a TODO item.
+
+@menu
+* Closing items::               When was this entry marked DONE?
+* Tracking TODO state changes::  When did the status change?
+@end menu
+
+@node Closing items, Tracking TODO state changes, Progress logging, Progress logging
+@subsection Closing items
+
+If you want to keep track of @emph{when} a certain TODO item was
+finished, turn on logging with@footnote{The corresponding in-buffer
+setting is: @code{#+STARTUP: logdone}.  You may also set this for the
+scope of a subtree by adding a @code{:LOGGING:} property with one or more
+of the logging keywords in the value.}
+
+@lisp
+(setq org-log-done t)
+@end lisp
+
+@noindent
+Then each time you turn a TODO entry into DONE using either @kbd{C-c
+C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
+@samp{CLOSED: [timestamp]} will be inserted just after the headline.  If
+you turn the entry back into a TODO item through further state cycling,
+that line will be removed again.  In the timeline (@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.  If you want to record a note
+along with the timestamp, use@footnote{The corresponding in-buffer
+setting is: @code{#+STARTUP: lognotedone}}
+
+@lisp
+(setq org-log-done '(done))
+@end lisp
+
+@node Tracking TODO state changes,  , Closing items, Progress logging
+@subsection Tracking TODO state changes
+
+When TODO keywords are used as workflow states (@pxref{Workflow
+states}), you might want to keep track of when a state change occurred
+and record a note about this change.  With the setting@footnote{The
+corresponding in-buffer setting is: @code{#+STARTUP: lognotestate}.}
+
+@lisp
+(setq org-log-done '(state))
+@end lisp
+
+@noindent
+each state change will prompt you for a note that will be attached to
+the current headline.  If you press @kbd{C-c C-c} without typing
+anything into the note buffer, only the time of the state change will be
+noted.  Very likely you do not want this verbose tracking all the time,
+so it is probably better to configure this behavior with in-buffer
+options.  For example, if you are tracking purchases, put these into a
+separate file that contains:
+
+@example
+#+SEQ_TODO: TODO(t) ORDERED(o) INVOICE(i) PAYED(p) | RECEIVED(r)
+#+STARTUP: lognotestate
+@end example
+
+If you only need to take a note for some of the states, mark those
+states with an additional @samp{@@}, like this:
+
+@example
+#+SEQ_TODO: TODO(t) ORDERED(o@@) INVOICE(i@@) PAYED(p) | RECEIVED(r)
+#+STARTUP: lognotestate
+@end example
+
+@node Priorities, Breaking down tasks, Progress logging, TODO items
 @section Priorities
 @cindex priorities
 
-If you use Org-mode extensively to organize your work, you may end up
-with a number of TODO entries so large that you'd like to prioritize
-them.  This can be done by placing a @emph{priority cookie} into the
-headline, like this
+If you use Org-mode extensively, you may end up enough TODO items that
+it starts to make sense to prioritize them.  Prioritizing can be done by
+placing a @emph{priority cookie} into the headline of a TODO item, like
+this
 
 @example
 *** TODO [#A] Write letter to Sam Fortune
 @end example
 
 @noindent
-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{Weekly/Daily agenda}).
+By default, Org-mode supports three 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{Weekly/Daily agenda}); outside the agenda, they have
+no inherent meaning to Org-mode.
+
+Priorities can be attached to any outline tree entries; they do not need
+to be TODO items.
 
 @table @kbd
 @kindex @kbd{C-c ,}
@@ -2993,8 +3022,9 @@
 @kindex S-@key{down}
 @item S-@key{up}
 @itemx S-@key{down}
-Increase/decrease priority of current headline.  Note that these keys
-are also used to modify time stamps (@pxref{Creating timestamps}).
+Increase/decrease priority of current headline@footnote{See also the
+option @code{org-priority-start-cycle-with-default'}.}.  Note that these
+keys are also used to modify time stamps (@pxref{Creating timestamps}).
 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
 @end table
 
@@ -3026,13 +3056,15 @@
 @section Checkboxes
 @cindex checkboxes
 
-Every item in a plain list (@pxref{Plain lists}) can be made a checkbox
-by starting it with the string @samp{[ ]}.  This feature is similar to
-TODO items (@pxref{TODO items}), but more lightweight.  Checkboxes are
-not included into the global TODO list, so they are often great to split
-a task into a number of simple steps.  Or you can use them in a shopping
-list.  To toggle a checkbox, use @kbd{C-c C-c}, or try Piotr Zielinski's
-@file{org-mouse.el}.  Here is an example of a checkbox list.
+Every item in a plain list (@pxref{Plain lists}) can be made into a
+checkbox by starting it with the string @samp{[ ]}.  This feature is
+similar to TODO items (@pxref{TODO items}), but is more lightweight.
+Checkboxes are not included into the global TODO list, so they are often
+great to split a task into a number of simple steps.  Or you can use
+them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
+use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
+
+Here is an example of a checkbox list.
 
 @example
 * TODO Organize party [3/6]
@@ -3048,16 +3080,17 @@
 @cindex statistics, for checkboxes
 @cindex checkbox statistics
 The @samp{[3/6]} and @samp{[1/3]} in the first and second line are
-cookies indicating how many checkboxes are present in this entry, and
-how many of them have been checked off.  This can give you an idea on
-how many checkboxes remain, even without opening a folded entry.  The
-cookies can be placed into a headline or into (the first line of) a
-plain list item. Each cookie covers all checkboxes structurally below
-that headline/item.  You have to insert the cookie yourself by typing
-either @samp{[/]} or @samp{[%]}.  In the first case you get an @samp{n
-out of m} result, in the second case you get information about the
+cookies indicating how many checkboxes present in this entry have been
+checked off, and the total number of checkboxes are present.  This can
+give you an idea on how many checkboxes remain, even without opening a
+folded entry.  The cookies can be placed into a headline or into (the
+first line of) a plain list item. Each cookie covers all checkboxes
+structurally below the headline/item on which the cookie appear.  You
+have to insert the cookie yourself by typing either @samp{[/]} or
+@samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
+the examples above.  With @samp{[%]} you get information about the
 percentage of checkboxes checked (in the above example, this would be
-@samp{[50%]} and @samp{[33%], respectively}).
+@samp{[50%]} and @samp{[33%]}, respectively).
 
 @noindent The following commands work with checkboxes:
 
@@ -3096,7 +3129,6 @@
 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
 @end table
 
-
 @node Tags, Properties and columns, TODO items, Top
 @chapter Tags
 @cindex tags
@@ -3104,14 +3136,15 @@
 @cindex matching, tags
 @cindex sparse tree, tag based
 
-If you wish to implement a system of labels and contexts for
-cross-correlating information, an excellent way is to assign @i{tags} to
-headlines.  Org-mode has extensive support for using tags.
-
-Every headline can contain a list of tags, at the end of the headline.
-Tags are normal words containing letters, numbers, @samp{_}, and
-@samp{@@}.  Tags must be preceded and followed by a single colon; like
-@samp{:WORK:}.  Several tags can be specified like @samp{:WORK:URGENT:}.
+An excellent way to implement labels and contexts for cross-correlating
+information is to assign @i{tags} to headlines.  Org-mode has extensive
+support for tags.
+
+Every headline can contain a list of tags; they occur at the end of the
+headline.  Tags are normal words containing letters, numbers, @samp{_},
+and @samp{@@}.  Tags must be preceded and followed by a single colon,
+e.g., @samp{:WORK:}.  Several tags can be specified, as in
+@samp{:work:URGENT:}.
 
 @menu
 * Tag inheritance::             Tags use the tree structure of the outline
@@ -3121,6 +3154,7 @@
 
 @node Tag inheritance, Setting tags, Tags, Tags
 @section Tag inheritance
+@cindex tag inheritance
 @cindex inheritance, of tags
 @cindex sublevels, inclusion into tags match
 
@@ -3129,20 +3163,21 @@
 well.  For example, in the list
 
 @example
-* Meeting with the French group      :WORK:
-** Summary by Frank                  :BOSS:NOTES:
-*** TODO Prepare slides for him      :ACTION:
+* Meeting with the French group      :work:
+** Summary by Frank                  :boss:notes:
+*** TODO Prepare slides for him      :action:
 @end example
 
 @noindent
-the final heading will have the tags @samp{:WORK:}, @samp{:BOSS:},
-@samp{:NOTES:}, and @samp{:ACTION:}.  When executing tag searches and
+the final heading will have the tags @samp{:work:}, @samp{:boss:},
+@samp{:notes:}, and @samp{:action:} even though the final heading is not
+explicitly marked with those tags.  When executing tag searches and
 Org-mode finds that a certain headline matches the search criterion, it
-will not check any sublevel headline, assuming that these likely also
-match, and that the list of matches can become very long.  This may
-not be what you want, however, and you can influence inheritance and
-searching using the variables @code{org-use-tag-inheritance} and
-@code{org-tags-match-list-sublevels}.
+will not check any sublevel headline, assuming that these also match and
+that the list of matches could become very long because of that.  If you
+do want the subevels be tested and listed as well, you may set the
+variable @code{org-tags-match-list-sublevels}.  To turn off tag
+inheritance entirely, use the variable @code{org-use-tag-inheritance}.
 
 @node Setting tags, Tag searches, Tag inheritance, Tags
 @section Setting tags
@@ -3174,13 +3209,13 @@
 the default tags for a given file with lines like
 
 @example
-#+TAGS: @@WORK @@HOME @@TENNISCLUB
-#+TAGS: Laptop Car PC Sailboat
+#+TAGS: @@work @@home @@tennisclub
+#+TAGS: laptop car pc sailboat
 @end example
 
 If you have globally defined your preferred set of tags using the
 variable @code{org-tag-alist}, but would like to use a dynamic tag list
-in a specific file: Just add an empty TAGS option line to that file:
+in a specific file, add an empty TAGS option line to that file:
 
 @example
 #+TAGS:
@@ -3193,13 +3228,13 @@
 keys to most tags.  This can be done globally with
 
 @lisp
-(setq org-tag-alist '(("@@WORK" . ?w) ("@@HOME" . ?h) ("Laptop" . ?l)))
+(setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
 @end lisp
 
 @noindent or on a per-file basis with
 
 @example
-#+TAGS: @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t)  Laptop(l)  PC(p)
+#+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
 @end example
 
 @noindent
@@ -3209,11 +3244,11 @@
 groups are allowed.}
 
 @example
-#+TAGS: @{ @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t) @}  Laptop(l)  PC(p)
-@end example
-
-@noindent you indicate that at most one of @samp{@@WORK}, @samp{@@HOME},
-and @samp{@@TENNISCLUB} should be selected.
+#+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
+@end example
+
+@noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
+and @samp{@@tennisclub} should be selected.
 
 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
 these lines to activate any changes.
@@ -3255,10 +3290,10 @@
 
 @noindent
 This method lets you assign tags to a headline with very few keys.  With
-the above setup, you could clear the current tags and set @samp{@@HOME},
-@samp{Laptop} and @samp{PC} tags with just the following keys: @kbd{C-c
-C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@HOME} to
-@samp{@@WORK} would be done with @kbd{C-c C-c w @key{RET}} or
+the above setup, you could clear the current tags and set @samp{@@home},
+@samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
+C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
+@samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
 @key{RET} @key{RET}}.
@@ -3279,12 +3314,14 @@
 @cindex tag searches
 @cindex searching for tags
 
-Once a tags system has been set up, it can be used to collect related
+Once a system of tags has been set up, it can be used to collect related
 information into special lists.
 
 @table @kbd
 @kindex C-c \
+@kindex C-c / T
 @item C-c \
+@itemx C-c / T
 Create a sparse tree with all headlines matching a tags search.  With a
 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
 @kindex C-c a m
@@ -3307,14 +3344,14 @@
 or @samp{-} is present.  Examples:
 
 @table @samp
-@item +WORK-BOSS
-Select headlines tagged @samp{:WORK:}, but discard those also tagged
-@samp{:BOSS:}.
-@item WORK|LAPTOP
-Selects lines tagged @samp{:WORK:} or @samp{:LAPTOP:}.
-@item WORK|LAPTOP&NIGHT
-Like before, but require the @samp{:LAPTOP:} lines to be tagged also
-@samp{NIGHT}.
+@item +work-boss
+Select headlines tagged @samp{:work:}, but discard those also tagged
+@samp{:boss:}.
+@item work|laptop
+Selects lines tagged @samp{:work:} or @samp{:laptop:}.
+@item work|laptop&night
+Like before, but require the @samp{:laptop:} lines to be tagged also
+@samp{:night:}.
 @end table
 
 @cindex TODO keyword matching, with tags search
@@ -3330,48 +3367,65 @@
 Examples:
 
 @table @samp
-@item WORK/WAITING
-Select @samp{:WORK:}-tagged TODO lines with the specific TODO
+@item work/WAITING
+Select @samp{:work:}-tagged TODO lines with the specific TODO
 keyword @samp{WAITING}.
-@item WORK/!-WAITING-NEXT
-Select @samp{:WORK:}-tagged TODO lines that are neither @samp{WAITING}
+@item work/!-WAITING-NEXT
+Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
 nor @samp{NEXT}
-@item WORK/+WAITING|+NEXT
-Select @samp{:WORK:}-tagged TODO lines that are either @samp{WAITING} or
+@item work/+WAITING|+NEXT
+Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
 @samp{NEXT}.
 @end table
 
 @cindex regular expressions, with tags search
 Any element of the tag/todo match can be a regular expression - in this
 case it must be enclosed in curly braces.  For example,
-@samp{WORK+@{^BOSS.*@}} matches headlines that contain the tag
-@samp{WORK} and any tag @i{starting} with @samp{BOSS}.
-
-@cindex level, require for tags match
-You can also require a headline to be of a certain level, by writing
-instead of any TAG an expression like @samp{LEVEL=3}.  For example, a
-search @samp{+LEVEL=3+BOSS/-DONE} lists all level three headlines that
-have the tag BOSS and are @emph{not} marked with the todo keyword DONE.
-
-@node Properties and columns, Timestamps, Tags, Top
+@samp{work+@{^boss.*@}} matches headlines that contain the tag
+@samp{:work:} and any tag @i{starting} with @samp{boss}.
+
+@cindex level, require for tags/property match
+@cindex category, require for tags/property match
+You can also require a headline to be of a certain level or category, by
+writing instead of any TAG an expression like @samp{LEVEL=3} or
+@samp{CATEGORY="work"}, respectively.  For example, a search
+@samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
+tag @samp{boss} and are @emph{not} marked with the todo keyword DONE.
+
+@node Properties and columns, Dates and times, Tags, Top
 @chapter Properties and Columns
 @cindex properties
 
 Properties are a set of key-value pairs associated with an entry.  There
 are two main applications for properties in Org-mode.  First, properties
-are like tags, but with a value.  For example, in a file where you
-document bugs and plan releases of a piece of software, instead of using
-tags like @code{:release_1:}, @code{:release_2:}, it can be more
-efficient to use a property @code{RELEASE} with a value @code{1.0} or
-@code{2.0}.  Second, you can use properties to implement (very basic)
-database capabilities in an Org-mode buffer, for example to create a
-list of Music CD's you own.  You can edit and view properties
+are like tags, but with a value.  Second, you can use properties to
+implement (very basic) database capabilities in an Org-mode buffer.  For
+an example of the first application, imagine maintaining a file where
+you document bugs and plan releases of a piece of software.  Instead of
+using tags like @code{:release_1:}, @code{:release_2:}, one can use a
+property, say @code{:Release:}, that in different subtrees has different
+values, such as @code{1.0} or @code{2.0}.  For an example of the second
+application of properties, imagine keeping track of one's music CD's,
+where properties could be things such as the album artist, date of
+release, number of tracks, and so on.
+
+Properties can be conveiently edited and viewed in column view
+(@pxref{Column view}).
+
+Properties are like tags, but with a value.  For example, in a file
+where you document bugs and plan releases of a piece of software,
+instead of using tags like @code{:release_1:}, @code{:release_2:}, it
+can be more efficient to use a property @code{:Release:} with a value
+@code{1.0} or @code{2.0}.  Second, you can use properties to implement
+(very basic) database capabilities in an Org-mode buffer, for example to
+create a list of Music CD's you own.  You can edit and view properties
 conveniently in column view (@pxref{Column view}).
 
 @menu
 * Property syntax::             How properties are spelled out
 * Special properties::          Access to other Org-mode features
 * Property searches::           Matching property values
+* Property inheritance::        Passing values down the tree
 * Column view::                 Tabular viewing and editing
 * Property API::                Properties for Lisp programmers
 @end menu
@@ -3399,8 +3453,8 @@
     :END:       
 @end example
 
-You may define the allowed values for a particular property @samp{XYZ}
-by setting a property @samp{XYZ_ALL}.  This special property is
+You may define the allowed values for a particular property @samp{:Xyz:}
+by setting a property @samp{:Xyz_ALL:}.  This special property is
 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
 the entire tree.  When allowed values are defined, setting the
 corresponding property becomes easier and is less prone to typing
@@ -3434,6 +3488,10 @@
 @item M-@key{TAB}
 After an initial colon in a line, complete property keys.  All keys used
 in the current file will be offered as possible completions.
+@kindex C-c C-x p
+@item C-c C-x p
+Set a property.  This prompts for a property name and a value.  If
+necessary, the property drawer is created as well.
 @item M-x org-insert-property-drawer
 Insert a property drawer into the current entry.  The drawer will be
 inserted early in the entry, but after the lines with planning
@@ -3452,6 +3510,9 @@
 Remove a property from the current entry.
 @item C-c C-c D
 Globally remove a property, from all entries in the current file.
+@item C-c C-c c
+Compute the property at point, using the operator and scope from the
+nearest column format definition.
 @end table
 
 @node Special properties, Property searches, Property syntax, Properties and columns
@@ -3461,9 +3522,9 @@
 Special properties provide alternative access method to Org-mode
 features discussed in the previous chapters, like the TODO state or the
 priority of an entry.  This interface exists so that you can include
-these states into columns view (@pxref{Column view}).  The following
-property names are special and should not be used as keys in the
-properties drawer:
+these states into columns view (@pxref{Column view}), or to use them in
+queries.  The following property names are special and should not be
+used as keys in the properties drawer:
 
 @example
 TODO         @r{The TODO keyword of the entry.}
@@ -3472,27 +3533,81 @@
 PRIORITY     @r{The priority of the entry, a string with a single letter.}
 DEADLINE     @r{The deadline time string, without the angular brackets.}
 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
-@end example
-
-@node Property searches, Column view, Special properties, Properties and columns
+TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
+TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
+CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
+             @r{must be run first to compute the values.}
+@end example
+
+@node Property searches, Property inheritance, Special properties, Properties and columns
 @section Property searches
 @cindex properties, searching
+@cindex properties, inheritance
+@cindex searching, of properties
+@cindex inheritance, of properties
 
 To create sparse trees and special lists with selection based on
 properties, the same commands are used as for tag searches (@pxref{Tag
 searches}), and the same logic applies.  For example, a search string
 
 @example
-+WORK-BOSS+PRIORITY="A"+coffee="unlimited"+with=@{Sarah\|Denny@}
++work-boss+PRIORITY="A"+Coffee="unlimited"+With=@{Sarah\|Denny@}
 @end example
 
 @noindent
-finds entries tagged @samp{:WORK:} but not @samp{:BOSS:}, which
-also have a priority value @samp{A}, a @samp{:coffee:} property with the
-value @samp{unlimited}, and a @samp{:with:} property that is matched by
+finds entries tagged @samp{:work:} but not @samp{:boss:}, which
+also have a priority value @samp{A}, a @samp{:Coffee:} property with the
+value @samp{unlimited}, and a @samp{:With:} property that is matched by
 the regular expression @samp{Sarah\|Denny}.
 
-@node Column view, Property API, Property searches, Properties and columns
+You can configure Org-mode to use property inheritance during a search,
+see @ref{Property inheritance} for details.
+
+There is also a special command for creating sparse trees based on a
+single property:
+
+@table @kbd
+@kindex C-c / p
+@item C-c / p
+Create a sparse tree based on the value of a property.  This first
+prompts for the name of a property, and then for a value.  A sparse tree
+is created with all entries that define this property with the given
+value.  If you enclose the value into curly braces, it is interpreted as
+a regular expression and matched against the property values.
+@end table
+
+@node Property inheritance, Column view, Property searches, Properties and columns
+@section Property Inheritance
+
+The outline structure of Org-mode documents lends itself for an
+inheritance model of properties: If the parent in a tree has a certain
+property, the children can inherit this property.  Org-mode does not
+turn this on by default, because it can slow down property searches
+significantly and is often not needed.  However, if you find inheritance
+useful, you can turn it on by setting the variable
+@code{org-use-property-inheritance}.  It may be set to @code{t}, to make
+all properties inherited from the parent, or to a list of properties
+that should be inherited.
+
+Org-mode has a few properties for which inheritance is hard-coded, at
+least for the special applications for which they are used:
+
+@table @code
+@item COLUMNS
+The @code{:COLUMNS:} property defines the format of column view
+(@pxref{Column view}).  It is inherited in the sense that the level
+where a @code{:COLUMNS:} property is defined is used as the starting
+point for a column view table, independently of the location in the
+subtree from where columns view is turned on.
+@item CATEGORY
+For agenda view, a category set through a @code{:CATEGORY:} property
+applies to the entire subtree.
+@item ARCHIVE
+For archiving, the @code{:ARCHIVE:} property may define the archive
+location for the entire subtree (@pxref{Moving subtrees}).
+@end table
+
+@node Column view, Property API, Property inheritance, Properties and columns
 @section Column View
 
 A great way to view and edit properties in an outline tree is
@@ -3512,6 +3627,7 @@
 @menu
 * Defining columns::            The COLUMNS format property
 * Using column view::           How to create and use column view
+* Capturing Column View::       A dynamic block for column view
 @end menu
 
 @node Defining columns, Using column view, Column view, Column view
@@ -3536,8 +3652,9 @@
 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
 @end example
 
-To specify a format that only applies to a specific tree, add a COLUMNS
-property to the top node of that tree, for example
+To specify a format that only applies to a specific tree, add a
+@code{:COLUMNS:} property to the top node of that tree, for example:
+
 @example
 ** Top node for columns view
    :PROPERTIES:
@@ -3545,7 +3662,7 @@
    :END:
 @end example
 
-If a @code{COLUMNS} property is present in an entry, it defines columns
+If a @code{:COLUMNS:} property is present in an entry, it defines columns
 for the entry itself, and for the entire subtree below it.  Since the
 column definition is part of the hierarchical structure of the document,
 you can define columns on level 1 that are general enough for all
@@ -3574,9 +3691,11 @@
 @{summary-type@}  @r{The summary type.  If specified, the column values for}
                 @r{parent nodes are computed from the children.}
                 @r{Supported summary types are:}
-                @{+@}  @r{Sum numbers in this column.}
-                @{:@}  @r{Sum times, HH:MM:SS, plain numbers are hours.}
-                @{X@}  @r{Checkbox status, [X] if all children are [X].}
+                @{+@}       @r{Sum numbers in this column.}
+                @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
+                @{$@}       @r{Currency, short for @samp{+;%.2f}.}
+                @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
+                @{X@}       @r{Checkbox status, [X] if all children are [X].}
 @end example
 
 @noindent
@@ -3584,7 +3703,8 @@
 values.
 
 @example
-:COLUMNS:  %20ITEM %9Approved(Approved?)@{X@} %Owner %11Status %10Time_Spent@{:@}
+:COLUMNS:  %20ITEM %9Approved(Approved?)@{X@} %Owner %11Status \@footnote{Please note that the COLUMNS definition must be on a single line - it is wrapped here only because of formatting constraints.}
+                   %10Time_Estimate@{:@} %CLOCKSUM
 :Owner_ALL:    Tammy Mark Karl Lisa Don
 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
 :Approved_ALL: "[ ]" "[X]"
@@ -3599,11 +3719,13 @@
 character, the column will be exactly as wide as it needs to be in order
 to fully display all values.  The @samp{Approved} column does have a
 modified title (@samp{Approved?}, with a question mark).  Summaries will
-be created for the @samp{Time_Spent} column by adding time duration
+be created for the @samp{Time_Estimate} column by adding time duration
 expressions like HH:MM, and for the @samp{Approved} column, by providing
-an @samp{[X]} status if all children have been checked.
-
-@node Using column view,  , Defining columns, Column view
+an @samp{[X]} status if all children have been checked.  The
+@samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
+in the subtree.
+
+@node Using column view, Capturing Column View, Defining columns, Column view
 @subsection Using Column View
 
 @table @kbd
@@ -3611,9 +3733,9 @@
 @kindex C-c C-x C-c
 @item C-c C-x C-c
 Create the column view for the local environment.  This command searches
-the hierarchy, up from point, for a @code{COLUMNS} property that defines
+the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
 a format.  When one is found, the column view table is established for
-the entire tree, starting from the entry that contains the @code{COLUMNS}
+the entire tree, starting from the entry that contains the @code{:COLUMNS:}
 property.  If none is found, the format is taken from the @code{#+COLUMNS}
 line or from the variable @code{org-columns-default-format}, and column
 view is established for the current entry and its subtree.
@@ -3638,6 +3760,9 @@
 invoke the same interface that you normally use to change that
 property.  For example, when editing a TAGS property, the tag completion
 or fast selection interface will pop up.
+@kindex C-c C-c
+@item C-c C-c
+When there is a checkbox at point, toggle it.
 @kindex v
 @item v
 View the full value of this property.  This is useful if the width of
@@ -3661,6 +3786,62 @@
 Delete the current column.
 @end table
 
+@node Capturing Column View,  , Using column view, Column view
+@subsection Capturing Column View
+
+Since column view is just an overlay over a buffer, it cannot be
+exported or printed directly.  If you want to capture a column view, use
+the dynamic block (@pxref{Dynamic blocks}).  The frame of this block
+looks like this:
+
+@example
+* The column view
+#+BEGIN: columnview :hlines 1 :id "label"
+
+#+END:
+@end example
+
+@noindent This dynamic block has the following parameters:
+
+@table @code
+@item :id
+This is most important parameter.  Column view is a feature that is
+often localized to a certain (sub)tree, and the capture block might be
+in a different location in the file.  To identify the tree whose view to
+capture, you can use 3 values:
+@example
+local     @r{use the tree in which the capture block is located}
+global    @r{make a global view, including all headings in the file}
+"label"   @r{call column view in the tree that has and @code{:ID:}}
+          @r{property with the value @i{label}}
+@end example
+@item :hlines
+When @code{t}, insert a hline after every line.  When a number N, insert
+a hline before each headline with level @code{<= N}.
+@item :vlines
+When set to @code{t}, enforce column groups to get vertical lines.
+@end table
+
+@noindent
+The following commands insert or update the dynamic block:
+
+@table @kbd
+@kindex C-c C-x r
+@item C-c C-x r
+Insert a dynamic block capturing a column view.  You will be prompted
+for the scope or id of the view.
+@kindex C-c C-c
+@item C-c C-c
+@kindex C-c C-x C-u
+@itemx C-c C-x C-u
+Update dynamical block at point.  The cursor needs to be in the
+@code{#+BEGIN} line of the dynamic block.
+@kindex C-u C-c C-x C-u
+@item C-u C-c C-x C-u
+Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
+you have several clocktable blocks in a buffer.
+@end table
+
 @node Property API,  , Column view, Properties and columns
 @section The Property API
 @cindex properties, API
@@ -3671,23 +3852,29 @@
 features based on them.  For more information see @ref{Using the
 property API}.
 
-@node Timestamps, Agenda views, Properties and columns, Top
-@chapter Timestamps
+@node Dates and times, Remember, Properties and columns, Top
+@chapter Dates and Times
+@cindex dates
+@cindex times
 @cindex time stamps
 @cindex date stamps
 
-Items can be labeled with timestamps to make them useful for project
-planning.
+To assist project planning, TODO items can be labeled with a date and/or
+a time.  The specially formatted string carrying the date and time
+information is called a @emph{timestamp} in Org-mode.  This may be a
+little confusing because timestamp is often used as indicating when
+something was created or last changed.  However, in Org-mode this term
+is used in a much wider sense.
 
 @menu
 * Time stamps::                 Assigning a time to a tree entry
 * Creating timestamps::         Commands which insert timestamps
 * Deadlines and scheduling::    Planning your work
-* Progress logging::            Documenting when what work was done.
+* Clocking work time::          
 @end menu
 
 
-@node Time stamps, Creating timestamps, Timestamps, Timestamps
+@node Time stamps, Creating timestamps, Dates and times, Dates and times
 @section Time stamps, deadlines and scheduling
 @cindex time stamps
 @cindex ranges, time
@@ -3698,20 +3885,19 @@
 A time stamp is a specification of a date (possibly with time or a range
 of times) in a special format, either @samp{<2003-09-16 Tue>} or
 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
-12:00-12:30>}@footnote{This is the standard ISO date/time format.  If
-you cannot get used to these, see @ref{Custom time format}}.  A time
-stamp can appear anywhere in the headline or body of an org-tree entry.
-Its presence causes entries to be shown on specific dates in the agenda
+12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
+use an alternative format, see @ref{Custom time format}.}.  A time stamp
+can appear anywhere in the headline or body of an org-tree entry.  Its
+presence causes entries to be shown on specific dates in the agenda
 (@pxref{Weekly/Daily agenda}).  We distinguish:
 
 @table @var
-@item Plain time stamp
+@item Plain time stamp; Event; Appointment
 @cindex timestamp
 A simple time stamp just assigns a date/time to an item.  This is just
-like writing down an appointment in a paper agenda, or like writing down
-an event in a diary, when you want to take note of when something
-happened.  In the timeline and agenda displays, the headline of an entry
-associated with a plain time stamp will be shown exactly on that date.
+like writing down an appointment or event in a paper agenda.  In the
+timeline and agenda displays, the headline of an entry associated with a
+plain time stamp will be shown exactly on that date.
 
 @example
 * Meet Peter at the movies <2006-11-01 Wed 19:15>
@@ -3764,7 +3950,7 @@
 
 @end table
 
-@node Creating timestamps, Deadlines and scheduling, Time stamps, Timestamps
+@node Creating timestamps, Deadlines and scheduling, Time stamps, Dates and times
 @section Creating timestamps
 @cindex creating timestamps
 @cindex timestamps, creating
@@ -3842,22 +4028,52 @@
 @cindex date, reading in minibuffer
 @cindex time, reading in minibuffer
 
-When Org-mode prompts for a date/time, the prompt suggests to enter an
-ISO date.  But it will in fact accept any string containing some date
-and/or time information.  You can, for example, use @kbd{C-y} to paste a
-(possibly multi-line) string copied from an email message.  Org-mode
-will find whatever information is in there and will replace anything not
-specified with the current date and time.  For example:
-
-@example
-  3-2-5         --> 2003-02-05
-  feb 15        --> currentyear-02-15
-  sep 12 9      --> 2009-09-12
-  12:45         --> today 12:45
-  22 sept 0:34  --> currentyear-09-22 0:34
-  12            --> currentyear-currentmonth-12
-  Fri           --> nearest Friday (today or later)
-  +4            --> 4 days from now (if +N is the only thing given)
+When Org-mode prompts for a date/time, the default is shown as an ISO
+date, and the prompt therefore seems to ask for an ISO date.  But it
+will in fact accept any string containing some date and/or time
+information, and it is really smart about interpreting your input.  You
+can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
+copied from an email message.  Org-mode will find whatever information
+is in there and derive anything you have not specified from the
+@emph{default date and time}.  The default is usually the current date
+and time, but when modifying an existing time stamp, or when entering
+the second stamp of a range, it is taken from the stamp in the buffer.
+When filling in information, Org-mode assumes that most of the time you
+will want to enter a date in the future: If you omit the month/year and
+the given day/month is @i{before} today, it will assume that you mean a
+future date@footnote{See the variable
+@code{org-read-date-prefer-future}.}.
+
+For example, lets assume that today is @b{June 13, 2006}.  Here is how
+various inputs will be interpreted, the items filled in by Org-mode are
+in @b{bold}.
+
+@example
+3-2-5         --> 2003-02-05
+14            --> @b{2006}-@b{06}-14
+12            --> @b{2006}-@b{07}-12
+Fri           --> nearest Friday (defaultdate or later)
+sep 15        --> @b{2006}-11-15
+feb 15        --> @b{2007}-02-15
+sep 12 9      --> 2009-09-12
+12:45         --> @b{2006}-@b{06}-@b{13} 12:45
+22 sept 0:34  --> @b{2006}-09-22 0:34
+@end example
+
+Furthermore you can specify a relative date by giving, as the
+@emph{first} thing in the input: a plus/minus sign, a number and a
+letter [dwmy] to indicate change in days weeks, months, years.  With a
+single plus or minus, the date is always relative to today.  With a
+double plus or minus, it is relative to the default date.  If instead of
+a single letter, you use the abbreviation of day name, the date will be
+the nth such day.  E.g.
+
+@example
++4d           --> four days from today
++4            --> same as above
++2w           --> two weeks from today
+++5           --> five days from default date
++2tue         --> second tuesday from now.
 @end example
 
 The function understands English month and weekday abbreviations.  If
@@ -3873,38 +4089,30 @@
 information entered at the prompt.  You can control the calendar fully
 from the minibuffer:
 
-@table @kbd
 @kindex <
-@item <
-Scroll calendar backwards by one month.
 @kindex >
-@item >
-Scroll calendar forwards by one month.
 @kindex mouse-1
-@item mouse-1
-Select date by clicking on it.
 @kindex S-@key{right}
-@item S-@key{right}
-One day forward.
 @kindex S-@key{left}
-@item S-@key{left}
-One day back.
 @kindex S-@key{down}
-@item S-@key{down}
-One week forward.
 @kindex S-@key{up}
-@item S-@key{up}
-One week back.
 @kindex M-S-@key{right}
-@item M-S-@key{right}
-One month forward.
 @kindex M-S-@key{left}
-@item M-S-@key{left}
-One month back.
 @kindex @key{RET}
-@item @key{RET}
-Choose date in calendar (only if nothing was typed into minibuffer).
-@end table
+@example
+> / <          @r{Scroll calendar forward/backward by one month.}
+mouse-1        @r{Select date by clicking on it.}
+S-@key{right}/@key{left}     @r{One day forward/backward.}
+S-@key{down}/@key{up}     @r{One week forward/backward.}
+M-S-@key{right}/@key{left}   @r{One month forward/backward.}
+@key{RET}           @r{Choose date in calendar.}
+@end example
+
+The actions of the date/time prompt may seem complex, but I asure you
+they will grow on you.  To help you understand what is going on, the
+current interpretation of your input will be displayed live in the
+minibuffer@footnote{If you find this distracting, turn the display of
+with @code{org-read-date-display-live}.}.
 
 @node Custom time format,  , The date/time prompt, Creating timestamps
 @subsection Custom time format
@@ -3953,20 +4161,23 @@
 @end itemize
 
 
-@node Deadlines and scheduling, Progress logging, Creating timestamps, Timestamps
+@node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and times
 @section Deadlines and Scheduling
 
-A time stamp may be preceded by special keywords to facilitate planning
-of work:
+A time stamp may be preceded by special keywords to facilitate planning:
 
 @table @var
 @item DEADLINE
 @cindex DEADLINE keyword
-The task (most likely a TODO item) is supposed to be finished on that
-date, and it will be listed then.  In addition, the compilation for
-@emph{today} will carry a warning about the approaching or missed
-deadline, starting @code{org-deadline-warning-days} before the due date,
-and continuing until the entry is marked DONE.  An example:
+
+Meaning: the task (most likely a TODO item, though not necessarily) is supposed
+to be finished on that date.
+
+On the deadline date, the task will be listed in the agenda.  In
+addition, the agenda for @emph{today} will carry a warning about the
+approaching or missed deadline, starting
+@code{org-deadline-warning-days} before the due date, and continuing
+until the entry is marked DONE.  An example:
 
 @example
 *** TODO write article about the Earth for the Guide
@@ -3980,9 +4191,12 @@
 
 @item SCHEDULED
 @cindex SCHEDULED keyword
-You are planning to start working on that task on the given date. The
-headline will be listed under the given date@footnote{It will still be
-listed on that date after it has been marked DONE.  If you don't like
+
+Meaning: you are planning to start working on that task on the given
+date.
+
+The headline will be listed under the given date@footnote{It will still
+be listed on that date after it has been marked DONE.  If you don't like
 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
 addition, a reminder that the scheduled date has passed will be present
 in the compilation for @emph{today}, until the entry is marked DONE.
@@ -3992,8 +4206,29 @@
 *** TODO Call Trillian for a date on New Years Eve.
     SCHEDULED: <2004-12-25 Sat>
 @end example
+
+@noindent
+@b{Important:} Scheduling an item in Org-mode should @i{not} be
+understood in the same way that we understand @i{scheduling a meeting}.
+Setting a date for a meeting is just a simple appointment, you should
+mark this entry with a simple plain time stamp, to get this item shown
+on the date where it applies.  This is a frequent mis-understanding from
+Org-users.  In Org-mode, @i{scheduling} means setting a date when you
+want to start working on an action item.
 @end table
 
+You may use time stamps with repeaters in scheduling and deadline
+entries.  Org-mode will issue early and late warnings based on the
+assumption that the time stamp represents the @i{nearest instance} of
+the repeater.  However, the use of diary sexp entries like
+@c
+@code{<%%(diary-float t 42)>}
+@c
+in scheduling and deadline timestamps is limited.  Org-mode does not
+know enough about the internals of each sexp function to issue early and
+late warnings.  However, it will show the item on each day where the
+sexp entry matches.
+
 @menu
 * Inserting deadline/schedule::  Planning items
 * Repeated tasks::              Items that show up again and again
@@ -4010,35 +4245,40 @@
 @kindex C-c C-d
 @item C-c C-d
 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
-happen in the line directly following the headline.
+happen in the line directly following the headline.  When called with a
+prefix arg, an existing deadline will be removed from the entry.
 @c FIXME Any CLOSED timestamp will be removed.????????
 @c
-@kindex C-c C-w
+@kindex C-c / d
 @cindex sparse tree, for deadlines
-@item C-c C-w
+@item C-c / d
 Create a sparse tree with all deadlines that are either past-due, or
 which will become due within @code{org-deadline-warning-days}.
 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
-prefix, check that many days.  For example, @kbd{C-1 C-c C-w} shows
+prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
 all deadlines due tomorrow.
 @c
 @kindex C-c C-s
 @item C-c C-s
 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
 happen in the line directly following the headline.  Any CLOSED
-timestamp will be removed.
+timestamp will be removed.  When called with a prefix argument, remove
+the scheduling date from the entry.
 @end table
 
 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
 @subsection Repeated Tasks
 
-Some tasks need to be repeated again and again, and Org-mode therefore
-allows to use a repeater in a DEADLINE or SCHEDULED time stamp, for
-example:
+Some tasks need to be repeated again and again.  Org-mode helps to
+organize such tasks using a so-called repeater in a DEADLINE or
+SCHEDULED time stamp.  In the following example
 @example
 ** TODO Pay the rent
    DEADLINE: <2005-10-01 Sat +1m>
 @end example
+the @code{+1m} is a repeater; the intended interpretation is that the
+task has a deadline on <2005-10-01> and repeats itself every (one) month
+starting from that time.
 
 Deadlines and scheduled items produce entries in the agenda when they
 are over-due, so it is important to be able to mark such an entry as
@@ -4057,9 +4297,11 @@
    DEADLINE: <2005-11-01 Tue +1m>
 @end example
 
-You will also be prompted for a note that will be put under the DEADLINE
-line to keep a record that you actually acted on the previous instance
-of this deadline.
+You will also be prompted for a note@footnote{You can change this using
+the option @code{org-log-repeat}, or the @code{#+STARTUP} options
+@code{logrepeat} and @code{nologrepeat}.} that will be put under the
+DEADLINE line to keep a record that you actually acted on the previous
+instance of this deadline.
 
 As a consequence of shifting the base date, this entry will no longer be
 visible in the agenda when checking past dates, but all future instances
@@ -4068,77 +4310,8 @@
 You may have both scheduling and deadline information for a specific
 task - just make sure that the repeater intervals on both are the same.
 
-@node Progress logging,  , Deadlines and scheduling, Timestamps
-@section Progress Logging
-@cindex progress logging
-@cindex logging, of progress
-
-Org-mode can automatically record a time stamp when you mark a TODO item
-as DONE, or even each time when you change the state of a TODO item.
-You can also measure precisely the time you spent on specific items in a
-project by starting and stopping a clock when you start and stop working
-on an aspect of a project.
-
-@menu
-* Closing items::               When was this entry marked DONE?
-* Tracking TODO state changes::  When did the status change?
-* Clocking work time::          When exactly did you work on this item?
-@end menu
-
-@node Closing items, Tracking TODO state changes, Progress logging, Progress logging
-@subsection Closing items
-
-If you want to keep track of @emph{when} a certain TODO item was
-finished, turn on logging with@footnote{The corresponding in-buffer
-setting is: @code{#+STARTUP: logdone}}
-
-@lisp
-(setq org-log-done t)
-@end lisp
-
-@noindent
-Then each time you turn a TODO entry into DONE using either @kbd{C-c
-C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
-@samp{CLOSED: [timestamp]} will be inserted just after the headline.  If
-you turn the entry back into a TODO item through further state cycling,
-that line will be removed again.  In the timeline (@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.  If you want to record a note
-along with the timestamp, use@footnote{The corresponding in-buffer
-setting is: @code{#+STARTUP: lognotedone}}
-
-@lisp
-(setq org-log-done '(done))
-@end lisp
-
-@node Tracking TODO state changes, Clocking work time, Closing items, Progress logging
-@subsection Tracking TODO state changes
-
-When TODO keywords are used as workflow states (@pxref{Workflow
-states}), you might want to keep track of when a state change occurred,
-and you may even want to attach notes to that state change.  With the
-setting
-
-@lisp
-(setq org-log-done '(state))
-@end lisp
-
-@noindent
-each state change will prompt you for a note that will be attached to
-the current headline.  Very likely you do not want this verbose tracking
-all the time, so it is probably better to configure this behavior with
-in-buffer options.  For example, if you are tracking purchases, put
-these into a separate file that starts with:
-
-@example
-#+SEQ_TODO: TODO ORDERED INVOICE PAYED RECEIVED SENT
-#+STARTUP: lognotestate
-@end example
-
-
-@node Clocking work time,  , Tracking TODO state changes, Progress logging
-@subsection Clocking work time
+@node Clocking work time,  , Deadlines and scheduling, Dates and times
+@section Clocking work time
 
 Org-mode allows you to clock the time you spent on specific tasks in a
 project.  When you start working on an item, you can start the clock.
@@ -4150,7 +4323,10 @@
 @kindex C-c C-x C-i
 @item C-c C-x C-i
 Start the clock on the current item (clock-in).  This inserts the CLOCK
-keyword together with a timestamp.
+keyword together with a timestamp.  If this is not the first clocking of
+this item, the multiple CLOCK lines will be wrapped into a
+@code{:CLOCK:} drawer (see also the variable
+@code{org-clock-into-drawer}.
 @kindex C-c C-x C-o
 @item C-c C-x C-o
 Stop the clock (clock-out).  The inserts another timestamp at the same
@@ -4173,6 +4349,10 @@
 @item C-c C-x C-x
 Cancel the current clock.  This is useful if a clock was started by
 mistake, or if you ended up working on something else.
+@kindex C-c C-x C-j
+@item C-c C-x C-j
+Jump to the entry that contains the currently running clock, an another
+window.
 @kindex C-c C-x C-d
 @item C-c C-x C-d
 Display time summaries for each subtree in the current buffer.  This
@@ -4184,18 +4364,29 @@
 @kindex C-c C-x C-r
 @item C-c C-x C-r
 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
-report as an org-mode table into the current file.
-@example
-#+BEGIN: clocktable :maxlevel 2 :emphasize nil
+report as an org-mode table into the current file.  When the cursor is
+at an existing clock table, just update it.  When called with a prefix
+argument, jump to the first clock report in the current document and
+update it.
+@example
+#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
 
 #+END: clocktable
 @end example
 @noindent
-If such a block already exists, its content is replaced by the new
-table.  The @samp{BEGIN} line can specify options:
-@example
-:maxlevels   @r{Maximum level depth to which times are listed in the table.}
+If such a block already exists at point, its content is replaced by the
+new table.  The @samp{BEGIN} line can specify options:
+@example
+:maxlevel    @r{Maximum level depth to which times are listed in the table.}
 :emphasize   @r{When @code{t}, emphasize level one and level two items}
+:scope       @r{The scope to consider.  This can be any of the following:}
+             nil        @r{the current buffer or narrowed region}
+             file       @r{the full current buffer}
+             subtree    @r{the subtree where the clocktable is located}
+             treeN      @r{the surrounding level N tree, for example @code{tree3}}
+             tree       @r{the surrounding level 1 tree}
+             agenda     @r{all agenda files}
+             ("file"..) @r{scan these files}
 :block       @r{The time block to consider.  This block is specified relative}
              @r{to the current time and may be any of these keywords:}
              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
@@ -4203,9 +4394,10 @@
 :tstart      @r{A time string specifying when to start considering times}
 :tend        @r{A time string specifying when to stop considering times}
 @end example
-So to get a clock summary for the current day, you could write
-@example
-#+BEGIN: clocktable :maxlevel 2 :block today
+So to get a clock summary of the current level 1 tree, for the current
+day, you could write
+@example
+#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1
 
 #+END: clocktable
 @end example
@@ -4218,6 +4410,12 @@
 
 #+END: clocktable
 @end example
+@kindex C-c C-c
+@item C-c C-c
+@kindex C-c C-x C-u
+@itemx C-c C-x C-u
+Update dynamical block at point.  The cursor needs to be in the
+@code{#+BEGIN} line of the dynamic block.
 @kindex C-u C-c C-x C-u
 @item C-u C-c C-x C-u
 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
@@ -4228,14 +4426,230 @@
 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
 worked on or closed during a day.
 
-@node Agenda views, Embedded LaTeX, Timestamps, Top
+@node Remember, Agenda views, Dates and times, Top
+@chapter Remember
+@cindex @file{remember.el}
+
+The @i{Remember} package by John Wiegley lets you store quick notes with
+little interruption of your work flow.  See
+@uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
+information.  It is an excellent way to add new notes and tasks to
+Org-mode files.  Org-mode significantly expands the possibilities of
+@i{remember}: You may define templates for different note types, and
+associate target files and headlines with specific templates.  It also
+allows you to select the location where a note should be stored
+interactively, on the fly.
+
+@menu
+* Setting up remember::         Some code for .emacs to get things going
+* Remember templates::          Define the outline of different note types
+* Storing notes::               Directly get the note to where it belongs
+* Refiling notes::              Moving a note or task to a project
+@end menu
+
+@node Setting up remember, Remember templates, Remember, Remember
+@section Setting up remember
+
+The following customization will tell @i{remember} to use org files as
+target, and to create annotations compatible with Org-mode links.
+
+@example
+(org-remember-insinuate)
+(setq org-directory "~/path/to/my/orgfiles/")
+(setq org-default-notes-file (concat org-directory "/notes.org"))
+(define-key global-map "\C-cr" 'org-remember)
+@end example
+
+The last line binds the command @code{org-remember} to a global
+key@footnote{Please select your own key, @kbd{C-c r} is only a
+suggestion.}.  @code{org-remember} basically just calls @code{remember},
+but it makes a few things easier: If there is an active region, it will
+automatically copy the region into the remember buffer.  It also allows
+to jump to the buffer and location where remember notes are being
+stored: Just call @code{org-remember} with a prefix argument.
+
+@node Remember templates, Storing notes, Setting up remember, Remember
+@section Remember templates
+@cindex templates, for remember
+
+In combination with Org-mode, you can use templates to generate
+different types of @i{remember} notes.  For example, if you would like
+to use one template to create general TODO entries, another one for
+journal entries, and a third one for collecting random ideas, you could
+use:
+
+@example
+(setq org-remember-templates
+ '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
+   ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
+   ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
+@end example
+
+@noindent In these entries, the first string is just a name, and the
+character specifies how to select the template.  It is useful if the
+character is also the first letter of the name.  The next string
+specifies the template.  Two more (optional) strings give the file in
+which, and the headline under which the new note should be stored.  The
+file (if not present or @code{nil}) defaults to
+@code{org-default-notes-file}, the heading to
+@code{org-remember-default-headline}.
+
+When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
+something, org will prompt for a key to select the template (if you have
+more than one template) and then prepare the buffer like
+@example
+* TODO
+  [[file:link to where you called remember]]
+@end example
+
+@noindent
+During expansion of the template, special @kbd{%}-escapes allow dynamic
+insertion of content:
+@example
+%^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
+            @r{You may specify a default value and a completion table with}
+            @r{%^@{prompt|default|completion2|completion3...@}}
+            @r{The arrow keys access a prompt-specific history.}
+%t          @r{time stamp, date only}
+%T          @r{time stamp with date and time}
+%u, %U      @r{like the above, but inactive time stamps}
+%^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
+            @r{You may define a prompt like @code{%^@{Birthday@}t}}
+%n          @r{user name (taken from @code{user-full-name})}
+%a          @r{annotation, normally the link created with @code{org-store-link}}
+%A          @r{like @code{%a}, but prompt for the description part}
+%i          @r{initial content, the region when remember is called with C-u.}
+            @r{The entire text will be indented like @code{%i} itself.}
+%c          @r{Content of the clipboard, or current kill ring head.}
+%^g         @r{prompt for tags, with completion on tags in target file.}
+%^G         @r{prompt for tags, with completion all tags in all agenda files.}
+%:keyword   @r{specific information for certain link types, see below}
+%[pathname] @r{insert the contents of the file given by @code{pathname}}
+%(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
+%!          @r{immediately store note after completing the template}
+            @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
+@end example
+
+@noindent
+For specific link types, the following keywords will be
+defined@footnote{If you define your own link types (@pxref{Adding
+hyperlink types}), any property you store with
+@code{org-store-link-props} can be accessed in remember templates in a
+similar way.}:
+
+@example
+Link type          |  Available keywords
+-------------------+----------------------------------------------
+bbdb               |  %:name %:company
+vm, wl, mh, rmail  |  %:type %:subject %:message-id
+                   |  %:from %:fromname %:fromaddress
+                   |  %:to   %:toname   %:toaddress
+                   |  %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user.  See the variable @code{org-from-is-user-regexp}.}}       
+gnus               |  %:group, @r{for messages also all email fields}
+w3, w3m            |  %:url
+info               |  %:file %:node
+calendar           |  %:date"
+@end example
+
+@noindent
+To place the cursor after template expansion use:
+
+@example
+%?          @r{After completing the template, position cursor here.}
+@end example
+
+@noindent
+If you change you mind about which template to use, call
+@code{org-remember} in the remember buffer.  You may then select a new
+template that will be filled with the previous context information.
+
+@node Storing notes, Refiling notes, Remember templates, Remember
+@section Storing notes
+
+When you are finished preparing a note with @i{remember}, you have to
+press @kbd{C-c C-c} to file the note away.  The handler will store the
+note in the file and under the headline specified in the template, or it
+will use the default file and headlines.  The window configuration will
+be restored, sending you back to the working context before the call to
+@code{remember}.  To re-use the location found during the last call to
+@code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
+i.e. specify a double prefix argument to @kbd{C-c C-c}.
+
+If you want to store the note directly to a different place, use
+@kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
+variable @code{org-remember-store-without-prompt} to make this behavior
+the default.}.  The handler will then first prompt for a target file -
+if you press @key{RET}, the value specified for the template is used.
+Then the command offers the headings tree of the selected file, with the
+cursor position at the default headline (if you had specified one in the
+template).  You can either immediately press @key{RET} to get the note
+placed there.  Or you can use the following keys to find a different
+location:
+@example
+@key{TAB}         @r{Cycle visibility.}
+@key{down} / @key{up}   @r{Next/previous visible headline.}
+n / p        @r{Next/previous visible headline.}
+f / b        @r{Next/previous headline same level.}
+u            @r{One level up.}
+@c 0-9          @r{Digit argument.}
+@end example
+@noindent
+Pressing @key{RET} or @key{left} or @key{right}
+then leads to the following result.
+
+@multitable @columnfractions 0.2 0.15 0.65
+@item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
+@item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
+@item                 @tab                        @tab depending on @code{org-reverse-note-order}.
+@item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
+@item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
+@item                 @tab @tab depending on @code{org-reverse-note-order}.
+@item not on headline @tab @key{RET}
+      @tab at cursor position, level taken from context.
+@end multitable
+
+Before inserting the text into a tree, the function ensures that the
+text has a headline, i.e. a first line that starts with a @samp{*}.  If
+not, a headline is constructed from the current date and some additional
+data.  If you have indented the text of the note below the headline, the
+indentation will be adapted if inserting the note into the tree requires
+demotion from level 1.
+
+@node Refiling notes,  , Storing notes, Remember
+@section Refiling notes
+@cindex refiling notes
+
+Remember is usually used to quickly capture notes and tasks into one or
+a few capture lists.  When reviewing the captured data, you may want to
+refile some of the entries into a different list, for example into a
+project.  Cutting, finding the right location and then pasting the note
+is cumbersome.  To simplify this process, you can use the following
+special command:
+
+@table @kbd
+@kindex C-c C-w
+@item C-c C-w
+Refile the entry at point.  This command offers possible locations for
+refiling the entry and lets you select one with completion.  The item is
+filed below the target heading as a subitem.  Depending on
+@code{org-reverse-note-order}, it will be either the first of last
+subitem, and you can toggle the value of this variable for the duration
+of the command by using a @kbd{C-u} prefix.@* By default, all level 1
+headlines in the current buffer are considered to be targets, but you
+can have more complex definitions across a number of files.  See the
+variable @code{org-refile-targets} for details.  The list of targets is
+compiled upon first use, you can update it by using a double prefix
+argument (@kbd{C-u C-u}) to this command.
+@end table
+
+@node Agenda views, Embedded LaTeX, Remember, Top
 @chapter Agenda Views
 @cindex agenda views
 
 Due to the way Org-mode works, TODO items, time-stamped items, and
 tagged headlines 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,
+files.  To get an overview of open action items, or of 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
@@ -4287,14 +4701,18 @@
 @cindex agenda files
 @cindex files for agenda
 
-The information to be shown is collected from all @emph{agenda files},
-the files listed in the variable @code{org-agenda-files}@footnote{If the
-value of that variable is not a list, but a single file name, then the
-list of agenda files will be maintained in that external file.}.  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
+The information to be shown is normally collected from all @emph{agenda
+files}, the files listed in the variable
+@code{org-agenda-files}@footnote{If the value of that variable is not a
+list, but a single file name, then the list of agenda files will be
+maintained in that external file.}. If a directory is part of this list,
+all files with the extension @file{.org} in this directory will be part
+of the list.
+
+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{<} 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
 
@@ -4319,6 +4737,42 @@
 The Org menu contains the current list of files and can be used
 to visit any of them.
 
+If you would like to focus the agenda temporarily onto a file not in
+this list, or onto just one file in the list or even only a subtree in a
+file, this can be done in different ways.  For a single agenda command,
+you may press @kbd{<} once or several times in the dispatcher
+(@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
+extended period, use the following commands:
+
+@table @kbd
+@kindex C-c C-x <
+@item C-c C-x <
+Permanently restrict the agenda to the current subtree.  When with a
+prefix argument, or with the cursor before the first headline in a file,
+the agenda scope is set to the entire file.  This restriction remains in
+effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
+or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
+agenda view, the new restriction takes effect immediately.
+@kindex C-c C-x <
+@item C-c C-x <
+Remove the permanent restriction created by @kbd{C-c C-x <}.
+@end table
+
+@noindent
+When working with @file{Speedbar}, you can use the following commands in
+the speedbar frame:
+@table @kbd
+@kindex <
+@item < @r{in the speedbar frame}
+Permanently restrict the agenda to the item at the cursor in the
+speedbar frame, either an Org-mode file or a subtree in such a file.
+If there is a window displaying an agenda view, the new restriction takes
+effect immediately.
+@kindex <
+@item > @r{in the speedbar frame}
+Lift the restriction again.
+@end table
+
 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
 @section The agenda dispatcher
 @cindex agenda dispatcher
@@ -4341,14 +4795,23 @@
 Create the timeline view for the current buffer (@pxref{Timeline}).
 @item # @r{/} !
 Create a list of stuck projects (@pxref{Stuck projects}).
-@item 1
-Restrict an agenda command to the current buffer.  After pressing
-@kbd{1}, you still need to press the character selecting the command.
-@item 0
+@item /
+Search for a regular expression in all agenda files and additionally in
+the files listed in @code{org-agenda-multi-occur-extra-files}.  This
+uses the Emacs command @code{multi-occur}.  A prefix argument can be
+used to specify the number of context lines for each match, default is
+1.
+@item <
+Restrict an agenda command to the current buffer@footnote{For backward
+compatibility, you can also press @kbd{1} to restrict to the current
+buffer.}.  After pressing @kbd{<}, you still need to press the character
+selecting the command.
+@item < <
 If there is an active region, restrict the following agenda command to
-the region.  Otherwise, restrict it to the current subtree.  After
-pressing @kbd{0}, you still need to press the character selecting the
-command.
+the region.  Otherwise, restrict it to the current subtree@footnote{For
+backward compatibility, you can also press @kbd{0} to restrict to the
+current buffer.}.  After pressing @kbd{< <}, you still need to press the
+character selecting the command.
 @end table
 
 You can also define custom commands that will be accessible through the
@@ -4384,10 +4847,12 @@
 @kindex C-c a a
 @item C-c a a
 Compile an agenda for the current week from a list of org files.  The
-agenda shows the entries for each day.  With a @kbd{C-u} prefix (or
-when the variable @code{org-agenda-include-all-todo} is @code{t}), all
-unfinished TODO items (including those without a date) are also listed at
-the beginning of the buffer, before the first date.@*
+agenda shows the entries for each day.  With a numeric
+prefix@footnote{For backward compatibility, the universal prefix
+@kbd{C-u} causes all TODO entries to be listed before the agenda.  This
+feature is deprecated, use the dedicated TODO list, or a block agenda
+instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
+to be displayed (see also the variable @code{org-agenda-ndays})
 @end table
 
 Remote editing from the agenda buffer means, for example, that you can
@@ -4443,6 +4908,18 @@
 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
 @end example
 
+@subsubheading Appointment reminders
+@cindex @file{appt.el}
+@cindex appointment reminders
+
+Org can interact with Emacs appointments notification facility.
+
+To add all the appointments of your agenda files, use the command
+@code{org-agenda-to-appt}.  This commands also lets you filter through
+the list of your appointments and add only those belonging to a specific
+category or matching a regular expression. See the docstring for
+details.
+
 @node Global TODO list, Matching tags and properties, Weekly/Daily agenda, Built-in agenda views
 @subsection The global TODO list
 @cindex global TODO list
@@ -4512,8 +4989,8 @@
 @item C-c a m
 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}).  If you often need a specific search,
+expression with tags, like @samp{+work+urgent-withboss} or
+@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
@@ -4616,16 +5093,27 @@
 @cindex category
 The category is a broad label assigned to each agenda item.  By default,
 the category is simply derived from the file name, but you can also
-specify it with a special line in the buffer, like this:
+specify it with a special line in the buffer, like this@footnote{For
+backward compatibility, the following also works: If there are several
+such lines in a file, each specifies the category for the text below it.
+The first category also applies to any text before the first CATEGORY
+line.  However, using this method is @emph{strongly} deprecated as it is
+incompatible with the outline structure of the document.  The correct
+method for setting multiple categories in a buffer is using a
+property.}:
 
 @example
 #+CATEGORY: Thesis
 @end example
 
-If there are several such lines in a file, each specifies the category
-for the text below it (but the first category also applies to any text
-before the first CATEGORY line).  The display in the agenda buffer looks
-best if the category is not longer than 10 characters.
+@noindent
+If you would like to have a special CATEGORY for a single entry or a
+(sub)tree, give the entry a @code{:CATEGORY:} property with the location
+as the value (@pxref{Properties and columns}).
+
+@noindent
+The display in the agenda buffer looks best if the category is not
+longer than 10 characters.
 
 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
 @subsection Time-of-Day Specifications
@@ -4725,10 +5213,10 @@
 @cindex motion commands in agenda
 @kindex n
 @item n
-Next line (same as @key{up}).
+Next line (same as @key{up} and @kbd{C-p}).
 @kindex p
 @item p
-Previous line (same as @key{down}).
+Previous line (same as @key{down} and @kbd{C-n}).
 @tsubheading{View/GoTo org file}
 @kindex mouse-3
 @kindex @key{SPC}
@@ -4807,7 +5295,9 @@
 keyword.
 @c
 @kindex s
+@kindex C-x C-s
 @item s
+@itemx C-x C-s
 Save all Org-mode buffers in the current Emacs session.
 @c
 @kindex @key{right}
@@ -4860,7 +5350,8 @@
 @c
 @kindex :
 @item :
-Set tags for the current headline.
+Set tags for the current headline.  If there is an active region in the
+agenda, change a tag for all headings in the region.
 @c
 @kindex a
 @item a
@@ -4931,6 +5422,10 @@
 @item X
 Cancel the currently running clock.
 
+@kindex J
+@item J
+Jump to the running clock in another window.
+
 @tsubheading{Calendar commands}
 @cindex calendar commands, from agenda
 @kindex c
@@ -5035,19 +5530,28 @@
 (setq org-agenda-custom-commands
       '(("w" todo "WAITING")
         ("W" todo-tree "WAITING")
-        ("u" tags "+BOSS-URGENT")
-        ("v" tags-todo "+BOSS-URGENT")
-        ("U" tags-tree "+BOSS-URGENT")
-        ("f" occur-tree "\\<FIXME\\>")))
+        ("u" tags "+boss-urgent")
+        ("v" tags-todo "+boss-urgent")
+        ("U" tags-tree "+boss-urgent")
+        ("f" occur-tree "\\<FIXME\\>")
+        ("h" . "HOME+Name tags searches") ; description for "h" prefix
+        ("hl" tags "+home+Lisa")
+        ("hp" tags "+home+Peter")
+        ("hk" tags "+home+Kim")))
 @end group
 @end lisp
 
 @noindent
-The initial single-character string in each entry defines the character
-you have to press after the dispatcher command @kbd{C-c a} in order to
-access the command.   The second parameter is the search type, followed
-by the string or regular expression to be used for the matching.  The
-example above will therefore define:
+The initial string in each entry defines the keys you have to press
+after the dispatcher command @kbd{C-c a} in order to access the command.
+Usually this will be just a single character, but if you have many
+similar commands, you can also define two-letter combinations where the
+first character is the same in several combinations and serves as a
+prefix key@footnote{You can provide a description for a prefix key by
+inserting a cons cell with the prefix and the description.}.  The second
+parameter is the search type, followed by the string or regular
+expression to be used for the matching.  The example above will
+therefore define:
 
 @table @kbd
 @item C-c a w
@@ -5057,8 +5561,8 @@
 as the same search, but only in the current buffer and displaying the
 results as a sparse tree
 @item C-c a u
-as a global tags search for headlines marked @samp{:BOSS:} but not
-@samp{:URGENT:}
+as a global tags search for headlines marked @samp{:boss:} but not
+@samp{:urgent:}
 @item C-c a v
 as the same search as @kbd{C-c a u}, but limiting the search to
 headlines that are also TODO items
@@ -5067,7 +5571,11 @@
 displaying the result as a sparse tree
 @item C-c a f
 to create a sparse tree (again: current buffer only) with all entries
-containing the word @samp{FIXME}.
+containing the word @samp{FIXME}
+@item C-c a h
+as a prefix command for a HOME tags search where you have to press an
+additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
+Peter, or Kim) as additional tag to match.
 @end table
 
 @node Block agenda, Setting Options, Storing searches, Custom agenda views
@@ -5088,12 +5596,12 @@
 (setq org-agenda-custom-commands
       '(("h" "Agenda and Home-related tasks"
          ((agenda)
-          (tags-todo "HOME")
-          (tags "GARDEN")))
+          (tags-todo "home")
+          (tags "garden")))
         ("o" "Agenda and Office-related tasks"
          ((agenda)
-          (tags-todo "WORK")
-          (tags "OFFICE")))))
+          (tags-todo "work")
+          (tags "office")))))
 @end group
 @end lisp
 
@@ -5101,7 +5609,7 @@
 This will define @kbd{C-c a h} to create a multi-block view for stuff
 you need to attend to at home.  The resulting agenda buffer will contain
 your agenda for the current week, all TODO items that carry the tag
-@samp{HOME}, and also all lines tagged with @samp{GARDEN}.  Finally the
+@samp{home}, and also all lines tagged with @samp{garden}.  Finally the
 command @kbd{C-c a o} provides a similar view for office tasks.
 
 
@@ -5122,7 +5630,7 @@
       '(("w" todo "WAITING"
          ((org-agenda-sorting-strategy '(priority-down))
           (org-agenda-prefix-format "  Mixed: ")))
-        ("U" tags-tree "+BOSS-URGENT"
+        ("U" tags-tree "+boss-urgent"
          ((org-show-following-heading nil)
           (org-show-hierarchy-above nil)))))
 @end group
@@ -5130,7 +5638,7 @@
 
 @noindent
 Now the @kbd{C-c a w} command will sort the collected entries only by
-priority, and the prefix format is modified to just say @samp{  Mixed:}
+priority, and the prefix format is modified to just say @samp{  Mixed: }
 instead of giving the category of the entry.  The sparse tags tree of
 @kbd{C-c a U} will now turn out ultra-compact, because neither the
 headline hierarchy above the match, nor the headline following the match
@@ -5152,14 +5660,14 @@
 (setq org-agenda-custom-commands
       '(("h" "Agenda and Home-related tasks"
          ((agenda)
-          (tags-todo "HOME")
-          (tags "GARDEN"
+          (tags-todo "home")
+          (tags "garden"
                 ((org-agenda-sorting-strategy '(priority-up)))))
          ((org-agenda-sorting-strategy '(priority-down))))
         ("o" "Agenda and Office-related tasks"
          ((agenda)
-          (tags-todo "WORK")
-          (tags "OFFICE")))))
+          (tags-todo "work")
+          (tags "office")))))
 @end group
 @end lisp
 
@@ -5218,14 +5726,14 @@
         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
         ("h" "Agenda and Home-related tasks"
          ((agenda)
-          (tags-todo "HOME")
-          (tags "GARDEN"))
+          (tags-todo "home")
+          (tags "garden"))
          nil
          ("~/views/home.html"))
         ("o" "Agenda and Office-related tasks"
          ((agenda)
-          (tags-todo "WORK")
-          (tags "OFFICE"))
+          (tags-todo "work")
+          (tags "office"))
          nil
          ("~/views/office.ps"))))
 @end group
@@ -5283,6 +5791,7 @@
 @example
 emacs -eval '(org-batch-store-agenda-views                      \
               org-agenda-ndays 30                               \
+              org-agenda-start-day "2007-11-01"                 \
               org-agenda-include-diary nil                      \
               org-agenda-files (quote ("~/org/project.org")))'  \
       -kill
@@ -5665,7 +6174,8 @@
 warning.  If there is an active region, only the region will be
 exported. If the selected region is a single tree, the tree head will
 become the document title.  If the tree head entry has or inherits an
-EXPORT_FILE_NAME property, that name will be used for the export.
+@code{:EXPORT_FILE_NAME:} property, that name will be used for the
+export. 
 @kindex C-c C-e v a
 @item C-c C-e v a
 Export only the visible part of the document.
@@ -5720,8 +6230,8 @@
 will be overwritten without warning.  If there is an active region, only
 the region will be exported. If the selected region is a single tree,
 the tree head will become the document title.  If the tree head entry
-has or inherits an EXPORT_FILE_NAME property, that name will be used for
-the export.
+has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
+used for the export.
 @kindex C-c C-e b
 @item C-c C-e b
 Export as HTML file and immediately open it with a browser.
@@ -5729,7 +6239,7 @@
 @item C-c C-e H
 Export to a temporary buffer, do not create a file.
 @kindex C-c C-e R
-@item C-c C-e H
+@item C-c C-e R
 Export the active region to a temporary buffer.  With prefix arg, do not
 produce file header and foot, but just the plain HTML section for the
 region.  This is good for cut-and-paste operations.
@@ -5877,6 +6387,7 @@
 @menu
 * LaTeX export commands::       How to invoke LaTeX export
 * Quoting LaTeX code::          Incorporating literal LaTeX code
+* Sectioning structure::        
 @end menu
 
 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
@@ -5920,7 +6431,7 @@
 @noindent
 creates two levels of headings and does the rest as items.
 
-@node Quoting LaTeX code,  , LaTeX export commands, LaTeX export
+@node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
 @subsection Quoting LaTeX code
 
 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
@@ -5939,6 +6450,23 @@
 All lines between these markers are exported literally
 #+END_LaTeX
 @end example
+
+
+
+@node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
+@subsection Sectioning structure
+@cindex LaTeX class
+@cindex LaTeX sectioning structure
+
+By default, the La@TeX{} output uses the class @code{article}.
+
+You can change this globally by setting a different value for
+@code{org-export-latex-default-class} or locally by adding an option
+like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
+listed in @code{org-export-latex-classes}, where you can also define the
+sectioning structure for each class.
+
+
 @node XOXO export, iCalendar export, LaTeX export, Exporting
 @section XOXO export
 @cindex XOXO export
@@ -5985,6 +6513,11 @@
 @code{org-combined-agenda-icalendar-file}.
 @end table
 
+The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
+the selected entries have them.  If not, the summary will be derived
+from the headline, and the description from the body (limited to
+@code{org-icalendar-include-body} characters).  
+
 How this calendar is best read and updated, depends on the application
 you are using.  The FAQ covers this issue.
 
@@ -5999,6 +6532,7 @@
 * Comment lines::               Some lines will not be exported
 * Initial text::                Text before the first headline
 * Footnotes::                   Numbers like [1]
+* Quoted examples::             Inserting quoted chnuks of text            
 * Enhancing text::              Subscripts, symbols and more
 * Export options::              How to influence the export settings
 @end menu
@@ -6056,7 +6590,7 @@
 #+TEXT: This goes between the table of contents and the first headline
 @end example
 
-@node Footnotes, Enhancing text, Initial text, Text interpretation
+@node Footnotes, Quoted examples, Initial text, Text interpretation
 @subsection Footnotes
 @cindex footnotes
 @cindex @file{footnote.el}
@@ -6068,7 +6602,7 @@
 The org-mode homepage[1] clearly needs help from
 a good web designer.
 
-[1] The link is: http://www.astro.uva.nl/~dominik/Tools/org
+[1] The link is: http://orgmode.org
 @end example
 
 @noindent
@@ -6081,14 +6615,48 @@
 @code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
 the settings in Org-mode.
 
-@node Enhancing text, Export options, Footnotes, Text interpretation
+@node Quoted examples, Enhancing text, Footnotes, Text interpretation
+@subsection Quoted examples
+@cindex quoted examples
+@cindex examples, quoted
+@cindex text, fixed width
+@cindex fixed width text
+
+When writing technical documents, you often need to insert examples that
+are not further interpreted by Org-mode.  For historical reasons, there
+are several ways to do this:
+
+@itemize @bullet
+@item
+If a headline starts with the word @samp{QUOTE}, the text below the
+headline will be typeset as fixed-width, to allow quoting of computer
+codes etc.
+@item
+Lines starting with @samp{:} are also typeset in fixed-width font. 
+@table @kbd
+@kindex C-c :
+@item C-c :
+Toggle fixed-width for entry (QUOTE) or region, see below.
+@end table
+@item
+Finally, text between
+@example
+#+BEGIN_EXAMPLE
+quoted text
+#+END_EXAMPLE
+@end example
+will also be exported in this way.
+@end itemize
+
+
+@node Enhancing text, Export options, Quoted examples, Text interpretation
 @subsection Enhancing text for export
 @cindex enhancing text
 @cindex richer text
 
 Some of the export backends of Org-mode allow for sophisticated text
 formatting, this is true in particular for the HTML and La@TeX{}
-backends. Org-mode has a number of typing conventions that allow to
+backends.  Org-mode has a number of typing conventions that allow to
 produce a richly formatted output.
 
 @itemize @bullet
@@ -6103,11 +6671,12 @@
 @cindex underlined text
 @cindex bold text
 @cindex italic text
-@item
-You can make words @b{*bold*}, @i{/italic/}, _underlined_,
-@code{=code=}, and even @samp{+strikethrough+}@footnote{but remember
-that strikethrough is typographically evil and should @i{never} be
-used.}.
+@cindex verbatim text
+@item
+You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
+and @code{~verbatim~}, and, if you must, @samp{+strikethrough+}.  Text
+in the code and verbatim string is not processed for org-mode specific
+syntax, it is exported verbatim.
 
 @cindex horizontal rules, in exported files
 @item
@@ -6137,11 +6706,27 @@
 @item C-c :
 Toggle fixed-width for entry (QUOTE) or region, see below.
 @end table
+Finally, text between
+@example
+#+BEGIN_EXAMPLE
+quoted text
+#+END_EXAMPLE
+@end example
+will also be exported in this way.
 
 @cindex linebreak, forced
 @item 
 A double backslash @emph{at the end of a line} enforces a line break at
 this position.
+
+@cindex HTML entities, LaTeX entities
+@item
+Strings like @code{\alpha} will be exported as @code{&alpha;}, in the
+HTML output.  These strings are exported as @code{$\alpha$} in the
+La@TeX{} output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in
+HTML and in La@TeX{}.  This applies for a long list of entities, see
+the variable @code{org-html-entities} for the complete list.
+@c FIXME
 @end itemize
 
 If these conversions conflict with your habits of typing ASCII text,
@@ -6172,6 +6757,7 @@
 @example
 #+TITLE:     the title to be shown (default is the buffer name)
 #+AUTHOR:    the author (default taken from @code{user-full-name})
+#+DATE:      A date, fixed, of a format string for @code{format-time-string}
 #+EMAIL:     his/her email address (default from @code{user-mail-address})
 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
 #+TEXT:      Some descriptive text to be inserted at the beginning.
@@ -6191,6 +6777,7 @@
 @cindex tables
 @cindex @TeX{}-like syntax for sub- and superscripts
 @cindex footnotes
+@cindex special strings
 @cindex emphasized text
 @cindex @TeX{} macros
 @cindex La@TeX{} fragments
@@ -6207,6 +6794,7 @@
 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
            @r{the simple @code{a_b} will be left as it is.}
+-:         @r{turn on/off conversion of special strings.}
 f:         @r{turn on/off foototes like this[1].}
 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
@@ -6214,6 +6802,7 @@
 skip:      @r{turn on/off skipping the text before the first heading}
 author:    @r{turn on/off inclusion of author name/email into exported file}
 timestamp: @r{turn on/off inclusion creation time into exported file}
+d:         @r{turn on/off inclusion of drawers}
 @end example
 
 These options take effect in both the HTML and La@TeX{} export, except
@@ -6274,11 +6863,11 @@
 the two following forms:
 
 @lisp
-("project-name"  :property value :property value ...)
+("project-name" :property value :property value ...)
 
 @r{or} 
  
-("project-name"  :components ("project-name" "project-name" ...))
+("project-name" :components ("project-name" "project-name" ...))
 
 @end lisp
 
@@ -6378,6 +6967,7 @@
 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
+@item @code{:special-strings}       @tab @code{org-export-with-special-strings}
 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
@@ -6399,14 +6989,16 @@
 @item @code{:email}                 @tab @code{user-mail-address}
 @end multitable
 
+If you use several email addresses, separate them by a semi-column.
+
 Most of the @code{org-export-with-*} variables have the same effect in
 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
 La@TeX{} export.
 
-When a property is given a value in org-publish-project-alist, its
-setting overrides the value of the corresponding user variable (if any)
-during publishing.  Options set within a file (@pxref{Export
+When a property is given a value in @code{org-publish-project-alist},
+its setting overrides the value of the corresponding user variable (if
+any) during publishing.  Options set within a file (@pxref{Export
 options}), however, override everything.
 
 @node Publishing links, Project page index, Publishing options, Configuration
@@ -6422,7 +7014,7 @@
 
 You may also link to related files, such as images. Provided you are
 careful with relative pathnames, and provided you have also configured
-org-publish to upload the related files, these links will work
+@code{org-publish} to upload the related files, these links will work
 too. @ref{Complex example} for an example of this usage.
 
 Sometime an Org-mode file to be published may contain links that are
@@ -6681,13 +7273,16 @@
 end of the file.  The first such line also applies to any entries before it.
 @item #+COLUMNS: %25ITEM .....
 Set the default format for columns view.  This format applies when
-columns view is invoked in location where no COLUMNS property applies.
+columns view is invoked in location where no @code{COLUMNS} property
+applies.
 @item #+CONSTANTS: name1=value1 ...
 Set file-local values for constants to be used in table formulas.  This
 line set the local variable @code{org-table-formula-constants-local}.
-The global version of theis variable is
+The global version of this variable is
 @code{org-table-formula-constants}.
-corresponding 
+@item #+DRAWERS: NAME1 .....
+Set the file-local set of drawers.  The corresponding global variable is
+@code{org-drawers}.
 @item #+LINK:  linkword replace
 These lines (several are allowed) specify link abbreviations.
 @xref{Link abbreviations}.  The corresponding variable is
@@ -6723,8 +7318,9 @@
 align      @r{align all tables}
 noalign    @r{don't align tables on startup}
 @end example
-Logging TODO state changes and clock intervals (variable
-@code{org-log-done}) can be configured using these options.
+Logging TODO state changes and clock intervals (variables
+@code{org-log-done} and @code{org-log-repeat}) can be configured using
+these options.
 @cindex @code{logdone}, STARTUP keyword
 @cindex @code{nologging}, STARTUP keyword
 @cindex @code{lognotedone}, STARTUP keyword
@@ -6776,7 +7372,7 @@
 keys.  The corresponding variable is @code{org-tag-alist}.
 @item #+TBLFM:
 This line contains the formulas for the table directly above the line.
-@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS:
+@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
 These lines provide settings for exporting files.  For more details see
 @ref{Export options}.
 @item #+SEQ_TODO:   #+TYP_TODO:
@@ -6830,6 +7426,9 @@
 @item
 If the cursor is on a numbered item in a plain list, renumber the
 ordered list.
+@item
+If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
+block is updated.
 @end itemize
 
 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
@@ -6937,18 +7536,17 @@
 @section Using org-mode on a tty
 @cindex tty keybindings
 
-Org-mode uses a number of keys that are not accessible on a tty.  This
-applies to most special keys like cursor keys, @key{TAB} and
-@key{RET}, when these are combined with modifier keys like @key{Meta}
-and/or @key{Shift}.  Org-mode uses these bindings because it needs to
-provide keys for a large number of commands, and because these keys
-appeared particularly easy to remember.  In order to still be able to
-access the core functionality of Org-mode on a tty, alternative
-bindings are provided.  Here is a complete list of these bindings,
-which are obviously more cumbersome to use.  Note that sometimes a
-work-around can be better.  For example changing a time stamp is
-really only fun with @kbd{S-@key{cursor}} keys.  On a tty you would
-rather use @kbd{C-c .}  to re-insert the timestamp.
+Because Org-mode contains a large number of commands, by default much of
+Org-mode's core commands are bound to keys that are generally not
+accessible on a tty, such as the cursor keys (@key{left}, @key{right},
+@key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
+together with modifiers like @key{Meta} and/or @key{Shift}.  To access
+these commands on a tty when special keys are unavailable, the following
+alternative bindings can be used.  The tty bindings below will likely be
+more cumbersome; you may find for some of the bindings below that a
+customized work-around suits you better.  For example, changing a time
+stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
+tty you would rather use @kbd{C-c .} to re-insert the timestamp.
 
 @multitable @columnfractions 0.15 0.2 0.2
 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
@@ -7013,10 +7611,27 @@
 @cindex @file{cdlatex.el}
 Org-mode can make use of the cdlatex package to efficiently enter
 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
+@item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
+@cindex @file{imenu.el}
+Imenu allows menu access to an index of items in a file.  Org-mode
+supports imenu - all you need to do to get the index is the following:
+@lisp
+(add-hook 'org-mode-hook 
+          (lambda () 'imenu-add-to-menubar "Imenu"))
+@end lisp
+By default the index is two levels deep - you can modify the depth using
+the option @code{org-imenu-depth}.
 @item @file{remember.el} by John Wiegley
 @cindex @file{remember.el}
 Org mode cooperates with remember, see @ref{Remember}.
 @file{Remember.el} is not part of Emacs, find it on the web.
+@item @file{speedbar.el} by Eric M. Ludlam
+@cindex @file{speedbar.el}
+Speedbar is a package that creates a special frame displaying files and
+index items in files.  Org-mode supports speedbar and allows you to
+drill into Org-mode files directly from the speedbar.  It also allows to
+restrict the scope of agenda commands to a file or a subtree by using
+the command @kbd{<} in the speedbar frame.
 @cindex @file{table.el}
 @item @file{table.el} by Takaaki Ota
 @kindex C-c C-c
@@ -7070,13 +7685,12 @@
 
 @cindex @file{CUA.el}
 @item @file{CUA.el} by Kim. F. Storm
-Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys
-used by CUA-mode (as well as pc-select-mode and s-region-mode) to
-select and extend the region.  If you want to use one of these
-packages along with Org-mode, configure the variable
-@code{org-CUA-compatible}.  When set, Org-mode will move the following
-keybindings in Org-mode files, and in the agenda buffer (but not
-during date selection).
+Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys used by
+CUA-mode (as well as pc-select-mode and s-region-mode) to select and
+extend the region.  If you want to use one of these packages along with
+Org-mode, configure the variable @code{org-replace-disputed-keys}.  When
+set, Org-mode will move the following keybindings in Org-mode files, and
+in the agenda buffer (but not during date selection).
 
 @example
 S-UP    -> M-p             S-DOWN  -> M-n
@@ -7197,6 +7811,12 @@
 @item @file{org2rem.el} by Bastien Guerry
 Translates Org-mode files into something readable by
 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
+@item @file{org-toc.el} by Bastien Guerry
+Produces a simple table of contents of an Org-mode file, for easy
+navigation. @url{http://www.cognition.ens.fr/~guerry/u/org-registry.el}.
+@item @file{org-registry.el} by Bastien Guerry
+Find which Org-file link to a certain document.
+@url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
 @end table
 
 @page
@@ -7299,15 +7919,18 @@
 buffer with @kbd{C-c C-l}.
 
 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
-@section Tables in arbitrary syntax
+@section Tables and Lists in arbitrary syntax
 @cindex tables, in other modes
+@cindex lists, in other modes
 @cindex orgtbl-mode
 
 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
 frequent feature request has been to make it work with native tables in
-specific languages, for example La@TeX{}.  However, this is extremely hard
-to do in a general way, would lead to a customization nightmare, and
-would take away much of the simplicity of the Orgtbl-mode table editor.
+specific languages, for example La@TeX{}.  However, this is extremely
+hard to do in a general way, would lead to a customization nightmare,
+and would take away much of the simplicity of the Orgtbl-mode table
+editor.
+
 
 This appendix describes a different approach.  We keep the Orgtbl-mode
 table in its native format (the @i{source table}), and use a custom
@@ -7316,10 +7939,17 @@
 the burden of writing conversion functions on the user, but it allows
 for a very flexible system.
 
+Bastien added the ability to do the same with lists.  You can use Org's
+facilities to edit and structure lists by turning @code{orgstruct-mode}
+on, then locally exporting such lists in another format (HTML, La@TeX{}
+or TeXInfo.)
+
+
 @menu
 * Radio tables::                Sending and receiving
 * A LaTeX example::             Step by step, almost a tutorial
 * Translator functions::        Copy and modify
+* Radio lists::                 Doing the same for lists.
 @end menu
 
 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
@@ -7388,7 +8018,7 @@
 @end itemize
 
 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
-@subsection A LaTeX example
+@subsection A LaTeX example of radio tables
 @cindex LaTeX, and orgtbl-mode
 
 The best way to wrap the source table in La@TeX{} is to use the
@@ -7492,7 +8122,7 @@
 applied.
 @end table
 
-@node Translator functions,  , A LaTeX example, Tables in arbitrary syntax
+@node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
 @subsection Translator functions
 @cindex HTML, and orgtbl-mode
 @cindex translator function
@@ -7565,6 +8195,49 @@
 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
 others can benefit from your work.
 
+@node  Radio lists,  , Translator functions, Tables in arbitrary syntax
+@subsection Radio lists
+@cindex radio lists
+@cindex org-list-insert-radio-list
+
+Sending and receiving radio lists works exactly the same way than
+sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
+need to load the @code{org-export-latex.el} package to use radio lists
+since the relevant code is there for now.}.  As for radio tables, you
+can insert radio lists templates in HTML, La@TeX{} and TeXInfo modes by
+calling @code{org-list-insert-radio-list}.
+
+Here are the differences with radio tables:
+
+@itemize @minus
+@item
+Use @code{ORGLST} instead of @code{ORGTBL}.
+@item
+The available translation functions for radio lists don't take
+parameters.
+@item 
+`C-c C-c' will work when pressed on the first item of the list.
+@end itemize
+
+Here is a La@TeX{} example.  Let's say that you have this in your
+La@TeX{} file:
+
+@example
+% BEGIN RECEIVE ORGLST to-buy
+% END RECEIVE ORGLST to-buy
+\begin@{comment@}
+#+ORGLIST: SEND to-buy orgtbl-to-latex
+- a new house
+- a new computer
+  + a new keyboard
+  + a new mouse
+- a new life
+\end@{comment@}
+@end example
+
+Pressing `C-c C-c' on @code{a new house} and will insert the converted
+La@TeX{} list between the two marker lines.
+
 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
 @section Dynamic blocks
 @cindex dynamic blocks
@@ -7651,7 +8324,7 @@
 (defun my-skip-unless-waiting ()
   "Skip trees that are not waiting"
   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
-    (if (re-search-forward ":WAITING:" subtree-end t)
+    (if (re-search-forward ":waiting:" subtree-end t)
         nil          ; tag found, do not skip
       subtree-end))) ; tag not found, continue after end of subtree
 @end lisp
@@ -7683,8 +8356,9 @@
 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
 Skip current entry if it has a deadline, or if it is scheduled.
 @item '(org-agenda-skip-entry 'regexp "regular expression")
-Skip current entry if the regular expression contained in the variable
-@code{org-agenda-skip-regexp} matches in the entry.
+Skip current entry if the regular expression matches in the entry.
+@item '(org-agenda-skip-entry 'notregexp "regular expression")
+Skip current entry unless the regular expression matches.
 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
 Same as above, but check and skip the entire subtree.
 @end table
@@ -7696,7 +8370,7 @@
 (org-add-agenda-custom-command
  '("b" todo "PROJECT"
    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
-                                'regexp ":WAITING:"))
+                                'regexp ":waiting:"))
     (org-agenda-overriding-header "Projects waiting for something: "))))
 @end lisp
 
@@ -7722,7 +8396,9 @@
 @defun org-entry-get pom property &optional inherit
 Get value of PROPERTY for entry at point-or-marker POM.
 If INHERIT is non-nil and the entry does not have the property,
-then also check higher levels of the hierarchy.
+then also check higher levels of the hierarchy.  This function ignores
+the value of @code{org-use-property-inheritance} and requires the
+explicit INHERIT flag.
 @end defun
 
 @defun org-entry-delete pom property
@@ -7741,7 +8417,7 @@
 Insert a property drawer at point.
 @end defun
 
-@node History and Acknowledgments, Index, Extensions and Hacking, Top
+@node History and Acknowledgments, Main Index, Extensions and Hacking, Top
 @appendix History and Acknowledgments
 @cindex acknowledgments
 @cindex history
@@ -7814,11 +8490,10 @@
 @i{John Foerch} figured out how to make incremental search show context
 around a match in a hidden outline tree.
 @item
-@i{Niels Giessen} had the idea to automatically archive DONE trees.
+@i{Niels Giesen} had the idea to automatically archive DONE trees.
 @item
 @i{Bastien Guerry} wrote the La@TeX{} exporter and has been prolific
 with patches, ideas, and bug reports.
-to Org-mode.
 @item
 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
 @item
@@ -7830,13 +8505,16 @@
 @item
 @i{Jason F. McBrayer} suggested agenda export to CSV format.
 @item
+@i{Max Mikhanosha} came up with the idea of refiling.
+@item
 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
 basis.
 @item
 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
 happy.
 @item
-@i{Rick Moynihan} proposed to allow multiple TODO sequences in a file.
+@i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
+and to be able to quickly restrict the agenda to a subtree.
 @item
 @i{Todd Neal} provided patches for links to Info files and elisp forms.
 @item
@@ -7914,12 +8592,12 @@
 @end itemize
 
 
-@node Index, Key Index, History and Acknowledgments, Top
-@unnumbered Index
+@node Main Index, Key Index, History and Acknowledgments, Top
+@unnumbered The Main Index
 
 @printindex cp
 
-@node Key Index,  , Index, Top
+@node Key Index,  , Main Index, Top
 @unnumbered Key Index
 
 @printindex ky
--- a/doc/misc/pcl-cvs.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/pcl-cvs.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -7,8 +7,8 @@
 
 @copying
 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007  Free Software
-Foundation, Inc.
+1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/pgg.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/pgg.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -8,8 +8,8 @@
 @copying
 This file describes PGG, an Emacs interface to various PGP implementations.
 
-Copyright @copyright{} 2001, 2003, 2004, 2005, 2006, 2007  Free Software
-Foundation, Inc.
+Copyright @copyright{} 2001, 2003, 2004, 2005, 2006, 2007, 2008
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/rcirc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/rcirc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/reftex.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/reftex.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -28,7 +28,7 @@
 @b{Ref@TeX{}} @value{VERSION}
 
 Copyright @copyright{} 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-2005, 2006, 2007  Free Software Foundation, Inc.
+2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/remember.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/remember.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -14,7 +14,8 @@
 @copying
 This manual is for Remember Mode, version 1.9
 
-Copyright @copyright{} 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2001, 2004, 2005, 2007, 2008
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/sasl.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/sasl.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -14,8 +14,8 @@
 @ifinfo
 This file describes the Emacs SASL library.
 
-Copyright @copyright{} 2004, 2005, 2006 Free Software Foundation, Inc.
-Copyright @copyright{} 2000 Daiki Ueno.
+Copyright @copyright{} 2000, 2004, 2005, 2006, 2007, 2008
+Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
--- a/doc/misc/sc.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/sc.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -16,7 +16,7 @@
 subsystems.
 
 Copyright @copyright{} 1993, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/ses.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/ses.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -11,7 +11,7 @@
 @copying
 This file documents SES: the Simple Emacs Spreadsheet.
 
-Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 
 @quotation
--- a/doc/misc/sieve.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/sieve.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -9,7 +9,7 @@
 @copying
 This file documents the Emacs Sieve package, for server-side mail filtering.
 
-Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 
 @quotation
--- a/doc/misc/smtpmail.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/smtpmail.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -3,7 +3,8 @@
 @settitle Emacs SMTP Library
 @syncodeindex vr fn
 @copying
-Copyright @copyright{} 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2003, 2004, 2005, 2006, 2007, 2008
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/speedbar.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/speedbar.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -6,7 +6,7 @@
 
 @copying
 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-2007  Free Software Foundation, Inc.
+2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/texinfo.tex	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/texinfo.tex	Wed Jan 30 07:57:28 2008 +0000
@@ -7,7 +7,7 @@
 %
 % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-% 2007 Free Software Foundation, Inc.
+% 2007, 2008 Free Software Foundation, Inc.
 %
 % This texinfo.tex file is free software; you can redistribute it and/or
 % modify it under the terms of the GNU General Public License as
Binary file doc/misc/tramp.texi has changed
--- a/doc/misc/trampver.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/trampver.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -1,10 +1,15 @@
 @c -*-texinfo-*-
 @c texi/trampver.texi.  Generated from trampver.texi.in by configure.
 
+@c This is part of the Emacs manual.
+@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+@c   Free Software Foundation, Inc.
+@c See file emacs.texi for copying conditions.
+
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@set trampver 2.1.12
+@set trampver 2.1.13-pre
 
 @c Other flags from configuration
 @set instprefix /usr/local
--- a/doc/misc/url.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/url.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -22,7 +22,7 @@
 This file documents the URL loading package.
 
 Copyright @copyright{} 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2002,
-2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
@@ -50,7 +50,7 @@
 @page
 @vskip 0pt plus 1filll
 Copyright @copyright{} 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2002,
-2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
--- a/doc/misc/vip.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/vip.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 
 @copying
 Copyright @copyright{} 1987, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/viper.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/viper.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -8,7 +8,7 @@
 
 @copying
 Copyright @copyright{} 1995, 1996, 1997, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/widget.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/widget.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -11,7 +11,7 @@
 
 @copying
 Copyright @copyright{} 2000, 2001, 2002, 2003, 2004, 2005,
-2006, 2007  Free Software Foundation, Inc.
+2006, 2007, 2008  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/doc/misc/woman.texi	Wed Jan 30 06:40:42 2008 +0000
+++ b/doc/misc/woman.texi	Wed Jan 30 07:57:28 2008 +0000
@@ -18,7 +18,7 @@
 (without) man'.
 
 Copyright @copyright{} 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- a/etc/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,21 @@
+2008-01-25  Michael Olson  <mwolson@gnu.org>
+
+	* ERC-NEWS: Update for ERC 5.3 release candidate.
+
+2008-01-22  Juanma Barranquero  <lekktu@gmail.com>
+
+	* DEVEL.HUMOR: New entry.
+
+2008-01-18  Carsten Dominik  <dominik@science.uva.nl>
+
+	* refcards/orgcard.tex: Update to Org-mode version 5.19.
+
+2008-01-12  Eli Zaretskii  <eliz@gnu.org>
+
+	* MACHINES: Add an explicit list of platforms that are no longer
+	supported.
+	* NEWS: Refer to this list.
+
 2008-01-08  Glenn Morris  <rgm@gnu.org>
 
 	* calccard.tex, cs-dired-ref.tex, cs-refcard.tex, cs-survival.tex:
@@ -24,7 +42,7 @@
 
 	* images/icons/emacs_16.png, images/icons/emacs_24.png
 	* images/icons/emacs_32.png, images/icons/emacs_48.png: Rename to
-	hicolor/16x16/apps/emacs.png hicolor/24x24/apps/emacs.png
+	hicolor/16x16/apps/emacs.png, hicolor/24x24/apps/emacs.png,
 	hicolor/32x32/apps/emacs.png and hicolor/48x48/apps/emacs.png.
 
 	* images/icons/README (Author): Update for renaming.
--- a/etc/DEVEL.HUMOR	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/DEVEL.HUMOR	Wed Jan 30 07:57:28 2008 +0000
@@ -184,3 +184,13 @@
   "[...] So please do not delete anything."
   "Done."
                                               -- RMS and David Kastrup
+
+----------------------------------------------------------------------
+
+  "I guess that can work in some circumstances, but it bypasses the
+printer drivers.  Couldn't that lead to problems for the printer
+drivers?"
+  "Current research is that software does not suffer feelings of
+depression or loneliness when it is left out of the picture, so I
+wouldn't worry about it too much."
+                                -- Lennart Borgman and Jason Rumney
--- a/etc/ERC-NEWS	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/ERC-NEWS	Wed Jan 30 07:57:28 2008 +0000
@@ -15,14 +15,237 @@
 `erc-join-channel' now accepts a prefix-argument to prompt for the key
 when channels are protected by keywords.
 
+** ERC will now automatically determine which nick prefixes are valid
+when joining a server.
+
+** Figure out which directory contains startup files when looking for
+.erc.el.  For Emacs this is usually ~/.emacs.d, and for XEmacs this is
+usually ~/.xemacs.
+
+** Fix bug with view-mode when running erc-toggle-debug-irc-protocol.
+
+** Permit several commands to be run even when the server connection is dead.
+This includes /CLEAR, /COUNTRY, /HELP, /LASTLOG, /QUIT, /GQUIT,
+/RECONNECT, /SERVER, and /SET.
+
+** Make /RECONNECT work better when the server connection is dead.
+Also, handle case where the server buffer has been killed.
+
+** Better handle interaction with /RECONNECT and indefinite reconnect
+attempts.  Display message which tells the user that they can stop the
+reconnect attempts by killing the server buffer.
+
+** New option `erc-reuse-frames' determines whether new frames are always
+created.  It defaults to not creating a new frame for an ERC buffer if
+there is already a window displaying it.  This only has an effect when
+the `erc-join-buffer' option is set to 'frame.
+
+** New command /ME'S handles the case where someone types "/me's" in an
+ERC buffer.  It concatenates the text " 's" to the beginning of the
+input and then sends the result like a normal /ME command.
+
+** Fix bug where some messages were being sent to the server too soon.
+In the past, this may have resulted in strange problems like seeing
+the connection attempt stall, which may have especially affected
+spotty or traffic-shaped connections.
+
+** Handle 307 (nick has identified) responses from the server.
+
+** Display a less-confusing message if the connection attempt fails.
+
+** On a tty, make sure that notices are displayed in blue rather than pink.
+
+** By default, open query buffers that are initiated by others in a new
+unselected window.  This may be changed by customizing the
+`erc-auto-query' option.  This should make ERC more friendly to new
+users.
+
+** New option `erc-query-display' indicates how to display a query buffer
+that is made using the /QUERY command.  The default is to display the
+query in a new selected window.
+
+** By default, display network name rather than server name in the modeline.
+This should ERC use less space in the modeline.  To get the old
+behavior back, set `erc-mode-line-format' to "%s %a".
+
+** New option `erc-remove-parsed-property' determines whether to remove
+the 'erc-parsed property.  This should save some memory in channels
+with large amounts of text on screen.  It is enabled by default.
+
+** Modules newly enabled by default
+
+*** move-to-prompt: Move to the prompt when typing text.
+*** networks: Provide data about IRC networks.
+
+** New formatting variables allowed in `erc-format-network':
+
+*** `%N': the name of the network.
+*** `%S': much like %s, but let the network name trump the server name.
+
+** Compatibility with old releases
+
+*** In `erc-server-coding-system' and `erc-coding-system-for-target', pass
+the `target' argument as the first and only argument to the function
+named by these options.
+
+*** In `erc-track-faces-priority-list', permit list entries to be lists of
+faces.  This can be used to differentiate between, for example,
+buttons in default text and buttons in notices.
+
+*** The `erc-assert' function has been removed in favor of using `assert'
+from cl-macs.el.
+
+*** If your application uses the 'erc-parsed text property outside of
+the insert hooks, you will need to set `erc-remove-parsed-property'
+to nil.
+
 ** Changes and additions to modules
 
+*** BBDB (erc-bbdb.el)
+
+**** Work around bug in XEmacs 21.4 that causes an error to be thrown when
+the first argument to `run-at-time' is nil.
+
+*** Button (erc-button.el)
+
+**** Recognize parentheses that are part of URLs.
+
+**** When in a channel, only buttonize nicks from that channel.
+
+*** DCC support (erc-dcc.el)
+
+**** Turn this into the "dcc" module for ERC, so that it can be more
+easily enabled.
+
+**** New option `erc-dcc-listen-host' determines which IP address to listen
+on for outside connection attempts.
+
+**** New option `erc-dcc-public-host' determines which IP address to advertise
+when sending a file.  This is useful for people who are on a local
+subnet.  Together, these two options replace the `erc-dcc-host'
+option.
+
+**** New option `erc-dcc-receive-cache' indicates how much of a received
+file to store in an Emacs buffer before flushing it to disk.  The
+default is 0.5 MB.
+
+**** Save only parts of received files in buffers, writing repeatedly to
+disk after we get at least `erc-dcc-receive-cache' bytes.  This allows
+users to receive very large files without running out of memory.
+
+**** Rename `erc-verbose-dcc' option to `erc-dcc-verbose' and also
+default it to nil.
+
+**** Fix edge case in erc-dcc-send-sentinel.
+
+**** If client confirms too much, then display byte count and kill the
+file buffer.
+
+*** Goodies (erc-goodies.el)
+
+**** New module move-to-prompt causes the point to be moved to the prompt
+if a user tries to type elsewhere in the buffer, and then inserts
+their keystrokes after the prompt.  It is enabled by default.
+
+**** New module keep-place keeps your place in unvisited ERC buffers
+when new messages arrive.
+
+**** Enable scroll-to-bottom in all ERC buffers when the module is enabled,
+rather than having the user do it manually.
+
+**** Fix bug with buffer ordering and scroll-to-bottom module.
+
+**** In the unmorse module, handle the morse code style that has "/ " at
+the end of every letter.
+
+*** Identd (erc-identd.el)
+
+**** Fix bad behavior when closing the identd process.
+
+*** Channel lists (erc-list.el)
+
+**** Replace the old module with a rewritten one, so that we can include
+it with Emacs.  The old version of erc-list.el has been renamed to
+erc-list-old.el, and is available as the list-old module.
+
+The new version does not yet have support for XEmacs.
+
+**** Don't display lots of output in the server buffer when running /LIST.
+
+*** Logging (erc-log.el)
+
+**** Permit the `erc-log-channels-directory' option to be set to a function
+name.  This makes it easier to write custom functions that determine
+where log files should be placed.
+
+**** New option `erc-log-filter-function' specifies the function to call
+for filtering text before writing it to a log file.  By default, no
+filtering is performed.
+
+*** Networks (erc-networks.el)
+
+**** Turn this into the "networks" module for ERC, so that it can be more
+easily enabled.  Enable it by default.
+
+**** Add support for Rizon.
+
+*** Internet services / Nickserv (erc-services.el)
+
+**** New hook option `erc-nickserv-identified-hook' is run after NickServ
+acknowledges a successful identification.
+
+**** Add support for the GRnet and Rizon networks.
+
+*** Timestamps (erc-stamp.el)
+
+**** By default, place timestamps on both the left and the right.
+The left timestamps appear once a day, and the right timestamps appear
+once a minute when new messages arrive.  To change this, customize the
+`erc-insert-timestamp-function' and
+`erc-insert-away-timestamp-function' options.
+
 *** Channel tracking (erc-track.el)
 
-If erc-track-position-in-mode-line is set to nil, the tracking
-information won't be shown in the mode line, which is a change
-from the previous behavior of showing it "After all other
-information".
+**** If `erc-track-position-in-mode-line' is set to nil, the tracking
+information won't be shown in the mode line, which is a change from
+the previous behavior of showing it "After all other information".
+
+If this variable is set to t, then the information will be added to
+the very end of the mode line.
+
+**** New option `erc-track-remove-disconnected-buffers' controls whether
+buffers associated with a server that is disconnected should be
+removed from the modified buffers list.  The default is to keep them
+in the list.
+
+**** New hook option `erc-track-list-changed-hook' is run whenever the
+contents of the modified channels list changes.  It is useful for
+people who use a separate mechanism to provide notification of channel
+activity.
+
+**** The `erc-track-switch-direction' option now can be set to the value
+'importance.  If set to this value, ERC will switch to channels in
+order of importance, which is determined by the position of the
+channel's face in `erc-track-faces-priority-list'.
+
+**** Activate erc-track-minor-mode earlier in the connection process.
+
+**** Don't track buttons in notices.
+
+**** Get a rough idea for which channels are currently active by
+switching between several normal conversation faces in the modeline.
+This behavior can be modified by changing the new
+`erc-track-faces-normal-list' option.
+
+**** Ignore display of who set the default channel topic and listing of
+users on the current channel.  Customize the `erc-track-exclude-types'
+option to indicate the types of messages to exclude.  These two
+message types are "333" and "353", respectively.
+
+*** Support for acting as an XDCC file-server (erc-xdcc.el)
+
+**** Turn this into the "xdcc" module for ERC, so that it can be more
+easily enabled.
 
 * Changes in ERC 5.2
 
--- a/etc/GNUS-NEWS	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/GNUS-NEWS	Wed Jan 30 07:57:28 2008 +0000
@@ -58,7 +58,7 @@
 
 ** International host names (IDNA) can now be decoded inside article bodies
 using `W i' (`gnus-summary-idna-message').  This requires that GNU Libidn
-(<http://www.gnu.org/software/libidn/>) has been installed.
+(`http://www.gnu.org/software/libidn/') has been installed.
 
 ** The non-ASCII group names handling has been much improved.  The back
 ends that fully support non-ASCII group names are now `nntp', `nnml',
@@ -106,13 +106,24 @@
 
 ** You can replace MIME parts with external bodies.  See
 `gnus-mime-replace-part' and `gnus-article-replace-part'.  *Note MIME
-Commands::, *Note Using MIME::.
+Commands::, *note Using MIME::.
 
 ** The option `mm-fill-flowed' can be used to disable treatment of
 format=flowed messages.  Also, flowed text is disabled when sending
 inline PGP signed messages.  *Note Flowed text: (emacs-mime)Flowed text.
 (New in Gnus 5.10.7)
 
+** Now the new command `S W' (`gnus-article-wide-reply-with-original') for
+a wide reply in the article buffer yanks a text that is in the active
+region, if it is set, as well as the `R'
+(`gnus-article-reply-with-original') command.  Note that the `R' command
+in the article buffer no longer accepts a prefix argument, which was
+used to make it do a wide reply.  *Note Article Keymap::.
+
+** The new command `C-h b' (`gnus-article-describe-bindings') used in the
+article buffer now shows not only the article commands but also the real
+summary commands that are accessible from the article buffer.
+
 
 
 * Changes in Message mode
--- a/etc/MACHINES	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/MACHINES	Wed Jan 30 07:57:28 2008 +0000
@@ -24,6 +24,9 @@
 configuration name(s) should select your new machine description and
 system description files.
 
+Some obsolete platforms are unsupported beginning with Emacs 23.1, see
+the full list at the end of this file.
+
 
 Here are the configurations Emacs is intended to work with, with the
 corresponding configuration names.  You can postpend version numbers
@@ -937,6 +940,81 @@
 
   (using the location of the 32-bit X libraries on your system).
 
+Support for the following obsolete platforms was removed in Emacs 23.1
+(the names in parentheses state the files in src/ that were removed):
+
+  Apollo SR10.x (unexapollo.c)
+  Convex (unexconvex.c and m/convex.c)
+  Xenix (unexenix.c and s/xenix.h)
+  Iris  (unexmips.c m/iris4d.h m/irist.h s/iris3-5.h s/iris3-6.h)
+  Gould (m/gould*)
+  Siemens machines running Sinix (unexsni.c)
+  Harris CXUX (s/cxux*)
+  ESIX, a variant of v.5.3 for the 386 (s/esix*)
+  Interactive (ISC) Unix (s/isc*)
+  Sony News (s/newsos*)
+  RTU 3.0, ucb universe (s/rtu.h)
+  UniSoft's UniPlus 5.2 (s/uniplus.h)
+  UMAX (s/umax.h)
+  AT&T UNIX PC model 7300 (m/7300.h)
+  Acorn
+  Alliant (m/alliant*)
+  Amdahl (m/amdahl*)
+  Altos 3068 Unix System V Release 2 (m/altos.h)
+  Apollo (m/apollo.h)
+  AT&T 3b (m/att3b.h)
+  Aviion (m/aviion*)
+  Celerity (m/celerity.h)
+  clipper (m/clipper.h)
+  convergent S series (m/cnvrgnt.h)
+  cydra (m/cydra5.h)
+  Motorola System V/88 machines (m/delta88k.h)
+  Bull DPX/2 range (m/dpx2.h)
+  Dual machines using unisoft port (m/dual.h)
+  Elxsi machine (running enix) (m/elxsi.h)
+  Fujitsu F301 machine (m/f301.h)
+  i860 (m/i860.h)
+  ibm ps/2 aix386 (m/ibmps2-aix.h)
+  ISI 68000's (m/is*)
+  Masscomp 5000 series running RTU, ucb universe (m/masscomp.h)
+  Megatest 68000's (m/mega68.h)
+  Whitechapel Computer Works MG1 (ns16000 based) (m/mg1.h)
+  Harris Night Hawk Series 1200 and Series 3000 (m/nh3000.h m/nh4000.h)
+  ns16000 (m/ns16000.h)
+  National Semiconductor 32000, running Genix (m/ns32000.h)
+  TI Nu machines using system V (m/nu.h)
+  HLH Orion (m/orion.h m/orion105.h)
+  Paragon i860 (m/paragon.h)
+  PFU A-series (m/pfa50.h)
+  Plexus running System V.2 (m/plexus.h)
+  pyramid. (m/pyramid.h)
+  sh3el (m/sh3el.h)
+  Bull SPS-7 (m/sps7.h)
+  Hitachi SR2001/SR2201 (m/sr2k.h)
+  Stride (m/stride.h)
+  Sun 1 (m/sun1.h)
+  Sun 2 (m/sun2.h)
+  SEQUENT SYMMETRY  (m/symmetry.h)
+  Tadpole 68k machines (m/tad68k.h)
+  tahoe (m/tahoe.h)
+  targon31 (m/targon31.h)
+  Tektronix* (m/tek4300.h m/tekxd88.h)
+  NCR Tower 32 running System V.2 (m/tower32.h)
+  NCR Tower 32 running System V.3 (m/tower32v3.h)
+  U-station (Nihon Unisys, SS5E; Sumitomo Denkoh, U-Station E30) (m/ustation.h)
+  Wicat (m/wicat.h)
+  Honeywell XPS100 running UNIX System V.2 (m/xps100.h)
+  Data General's DG/UX  (s/dgux*)
+  Irix before version 6
+  osf1 (s/osf*)
+  SunOS4 (s/sunos*)
+  RISCiX (s/riscix*)
+  SCO 3.2v4 (s/sco4.h)
+  SCO 3.2v5 (s/sco5.h)
+  Sun's 386-based RoadRunner (m/sun386.h)
+  Sun3 machines (m/sun3*)
+  Integrated Solutions 386 machine (m/is386.h)
+
 
 Local variables:
 mode: text
--- a/etc/NEWS	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/NEWS	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2007 Free Software Foundation, Inc.
+Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to emacs-pretest-bug@gnu.org.
@@ -38,6 +38,9 @@
 
 ** Support for Sun windows has been removed.
 
+** Support for many obsolete platforms has been removed.
+See the list at the end of etc/MACHINES for details.
+
 ** The `emacstool' utility has been removed.
 
 ** The new configuration option "--with-dbus" enables D-Bus language
@@ -220,6 +223,9 @@
 
 * Changes in Specialized Modes and Packages in Emacs 23.1
 
+** ChangeLog now has function bound to C-c C-f that finds the file in
+the current log entry.
+
 ** abbrev was rewritten in Elisp and extended with more flexibility.
 *** New functions: abbrev-get, abbrev-put, abbrev-table-get, abbrev-table-put,
     abbrev-table-p.
@@ -277,6 +283,9 @@
 ** eldoc highlights the function argument under point
 with the face `eldoc-highlight-function-argument'.
 
+** hide-ifdef-mode permits to shadow ifdef-blocks instead of hiding them.
+See option `hide-ifdef-shadow' and function `hide-ifdef-toggle-shadowing'.
+
 +++
 ** defcustom accepts new keyword arguments, `:safe' and `:risky', which
 set a variable's `safe-local-variable' and `risky-local-variable' property.
@@ -313,13 +322,15 @@
 
 ** BibTeX mode:
 
+*** New command `bibtex-initialize' (re)initializes BibTeX buffers. 
+
 *** New `bibtex-entry-format' options `whitespace', `braces', and
 `string', disabled by default.
 
 *** New variable `bibtex-cite-matcher-alist' contains rules to
 identify cited keys in BibTeX entries, used by `bibtex-find-crossref'.
 
-*** Command `bibtex-url' now allows multiple URLs per entry.
+*** Command `bibtex-url' allows multiple URLs per entry.
 
 +++
 ** Tramp
@@ -419,11 +430,6 @@
 `byte-compile-warning-enabled-p', `byte-compile-disable-warning', and
 `byte-compile-enable-warning.'
 
-** shell.el no longer defines the aliases `dirtrack-toggle' and
-`dirtrack-mode' for `shell-dirtrack-mode'.  These names were removed
-because they clash with commands provided by dirtrack.el.  Use
-`shell-dirtrack-mode' instead.
-
 
 * Lisp Changes in Emacs 23.1
 
@@ -437,6 +443,11 @@
 ** New function `match-substitute-replacement' returns the result of
 `replace-match' without actually using it in the buffer.
 
+** If a local hook function has a non-nil `permanent-local-hook'
+property, then `kill-all-local-variables' does not remove it from
+the local value of the hook variable.  This means it remains
+even if you change major modes.
+
 +++
 ** A list of default values can be specified for the DEFAULT argument of
 functions `read-from-minibuffer', `read-string', `read-command',
--- a/etc/NEWS.22	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/NEWS.22	Wed Jan 30 07:57:28 2008 +0000
@@ -112,6 +112,13 @@
 
 *** VC has some support for Git.
 
+* Incompatible Lisp Changes in Emacs 22.2
+
+** shell.el no longer defines the aliases `dirtrack-toggle' and
+`dirtrack-mode' for `shell-dirtrack-mode'.  These names were removed
+because they clash with commands provided by dirtrack.el.  Use
+`shell-dirtrack-mode' instead.
+
 * Lisp Changes in Emacs 22.2.
 
 ** Frame-local variables are deprecated and are slated for removal.
--- a/etc/TODO	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/TODO	Wed Jan 30 07:57:28 2008 +0000
@@ -12,6 +12,20 @@
 prepared to sign legal papers to transfer the copyright on your work
 to the FSF.
 
+* Simple tasks. These don't require much emacs knowledge, they are
+suitable for anyone from beginners to experts.
+
+** Major modes should have a menu entry.  Examples of modes that do
+not have one at the moment and probably should: text-mode,
+change-log-mode, conf-*-mode.
+
+** Change the text for the mode-line tooltips to not use things like C-x 0.
+In general make sure that tooltips have obvious meanings.  Check if
+all items on the mode-line have a suitable tooltip.
+
+** Check what minor modes don't use define-minor-mode and convert them
+to use it.
+
 * Small but important fixes needed in existing features:
 
 ** Make "emacs --daemon" start emacs without showing any frame. 
@@ -180,6 +194,10 @@
 
 * Other features we would like:
 
+** Make longlines-mode wrap lines based on screen position instead
+   of character position, so that variable-width fonts can be handled
+   properly.
+
 ** Allow frames(terminals) created by emacsclient to inherit their environment
 from the emacsclient process.
 ** Remove the default toggling behavior of minor modes when called from elisp
--- a/etc/emacs3.py	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/emacs3.py	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 
 """Definitions used by commands sent to inferior Python in python.el."""
 
-# Copyright (C) 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # Author: Dave Love <fx@gnu.org>
 
 # This file is part of GNU Emacs.
--- a/etc/images/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/README	Wed Jan 30 07:57:28 2008 +0000
@@ -34,63 +34,60 @@
   License: GNU General Public License version 3 or later (see COPYING)
 
 
-* The following icons are from GTK+ 2.x and GNOME 2.x.  They are not
-part of Emacs, but distributed and used by Emacs.
+* The following icons are from GTK+ 2.x. They are not part of Emacs, but
+are distributed and used by Emacs.  They are licensed under the
+GNU Library General Public License version 2 or later.  See the source
+of the gtk+ package for more information.
 
-  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
-  Tuomas Kuosmanen, Rodney Dawes, Jakub Steiner, Alexander Larsson,
-  Tor Lillqvist, Garrett LeSage, Dennis Cranston, Jody Goldberg, Luca
-  Ferretti, Mark Finlay, Lapo Calamandrei, Andreas Nilsson and Marco
-  Pesenti Gritti
-  License: GNU General Public License version 2
-
-* From GTK+ 2.x:
+  close.xpm copy.xpm cut.xpm help.xpm home.xpm index.xpm info.pbm
+  info.xpm jump-to.xpm left-arrow.xpm new.xpm open.xpm paste.xpm
+  preferences.xpm print.xpm refresh.xpm right-arrow.xpm save.xpm
+  saveas.xpm search.xpm sort-ascending.xpm sort-descending.xpm
+  spell.xpm undo.xpm up-arrow.xpm
 
-    close.xpm copy.xpm cut.xpm help.xpm home.xpm index.xpm info.pbm
-    info.xpm jump-to.xpm left-arrow.xpm new.xpm open.xpm paste.xpm
-    preferences.xpm print.xpm refresh.xpm right-arrow.xpm save.xpm
-    saveas.xpm search.xpm sort-ascending.xpm sort-descending.xpm
-    spell.xpm undo.xpm up-arrow.xpm
+  back-arrow.xpm and fwd-arrow.xpm are slightly modified undo and redo.
+  diropen.xpm is file-manager.png from Gnome hicolor theme.
+
 
-    back-arrow.xpm and fwd-arrow.xpm are slightly modified undo and redo.
-    diropen.xpm is file-manager.png from Gnome hicolor theme.
+* The following icons are from GNOME 2.x. They are not part of Emacs,
+but are distributed and used by Emacs.  They are licensed under the
+GNU General Public License version 2 or later.  See the source of
+the gnome-icons-theme package for more information.
 
-* From GNOME 2.x:
-
-  Emacs images and their source in the GNOME icons stock/ directory:
+Emacs images and their source in the GNOME icons stock/ directory:
 
-    attach.xpm                document/stock_attach
-    cancel.xpm                slightly modified generic/stock_stop
-    connect.xpm               net/stock_connect
-    contact.xpm               net/stock_contact
-    data-save.xpm             data/stock_data-save
-    delete.xpm                generic/stock_delete
-    describe.xpm              generic/stock_properties
-    disconnect.xpm            net/stock_disconnect
-    exit.xpm                  generic/stock_exit
-    lock-broken.xpm           data/stock_lock-broken
-    lock-ok.xpm               data/stock_lock-ok
-    lock.xpm                  data/stock_lock
-    redo.xpm                  generic/stock_redo
-    search-replace.xpm        slightly modified generic/stock_search-and-replace
-    next-page.xpm             navigation/stock_next-page
-    refresh.xpm               generic/stock_refresh
-    separator.xpm             ?
-    show.xpm                  slightly modified document/stock_new
-    sort-ascending.xpm        slightly modified data/stock_sort-ascending
-    sort-column-ascending.xpm data/stock_sort-column-ascending
-    sort-criteria.xpm         data/stock_sort-criteria
-    sort-descending.xpm       slightly modified data/stock_sort-descending
-    sort-row-ascending.xpm    data/stock_sort-row-ascending
-    zoom-in.xpm               navigation/stock_zoom-in
-    zoom-out.xpm              navigation/stock_zoom-out
+  attach.xpm                document/stock_attach
+  cancel.xpm                slightly modified generic/stock_stop
+  connect.xpm               net/stock_connect
+  contact.xpm               net/stock_contact
+  data-save.xpm             data/stock_data-save
+  delete.xpm                generic/stock_delete
+  describe.xpm              generic/stock_properties
+  disconnect.xpm            net/stock_disconnect
+  exit.xpm                  generic/stock_exit
+  lock-broken.xpm           data/stock_lock-broken
+  lock-ok.xpm               data/stock_lock-ok
+  lock.xpm                  data/stock_lock
+  redo.xpm                  generic/stock_redo
+  search-replace.xpm        slightly modified generic/stock_search-and-replace
+  next-page.xpm             navigation/stock_next-page
+  refresh.xpm               generic/stock_refresh
+  separator.xpm             ?
+  show.xpm                  slightly modified document/stock_new
+  sort-ascending.xpm        slightly modified data/stock_sort-ascending
+  sort-column-ascending.xpm data/stock_sort-column-ascending
+  sort-criteria.xpm         data/stock_sort-criteria
+  sort-descending.xpm       slightly modified data/stock_sort-descending
+  sort-row-ascending.xpm    data/stock_sort-row-ascending
+  zoom-in.xpm               navigation/stock_zoom-in
+  zoom-out.xpm              navigation/stock_zoom-out
 
-    next-node.xpm and prev-node.xpm are from gthumb version 2.0 (part of
-    GNOME 2.x) where they are called next-image-24.png and prev-image-24.png.
-    up-node.xpm is just next-node.xpm rotated 90 degrees.
+  next-node.xpm and prev-node.xpm are from gthumb version 2.0 (part of
+  GNOME 2.x) where they are called next-image-24.png and prev-image-24.png.
+  up-node.xpm is just next-node.xpm rotated 90 degrees.
 
-    Some icons in the mail/ and gnus/ subdirectories are also taken
-    from this source (see their separate README files).
+  Some icons in the mail/ and gnus/ subdirectories are also taken
+  from this source (see their separate README files).
 
 The images in the low-color/ subdirectory are low-color versions of
 the files of the same name in this directory, and are subject to the
--- a/etc/images/gnus/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/gnus/README	Wed Jan 30 07:57:28 2008 +0000
@@ -23,16 +23,11 @@
 License: GNU General Public License version 3 or later (see COPYING)
 
 The following icons are from GNOME 2.x. They are not part of Emacs,
-but distributed and used by Emacs.
+but are distributed and used by Emacs.  They are licensed under the
+GNU General Public License version 2 or later.  See the source of the
+gnome-icons-theme package for more information.
 
-  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
-  Tuomas Kuosmanen, Rodney Dawes, Jakub Steiner, Alexander Larsson,
-  Tor Lillqvist, Garrett LeSage, Dennis Cranston, Jody Goldberg, Luca
-  Ferretti, Mark Finlay, Lapo Calamandrei, Andreas Nilsson and Marco
-  Pesenti Gritti
-  License: GNU General Public License version 2
-
-toggle-subscription.xpm       (GNOME stock/document/stock_task-recurring)
-kill-group.pbm and kill-group.xpm are converted from close.xpm
-rot13.pbm and rot13.xpm are converted from lock.xpm
-mail-send.xpm  ?
+  toggle-subscription.xpm       (GNOME stock/document/stock_task-recurring)
+  kill-group.pbm and kill-group.xpm are converted from close.xpm
+  rot13.pbm and rot13.xpm are converted from lock.xpm
+  mail-send.xpm  ?
--- a/etc/images/icons/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/icons/README	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,7 @@
 COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
-Files: hicolor/16x16/apps/emacs.png hicolor/24x24/apps/emacs.png hicolor/32x32/apps/emacs.png hicolor/48x48/apps/emacs.png
+Files: hicolor/16x16/apps/emacs.png hicolor/24x24/apps/emacs.png
+       hicolor/32x32/apps/emacs.png hicolor/48x48/apps/emacs.png
 Author: Andrew Zhilin <andrew_zhilin@yahoo.com>
 Copyright (C) 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
@@ -8,5 +9,5 @@
 Files: emacs16_mac.png emacs24_mac.png emacs32_mac.png emacs48_mac.png
        emacs256_mac.png emacs512_mac.png
 Author: Kentaro Ohkouchi <nanasess@fsm.ne.jp>
-Copyright (C) 2007  Free Software Foundation, Inc.
+Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
--- a/etc/images/mail/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/mail/README	Wed Jan 30 07:57:28 2008 +0000
@@ -1,14 +1,9 @@
 COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 The following icons are from GNOME 2.x. They are not part of Emacs,
-but distributed and used by Emacs.
-
-  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
-  Tuomas Kuosmanen, Rodney Dawes, Jakub Steiner, Alexander Larsson,
-  Tor Lillqvist, Garrett LeSage, Dennis Cranston, Jody Goldberg, Luca
-  Ferretti, Mark Finlay, Lapo Calamandrei, Andreas Nilsson and Marco
-  Pesenti Gritti
-  License: GNU General Public License version 2
+but are distributed and used by Emacs.  They are licensed under the
+GNU General Public License version 2 or later.  See the source of the
+gnome-icons-theme package for more information.
 
 Emacs images and their GNOME source (GNOME icons are from stock/net/
 directory unless otherwise stated):
--- a/etc/images/smilies/grayscale/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/smilies/grayscale/README	Wed Jan 30 07:57:28 2008 +0000
@@ -2,5 +2,5 @@
        frown.xpm grin.xpm indifferent.xpm reverse-smile.xpm sad.xpm
        smile.xpm wry.xpm 
 Author: Adam Sjøgren
-Copyright (C) 2007 Free Software Foundation, Inc.
+Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
--- a/etc/images/smilies/medium/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/images/smilies/medium/README	Wed Jan 30 07:57:28 2008 +0000
@@ -2,5 +2,5 @@
        frown.xpm grin.xpm indifferent.xpm reverse-smile.xpm sad.xpm
        smile.xpm wry.xpm 
 Author: Adam Sjøgren
-Copyright (C) 2007 Free Software Foundation, Inc.
+Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
--- a/etc/refcards/README	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/refcards/README	Wed Jan 30 07:57:28 2008 +0000
@@ -12,6 +12,6 @@
 
 File: gnus-logo.eps, gnus-logo.pdf
   Author: Luis Fernandes <elf@ee.ryerson.ca>
-  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
     Free Software Foundation, Inc.
   License: GNU General Public License version 3 or later (see COPYING)
--- a/etc/refcards/orgcard.tex	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/refcards/orgcard.tex	Wed Jan 30 07:57:28 2008 +0000
@@ -1,8 +1,8 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{5.03}
-\def\versionyear{2007}          % latest update
+\def\orgversionnumber{5.19}
+\def\versionyear{2008}          % latest update
 \def\year{2008}                 % latest copyright year
-%
+
 %**start of header
 \newcount\columnsperpage
 \newcount\letterpaper
@@ -12,17 +12,11 @@
 
 \columnsperpage=3
 
-% Set letterpaper to 0 for A4 paper, 1 for letter (US) paper.  Useful
+% Set letterpapaer to 0 for A4 paper, 1 for letter (US) paper.  Useful
 % only when columnsperpage is 2 or 3.
 
 \letterpaper=0
 
-% PDF output layout.  0 for A4, 1 for letter (US), a `l' is added for
-% a landscape layout.
-
-\input pdflayout.sty
-\pdflayout=(0l)
-
 % Nothing else needs to be changed below this line.
 % Copyright (C) 1987, 1993, 1996, 1997, 2001, 2002, 2003, 2004,
 %   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
@@ -31,7 +25,7 @@
 
 % GNU Emacs is free software; you can redistribute it and/or modify
 % it under the terms of the GNU General Public License as published by
-% the Free Software Foundation; either version 3, or (at your option)
+% the Free Software Foundation; either version 2, or (at your option)
 % any later version.
 
 % GNU Emacs is distributed in the hope that it will be useful,
@@ -314,6 +308,7 @@
 \section{Structure Editing}
 
 \key{insert new heading/item at current level}{M-RET}
+\key{insert new heading after subtree}{C-RET}
 \key{insert new TODO entry/checkbox item}{M-S-RET}
 
 \key{promote current heading up one level}{M-LEFT}
@@ -322,6 +317,7 @@
 \key{demote current subtree down one level}{M-S-RIGHT}
 
 \key{move subtree/list item up/down}{M-S-UP/DOWN}
+\key{refile subtree}{C-c C-w}
 \key{kill subtree}{C-c C-x C-w}
 \key{copy subtree}{C-c C-x M-w}
 \key{yank subtree}{C-c C-x C-y}
@@ -342,10 +338,10 @@
 
 \section{Filtering and Sparse Trees}
 
-\key{show sparse tree for all matches of a regexp}{C-c /}
+% FIXME: this is garbage
+\key{construct a sparse tree by various criteria}{C-c /}
 \key{view TODO's in sparse tree}{C-c C-v}
 \key{global TODO list in agenda mode}{C-c t$^1$}
-\key{create sparse tree with all deadlines due}{C-c C-w}
 \key{time sorted view of current org file}{C-c a L}
 %\key{agenda for the week}{C-c a$^1$}
 %\key{agenda for date at cursor}{C-c C-o}
@@ -552,9 +548,11 @@
 
 \section{Properties and Column View}
 
+\key{set property}{C-c C-x p}
 \key{special commands in property lines}{C-c C-c}
 \key{next/previous allowed value}{S-left/right}
 \key{turn on column view}{C-c C-x C-c}
+\key{capture columns view in dynamic block}{C-c C-x r}
 
 \key{quit column view}{q}
 \key{next/previous allowed value}{S-left/right}
@@ -575,7 +573,7 @@
 \key{Like \kbd{C-c .} but make stamp inactive}{C-c !} % FIXME
 \key{insert DEADLINE timestamp}{C-c C-d}
 \key{insert SCHEDULED timestamp}{C-c C-s}
-\key{create sparse tree with all deadlines due}{C-c C-w}
+\key{create sparse tree with all deadlines due}{C-c / d}
 \key{the time between 2 dates in a time range}{C-c C-y}
 \key{change timestamp at cursor by $\pm 1$ day}{S-RIGHT/LEFT$^3$}
 \key{change year/month/day at cursor by $\pm 1$}{S-UP/DOWN$^3$}
@@ -606,6 +604,7 @@
 \key{add/move current file to front of agenda}{C-c [}
 \key{remove current file from your agenda}{C-c ]}
 \key{cycle through agenda file list}{C-'}
+\key{set/remove restriction lock}{C-c C-x </>}
 
 \key{compile agenda for the current week}{C-c a a$^1$}
 \key{compile global TODO list}{C-c a t$^1$}
@@ -618,13 +617,6 @@
 \key{configure stuck projects}{C-c a !$^1$}
 \key{agenda for date at cursor}{C-c C-o}
 
-\vskip 1mm
-To set categories, add lines like$^2$:
-\vskip -1mm
-\beginexample%
-\#+CATEGORY: MyCateg
-\endexample
-
 {\bf Commands available in an agenda buffer}
 
 {\bf View Org file}
@@ -658,7 +650,7 @@
 \key{kill item and source}{C-k}
 \key{archive the subtree}{\$}
 \key{show tags of current headline}{T}
-\key{set tags for current headline}{:}
+\key{set tags for current headline/region}{:}
 \key{toggle ARCHIVE tag}{a}
 \key{set priority of current item}{p}
 \key{raise/lower priority of current item}{S-UP/DOWN$^3$}
@@ -669,9 +661,8 @@
 \key{insert new entry into diary}{i}
 
 \newcolumn
-\key{start the clock on current item (clock-in)}{I}
-\key{stop the clock (clock-out)}{O}
-\key{cancel current clock}{X}
+\key{start/stop/cancel the clock on current item}{I / O / X}
+\key{jump to running clock entry}{J}
 
 {\bf Misc}
 
--- a/etc/refcards/pdflayout.sty	Wed Jan 30 06:40:42 2008 +0000
+++ b/etc/refcards/pdflayout.sty	Wed Jan 30 07:57:28 2008 +0000
@@ -1,4 +1,4 @@
-% Copyright (C) 2007  Free Software Foundation, Inc.
+% Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 % This file is part of GNU Emacs.
 
--- a/leim/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/leim/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,8 @@
+2008-01-14  Aidan Kehoe  <kehoea@parhasard.net>  (tiny change)
+
+        * quail/latin-ltx.el ("TeX"): Correct the mappings for \v{k} and
+	\vk.
+
 2008-01-06  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* makefile.w32-in:
--- a/leim/quail/latin-ltx.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/leim/quail/latin-ltx.el	Wed Jan 30 07:57:28 2008 +0000
@@ -263,7 +263,7 @@
  ("\\v{G}" ?Ǧ) ("\\vG" ?Ǧ)
  ("\\v{g}" ?ǧ) ("\\vg" ?ǧ)
  ("\\v{K}" ?Ǩ) ("\\vK" ?Ǩ)
- ("\\v{k}" ?k) ("\\vk" ?k)
+ ("\\v{k}" ?Ç©) ("\\vk" ?Ç©)
 
  ("\\v{\\j}" ?Ç°) ("\\vj" ?Ç°)
  ("\\'{G}" ?Ç´) ("\\'G" ?Ç´)
--- a/lib-src/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lib-src/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,48 @@
+2008-01-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacsclient.c (decode_options): Default to a NULL display, as Emacs-22.
+	Allow the -d option under w32 again, for those rare cases where it
+	actually does make sense.
+
+2008-01-25  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emacsclient.c (set_tcp_socket): Don't send "\n" after
+	the authentication string; there's no need to haste.
+
+2008-01-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* pop.c (pop_stat, pop_last): Fix last fix.
+
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* movemail.c: Remove references to XENIX.
+
+2008-01-13  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* movemail.c:
+	* make-docfile.c: Remove reference to symbols defined by systems
+	not supported anymore: MAC_OS8, XENIX and STRIDE.
+
+2008-01-12  Eli Zaretskii  <eliz@gnu.org>
+
+	* emacsclient.c (decode_options) [WINDOWSNT]: Don't use the value
+	of DISPLAY in the environment.  Don't support -d.
+	(print_help_and_exit) [WINDOWSNT]: Don't show the --display option.
+	(longopts) [WINDOWSNT]: Remove --display.
+
+2008-01-10  Chong Yidong  <cyd@stupidchicken.com>
+
+	* pop.c (pop_stat, pop_last): Check validity of string-to-integer
+	conversion.  Mistakes spotted by Nico Golde.
+
+2008-01-09  Glenn Morris  <rgm@gnu.org>
+
+	* emacsclient.c: Add missing final newlines to message calls.
+
+2008-01-09  Daniel Hackney  <dan@haxney.org>  (tiny change)
+
+	* emacsclient.c (set_socket): Add final newline to socket error message.
+
 2008-01-04  Glenn Morris  <rgm@gnu.org>
 
 	* ebrowse.c (version) <emacs_copyright>: New variable.
--- a/lib-src/emacsclient.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/lib-src/emacsclient.c	Wed Jan 30 07:57:28 2008 +0000
@@ -170,7 +170,9 @@
   { "socket-name",	required_argument, NULL, 's' },
 #endif
   { "server-file",	required_argument, NULL, 'f' },
+#ifndef WINDOWSNT
   { "display",	required_argument, NULL, 'd' },
+#endif
   { 0, 0, 0, 0 }
 };
 
@@ -227,7 +229,7 @@
 
 
 /* Return the current working directory.  Returns NULL on errors.
-   Any other returned value must be freed with free. This is used
+   Any other returned value must be freed with free.  This is used
    only when get_current_dir_name is not defined on the system.  */
 char*
 get_current_dir_name ()
@@ -477,9 +479,15 @@
      char **argv;
 {
   alternate_editor = egetenv ("ALTERNATE_EDITOR");
+
+  /* We used to set `display' to $DISPLAY by default, but this changed the
+     default behavior and is sometimes inconvenient.  So instead of forcing
+     users to say "--display ''" when they want to use Emacs's existing tty
+     or display connection, we force them to use "--display $DISPLAY" if
+     they want Emacs to connect to their current display.  */
+#if 0
   display = egetenv ("DISPLAY");
-  if (display && strlen (display) == 0)
-    display = NULL;
+#endif
 
   while (1)
     {
@@ -515,9 +523,15 @@
 	  server_file = optarg;
 	  break;
 
+	  /* We used to disallow this argument in w32, but it seems better
+	     to allow it, for the occasional case where the user is
+	     connecting with a w32 client to a server compiled with X11
+	     support.  */
+#if 1 /* !defined WINDOWS */
 	case 'd':
 	  display = optarg;
 	  break;
+#endif
 
 	case 'n':
 	  nowait = 1;
@@ -552,6 +566,9 @@
 	}
     }
 
+  if (display && strlen (display) == 0)
+    display = NULL;
+
   if (!tty && display)
     window_system = 1;
 #if !defined (WINDOWSNT) && !defined (HAVE_CARBON)
@@ -594,8 +611,10 @@
 -c, --create-frame    	Create a new frame instead of trying to\n\
 			use the current Emacs frame\n\
 -e, --eval    		Evaluate the FILE arguments as ELisp expressions\n\
--n, --no-wait		Don't wait for the server to return\n\
--d, --display=DISPLAY	Visit the file in the given display\n"
+-n, --no-wait		Don't wait for the server to return\n"
+#ifndef WINDOWSNT
+"-d, --display=DISPLAY	Visit the file in the given display\n"
+#endif
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
 "-s, --socket-name=FILENAME\n\
 			Set filename of the UNIX socket for communication\n"
@@ -882,7 +901,7 @@
 
   if (WSAStartup (MAKEWORD (2, 0), &wsaData))
     {
-      message (TRUE, "%s: error initializing WinSock2", progname);
+      message (TRUE, "%s: error initializing WinSock2\n", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -939,7 +958,7 @@
     }
   else
     {
-      message (TRUE, "%s: invalid configuration info", progname);
+      message (TRUE, "%s: invalid configuration info\n", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -949,7 +968,7 @@
 
   if (! fread (authentication, AUTH_KEY_LENGTH, 1, config))
     {
-      message (TRUE, "%s: cannot read authentication info", progname);
+      message (TRUE, "%s: cannot read authentication info\n", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -1002,7 +1021,7 @@
 
   send_to_emacs (s, "-auth ");
   send_to_emacs (s, auth_string);
-  send_to_emacs (s, "\n");
+  send_to_emacs (s, " ");
 
   return s;
 }
@@ -1092,7 +1111,7 @@
   if (emacs_socket)
     send_to_emacs (emacs_socket, "-suspend \n");
 
-  /* Unblock this signal and call the default handler by temprarily
+  /* Unblock this signal and call the default handler by temporarily
      changing the handler and resignalling. */
   sigprocmask (SIG_BLOCK, NULL, &set);
   sigdelset (&set, signalnum);
@@ -1167,7 +1186,7 @@
       strcpy (server.sun_path, socket_name);
     else
       {
-        message (TRUE, "%s: socket-name %s too long",
+        message (TRUE, "%s: socket-name %s too long\n",
                  progname, socket_name);
         fail ();
       }
@@ -1202,7 +1221,7 @@
 		  strcpy (server.sun_path, socket_name);
 		else
 		  {
-		    message (TRUE, "%s: socket-name %s too long",
+		    message (TRUE, "%s: socket-name %s too long\n",
 			     progname, socket_name);
 		    exit (EXIT_FAILURE);
 		  }
@@ -1266,7 +1285,7 @@
       s = set_local_socket ();
       if ((s != INVALID_SOCKET) || alternate_editor)
 	return s;
-      message (TRUE, "%s: error accessing socket \"%s\"",
+      message (TRUE, "%s: error accessing socket \"%s\"\n",
 	       progname, socket_name);
       exit (EXIT_FAILURE);
     }
@@ -1282,7 +1301,7 @@
       if ((s != INVALID_SOCKET) || alternate_editor)
 	return s;
 
-      message (TRUE, "%s: error accessing server file \"%s\"",
+      message (TRUE, "%s: error accessing server file \"%s\"\n",
 	       progname, server_file);
       exit (EXIT_FAILURE);
     }
--- a/lib-src/make-docfile.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/lib-src/make-docfile.c	Wed Jan 30 07:57:28 2008 +0000
@@ -62,11 +62,7 @@
 #endif /* not DOS_NT */
 
 #ifndef DIRECTORY_SEP
-#ifdef MAC_OS8
-#define DIRECTORY_SEP ':'
-#else  /* not MAC_OS8 */
 #define DIRECTORY_SEP '/'
-#endif	/* not MAC_OS8 */
 #endif
 
 #ifndef IS_DIRECTORY_SEP
--- a/lib-src/movemail.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/lib-src/movemail.c	Wed Jan 30 07:57:28 2008 +0000
@@ -113,7 +113,7 @@
 #define R_OK 4
 #endif
 
-#if defined (XENIX) || defined (WINDOWSNT)
+#ifdef WINDOWSNT
 #include <sys/locking.h>
 #endif
 
@@ -388,13 +388,13 @@
       if (indesc < 0)
 	pfatal_with_name (inname);
 
-#if defined (BSD_SYSTEM) || defined (XENIX)
+#ifdef BSD_SYSTEM
       /* In case movemail is setuid to root, make sure the user can
 	 read the output file.  */
       /* This is desirable for all systems
 	 but I don't want to assume all have the umask system call */
       umask (umask (0) & 0333);
-#endif /* BSD_SYSTEM || XENIX */
+#endif /* BSD_SYSTEM */
       outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666);
       if (outdesc < 0)
 	pfatal_with_name (outname);
@@ -422,15 +422,11 @@
 #ifdef MAIL_USE_LOCKF
 	  status = lockf (indesc, F_LOCK, 0);
 #else /* not MAIL_USE_LOCKF */
-#ifdef XENIX
-	  status = locking (indesc, LK_RLCK, 0L);
-#else
 #ifdef WINDOWSNT
 	  status = locking (indesc, LK_RLCK, -1L);
 #else
 	  status = flock (indesc, LOCK_EX);
 #endif
-#endif
 #endif /* not MAIL_USE_LOCKF */
 #endif /* MAIL_USE_SYSTEM_LOCK */
 	}
@@ -503,13 +499,7 @@
 #ifdef MAIL_USE_SYSTEM_LOCK
       if (! preserve_mail)
 	{
-#if defined (STRIDE) || defined (XENIX)
-	  /* Stride, xenix have file locking, but no ftruncate.
-	     This mess will do. */
-	  close (open (inname, O_CREAT | O_TRUNC | O_RDWR, 0666));
-#else
 	  ftruncate (indesc, 0L);
-#endif /* STRIDE or XENIX */
 	}
 #endif /* MAIL_USE_SYSTEM_LOCK */
 
--- a/lib-src/pop.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/lib-src/pop.c	Wed Jan 30 07:57:28 2008 +0000
@@ -352,6 +352,7 @@
      int *size;
 {
   char *fromserver;
+  char *end_ptr;
 
   if (server->in_multi)
     {
@@ -377,18 +378,26 @@
       return (-1);
     }
 
-  *count = atoi (&fromserver[4]);
-
-  fromserver = index (&fromserver[4], ' ');
-  if (! fromserver)
+  errno = 0;
+  *count = strtol (&fromserver[4], &end_ptr, 10);
+  /* Check validity of string-to-integer conversion. */
+  if (fromserver + 4 == end_ptr || *end_ptr != ' ' || errno)
     {
-      strcpy (pop_error,
-	      "Badly formatted response from server in pop_stat");
+      strcpy (pop_error, "Unexpected response from POP server in pop_stat");
       pop_trash (server);
       return (-1);
     }
 
-  *size = atoi (fromserver + 1);
+  fromserver = end_ptr;
+
+  errno = 0;
+  *size = strtol (fromserver + 1, &end_ptr, 10);
+  if (fromserver + 1 == end_ptr || errno)
+    {
+      strcpy (pop_error, "Unexpected response from POP server in pop_stat");
+      pop_trash (server);
+      return (-1);
+    }
 
   return (0);
 }
@@ -913,7 +922,17 @@
     }
   else
     {
-      return (atoi (&fromserver[4]));
+      char *end_ptr;
+      int count;
+      errno = 0;
+      count = strtol (&fromserver[4], &end_ptr, 10);
+      if (fromserver + 4 == end_ptr || errno)
+	{
+	  strcpy (pop_error, "Unexpected response from server in pop_last");
+	  pop_trash (server);
+	  return (-1);
+	}
+      return count;
     }
 }
 
--- a/lisp/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,1291 @@
-2008-01-17  Mark A. Hershberger  <mah@everybody.org>
-
-	* xml.el (xml-escape-string): Don't do any encoding changes on the
-	string.
+2008-01-30  Richard Stallman  <rms@gnu.org>
+
+	* progmodes/etags.el (tags-query-replace): Delete unused optional args.
+	Doc fix.
+
+	* files.el (hack-local-variables): Don't query about fake variables.
+
+2008-01-30  Markus Triska  <markus.triska@gmx.at>
+
+	* linum.el: New file.
+
+2008-01-29  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-methods): Use "-H" option for "sudo".  Suggested
+	by Trent W. Buck <trentbuck@gmail.com>.  Make ("%h") a single
+	element in "plinkx".
+	(tramp-handle-shell-command): Reuse "*Async Shell Command*" or
+	"*Shell Command Output*" buffers.  Check, whether there is already
+	an asynchronous process running.  Display always the buffer of the
+	asynchronous process.
+	(tramp-compute-multi-hops): Adapt error message.
+
+2008-01-29  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-langs.el (c-specifier-key): Exclude "template"
+	from this regexp; part of same fix as next change to cc-engine.el.
+
+	* progmodes/cc-engine.el (c-guess-basic-syntax, CASE 5A.5): Anchor
+	the "{" of a template function correctly on "template", not the
+	following "<".
+
+	* progmodes/cc-defs.el (c-version): Increase to 5.31.5.
+
+2008-01-29  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-mode): Adapt to i-m-current-[vh]scroll
+	being an alist now.
+
+	* image-mode.el (image-mode-current-vscroll)
+	(image-mode-current-hscroll): Add doc strings.
+	(image-set-window-vscroll, image-set-window-hscroll)
+	(image-reset-current-vhscroll, image-mode): Adapt to
+	i-m-current-[vh]scroll being an alist now.
+
+2008-01-29  Martin Rudalics  <rudalics@gmx.at>
+
+	* emacs-lisp/find-func.el (find-function-search-for-symbol):
+	Strip extension from .emacs.el to make sure symbol is searched
+	in .emacs too.
+
+2008-01-29  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-mode): Use facilities below to
+	restore [vh]scroll when switching buffers.
+
+	* image-mode.el (image-mode-current-vscroll)
+	(image-mode-current-hscroll): New variables.
+	(image-set-window-hscroll, image-set-window-vscroll): New
+	functions.
+	(image-forward-hscroll, image-next-line, image-bol, image-eol)
+	(image-bob, image-eob): Use them.
+	(image-reset-current-vhscroll): New function.
+	(image-mode): Make new variables buffer-local and reset [vh]scroll
+	on window configuration changes.
+
+2008-01-27  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gdb-ui.el (gdb-create-define-alist): Don't call
+	gdb-cpp-define-alist-program if file is nil (currently only
+	" *partial-output-...").
+
+2008-01-27  Richard Stallman  <rms@gnu.org>
+
+	* allout.el: Many doc fixes.
+	(allout-encrypt-string): Fix error message.
+
+2008-01-26  Eli Zaretskii  <eliz@gnu.org>
+
+	* progmodes/etags.el (tags-query-replace): Doc fix.
+
+2008-01-25  Juanma Barranquero  <lekktu@gmail.com>
+
+	* allout.el (allout-unload-function): New function.
+
+2008-01-25  Juanma Barranquero  <lekktu@gmail.com>
+
+	* allout.el (allout-prefix-data): Doc fix.
+	(allout-show-current-subtree): Reflow docstring.
+	(allout-use-mode-specific-leader, allout-use-hanging-indents)
+	(produce-allout-mode-map, allout-overlay-interior-modification-handler)
+	(allout-next-heading, allout-previous-heading, allout-rebullet-heading)
+	(allout-rebullet-topic, allout-rebullet-topic-grunt, allout-kill-topic)
+	(allout-copy-topic-as-kill, allout-listify-exposed)
+	(allout-process-exposed, allout-encrypted-key-info)
+	(allout-update-passphrase-mnemonic-aids)
+	(allout-next-topic-pending-encryption)
+	(allout-tests-globally-true): Fix typos in docstrings.
+
+2008-01-23  Jason Rumney  <jasonr@gnu.org>
+
+	* lpr.el (printer-name): Do not set on MS Windows.
+
+2008-01-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-shell-command): Use "/bin/sh -c" for
+	the command.
+
+2008-01-28  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* whitespace.el: Moved to obsolete dir.
+
+	* blank-mode.el: New version 9.2.  Replace whitespace funs by aliases
+	in blank-mode.
+	(whitespace-buffer): New fun.
+	(whitespace-region): Alias for whitespace-buffer, because there is no
+	blank-region fun.
+	(whitespace-cleanup): Alias for blank-cleanup.
+	(whitespace-cleanup-region): Alias for blank-cleanup-region.
+
+2008-01-27  Juanma Barranquero  <lekktu@gmail.com>
+
+	* server.el (server-log-time-function): Doc fix.
+	(server-buffer): Fix typo in docstring.
+
+2008-01-27  Martin Rudalics  <rudalics@gmx.at>
+
+	* view.el (view-buffer): Explain in doc-string why exit-action
+	should not be set to kill-buffer.
+
+	* arc-mode.el (archive-extract):
+	* tar-mode.el (tar-extract): Use kill-buffer-if-not-modified as
+	exit-action when viewing the buffer.
+
+2008-01-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* add-log.el (change-log-search-file-name): Work harder to find
+	the correct file name.
+	(change-log-find-file): Fix typo.
+	(change-log-start-entry-re): Move definition earlier.
+
+2007-01-27  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* add-log.el (change-log-search-file-name, change-log-find-file):
+	New function.
+	(change-log-font-lock-keywords): Move file name matching ...
+	(change-log-file-names-re): ... here.  New defconst.
+	(change-log-mode-map): New binding C-c C-f to change-log-find-file.
+
+2008-01-27  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-awk.el, progmodes/cc-engine.el: Correct typos,
+	enhance comments.
+
+2008-01-27  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-compute-multi-hops): In case of su(do)?
+	methods, the host name must be a local host.
+
+2008-01-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add TODO item about not defaulting to RCS.
+
+	* server.el (server-process-filter): Check for non-nil before
+	calling file-directory-p.
+
+2008-01-27  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-vars.el (c-hanging-braces-alist): New element for
+	arglist-cont-nonempty.
+
+	* progmodes/cc-cmds.el (c-brace-newlines): Determine the newlines
+	for a brace with syntax arglist-cont-nonempty.
+
+	* progmodes/cc-styles.el (c-style-alist): Add elements for
+	arglist-cont-nonempty into 5 styles (gnu, ellemtel, linux, python,
+	awk).
+
+2008-01-27  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* button.el (define-button-type): Clarify type of NAME in docstring.
+
+2008-01-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* server.el (server-buffer): New const.
+	(server-log): New var.
+	(server-log): Use them.
+	(server-process-filter): (Try to) run the continuation in the same cwd
+	as the client's.
+
+2008-01-26  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-defs.el (c-save-buffer-state):
+	Bind buffer-file-name and buffer-file-truename to nil, to prevent
+	primitives generating "buffer is read only" messages.
+
+2008-01-20  Ulf Jasper  <ulf.jasper@web.de>
+
+	* icalendar.el (icalendar-version): Increase to "0.17".
+	(icalendar-import-format): Doc fix.  Allow function type.
+	(icalendar--read-element): Doc fix.
+	(icalendar--parse-summary-and-rest): Doc fix.  Handle function
+	type icalendar-import-format.  Make regexps non-greedy.
+	(icalendar--format-ical-event): Handle function type
+	icalendar-import-format.
+	(icalendar-import-format-sample): New function.
+
+2008-01-26  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* vc.el (vc-exec-after): For mode-line-process highlighting, if
+	`compile' is not available, fall back to font-lock-warning-face.
+
+2008-01-26  Phil Sung  <psung@mit.edu>  (tiny change)
+
+	* wdired.el (wdired-get-filename): Change `(1+ beg)' to `beg' so
+	that the filename end is found even when the filename is empty.
+	Fixes error and spurious newlines when marking files for deletion.
+
+2008-01-26  Martin Rudalics  <rudalics@gmx.at>
+
+	* subr.el (find-tag-default): Simplify using exclusively
+	skip-syntax-backward/-forward.
+
+2008-01-26  Michael Albinus  <michael.albinus@gmx.de>
+
+	* vc.el (vc-directory, vc-update-change-log): Remove check for
+	Tramp.  Both functions work for it, though pretty slow
+	(`vc-directory').  Maybe the implementation can be optimized.
+
+	* net/tramp.el (tramp-dissect-file-name): Raise an error when
+	Tramp 2.0 syntax is used.
+	Suggested by Trent W. Buck <trentbuck@gmail.com>.
+
+2008-01-26  Eli Zaretskii  <eliz@gnu.org>
+
+	* ls-lisp.el (ls-lisp-insert-directory): If -n switch is used,
+	invoke directory-files-and-attributes with last argument `integer'
+	instead of `string'.
+	(insert-directory): Add -n to the list of supported switches
+	mentioned in the doc string.
+
+2008-01-26  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* blank-mode.el: New version 9.1.  Handle "long" line tail
+	visualization.  Doc fix.
+	(blank-line-length): Rename to blank-line-column.
+	(blank-chars-value-list, blank-toggle-option-alist, blank-help-text):
+	Initialization fix.
+	(blank-replace-spaces-by-tabs): New fun.
+	(blank-cleanup, blank-cleanup-region, blank-color-on): Code fix.
+
+2008-01-25  Richard Stallman  <rms@gnu.org>
+
+	* subr.el (add-hook): Implement `permanent-local-hook' property.
+
+	* loadhist.el (file-provides, file-requires): Push the filename right.
+
+2008-01-25  Martin Rudalics  <rudalics@gmx.at>
+
+	* emacs-lisp/find-func.el (find-library): Wrap search for
+	library name in condition-case to avoid reporting a scan-error.
+
+2008-01-25  Juanma Barranquero  <lekktu@gmail.com>
+
+	* server.el (server-process-filter): Don't force
+	the authentication string to be followed by "\n".
+
+2008-01-25  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* blank-mode.el: New version 9.0.  New commands to clean up some blank
+	problems like trailing blanks.  New faces and regexp for visualizing
+	the blank problems.  Doc fix.
+	(blank-chars, blank-global-modes, blank-chars-value-list)
+	(blank-toggle-option-alist, blank-help-text): Initialization fix.
+	(blank-indentation, blank-empty, blank-space-after-tab): New faces.
+	(blank-indentation, blank-empty, blank-space-after-tab)
+	(blank-indentation-regexp, blank-empty-at-bob-regexp)
+	(blank-empty-at-eob-regexp, blank-space-after-tab-regexp): New options.
+	(blank-cleanup, blank-cleanup-region): New commands.
+	(blank-color-on): Code fix.
+
+2008-01-25  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* ibuffer.el (ibuffer-default-sorting-mode): Add option to sort by
+	file name.
+	(ibuffer-mode-map): Add binding to sort by file name.
+	(ibuffer-filename/process-header-map): New variable.
+	(filename-and-process): Add a header that sorts by file name.
+	(ibuffer-mode): Mention sorting by file name.
+
+	* ibuf-ext.el (filename/process): New sorter.
+
+2008-01-25  Sven Joachim  <svenjoac@gmx.de>
+
+	* view.el (kill-buffer-if-not-modified): Don't pass t to
+	buffer-modified-p.
+
+2008-01-24  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-do-copy-or-rename-file): Flush the cache of
+	the source file in case of `rename'.
+	Reported by Pete Forman <pete.forman@westerngeco.com>.
+
+2008-01-24  Ken Manheimer  <ken.manheimer@gmail.com>
+
+	* allout.el (allout-keybindings-list): In initial setting, express
+	meta-prefixed allout keys as vectors instead of strings, since the
+	string form is interpreted in some cases as composed key
+	modifiers, eg, accented keys.
+
+	(allout-line-boundary-regexp): Clarify description.
+
+	(set-allout-regexp): Repair the expressions so that the formfeed
+	part is identified as one of the top-level groups, and is
+	included in all the forms, not just the -line-boundary-regexp one.
+
+	(allout-prefix-data): Incorporate information from the various
+	allout regexp's formfeed alternative group, when present.
+
+	(allout-write-file-hook-handler): Rectify mangling of the error
+	handling.  It was broken in version 1.100, where an `error'
+	condition-case handler was apparently reformatted as if it was a
+	call to the error function.  An apparent repair attempt in version
+	1.101 situated the original body of the error handling code as
+	bogus condition-case handlers.  I've returned to just about the
+	working code that was originally there, removing an unnecessary -
+	but benign - enclosing 'progn'.  \(Automated or cursory code fixes
+	often aren't.)
+
+	(allout-region-active-p): Fallback to value of mark-active if
+	neither use-region-p nor region-active-p are present, for
+	compatability with current and recent emacs major releases.
+
+2008-01-24  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* textmodes/reftex-toc.el (reftex-toc-next, reftex-toc-previous)
+	(reftex-toc-restore-region):
+	* textmodes/reftex-index.el (reftex-index-initialize-phrases-buffer)
+	(reftex-index-phrases-apply-to-region):
+	* textmodes/ispell.el (ispell-word):
+	* progmodes/vhdl-mode.el (vhdl-keep-region-active):
+	* progmodes/pascal.el (pascal-mark-defun):
+	* progmodes/f90.el (f90-mark-subprogram, f90-indent-region)
+	(f90-fill-region):
+	* emulation/tpu-edt.el (tpu-set-mark):
+	* emulation/crisp.el (crisp-region-active):
+	* winner.el (winner-active-region):
+	* ansi-color.el (ansi-color-set-extent-face): Use featurep instead
+	of bound tests in order to resolve conditionals at compile time.
+
+2008-01-24  Juanma Barranquero  <lekktu@gmail.com>
+
+	* delsel.el (delsel-unload-function): Don't use `remprop'; it is
+	not autoloaded, and we wouldn't want to load CL just to unload
+	delsel.el anyway.  Suggested by Martin Rudalics <rudalics@gmx.at>.
+
+2008-01-24  Martin Rudalics  <rudalics@gmx.at>
+
+	* delsel.el (delete-selection-pre-hook): Avoid clearing out
+	pre-command-hook when text is read-only.
+
+2008-01-24  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* vc.el (vc-process-filter): Do nothing if buffer not live.
+	(vc-diff-finish): Rename from vc-diff-sentinel.
+	No longer take REV1-NAME and REV2-NAME.
+	Instead, take BUFFER-NAME.  Do nothing if buffer not live.
+	Don't do window resize if no window displays buffer.
+	(vc-diff-internal): Use vc-diff-finish.
+
+	* vc.el (vc-next-action): Fix two instances of "free-var file" bug:
+	In both cases, convert single call to one wrapped in dolist.
+
+2008-01-24  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add a TODO item about missing files.
+	(vc-exec-after): Add a tooltip to the new mode-line item.
+
+2008-01-24  Glenn Morris  <rgm@gnu.org>
+
+	* t-mouse.el (gpm-mouse-start): Declare as a function.
+
+2008-01-23  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-remote-process-environment): Set "LC_ALL=C".
+	(tramp-end-of-output): Add `tramp-rsh-end-of-line' into the regexp.
+	(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
+	Don't send `tramp-rsh-end-of-line' additionally, when setting the
+	prompt.
+	(tramp-wait-for-output): Distinguish different prompt formats.
+	(tramp-get-test-nt-command): Don't check for "\n" in the prompt.
+	(tramp-local-host-p): Check whether temp directory is writable.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add TODO items.
+
+2008-01-23  Carsten Dominik  <dominik@science.uva.nl>
+
+	* replace.el (occur-mode-find-occurrence-hook): New hook that can
+	be used to reveal or highlight the location of a match.
+	(occur-mode-goto-occurrence, occur-mode-goto-occurrence-other-window)
+	(occur-mode-display-occurrence): Run `occur-mode-find-occurrence-hook'.
+
+2008-01-23  Martin Rudalics  <rudalics@gmx.at>
+
+	* progmodes/hideif.el (hide-ifdef-shadow): Add version number
+	for defcustom.
+	(hide-ifdef-shadow): Add version number for defface.
+
+2008-01-23  Glenn Morris  <rgm@gnu.org>
+
+	* textmodes/org.el (org-export-latex-cleaned-string): Fix declaration.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* progmodes/sh-script.el (sh-basic-offset):
+	* progmodes/cc-vars.el (c-syntactic-indentation)
+	(c-syntactic-indentation-in-macros): Mark as safe.
+
+2008-01-23  Richard Stallman  <rms@gnu.org>
+
+	* icomplete.el (icomplete-get-keys):
+	Look up KEYS using all maps in proper buffer.
+
+2008-01-23  Juanma Barranquero  <lekktu@gmail.com>
+
+	* frame.el (display-mm-height, display-mm-width):
+	* whitespace.el (whitespace-check-leading-whitespace)
+	(whitespace-check-trailing-whitespace)
+	(whitespace-check-spacetab-whitespace)
+	(whitespace-check-indent-whitespace)
+	(whitespace-check-ateol-whitespace):
+	* progmodes/ada-xref.el (ada-convert-file-name): Fix typo in docstring.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
+	after-save-hook so that it is not called multiple times.
+
+	* vc-svn.el (vc-svn-resolve-when-done): Likewise.
+
+2008-01-23  Eli Zaretskii  <eliz@gnu.org>
+
+	* view.el (view-file-other-window, view-file-other-frame):
+	Don't kill the buffer if it is modified.  Doc fixes.
+	(kill-buffer-if-not-modified): New function.
+	(view-file): Don't kill the buffer if it is modified.
+
+	* progmodes/ebrowse.el (ebrowse-view-file-other-window): Delete.
+	(ebrowse-view/find-file-and-search-pattern):
+	Call view-file-other-window instead of ebrowse-view-file-other-window.
+	(ebrowse-view-file-other-frame): Don't call
+	current-window-configuration.  Fix second argument in the call to
+	view-mode-enter.  Doc fix.
+
+2008-01-23  Richard Stallman  <rms@gnu.org>
+
+	* subr.el (atomic-change-group): Prevent undo list truncation.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* files.el (safe-local-eval-forms):
+	Mark (add-hook 'write-file-hooks 'time-stamp) as safe.
+
+2008-01-23  Nick Roberts  <nickrob@snap.net.nz>
+
+	* comint.el (comint-insert-input): Set point first.
+
+	* progmodes/gdb-ui.el (gdb-dequeue-input): Make doubly sure
+	session doesn't hang because gdb-pending-triggers is non-nil.
+	(gdb-frame-handler): Use buffer-file-name instead of
+	buffer-name in case of duplicate file names.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* progmodes/verilog-mode.el (verilog-mode-map): Don't bind C-M-a,
+	C-M-e and C-M-h for emacs, they work by default.
+	(verilog-emacs-features): Remove.
+	(verilog-setup-dual-comments, verilog-populate-syntax-table):
+	Remove.  Move syntax table initialization ...
+	(verilog-mode-syntax-table): ... here.
+	(verilog-mode): Don't initialize the syntax table here.
+	(verilog-mark-defun): Only do something useful for XEmacs, Emacs
+	does not need it.
+
+2008-01-23  Wilson Snyder  <wsnyder@wsnyder.org>
+
+	* progmodes/verilog-mode.el (verilog-booleanp): New function for
+	backward compatibility.  Replace all uses of booleanp with
+	verilog-booleanp.
+
+2008-01-23  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-hg.el (vc-hg-diff): Don't pass an empty string.
+
+2008-01-23  Wilson Snyder  <wsnyder@wsnyder.org>
+
+	* progmodes/verilog-mode.el (top-level): Fix spacing.
+	(verilog-mode-version, verilog-mode-release-date):
+	Update version number.
+	(verilog-mode-release-emacs): New variable.
+	(compile-command, reporter-prompt-for-summary-p):
+	Define for byte compiler.
+	(verilog-startup-message-lines, verilog-startup-message-displayed)
+	(verilog-display-startup-message): Remove.
+	(verilog-highlight-p1800-keywords): Improve docstring.
+	(sigs-in, sigs-out, got-sig, got-rvalue, uses-delayed)
+	(vector-skip-list): Only defvar at compile time.
+	(verilog-highlight-translate-off, verilog-indent-level)
+	(verilog-indent-level-module, verilog-indent-level-declaration)
+	(verilog-indent-declaration-macros, verilog-indent-lists)
+	(verilog-indent-level-behavioral, verilog-indent-level-directive)
+	(verilog-cexp-indent, verilog-case-indent, verilog-auto-newline)
+	(verilog-auto-indent-on-newline, verilog-tab-always-indent)
+	(verilog-tab-to-comment, verilog-indent-begin-after-if)
+	(verilog-align-ifelse, verilog-minimum-comment-distance)
+	(verilog-auto-lineup, verilog-highlight-p1800-keywords)
+	(verilog-auto-endcomments, verilog-auto-read-includes)
+	(verilog-auto-star-expand, verilog-auto-star-save)
+	(verilog-library-flags, verilog-library-directories)
+	(verilog-library-files, verilog-library-extensions)
+	(verilog-active-low-regexp, verilog-auto-sense-include-inputs)
+	(verilog-auto-sense-defines-constant, verilog-auto-reset-widths)
+	(verilog-assignment-delay, verilog-auto-inst-vector)
+	(verilog-auto-inst-template-numbers, verilog-auto-input-ignore-regexp)
+	(verilog-auto-inout-ignore-regexp, verilog-auto-output-ignore-regexp)
+	(verilog-auto-unused-ignore-regexp, verilog-typedef-regexp):
+	Add safe-local-variable properties.
+	(verilog-statement-menu, verilog-company, verilog-re-search-forward)
+	(verilog-re-search-backward, verilog-error-regexp-add)
+	(verilog-end-block-re, verilog-emacs-features)
+	(verilog-populate-syntax-table, verilog-setup-dual-comments)
+	(verilog-type-font-keywords, verilog-inside-comment-p)
+	(electric-verilog-backward-sexp, verilog-backward-sexp)
+	(verilog-forward-sexp, verilog-font-lock-init, verilog-mode)
+	(electric-verilog-terminate-line, electric-verilog-semi)
+	(electric-verilog-tab, verilog-insert-1, verilog-insert-indices)
+	(verilog-generate-numbers, verilog-comment-region, verilog-label-be)
+	(verilog-beg-of-statement, verilog-in-case-region-p)
+	(verilog-in-struct-region-p, verilog-in-generate-region-p)
+	(verilog-in-fork-region-p, verilog-backward-case-item)
+	(verilog-set-auto-endcomments, verilog-get-expr)
+	(verilog-expand-vector-internal, verilog-surelint-off)
+	(verilog-batch-execute-func, verilog-calculate-indent)
+	(verilog-calc-1, verilog-calculate-indent-directive)
+	(verilog-leap-to-head, verilog-continued-line)
+	(verilog-backward-token, verilog-backward-syntactic-ws)
+	(verilog-forward-syntactic-ws, verilog-backward-ws&directives)
+	(verilog-forward-ws&directives, verilog-at-constraint-p)
+	(verilog-skip-backward-comments, verilog-indent-line-relative)
+	(verilog-do-indent, verilog-indent-comment, verilog-more-comment)
+	(verilog-pretty-declarations, verilog-pretty-expr)
+	(verilog-just-one-space, verilog-indent-declaration)
+	(verilog-get-completion-decl, verilog-goto-defun, verilog-showscopes)
+	(verilog-header, verilog-signals-combine-bus, verilog-read-decls)
+	(verilog-read-always-signals-recurse, verilog-read-instants)
+	(verilog-read-auto-template, verilog-set-define)
+	(verilog-read-defines, verilog-read-signals, verilog-getopt)
+	(verilog-is-number, verilog-expand-dirnames, verilog-modi-lookup)
+	(verilog-modi-cache-results, verilog-insert-one-definition)
+	(verilog-make-width-expression, verilog-delete-autos-lined)
+	(verilog-auto-save-check, verilog-auto-arg, verilog-auto-inst-port)
+	(verilog-auto-inst, verilog-auto-inst-param, verilog-auto-reg)
+	(verilog-auto-reg-input, verilog-auto-wire, verilog-auto-output)
+	(verilog-auto-output-every, verilog-auto-input, verilog-auto-inout)
+	(verilog-auto-inout-module, verilog-auto-sense, verilog-auto-reset)
+	(verilog-auto-tieoff, verilog-auto-unused, verilog-auto-ascii-enum)
+	(verilog-auto, verilog-sk-define-signal, verilog-mode-mouse-map)
+	(verilog-load-file-at-mouse, verilog-load-file-at-point)
+	(verilog-library-files): Cleanup spacing of )'s they should not be
+	on unique lines.  Fix checkdoc warnings.
+
+2008-01-22  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/hideif.el (hide-ifdef-initially, hide-ifdef-read-only)
+	(hide-ifdef-lines, hide-ifdef-shadow): Remove autoload cookies
+	from defcustoms.
+	(hide-ifdef-shadow): Remove autoload cookie from defface.
+
+	* vc.el (vc-diff-sentinel): Do not write a footer if there were
+	differences.
+
+2008-01-21  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* pcvs-defs.el (cvs-menu): Improve cvs-mode-find-file,
+	cvs-mode-find-file-other-window.  Add cvs-mode-diff-yesterday and
+	manual entry.
+
+2008-01-21  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/dbus.el (dbus-ignore-errors): New macro.
+	(dbus-unregister-object): New defun.  Moved from dbusbind.c.
+	(dbus-handle-event, dbus-list-activatable-names, dbus-list-names)
+	(dbus-list-queued-owners, dbus-get-name-owner, dbus-introspect)
+	(dbus-get-signatures): Apply `dbus-ignore-errors'.
+
+2008-01-21  Martin Rudalics  <rudalics@gmx.at>
+
+	* outline.el (outline-up-heading): Fix check for top level to
+	avoid infinite looping in hide-other.
+
+2008-01-21  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* vc.el (vc-process-sentinel): After calling the previous
+	sentinel, do nothing if the process' buffer is not live.
+
+2008-01-21  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* blank-mode.el: Fix a problem of cleaning blank faces when turning off
+	blank-mode in some buffers (like *info* buffers).  Reported by Juanma
+	Barranquero <lekktu@gmail.com>.  Eliminate `-face' suffix of all
+	blank-mode faces.  Doc fix.  New version 8.1.
+	(blank-turn-on, blank-turn-off): Replace (and CONDITION BODY) by (when
+	CONDITION BODY).
+	(blank-space-face): Face/option name replaced by blank-space.
+	(blank-hspace-face): Face/option name replaced by blank-hspace.
+	(blank-tab-face): Face/option name replaced by blank-tab.
+	(blank-newline-face): Face/option name replaced by blank-newline.
+	(blank-trailing-face): Face/option name replaced by blank-trailing.
+	(blank-line-face): Face/option name replaced by blank-line.
+	(blank-space-before-tab-face): Face/option name replaced by
+	blank-space-before-tab.
+	(blank-color-on, blank-color-off, blank-display-char-on): Fix code.
+
+2008-01-21  Juanma Barranquero  <lekktu@gmail.com>
+
+	* blank-mode.el (blank-style, blank-chars, blank-hspace-regexp)
+	(blank-space-regexp, blank-tab-regexp, blank-trailing-regexp)
+	(blank-space-before-tab-regexp, blank-global-modes, blank-mode)
+	(global-blank-mode): Doc fixes.
+	(blank, blank-space-face, blank-hspace-face, blank-tab-face)
+	(blank-newline-face, blank-trailing-face, blank-line-face)
+	(blank-space-before-tab-face, blank-display-mappings)
+	(blank-chars-value-list, blank-style-value-list, blank-toggle-options)
+	(global-blank-toggle-options, blank-help-text, blank-interactive-char)
+	(blank-turn-on, blank-turn-off, blank-color-on, blank-color-off):
+	Fix typos in docstrings.
+
+2008-01-21  Juanma Barranquero  <lekktu@gmail.com>
+
+	* server.el (server-log-time-function): New variable.
+	(server-log): Use it.
+
+2008-01-21  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/hideif.el: Move defcustoms and defface to start of file.
+
+	* textmodes/org.el (org-entry-properties): Let-bind `clocksum'.
+
+2008-01-21  Juanma Barranquero  <lekktu@gmail.com>
+
+	* textmodes/org.el (org-unmodified, org-cycle-emulate-tab)
+	(org-descriptive-links, org-link-file-path-type)
+	(org-remember-use-refile-when-interactive)
+	(org-agenda-skip-timestamp-if-done, org-agenda-scheduled-leaders)
+	(org-export-ascii-bullets, org-agenda-deadline-faces)
+	(turn-on-orgstruct++, orgtbl-to-texinfo, org-mhe-get-header)
+	(org-batch-agenda, org-batch-agenda-csv, org-fix-agenda-info)
+	(org-kill-note-or-show-branches): Fix typos in docstrings.
+
+2008-01-20  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* vc.el (vc-process-sentinel): Set mode-line-process.
+	(vc-exec-after): Likewise, for the `run' process status.
+
+2008-01-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* ibuffer.el (ibuffer-mode): Fix last change.
+
+2008-01-20  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-hg.el (vc-hg-registered):
+	* vc-svn.el (vc-svn-registered): Make it work for non-existent files.
+
+2008-01-20  Martin Rudalics  <rudalics@gmx.at>
+
+	* repeat.el (repeat-undo-count): New variable.
+	(repeat): For self-insertions make undo boundary only after 20
+	repetitions.  Inhibit point recording unless repeat-repeat-char is nil.
+
+2008-01-19  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* net/imap.el (imap-ping-server): New variable.
+	(imap-opened): On add extra ping if imap-ping-server is non-nil.
+	(imap-ping-server): Minor doc string fixes.
+
+2008-01-19  Knut Anders Hatlen  <kahatlen@gmail.com>  (tiny change)
+
+	* net/imap.el (imap-ping-server): New function.
+	(imap-opened): Call imap-ping-server.
+
+2008-01-20  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/python.el: Quote all calls to "auxiliary skeleton"s to
+	prevent infloops.
+
+2008-01-20  Martin Svenson  <phromo@gmail.com>  (tiny change)
+
+	* progmodes/python.el (python-imports): Default to "None".
+
+2008-01-19  Tom Tromey  <tromey@redhat.com>
+
+	* vc-svn.el (vc-svn-after-dir-status): New function.
+	(vc-svn-dir-status): Run svn asynchronously.
+
+2008-01-19  Martin Rudalics  <rudalics@gmx.at>
+
+	* progmodes/hideif.el (hide-ifdef-shadow): New option.
+	(hide-ifdef-shadow): New face.
+	(hide-ifdef-toggle-shadowing): New function to toggle between
+	shadowing and making code invisible.
+	(hide-ifdef-mode-submap): Add binding for hide-ifdef-toggle-shadowing.
+	(hide-ifdef-mode-menu): Add entry for hide-ifdef-toggle-shadowing.
+	(hide-ifdef-region-internal): Give new overlay hide-ifdef
+	property.  Shadow text when hide-ifdef-shadow is non-nil.
+	(hif-show-ifdef-region): Remove overlays with hide-ifdef property set.
+	(hif-hide-line): Use when instead of if.
+	(hide-ifdef-initially, hide-ifdef-read-only, hide-ifdef-lines):
+	Remove unneeded * from doc-strings.
+
+2008-01-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* doc-view.el (doc-view-goto-page): Don't move point any more, now that
+	the hscroll behavior was fixed.
+	(doc-view-mode): Disable auto-hscroll-mode.
+
+2008-01-18  Tom Tromey  <tromey@redhat.com>
+
+	* vc-svn.el (vc-svn-dir-status): New function.
+
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Make vc-status asynchronous.
+	(vc-update-vc-status-buffer): New function broken out of ...
+	(vc-status-refresh): ... here.  Pass vc-update-vc-status-buffer to
+	the dir-status backend function.
+
+	* vc-hg.el (vc-hg-dir-status): Compute the status asynchronously.
+	Move the output processing to ...
+	(vc-hg-after-dir-status): ... here.  Call the function passed as
+	an argument with the results.
+
+2008-01-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd.
+	(doc-view-insert-image): Do something if the image is missing.
+	(doc-view-mode): Don't use file-remote-p.
+
+2008-01-18  Bastien Guerry  <Bastien.Guerry@ens.fr>
+
+	* textmodes/org-export-latex.el (org-export-latex-cleaned-string): Fix.
+	(org-export-latex-special-chars): Convert "..." in \ldots
+	and skip tables.
+	(org-export-latex-fontify-headline): Change parameter name.
+	(org-export-as-latex): Handle export of subtrees.
+	(org-export-latex-make-header): New argument TITLE.
+	(org-export-latex-content): New argument EXCLUDE-LIST.
+	(org-list-parse-list): New name for org-export-latex-parse-list.
+	(org-export-latex-make-header): New name for
+	org-export-latex-make-preamble.
+	(org-list-to-generic): New name of org-export-list-to-generic.
+	(org-list-to-latex): New name of org-export-list-to-latex.
+	(org-list-item-begin, org-list-end, org-list-insert-radio-list)
+	(org-list-send-list, org-list-to-texinfo)
+	(org-list-to-html): New functions.
+	(org-export-latex-tables-column-borders)
+	(org-export-latex-default-class, org-export-latex-classes)
+	(org-export-latex-classes-sectioning)
+	(org-list-radio-list-templates): New options.
+	(org-export-latex-header): New variable.
+	(org-latex-entities): New constant.
+	(org-export-latex-default-sectioning, org-export-latex-preamble)
+	(org-export-latex-prepare-text-option)
+	(org-export-latex-get-sectioning): Remove.
+
+2008-01-18  Carsten Dominik  <dominik@science.uva.nl>
+
+	* textmodes/org-publish.el (org-publish-current-project):
+	Fix bug with forcing publication.
+
+	* textmodes/org.el (org-export-with-special-strings): New option.
+	(org-export-html-convert-special-strings): New function.
+	(org-html-do-expand): `org-export-html-convert-special-strings'
+	added to the list of conversion.
+	(org-infile-export-plist, org-get-current-options): Add support
+	for "-" in the #+OPTION line to let user switch on/off special
+	strings conversion.
+	(org-export-plist-vars): New :html-table-tag property.
+	(org-export-as-html, org-format-org-table-html)
+	(org-format-table-table-html) Use the :html-table-tag property
+	instead of the `org-export-html-table-tag' global value.
+	(org-additional-option-like-keywords): Add "TBLFM".
+	(org-entry-properties): Include the CLOCKSUM special property.
+	(org-columns-edit-value): Do not allow to edit the special
+	CLOCKSUM property.
+	(org-flag-drawer): Use the original value of `outline-regexp'.
+	(org-remember-handler): Add invisible-ok flag to call to
+	`org-end-of-subtree'.
+	(org-agenda-highlight-todo): Respect
+	`org-agenda-todo-keyword-format'.
+	(org-agenda-todo-keyword-format): New option.
+	(org-infile-export-plist): No restriction while searching for options.
+	(org-remember-handler): Remove comments at the end of the buffer.
+	(org-remember-use-refile-when-interactive): New option.
+	(org-table-sort-lines): Make sure sorting works on link
+	descritions only, and ignores the link.
+	(org-sort-entries-or-items): Make sure the end of the subtree is
+	included.
+	(org-refile-use-outline-path): New allowed values `file' and
+	`full-file-path'.
+	(org-get-refile-targets): Respect new values for
+	`org-refile-use-outline-path'.
+	(org-agenda-get-restriction-and-command): DEL goes back to initial list.
+	(org-export-as-xoxo): Restore point when done.
+	(org-open-file): Allow multiple %s in command.
+	(org-clock-in-switch-to-state): New option.
+	(org-first-list-item-p): New function.
+	(org-last-remember-storage-locations): New variable.
+	(org-get-refile-targets): Interpret the new maxlevel setting.
+	(org-refile-targets): New option `:maxlevel'.
+	(org-copy-subtree): Include empty lines before but not after subtree.
+	(org-back-over-empty-lines, org-skip-whitespace): New functions.
+	(org-move-item-down, org-move-item-up): Include empty lines before
+	but not after item.
+	(org-first-sibling-p): New function.
+	(org-remember-apply-template): Defaults, completions and history
+	for template prompts.  Also, interpret new `%!' escape.
+	(org-context-choices): New constant.
+	(org-bound-and-true-p): New macro.
+	(org-imenu-depth): New option.
+	(org-imenu-markers): New variable.
+	(org-imenu-new-marker, org-imenu-get-tree)
+	(org-speedbar-set-agenda-restriction): New functions.
+	(org-agenda-set-restriction-lock)
+	(org-agenda-remove-restriction-lock)
+	(org-agenda-maybe-redo): New functions.
+	(org-agenda-restriction-lock): New face.
+	(org-agenda-restriction-lock-overlay)
+	(org-speedbar-restriction-lock-overlay): New variables.
+	(org-open-at-point): Remove obsolete way to do redirection in
+	shell links.
+	(org-imenu-and-speedbar): New customization group.
+	(org-entry-properties): Return keyword-less time strings.
+	(org-clock-heading-function): New option.
+	(org-clock-in): Use `org-clock-heading-function'.
+	(org-calendar-holiday): Try to use `calendar-check-holidays'
+	instead of the obsolete `check-calendar-holidays'.
+	(org-export-html-special-string-regexps): New constant.
+	(org-massive-special-regexp): New variable.
+	(org-compute-latex-and-specials-regexp)
+	(org-do-latex-and-special-faces): New functions.
+	(org-latex-and-export-specials): New face.
+	(org-highlight-latex-fragments-and-specials): New option.
+	(org-link-escape-chars): Use characters instead of strings.
+	(org-link-escape-chars-browser, org-link-escape)
+	(org-link-unescape): Use characters instead of strings.
+	(org-export-html-convert-sub-super, org-html-do-expand): Check for
+	protected text.
+	(org-emphasis-alist): Additional `verbatim' flag.
+	(org-set-emph-re): Handle the verbatim flag and compute
+	`org-verbatim-re'.
+	(org-cleaned-string-for-export): Protect verbatim elements.
+	(org-verbatim-re): New variable.
+	(org-hide-emphasis-markers): New option.
+	(org-additional-option-like-keywords): Add new keywords.
+	(org-get-entry): Rename from `org-get-cleaned-entry'.
+	(org-icalendar-cleanup-string): New function for quoting icalendar text.
+	(org-agenda-skip-scheduled-if-done): New option.
+	(org-agenda-get-scheduled, org-agenda-get-blocks): Use
+	`org-agenda-skip-scheduled-if-done'.
+	(org-prepare-agenda-buffers): Allow buffers as arguments.
+	(org-entry-properties): Add CATEGORY as a special property.
+	(org-use-property-inheritance): Allow a list of properties as a value.
+	(org-eval-in-calendar): No longer update the prompt.
+	(org-read-date-popup-calendar): Rename from
+	`org-popup-calendar-for-date-prompt'.
+	(org-read-date-display-live): New variable.
+	(org-read-date-display): New function.
+	(org-read-date-analyze): New function.
+	(org-remember-apply-template): Define `remember-finalize' if it is
+	not yet defined.
+	(org-remember-insinuate): New function.
+	(org-read-date-prefer-future): New option.
+	(org-read-date): Respect the setting of
+	`org-read-date-prefer-future'.  Use `org-read-date-analyze'.
+	(org-set-font-lock-defaults): Use `org-archive-tag' instead of a
+	hardcoded string.
+	(org-remember-apply-template): Use `remember-finalize' instead of
+	`remember-buffer'.
+	(org-columns-compute, org-column-number-to-string)
+	(org-columns-uncompile-format, org-columns-compile-format)
+	(org-columns-compile-format): Handle printf format specifier.
+	(org-columns-new, org-column-number-to-string)
+	(org-columns-uncompile-format, org-columns-compile-format):
+	Support for new currency summary type.
+	(org-tree-to-indirect-buffer): Do not kill old buffer when
+	`org-indirect-buffer-display' is `new-frame'.
+	(org-indirect-buffer-display): Document that `new-frame' leads to
+	indiret buffer proliferation.
+	(org-agenda-list): Use `org-extend-today-until'.
+	(org-extend-today-until): New option.
+	(org-format-org-table-html): Use lower-case for <col> tag.
+	(org-agenda-execute): New command.
+	(org-agenda-mode-map): Keybindings of "g" "G", "e" modified.
+	(org-select-remember-template): New function.
+	(org-remember-apply-template): Use `org-select-remember-template'.
+	(org-go-to-remember-target): New function.
+
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add a TODO note about vc-state.
+	(vc-next-action): Register 'unregistered and 'ignored files.
+	Use when and unless instead of if where appropriate.
+	(vc-start-entry): Fix typo.
+	(vc-status): Autoload it.
+
+2008-01-18  Glenn Morris  <rgm@gnu.org>
+
+	* ffap.el (ffap-alist): Remove space from RFC regexp.
+
+2008-01-18  Richard Stallman  <rms@gnu.org>
+
+	* custom.el (custom-theme-recalc-face): Use face-spec-set rather
+	than face-spec-recalc.
+
+2008-01-18  Glenn Morris  <rgm@gnu.org>
+
+	* ibuffer.el (ibuffer-mode): Fix typo in previous change.
+
+2008-01-17  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+	    Miles Bader  <miles@gnu.org>
+
+	* blank-mode.el: New file.  Minor mode to visualise (HARD) SPACE,
+	TAB, NEWLINE.  Miles Bader <miles@gnu.org> wrote the original code
+	for handling display table (via visws.el package), his code was
+	modified, but the main idea was kept.
+
+2008-01-17  Glenn Morris  <rgm@gnu.org>
+
+	* ibuf-ext.el (ibuffer-auto-mode, ibuffer-save-filter-groups)
+	(ibuffer-save-filters): Remove calls to deleted
+	ibuffer-update-mode-name.
+
+2008-01-16  Martin Rudalics  <rudalics@gmx.at>
+
+	* longlines.el (longlines-mode, longlines-show-region)
+	(longlines-unshow-hard-newlines): Bind buffer-file-name and
+	buffer-file-truename to nil while modifying buffer.
+
+	* cus-edit.el (custom-reset-standard-variables-list)
+	(custom-reset-standard-faces-list): New variables.
+	(custom-reset-standard-save-and-update): New function.
+	(Custom-save): Apply custom-mark-to-save before and
+	custom-state-set-and-redraw after saving options.
+	(Custom-reset-standard): Apply custom-mark-to-reset-standard to
+	options and call custom-reset-standard-save-and-update.
+	(custom-variable, custom-face, custom-group): Provide new
+	entries for custom-mark-to-save, custom-mark-to-reset-standard,
+	and custom-state-set-and-redraw.
+	(custom-variable-mark-to-save)
+	(custom-variable-state-set-and-redraw)
+	(custom-variable-mark-to-reset-standard)
+	(custom-face-mark-to-save, custom-face-state-set-and-redraw)
+	(custom-face-mark-to-reset-standard)
+	(custom-group-mark-to-save, custom-group-state-set-and-redraw)
+	(custom-group-mark-to-reset-standard): New functions.
+	(custom-variable-save): Move save, state-set, and redraw
+	functionality to custom-variable-mark-to-save.
+	(custom-face-save): Move save, state-set, and redraw
+	functionality to custom-face-mark-to-save.
+	(custom-group-save): Move save, state-set, and redraw
+	functionality to custom-group-mark-to-save.
+	(custom-variable-reset-standard, custom-face-reset-standard)
+	(custom-group-reset-standard): Move save, state-set, and redraw
+	functionality to custom-reset-standard-save-and-update.
+
+	(custom-buffer-create-internal): Fix text in verbose help.
+	(custom-face-value-create): Indent doc-strings of faces like
+	those of variables.
+
+2008-01-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* server.el (server-process-filter): Replace lineno and columnnno
+	which defaulted to 1&0 with filepos which defaults to nil.
+	(server-goto-line-column): Only receive the filepos.
+	Only move if filepos is non-nil.
+	(server-visit-files): Slight restructure to consolidate two calls to
+	server-goto-line-column into just one.
+
+	* nxml/nxml-mode.el (nxml-mode): Use mode-line-process to indicate
+	the use of degraded mode.
+	(nxml-degrade): Don't change mode-name.
+
+	* nxml/rng-nxml.el (rng-nxml-mode-init):
+	Don't overwrite mode-line-process.
+
+	* ibuffer.el (mode): Pass the buffer to format-mode-line.
+	(ibuffer-update-mode-name): Remove.
+	(ibuffer-redisplay, ibuffer-update, ibuffer-mode): Don't call it.
+	(ibuffer-mode): Use mode-line-process instead.
+
+	* ibuf-ext.el (ibuffer-auto-update-changed, ibuffer-auto-mode):
+	Use derived-mode-p.
+	(ibuffer-mark-by-mode-regexp): Pass the buffer to format-mode-line.
+
+	* help.el (describe-mode): Pass the right buffer to format-mode-line.
+
+2008-01-16  Glenn Morris  <rgm@gnu.org>
+
+	* comint.el (comint-regexp-arg): Fix no-input case.
+
+2008-01-16  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* smerge-mode.el (smerge-start-session): Rename from smerge-auto.
+	* pcvs.el (cvs-revert-if-needed):
+	* vc.el (vc-maybe-resolve-conflicts): Rename callers.
+
+	* vc-svn.el (vc-svn-find-file-hook):
+	* vc-arch.el (vc-arch-find-file-hook): Undo previous change.
+
+2008-01-16  Ulf Jasper  <ulf.jasper@web.de>
+
+	* calendar/icalendar.el (icalendar-version): Increase to 0.16.
+	(icalendar-export-file, icalendar-import-file):
+	Restore significant trailing whitespace in `interactive' prompts.
+
+2008-01-16  Tom Tromey  <tromey@redhat.com>
+
+	* calendar/icalendar.el (icalendar--convert-tz-offset)
+	(icalendar--parse-vtimezone, icalendar--convert-all-timezones)
+	(icalendar--find-time-zone): New functions.
+	(icalendar--decode-isodatetime): Add `zone' argument, passed to
+	`decode-time'.  Doc fix.
+	(icalendar--convert-ical-to-diary): Compute zone-map.
+	Pass timezone to icalendar--decode-isodatetime.
+
+2008-01-16  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-vars.el (c-constant-symbol): Put this defun inside
+	an eval-and-compile, so as to permit byte-compiling (e.g. in
+	bootstrap).
+
+2008-01-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/easymenu.el (easy-menu-avoid-duplicate-keys): New var.
+	(easy-menu-create-menu, easy-menu-convert-item-1): Use it to avoid
+	using the same key for different menu entries.
+
+	* smerge-mode.el (smerge-refine): Also work on "same change conflicts".
+	(smerge-makeup-conflict): New command.
+
+2008-01-15  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* log-edit.el (log-edit): Doc fix.
+
+2008-01-15  Glenn Morris  <rgm@gnu.org>
+
+	* diff-mode.el (diff-end-of-hunk): Revert 2008-01-08 change.
+
+2008-01-14  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-vars.el (c-constant-symbol): New function which
+	supersedes c-const-symbol.  During a customize-.. call it enables
+	an element of (e.g.) c-hanging-braces alist to have its name
+	displayed, even when the default value of c-h-b etc. doesn't
+	include the elemnt.  Replace uses of the old function by the new.
+
+	* progmodes/cc-vars.el (c-hanging-braces-alist): Remove the
+	obscure non-working fragment ":value c-".
+
+2008-01-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* abbrev.el (clear-abbrev-table): Can't pass a symbol to intern.
+
+2008-01-14  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-local-host-p): Use `tramp-file-name-host'
+	instead of `tramp-file-name-real-host'.
+
+	* net/trampver.el: Update release number.
+
+2008-01-14  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-engine.el (c-guess-basic-syntax): Prevent a macro
+	call inside a struct being recognised as a K&R argument.
+
+2008-01-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/compile.el (compilation-error-regexp-alist-alist):
+	Accept "fatal error" from MSFT.
+	Reported by Jared Finder <jfinder@crypticstudios.com>.
+
+2008-01-14  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* smerge-mode.el (smerge-auto): New function.
+	* vc-svn.el (vc-svn-find-file-hook):
+	* vc-arch.el (vc-arch-find-file-hook):
+	* pcvs.el (cvs-revert-if-needed):
+	* vc.el (vc-maybe-resolve-conflicts): Use it instead of vc-mode.
+	(top-level): Add a Todo list.
+
+2008-01-13  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el (vc-update): Resolve conflicts if necessary instead of
+	just updating the buffer.
+
+	* vc-cvs.el (vc-cvs-merge-news): Ignore the error status of the
+	update command so that we can parse the output.
+
+2008-01-13  Martin Rudalics  <rudalics@gmx.at>
+
+	* mail/rmail.el (rmail-convert-to-babyl-format):
+	Remove save-excursion to avoid infinite looping.
+	Reported by: dnz <dnz@bk.ru>.
+
+2008-01-12  Glenn Morris  <rgm@gnu.org>
+
+	* woman.el (woman-parse-numeric-arg): Change handling of `==':
+	can be interned without a function definition.
+
+2008-01-12  Jason Rumney  <jasonr@gnu.org>
+
+	* nxml/nxml-mode.el (nxml-enable-unicode-char-name-sets)
+	(rng-nxml-mode-init): Declare.
+
+2008-01-11  Jason Rumney  <jasonr@gnu.org>
+
+	* nxml/rng-nxml.el (rng-preferred-prefix-alist): Add some defaults.
+	(rng-preferred-prefix-alist-default): Remove.
+
+	* nxml/nxml-uchnm.el (nxml-internal-unicode-char-name-sets-enabled):
+	Rename from nxml-enable-unicode-char-name-sets-flag.
+	(nxml-enable-unicode-char-name-sets-1): Merge into
+	nxml-enable-unicode-char-name-sets.
+	(nxml-enable-unicode-char-name-sets): Don't unconditionally set
+	nxml-char-name-ignore-case here.
+
+	* nxml/nxml-mode.el (nxml-mode): Call rng-nxml-mode-init directly.
+	Update doc string and commentary.
+	(nxml-char-name-ignore-case): Change default value.
+	(nxml-mode): Call nxml-enable-unicode-char-name-sets directly.
+
+2008-01-11  Martin Rudalics  <rudalics@gmx.at>
+
+	* cus-start.el (all): Add missing version entries.
+
+2008-01-11  Glenn Morris  <rgm@gnu.org>
+
+	* language/china-util.el (big5-to-flat-code, flat-code-to-big5)
+	(euc-to-flat-code, flat-code-to-euc):
+	* textmodes/org.el (elmo-msgdb-overview-get-entity)
+	(wl-summary-buffer-msgdb): Declare as funtions.
+
+2008-01-10  Martin Rudalics  <rudalics@gmx.at>
+
+	* progmodes/ada-mode.el (ada-set-syntax-table-properties):
+	Bind buffer-file-name and buffer-file-truename.
+
+	* fringe.el (fringe-mode-explicit): New variable.
+	(set-fringe-mode): Don't alter default-frame-alist when just
+	loading this file.
+
+2008-01-10  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-buffer-file-name): New variable.
+	(doc-view-convert-current-doc, doc-view-search)
+	(doc-view-current-cache-dir, doc-view-initiate-display)
+	(doc-view-mode): Use it.
+	(doc-view-bookmark-make-cell): Use variable buffer-file-name
+	instead of function.
+
+2008-01-10  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-svn.el (vc-svn-registered): Return the correct value for
+	ignored and unregistered files.
+
+2008-01-10  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (tramp): Require tramp because we use tramp-tramp-file-p.
+
+2008-01-10  Tom Tromey  <tromey@redhat.com>
+
+	* vc.el (vc-status-unmark-all-files): New function.
+	(vc-status-unmark-all-files): Likewise.
+	(vc-status-mode-map): Add bindings.
+
+2008-01-10  Michael Kifer  <kifer@cs.stonybrook.edu>
+
+	* ediff*.el: Uncomment declare-function.
+
+	* viper*.el: Uncomment declare-function.
+
+2008-01-09  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-mode): Support tramp, compressed files and
+	files inside archives uniformly.
+
+2008-01-09  Eric S. Raymond  <esr@snark.thyrsus.com>
+
+	* testmodes/sgml-mode.el (sgml-tag-syntax-table): Initialize this
+	constant with a computation on sgml-specials rather than a literal
+	list.  Without this change the syntax table is generated
+	incorrectly, and the mode will think it's in a comment following
+	any instance of the string "--".
+
+2008-01-09  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-mode-p): Add EPS as supported type.
+	(doc-view-mode): Support document files inside archives.
+
+2008-01-09  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el (vc-deduce-fileset): Return the currently selected file if
+	no files are selected when using vc-status.
+
+2008-01-09  Michael Kifer  <kifer@cs.stonybrook.edu>
+
+	* ediff*.el: Comment out declare-function.  "make bootstrap"
+	stops with an error and Emacs does not compile with those things in.
+	Besides, declare-function is not defined in XEmacs.
+
+	* ediff-util (eqiff-quit): Autoraise minibuffer.
+
+	* ediff-diff (ediff-convert-fine-diffs-to-overlays): Make it a defun.
+
+	* viper*.el: Comment out declare-function -- not defined in XEmacs.
+
+	* viper-ex.el (viper-info-on-file): Take care of indirect buffers.
+
+	* viper.el (viper-set-hooks, set-cursor-color):
+	Set viper-vi-state-cursor-color.
+
+2008-01-09  Tom Tromey  <tromey@redhat.com>
+
+	* vc.el (vc-status-headers): Rename from vc-status-insert-headers.
+	Just return header.
+	(vc-status-move-to-goal-column): New function.
+	(vc-status-mode-map): Define more keys.
+	(vc-status-mode): Use vc-status-refresh.  Now 'special.
+	(vc-status-refresh): New function.
+	(vc-status-next-line): Likewise.
+	(vc-status-previous-line): Likewise.
+	(vc-status-mark-file): Use vc-status-next-line.
+	(vc-status-unmark-file): Use vc-status-previous-line.
+	(vc-status-unmark-file-up): New function.
+	(vc-status-register): Likewise.
+	(vc-status-find-file): Likewise.
+	(vc-status-find-file-other-window): Likewise.
+	(vc-status-current-file): Likewise.
+	(vc-ensure-vc-buffer): Understand vc-status mode.
+
+	* vc-hg.el (vc-hg-dir-status): Don't pass -A to "hg status".
+
+2008-01-09  Glenn Morris  <rgm@gnu.org>
+
+	* ffap.el (ffap-string-at-point-mode-alist): Add `\' to file
+	entry, for Windows.
+
+2008-01-09  Tom Tromey  <tromey@redhat.com>
+
+	* play/blackbox.el (blackbox-mode-map): Add `q' and [return] bindings.
+
+2008-01-09  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* ps-print.el: Some face attributes (like :strike-through) were not
+	being recognised.  Reported by Leo <sdl.web@gmail.com>.
+	(ps-print-version): New version 6.8.2.
+	(ps-face-strikout-p, ps-face-overline-p, ps-face-box-p): New funs.
+	(ps-screen-to-bit-face): Fix code.
+
+2008-01-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* ffap.el (ffap-read-file-or-url): Don't use let-binding to temporarily
+	add a file-name handler.
+
+2008-01-08  Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de>
+
+	* textmodes/bibtex.el (bibtex-initialize): New autoloaded command.
+	Rename from function bibtex-files-expand.  New optional arg select.
+	(bibtex-flash-head): Allow blink-matching-delay being zero.
+	(bibtex-clean-entry): Use atomic-change-group.
+	(bibtex-format-entry): Check presence of required fields only
+	after formatting of fields.  Use member-ignore-case.  Do not use
+	bibtex-parse-entry.  Do not use booktitle field to set a missing title.
+	(bibtex-autofill-entry): Do not call undo-boundary.
+	(bibtex-lessp): Handle crossref keys that point to another bibtex file.
+	(bibtex-sort-buffer, bibtex-prepare-new-entry, bibtex-validate):
+	Parse keys if necessary.
 
 2008-01-08  Nick Roberts  <nickrob@snap.net.nz>
 
@@ -10,8 +1294,8 @@
 
 2008-01-08  Nick Roberts  <nickrob@snap.net.nz>
 
-	* progmodes/gdb-ui.el (gud-gdb-command-name): Explain
-	"--annotate=3" option is necessary for the Graphical Interface.
+	* progmodes/gdb-ui.el (gud-gdb-command-name):
+	Explain "--annotate=3" option is necessary for the Graphical Interface.
 
 2008-01-08  Nick Roberts  <nickrob@snap.net.nz>
 
@@ -79,10 +1363,8 @@
 
 	* time-stamp.el (time-stamp-time-zone):
 	* whitespace.el (whitespace-check-buffer-leading)
-	(whitespace-check-buffer-trailing)
-	(whitespace-check-buffer-indent)
-	(whitespace-check-buffer-spacetab)
-	(whitespace-check-buffer-ateol):
+	(whitespace-check-buffer-trailing, whitespace-check-buffer-indent)
+	(whitespace-check-buffer-spacetab, whitespace-check-buffer-ateol):
 	* progmodes/sh-script.el (sh-indentation):
 	* textmodes/ispell.el (ispell-local-pdict):
 	Add safe-local-variable properties.
@@ -212,8 +1494,7 @@
 	* vc-arch.el (vc-arch-root): Only set a property if the file is
 	managed by this backend.
 
-	* vc-hg.el (vc-hg-state): Support the new status code for
-	up-to-date.
+	* vc-hg.el (vc-hg-state): Support the new status code for up-to-date.
 
 2008-01-04  Tassilo Horn  <tassilo@member.fsf.org>
 
@@ -223,8 +1504,8 @@
 
 	* doc-view.el (doc-view-scroll-up-or-next-page)
 	(doc-view-scroll-down-or-previous-page): Use image-scroll-up and
-	image-scroll-down instead of the non-image equivalents.  Don't
-	rely on a signalled condition but switch pages when scrolling
+	image-scroll-down instead of the non-image equivalents.
+	Don't rely on a signalled condition but switch pages when scrolling
 	doesn't change the vertical position anymore.
 	(doc-view-mode-map): Remap scroll-{up,down} to
 	image-scroll-{up,down}.
@@ -242,7 +1523,8 @@
 	* bs.el (bs--sort-by-mode, bs--get-mode-name):
 	* imenu.el (imenu-add-to-menubar):
 	* makesum.el (make-command-summary):
-	* mouse.el (mouse-major-mode-menu, mouse-popup-menubar, mouse-buffer-menu):
+	* mouse.el (mouse-major-mode-menu, mouse-popup-menubar)
+	(mouse-buffer-menu):
 	* msb.el (msb--mode-menu-cond):
 	* calc/calc-embed.el (calc-do-embedded):
 	* emacs-lisp/helper.el (Helper-describe-mode):
@@ -257,7 +1539,8 @@
 	* progmodes/ada-xref.el (ada-prj-find-prj-file):
 	* progmodes/ada-mode.el (comment-region):
 	* calendar/todo-mode.el (todo-insert-item):
-	* bookmark.el (bookmark-buffer-name): Test major-mode rather than mode-name.
+	* bookmark.el (bookmark-buffer-name):
+	Test major-mode rather than mode-name.
 
 2008-01-04  Richard Stallman  <rms@gnu.org>
 
@@ -328,13 +1611,13 @@
 	* progmodes/grep.el (grep-find-ignored-directories):
 	Initialize from the value of vc-directory-exclusion-list.
 
-	* vc-hooks (vc-directory-exclusion-list):  Include "_darcs",
+	* vc-hooks (vc-directory-exclusion-list): Include "_darcs",
 	even though we don't have a back end for darcs yet.
 
 2008-01-02  Karl Fogel  <kfogel@red-bean.com>
 
-	Change a return type, for greater extensibility.  See
-	http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg01077.html
+	Change a return type, for greater extensibility.
+	See http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg01077.html
 	and its thread for discussion leading to this change.
 
 	* emacs-cvs/lisp/bookmark.el:
@@ -396,10 +1679,10 @@
 
 2008-01-01  Eric S. Raymond  <esr@snark.thyrsus.com>
 
-	* vc-svn.el (vc-svn-parse-status): Set the 'unregisted property
+	* vc-svn.el (vc-svn-parse-status): Set the `unregisted' property
 	correctly.
 
-	* vc.el (vc-dired-hook):  Speed tuning.  Replace a vc-backend call
+	* vc.el (vc-dired-hook): Speed tuning.  Replace a vc-backend call
 	with vc-state.
 	(vc-next-action): Fix vc-transfer-file call.
 
@@ -889,6 +2172,12 @@
 	* newcomment.el (comment-region-default): Don't triple the
 	comment starter if the first region line isn't indented enough.
 
+2007-12-21  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* net/imap.el (imap-authenticate): Use current-buffer instead of
+	buffer, for the cases where imap-authenticate is called with a nil
+	buffer parameter.
+
 2007-12-21  Martin Rudalics  <rudalics@gmx.at>
 
 	* autoinsert.el (auto-insert-alist): Remove nonsensical precision
@@ -1579,6 +2868,12 @@
 	* textmodes/reftex-toc.el (reftex-make-separate-toc-frame):
 	Try x-focus-frame before focus-frame.  Only try focus-frame on XEmacs.
 
+2007-12-03  Nathan J. Williams  <nathanw@MIT.EDU>  (tiny change)
+
+	* net/imap.el (imap-mailbox-status-asynch): Upcase STATUS items.
+	(imap-parse-status): Upcase status-att for servers that sends them
+	lower-case (e.g., MS Exchange 2007).
+
 2007-12-03  Karl Fogel  <kfogel@red-bean.com>
 
 	* saveplace.el (save-place-quiet): Remove, reverting 1.39.
@@ -4771,7 +6066,7 @@
 	Require tramp-cmds.el.
 	(tramp-make-tramp-temp-file): We can get rid of DONT-CREATE.
 	(tramp-handle-file-name-all-completions): Expand DIRECTORY.
-	 (tramp-do-copy-or-rename-file-directly): Make more rigid checks.
+	(tramp-do-copy-or-rename-file-directly): Make more rigid checks.
 	(tramp-do-copy-or-rename-file-out-of-band)
 	(tramp-maybe-open-connection): Use `make-temp-name'.  This is
 	possible, because we don't need to create the temporary file, but
@@ -7117,18 +8412,6 @@
 	* net/browse-url.el (browse-url-encode-url): Use copy-sequence.
 	Reported by Jan Dj,Ad(Brv <jan.h.d@swipnet.se>.
 
-2007-09-10  Stefan Monnier  <monnier@iro.umontreal.ca>
-
-	* progmodes/python.el: Merge changes from Dave Love's v2007-Sep-10.
-	(python-font-lock-keywords): Update to the 2.5 version of the language.
-	(python-quote-syntax): Let-bind font-lock-syntactic-keywords to nil.
-	(python-backspace): Only behave funny in code.
-	(python-compilation-regexp-alist): Add PDB stack trace regexp.
-	(inferior-python-mode): Add PDB prompt regexp.
-	(python-fill-paragraph): Refine the fenced-string regexp.
-	(python-find-imports): Handle imports spanning several lines.
-	(python-mode): Add `class' to hideshow support.
-
 2007-09-10  Dave Love  <fx@gnu.org>
 
 	* outline.el (outline-4, outline-5, outline-7):
--- a/lisp/ChangeLog.12	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ChangeLog.12	Wed Jan 30 07:57:28 2008 +0000
@@ -250,7 +250,7 @@
 2007-04-15  Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de>
 
 	* textmodes/bibtex.el (bibtex-field-list): Use functionp.
-	(bibtex-make-field): Check that INIT is a string. Use functionp.
+	(bibtex-make-field): Check that INIT is a string.  Use functionp.
 
 2007-04-14  Glenn Morris  <rgm@gnu.org>
 
@@ -1214,7 +1214,7 @@
 	* progmodes/idlw-help.el (idlwave-do-context-help1): Don't visit
 	special help topics for keywords.
 	(idlwave-help-assistant-command): Include ".exe" for ms-dos
-	etc. Assistant command.
+	etc.  Assistant command.
 
 2007-03-08  Chong Yidong  <cyd@stupidchicken.com>
 
@@ -2133,7 +2133,7 @@
 	(newsticker--decode-iso8601-date): Bugfix for datestrings without
 	days.
 	(newsticker--buffer-do-insert-text): Fix.
-	(newsticker--buffer-insert-enclosure): Fix. length might be missing.
+	(newsticker--buffer-insert-enclosure): Fix.  Length might be missing.
 	(newsticker--buffer-make-item-completely-visible):
 	`switch-to-buffer' not necessary.
 
@@ -5365,7 +5365,7 @@
 	After 5.3, 5.4:
 	(cperl-facemenu-add-face-function): Add docs, fix U<>.
 	Copyright message updated.
-	(cperl-init-faces): Work around a bug in `font-lock'. May slow
+	(cperl-init-faces): Work around a bug in `font-lock'.  May slow
 			facification down a bit.
 		Misprint for my|our|local for old `font-lock'
 			"our" was not fontified same as "my|local".
@@ -5881,7 +5881,7 @@
 
 2006-09-26  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
-	* progmodes/ebnf2ps.el: Doc fix. Implement arrow spacing and scaling.
+	* progmodes/ebnf2ps.el: Doc fix.  Implement arrow spacing and scaling.
 	(ebnf-version): New version 4.3.
 	(ebnf-arrow-extra-width, ebnf-arrow-scale): New options.
 	(ebnf-prologue): Adjust PostScript programming.
@@ -33349,7 +33349,7 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
--- a/lisp/ChangeLog.6	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ChangeLog.6	Wed Jan 30 07:57:28 2008 +0000
@@ -2769,7 +2769,7 @@
 	(gnus-request-accept-article): Make sure there's a newline at the
 	end of the buffer.
 	(gnus-adjust-marked-articles): Don't remove illegal ticked
-	articles (for forwards compatability).
+	articles (for forwards compatibility).
 
 1996-02-03  Lars Magne Ingebrigtsen  <larsi@aegir.ifi.uio.no>
 
--- a/lisp/ChangeLog.unicode	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ChangeLog.unicode	Wed Jan 30 07:57:28 2008 +0000
@@ -8,6 +8,11 @@
 
 	* international/characters.el (script-list): Add cham.
 
+2008-01-17  Mark A. Hershberger  <mah@everybody.org>
+
+	* xml.el (xml-escape-string): Don't do any encoding changes on the
+	string.
+
 2008-01-16  Kenichi Handa  <handa@ni.aist.go.jp>
 
 	* language/ind-util.el (in-is13194-post-read-conversion): Delete
--- a/lisp/abbrev.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/abbrev.el	Wed Jan 30 07:57:28 2008 +0000
@@ -524,7 +524,9 @@
       (aset table i 0))
     ;; Preserve the table's properties.
     (assert sym)
-    (intern sym table)
+    (let ((newsym (intern "" table)))
+      (set newsym nil)	     ; Make sure it won't be confused for an abbrev.
+      (setplist newsym (symbol-plist sym)))
     (abbrev-table-put table :abbrev-table-modiff
                       (1+ (abbrev-table-get table :abbrev-table-modiff)))))
 
--- a/lisp/add-log.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/add-log.el	Wed Jan 30 07:57:28 2008 +0000
@@ -240,8 +240,11 @@
 ;; backward-compatibility alias
 (put 'change-log-acknowledgement-face 'face-alias 'change-log-acknowledgement)
 
+(defconst change-log-file-names-re "^\\( +\\|\t\\)\\* \\([^ ,:([\n]+\\)")
+(defconst change-log-start-entry-re "^\\sw.........[0-9:+ ]*")
+
 (defvar change-log-font-lock-keywords
-  '(;;
+  `(;;
     ;; Date lines, new (2000-01-01) and old (Sat Jan  1 00:00:00 2000) styles.
     ;; Fixme: this regepx is just an approximate one and may match
     ;; wrongly with a non-date line existing as a random note.  In
@@ -255,7 +258,7 @@
       (2 'change-log-email)))
     ;;
     ;; File names.
-    ("^\\( +\\|\t\\)\\* \\([^ ,:([\n]+\\)"
+    (,change-log-file-names-re
      (2 'change-log-file)
      ;; Possibly further names in a list:
      ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 'change-log-file))
@@ -287,10 +290,49 @@
      3 'change-log-acknowledgement))
   "Additional expressions to highlight in Change Log mode.")
 
+(defun change-log-search-file-name (where)
+  "Return the file-name for the change under point."
+  (save-excursion
+    (goto-char where)
+    (beginning-of-line 1)
+    (if (looking-at change-log-start-entry-re)
+	;; We are at the start of an entry, search forward for a file
+	;; name.
+	(progn
+	  (re-search-forward change-log-file-names-re nil t)
+	  (match-string 2))
+      (if (looking-at change-log-file-names-re)
+	  ;; We found a file name.
+	  (match-string 2)
+	;; Look backwards for either a file name or the log entry start.
+	(if (re-search-backward
+	     (concat "\\(" change-log-start-entry-re 
+		     "\\)\\|\\("
+		     change-log-file-names-re "\\)") nil t)
+	    (if (match-beginning 1)
+		;; We got the start of the entry, look forward for a
+		;; file name.
+		(progn
+		  (re-search-forward change-log-file-names-re nil t)
+		  (match-string 2))
+	      (match-string 4))
+	  ;; We must be before any file name, look forward.
+	  (re-search-forward change-log-file-names-re nil t)
+	  (match-string 2))))))
+
+(defun change-log-find-file ()
+  "Visit the file for the change under point."
+  (interactive)
+  (let ((file (change-log-search-file-name (point))))
+    (if (and file (file-exists-p file))
+	(find-file file)
+      (message "No such file or directory: %s" file))))
+
 (defvar change-log-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [?\C-c ?\C-p] 'add-log-edit-prev-comment)
     (define-key map [?\C-c ?\C-n] 'add-log-edit-next-comment)
+    (define-key map [?\C-c ?\C-f] 'change-log-find-file)
     map)
   "Keymap for Change Log major mode.")
 
@@ -1101,8 +1143,6 @@
 	  (change-log-get-method-definition-1 ""))
 	(concat change-log-get-method-definition-md "]"))))))
 
-(defconst change-log-start-entry-re "^\\sw.........[0-9:+ ]*")
-
 (defun change-log-sortable-date-at ()
   "Return date of log entry in a consistent form for sorting.
 Point is assumed to be at the start of the entry."
--- a/lisp/allout.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/allout.el	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 
 ;; Author: Ken Manheimer <ken dot manheimer at gmail dot com>
 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com>
-;; Created: Dec 1991 - first release to usenet
+;; Created: Dec 1991 -- first release to usenet
 ;; Version: 2.2.1
 ;; Keywords: outlines wp languages
 ;; Website: http://myriadicity.net/Sundry/EmacsAllout
@@ -36,11 +36,11 @@
 ;;  - Topic-oriented editing including coherent topic and subtopic
 ;;    creation, promotion, demotion, cut/paste across depths, etc.
 ;;  - Incremental search with dynamic exposure and reconcealment of text
-;;  - Customizable bullet format - enables programming-language specific
+;;  - Customizable bullet format -- enables programming-language specific
 ;;    outlining, for code-folding editing.  (Allout code itself is to try it;
-;;    formatted as an outline - do ESC-x eval-buffer in allout.el; but
+;;    formatted as an outline -- do ESC-x eval-buffer in allout.el; but
 ;;    emacs local file variables need to be enabled when the
-;;    file was visited - see `enable-local-variables'.)
+;;    file was visited -- see `enable-local-variables'.)
 ;;  - Configurable per-file initial exposure settings
 ;;  - Symmetric-key and key-pair topic encryption, plus symmetric passphrase
 ;;    mnemonic support, with verification against an established passphrase
@@ -53,7 +53,7 @@
 ;;    exposure control (see the allout-mode docstring)
 ;;  - Easy rendering of exposed portions into numbered, latex, indented, etc
 ;;    outline styles
-;;  - Careful attention to whitespace - enabling blank lines between items
+;;  - Careful attention to whitespace -- enabling blank lines between items
 ;;    and maintenance of hanging indentation (in paragraph auto-fill and
 ;;    across topic promotion and demotion) of topic bodies consistent with
 ;;    indentation of their topic header.
@@ -76,7 +76,7 @@
 ;; `allout-mode' as a minor mode.  (It has changed since allout
 ;; 3.x, for those of you that depend on the old method.)
 ;;
-;; Note - the lines beginning with `;;;_' are outline topic headers.
+;; Note -- the lines beginning with `;;;_' are outline topic headers.
 ;;        Just `ESC-x eval-buffer' to give it a whirl.
 
 ;; ken manheimer (ken dot manheimer at gmail dot com)
@@ -117,12 +117,12 @@
 willing to let allout use a bunch of \C-c keybindings."
   :type 'string
   :group 'allout)
+
 ;;;_  = allout-keybindings-list
-;;; You have to reactivate allout-mode - `(allout-mode t)' - to
+;;; You have to reactivate allout-mode -- `(allout-mode t)' -- to
 ;;; institute changes to this var.
 (defvar allout-keybindings-list ()
   "*List of `allout-mode' key / function bindings, for `allout-mode-map'.
-
 String or vector key will be prefaced with `allout-command-prefix',
 unless optional third, non-nil element is present.")
 (setq allout-keybindings-list
@@ -155,11 +155,11 @@
         ("*" allout-rebullet-current-heading)
         ("#" allout-number-siblings)
         ("\C-k" allout-kill-line t)
-        ("\M-k" allout-copy-line-as-kill t)
+        ([?\M-k] allout-copy-line-as-kill t)
         ("\C-y" allout-yank t)
-        ("\M-y" allout-yank-pop t)
+        ([?\M-y] allout-yank-pop t)
         ("\C-k" allout-kill-topic)
-        ("\M-k" allout-copy-topic-as-kill)
+        ([?\M-k] allout-copy-topic-as-kill)
                                         ; Miscellaneous commands:
 	;([?\C-\ ] allout-mark-topic)
         ("@" allout-resolve-xref)
@@ -170,7 +170,7 @@
 
 ;;;_  = allout-auto-activation
 (defcustom allout-auto-activation nil
-  "*Regulates auto-activation modality of allout outlines - see `allout-init'.
+  "*Regulates auto-activation modality of allout outlines -- see `allout-init'.
 
 Setq-default by `allout-init' to regulate whether or not allout
 outline mode is automatically activated when the buffer-specific
@@ -212,35 +212,35 @@
 
 The types of elements in the layout specification are:
 
- integer - dictate the relative depth to open the corresponding topic(s),
-           where:
-         - negative numbers force the topic to be closed before opening
-           to the absolute value of the number, so all siblings are open
-           only to that level.
-         - positive numbers open to the relative depth indicated by the
-           number, but do not force already opened subtopics to be closed.
-         - 0 means to close topic - hide all subitems.
- :   - repeat spec - apply the preceeding element to all siblings at
-       current level, *up to* those siblings that would be covered by specs
-       following the `:' on the list.  Ie, apply to all topics at level but
-       trailing ones accounted for by trailing specs.  (Only the first of
-       multiple colons at the same level is honored - later ones are ignored.)
- *   - completely exposes the topic, including bodies
- +   - exposes all subtopics, but not the bodies
- -   - exposes the body of the corresponding topic, but not subtopics
- list - a nested layout spec, to be applied intricately to its
+ INTEGER -- dictate the relative depth to open the corresponding topic(s),
+            where:
+         -- negative numbers force the topic to be closed before opening
+            to the absolute value of the number, so all siblings are open
+            only to that level.
+         -- positive numbers open to the relative depth indicated by the
+            number, but do not force already opened subtopics to be closed.
+         -- 0 means to close topic -- hide all subitems.
+ :   -- repeat spec -- apply the preceeding element to all siblings at
+        current level, *up to* those siblings that would be covered by specs
+        following the `:' on the list.  Ie, apply to all topics at level but
+        trailing ones accounted for by trailing specs.  (Only the first of
+        multiple colons at the same level is honored -- later ones are ignored.)
+ *   -- completely exposes the topic, including bodies
+ +   -- exposes all subtopics, but not the bodies
+ -   -- exposes the body of the corresponding topic, but not subtopics
+ LIST -- a nested layout spec, to be applied intricately to its
         corresponding item(s)
 
 Examples:
- '(-2 : 0)
+ (-2 : 0)
 	Collapse the top-level topics to show their children and
         grandchildren, but completely collapse the final top-level topic.
- '(-1 () : 1 0)
+ (-1 () : 1 0)
 	Close the first topic so only the immediate subtopics are shown,
         leave the subsequent topics exposed as they are until the second
 	second to last topic, which is exposed at least one level, and
         completely close the last topic.
- '(-2 : -1 *)
+ (-2 : -1 *)
         Expose children and grandchildren of all topics at current
 	level except the last two; expose children of the second to
 	last and completely expose the last one, including its subtopics.
@@ -283,7 +283,7 @@
 (defcustom allout-use-hanging-indents t
   "*If non-nil, topic body text auto-indent defaults to indent of the header.
 Ie, it is indented to be just past the header prefix.  This is
-relevant mostly for use with indented-text-mode, or other situations
+relevant mostly for use with `indented-text-mode', or other situations
 where auto-fill occurs."
   :type 'boolean
   :group 'allout)
@@ -360,7 +360,7 @@
 Cycling only happens on when the command is repeated, not when it
 follows a different command.
 
-Smart-placement means that repeated calls to this function will
+Smart placement means that repeated calls to this function will
 advance as follows:
 
  - if the cursor is not on the end-of-line,
@@ -442,25 +442,25 @@
 purely by convention, however.  Some conventions suggest
 themselves:
 
- `(' - open paren - an aside or incidental point
- `?' - question mark - uncertain or outright question
- `!' - exclamation point/bang - emphatic
- `[' - open square bracket - meta-note, about item instead of item's subject
- `\"' - double quote - a quotation or other citation
- `=' - equal sign - an assignement, equating a name with some connotation
- `^' - carat - relates to something above
+ `(' - open paren -- an aside or incidental point
+ `?' - question mark -- uncertain or outright question
+ `!' - exclamation point/bang -- emphatic
+ `[' - open square bracket -- meta-note, about item instead of item's subject
+ `\"' - double quote -- a quotation or other citation
+ `=' - equal sign -- an assignement, equating a name with some connotation
+ `^' - carat -- relates to something above
 
 Some are more elusive, but their rationale may be recognizable:
 
- `+' - plus - pending consideration, completion
- `_' - underscore - done, completed
- `&' - ampersand - addendum, furthermore
+ `+' - plus -- pending consideration, completion
+ `_' - underscore -- done, completed
+ `&' - ampersand -- addendum, furthermore
 
 \(Some other non-plain bullets have special meaning to the
 software.  By default:
 
- `~' marks encryptable topics - see `allout-topic-encryption-bullet'
- `#' marks auto-numbered bullets - see `allout-numbered-bullet'.)
+ `~' marks encryptable topics -- see `allout-topic-encryption-bullet'
+ `#' marks auto-numbered bullets -- see `allout-numbered-bullet'.)
 
 See `allout-plain-bullets-string' for the standard, alternating
 bullets.
@@ -502,7 +502,7 @@
 the header-prefix, and an `_' underscore is tacked on the end, to
 distinguish them from regular comment strings.  comment-start
 strings that do end in spaces are not tripled, but an underscore
-is substituted for the space. [This presumes that the space is
+is substituted for the space.  [This presumes that the space is
 for appearance, not comment syntax.  You can use
 `allout-mode-leaders' to override this behavior, when
 undesired.]"
@@ -543,7 +543,7 @@
 ;;;###autoload
 (put 'allout-old-style-prefixes 'safe-local-variable
      (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil)))))
-;;;_  = allout-stylish-prefixes - alternating bullets
+;;;_  = allout-stylish-prefixes -- alternating bullets
 (defcustom allout-stylish-prefixes t
   "*Do fancy stuff with topic prefix bullets according to level, etc.
 
@@ -707,9 +707,9 @@
 (defcustom allout-passphrase-hint-handling 'always
   "*Dictate outline encryption passphrase reminder handling:
 
- always - always show reminder when prompting
- needed - show reminder on passphrase entry failure
- disabled - never present or adjust reminder
+ always -- always show reminder when prompting
+ needed -- show reminder on passphrase entry failure
+ disabled -- never present or adjust reminder
 
 See the docstring for the `allout-enable-file-variable-adjustment'
 variable for details about allout ajustment of file variables."
@@ -732,7 +732,7 @@
         can continue editing but the copy on the file system will be
         encrypted.)
         Auto-saves will use the \"All except current topic\" mode if this
-        one is selected, to avoid practical difficulties - see below.
+        one is selected, to avoid practical difficulties -- see below.
  - All except current topic: skip the topic currently being edited, even if
        it's pending encryption.  This may expose the current topic on the
        file sytem, but avoids the nuisance of prompts for the encryption
@@ -790,7 +790,7 @@
   :group 'allout)
 (make-variable-buffer-local 'allout-enable-file-variable-adjustment)
 
-;;;_* CODE - no user customizations below.
+;;;_* CODE -- no user customizations below.
 
 ;;;_ #1 Internal Outline Formatting and Configuration
 ;;;_  : Version
@@ -810,7 +810,7 @@
 (defvar allout-mode nil "Allout outline mode minor-mode flag.")
 (make-variable-buffer-local 'allout-mode)
 ;;;_   = allout-layout nil
-(defvar allout-layout nil            ; LEAVE GLOBAL VALUE NIL - see docstring.
+(defvar allout-layout nil            ; LEAVE GLOBAL VALUE NIL -- see docstring.
   "Buffer-specific setting for allout layout.
 
 In buffers where this is non-nil (and if `allout-init' has been run, to
@@ -854,7 +854,7 @@
 (defvar allout-bullets-string ""
   "A string dictating the valid set of outline topic bullets.
 
-This var should *not* be set by the user - it is set by `set-allout-regexp',
+This var should *not* be set by the user -- it is set by `set-allout-regexp',
 and is produced from the elements of `allout-plain-bullets-string'
 and `allout-distinctive-bullets-string'.")
 (make-variable-buffer-local 'allout-bullets-string)
@@ -886,7 +886,7 @@
 (make-variable-buffer-local 'allout-depth-one-regexp)
 ;;;_   = allout-line-boundary-regexp
 (defvar allout-line-boundary-regexp ()
-  "`allout-regexp' with outline style beginning-of-line anchor.
+  "`allout-regexp' prepended with a newline for the search target.
 
 This is properly set by `set-allout-regexp'.")
 (make-variable-buffer-local 'allout-line-boundary-regexp)
@@ -970,7 +970,7 @@
 					  comment-start
 					  t)))
 			      allout-use-mode-specific-leader
-			    ;; Oops - garbled value, equate with effect of 't:
+			    ;; Oops -- garbled value, equate with effect of t:
 			    t)))
 	 (leader
 	  (cond
@@ -998,8 +998,8 @@
 	nil
       (setq allout-header-prefix leader)
       (if (not allout-old-style-prefixes)
-          ;; setting allout-primary-bullet makes the top level topics use -
-          ;; actually, be - the special prefix:
+          ;; setting allout-primary-bullet makes the top level topics use --
+          ;; actually, be -- the special prefix:
           (setq allout-primary-bullet leader))
       allout-header-prefix)))
 (defalias 'allout-infer-header-lead
@@ -1058,7 +1058,7 @@
   (setq allout-plain-bullets-string-len (length allout-plain-bullets-string))
   (setq allout-header-subtraction (1- (length allout-header-prefix)))
 
-  (let (new-part old-part)
+  (let (new-part old-part formfeed-part)
     (setq new-part (concat "\\("
                            (regexp-quote allout-header-prefix)
                            "[ \t]*"
@@ -1072,18 +1072,26 @@
                            "\\)"
                            "+"
                            " ?[^" allout-primary-bullet "]")
+          formfeed-part "\\(\^L\\)"
+
           allout-regexp (concat new-part
                                 "\\|"
                                 old-part
-                                "\\|\^l")
+                                "\\|"
+                                formfeed-part)
 
           allout-line-boundary-regexp (concat "\n" new-part
                                               "\\|"
-                                              "\n" old-part)
+                                              "\n" old-part
+                                              "\\|"
+                                              "\n" formfeed-part)
 
           allout-bob-regexp (concat "\\`" new-part
                                     "\\|"
-                                    "\\`" old-part))
+                                    "\\`" old-part
+                                    "\\|"
+                                    "\\`" formfeed-part
+                                    ))
 
     (setq allout-depth-specific-regexp
           (concat "\\(^\\|\\`\\)"
@@ -1140,10 +1148,10 @@
 (defvar allout-mode-map nil "Keybindings for (allout) outline minor mode.")
 ;;;_   > produce-allout-mode-map (keymap-alist &optional base-map)
 (defun produce-allout-mode-map (keymap-list &optional base-map)
-  "Produce keymap for use as allout-mode-map, from KEYMAP-LIST.
+  "Produce keymap for use as `allout-mode-map', from KEYMAP-LIST.
 
 Built on top of optional BASE-MAP, or empty sparse map if none specified.
-See doc string for allout-keybindings-list for format of binding list."
+See doc string for `allout-keybindings-list' for format of binding list."
   (let ((map (or base-map (make-sparse-keymap)))
 	(pref (list allout-command-prefix)))
     (mapc (function
@@ -1255,7 +1263,7 @@
 element of the pair onto the end of the existing value.
 
 Extension, and resumptions in general, should not be used for hook
-functions - use the 'local mode of `add-hook' for that, instead.
+functions -- use the 'local mode of `add-hook' for that, instead.
 
 The settings are stored on `allout-mode-prior-settings'."
   (while pairs
@@ -1274,7 +1282,7 @@
       (when (not (assoc name allout-mode-prior-settings))
         ;; Not already added as a resumption, create the prior setting entry.
         (if (local-variable-p name)
-            ;; is already local variable - preserve the prior value:
+            ;; is already local variable -- preserve the prior value:
             (push (list name prior-value) allout-mode-prior-settings)
           ;; wasn't local variable, indicate so for resumption by killing
           ;; local value, and make it local:
@@ -1340,9 +1348,9 @@
 
 Functions on the hook must take three arguments:
 
- - from - integer indicating the point at the start of the change.
- - to - integer indicating the point of the end of the change.
- - flag - change mode: nil for exposure, otherwise concealment.
+ - FROM -- integer indicating the point at the start of the change.
+ - TO -- integer indicating the point of the end of the change.
+ - FLAG -- change mode: nil for exposure, otherwise concealment.
 
 This hook might be invoked multiple times by a single command.
 
@@ -1354,10 +1362,10 @@
 
 Functions on the hook should take two arguments:
 
- - new-start - integer indicating the point at the start of the first new item.
- - new-end - integer indicating the point of the end of the last new item.
-
-Some edits that introduce new items may missed by this hook -
+ - NEW-START -- integer indicating position of start of the first new item.
+ - NEW-END -- integer indicating position of end of the last new item.
+
+Some edits that introduce new items may missed by this hook:
 specifically edits that native allout routines do not control.
 
 This hook might be invoked multiple times by a single command.")
@@ -1367,10 +1375,10 @@
 
 Functions on the hook must take two arguments:
 
- - depth - integer indicating the depth of the subtree that was deleted.
- - removed-from - integer indicating the point where the subtree was removed.
-
-Some edits that remove or invalidate items may missed by this hook -
+ - DEPTH -- integer indicating the depth of the subtree that was deleted.
+ - REMOVED-FROM -- integer indicating the point where the subtree was removed.
+
+Some edits that remove or invalidate items may missed by this hook:
 specifically edits that native allout routines do not control.
 
 This hook might be invoked multiple times by a single command.")
@@ -1380,10 +1388,10 @@
 
 Functions on the hook should take two arguments:
 
- - depth-change - integer indicating depth increase, negative for decrease
- - start - integer indicating the start point of the shifted parent item.
-
-Some edits that shift items can be missed by this hook - specifically edits
+ - DEPTH-CHANGE -- integer indicating depth increase, negative for decrease
+ - START -- integer indicating the start point of the shifted parent item.
+
+Some edits that shift items can be missed by this hook: specifically edits
 that native allout routines do not control.
 
 This hook might be invoked multiple times by a single command.")
@@ -1460,7 +1468,7 @@
   "Variable for regexps matching plaintext to remove before encryption.
 
 This is for the sake of redoing encryption in cases where the ciphertext
-incidentally contains strings that would disrupt mode operation -
+incidentally contains strings that would disrupt mode operation --
 for example, a line that happens to look like an allout-mode topic prefix.
 
 Entries must be symbols that are bound to the desired regexp values.
@@ -1478,7 +1486,7 @@
 (make-variable-buffer-local 'allout-encryption-ciphertext-rejection-ceiling)
 ;;;_   > allout-mode-p ()
 ;; Must define this macro above any uses, or byte compilation will lack
-;; proper def, if file isn't loaded - eg, during emacs build!
+;; proper def, if file isn't loaded -- eg, during emacs build!
 (defmacro allout-mode-p ()
   "Return t if `allout-mode' is active in current buffer."
   'allout-mode)
@@ -1501,13 +1509,12 @@
             (condition-case failure
                 (setq allout-after-save-decrypt
                       (allout-encrypt-decrypted except-mark))
-	      (message "allout-write-file-hook-handler suppressing error %s"
-		       failure)
-	      (sit-for 2)
-	      (error "allout-write-file-hook-handler suppressing error %s"
-		     failure))))
+              (error (message
+                      "allout-write-file-hook-handler suppressing error %s"
+                      failure)
+                     (sit-for 2)))))
       ))
-    nil)
+  nil)
 ;;;_   > allout-auto-save-hook-handler ()
 (defun allout-auto-save-hook-handler ()
   "Implement `allout-encrypt-unencrypted-on-saves' policy for auto save."
@@ -1653,9 +1660,9 @@
   (put 'allout-exposure-category 'invisible 'allout)
   (put 'allout-exposure-category 'evaporate t)
   ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook.  The
-  ;; latter would be sufficient, but it seems that a separate behavior -
-  ;; the _transient_ opening of invisible text during isearch - is keyed to
-  ;; presence of the isearch-open-invisible property - even though this
+  ;; latter would be sufficient, but it seems that a separate behavior --
+  ;; the _transient_ opening of invisible text during isearch -- is keyed to
+  ;; presence of the isearch-open-invisible property -- even though this
   ;; property controls the isearch _arrival_ behavior.  This is the case at
   ;; least in emacs 21, 22.0, and xemacs 21.4.
   (put 'allout-exposure-category 'isearch-open-invisible
@@ -1709,7 +1716,7 @@
 `\\C-c' as the command prefix, if the allout bindings don't conflict with
 any personal bindings you have on \\C-c.  In any case, outline structure
 navigation and authoring is simplified by positioning the cursor on an
-item's bullet character, the \"hot-spot\" - then you can invoke allout
+item's bullet character, the \"hot-spot\" -- then you can invoke allout
 commands with just the un-prefixed, un-control-shifted command letters.
 This is described further in the HOT-SPOT Operation section.
 
@@ -1730,7 +1737,7 @@
 \\[allout-backward-current-level] `allout-backward-current-level'
 \\[allout-end-of-entry] `allout-end-of-entry'
 \\[allout-beginning-of-current-entry] `allout-beginning-of-current-entry' (alternately, goes to hot-spot)
-\\[allout-beginning-of-line]  `allout-beginning-of-line' - like regular beginning-of-line, but
+\\[allout-beginning-of-line]  `allout-beginning-of-line' -- like regular beginning-of-line, but
      if immediately repeated cycles to the beginning of the current item
      and then to the hot-spot (if `allout-beginning-of-line-cycles' is set).
 
@@ -1748,9 +1755,9 @@
 \\[allout-rebullet-current-heading] `allout-rebullet-current-heading' Prompt for alternate bullet for
             current topic
 \\[allout-rebullet-topic] `allout-rebullet-topic'   Reconcile bullets of topic and
-            its' offspring - distinctive bullets are not changed, others
+            its' offspring -- distinctive bullets are not changed, others
             are alternated according to nesting depth.
-\\[allout-number-siblings] `allout-number-siblings'  Number bullets of topic and siblings -
+\\[allout-number-siblings] `allout-number-siblings'  Number bullets of topic and siblings --
            the offspring are not affected.
            With repeat count, revoke numbering.
 
@@ -1779,7 +1786,7 @@
 \\[allout-copy-exposed-to-buffer] `allout-copy-exposed-to-buffer'
                             Duplicate outline, sans concealed text, to
                             buffer with name derived from derived from that
-                            of current buffer - \"*BUFFERNAME exposed*\".
+                            of current buffer -- \"*BUFFERNAME exposed*\".
 \\[allout-flatten-exposed-to-buffer] `allout-flatten-exposed-to-buffer'
                             Like above 'copy-exposed', but convert topic
                             prefixes to section.subsection... numeric
@@ -1848,7 +1855,7 @@
 
                             Terminology
 
-Topic hierarchy constituents - TOPICS and SUBTOPICS:
+Topic hierarchy constituents -- TOPICS and SUBTOPICS:
 
 ITEM:   A unitary outline element, including the HEADER and ENTRY text.
 TOPIC:  An ITEM and any ITEMs contained within it, ie having greater DEPTH
@@ -1956,7 +1963,7 @@
 
     (cond
 
-     ;; Provision for v19.18, 19.19 bug -
+     ;; Provision for v19.18, 19.19 bug --
      ;; Emacs v 19.18, 19.19 file-var code invokes prop-line-designated
      ;; modes twice when file is visited.  We have to avoid toggling mode
      ;; off on second invocation, so we detect it as best we can, and
@@ -2101,7 +2108,7 @@
                 (progn
                   (apply 'allout-expose-topic (list use-layout))
                   (message "Adjusting '%s' exposure... done." (buffer-name)))
-              ;; Problem applying exposure - notify user, but don't
+              ;; Problem applying exposure -- notify user, but don't
               ;; interrupt, eg, file visit:
               (error (message "%s" (car (cdr err)))
                      (sit-for 1))))))
@@ -2136,6 +2143,16 @@
 ;;;_  > allout-minor-mode
 (defalias 'allout-minor-mode 'allout-mode)
 
+;;;_  > allout-unload-function
+(defun allout-unload-function ()
+  "Unload the allout outline library."
+  (save-current-buffer
+    (dolist (buffer (buffer-list))
+      (set-buffer buffer)
+      (when allout-mode (allout-mode -1))))
+  ;; continue standard unloading
+  nil)
+
 ;;;_  - Position Assessment
 ;;;_   > allout-hidden-p (&optional pos)
 (defsubst allout-hidden-p (&optional pos)
@@ -2158,10 +2175,10 @@
   "Get confirmation before making arbitrary changes to invisible text.
 
 We expose the invisible text and ask for confirmation.  Refusal or
-keyboard-quit abandons the changes, with keyboard-quit additionally
+`keyboard-quit' abandons the changes, with keyboard-quit additionally
 reclosing the opened text.
 
-No confirmation is necessary when inhibit-read-only is set - eg, allout
+No confirmation is necessary when `inhibit-read-only' is set -- eg, allout
 internal functions use this feature cohesively bunch changes."
 
   (when (and (not inhibit-read-only) (not after))
@@ -2199,7 +2216,7 @@
 (defun allout-before-change-handler (beg end)
   "Protect against changes to invisible text.
 
-See allout-overlay-interior-modification-handler for details."
+See `allout-overlay-interior-modification-handler' for details."
 
   (if (and (allout-mode-p) undo-in-progress (allout-hidden-p))
       (allout-show-to-offshoot))
@@ -2224,7 +2241,7 @@
   (if (and (allout-mode-p) (allout-hidden-p))
       (allout-show-to-offshoot)))
 
-;;;_ #3 Internal Position State-Tracking - "allout-recent-*" funcs
+;;;_ #3 Internal Position State-Tracking -- "allout-recent-*" funcs
 ;;; All the basic outline functions that directly do string matches to
 ;;; evaluate heading prefix location set the variables
 ;;; `allout-recent-prefix-beginning'  and `allout-recent-prefix-end'
@@ -2252,10 +2269,12 @@
 (defsubst allout-prefix-data ()
   "Register allout-prefix state data.
 
-For reference by `allout-recent' funcs.  Returns BEGINNING."
-  (setq allout-recent-prefix-end (or (match-end 1) (match-end 2))
+For reference by `allout-recent' funcs.  Return
+the new value of `allout-recent-prefix-beginning'."
+  (setq allout-recent-prefix-end (or (match-end 1) (match-end 2) (match-end 3))
         allout-recent-prefix-beginning (or (match-beginning 1)
-                                           (match-beginning 2))
+                                           (match-beginning 2)
+                                           (match-beginning 3))
         allout-recent-depth (max 1 (- allout-recent-prefix-end
                                       allout-recent-prefix-beginning
                                       allout-header-subtraction)))
@@ -2306,7 +2325,7 @@
 (defsubst allout-do-doublecheck ()
   "True if current item conditions qualify for checking on topic aberrance."
   (and
-   ;; presume integrity of outline and yanked content during yank - necessary,
+   ;; presume integrity of outline and yanked content during yank -- necessary
    ;; to allow for level disparity of yank location and yanked text:
    (not allout-inhibit-aberrance-doublecheck)
    ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck:
@@ -2344,12 +2363,12 @@
           (allout-prefix-data)
           (goto-char allout-recent-prefix-beginning)
           (cond
-           ;; sibling - continue:
+           ;; sibling -- continue:
            ((eq allout-recent-depth depth))
-           ;; first offspring is excessive - aberrant:
+           ;; first offspring is excessive -- aberrant:
            ((> allout-recent-depth (1+ depth))
             (setq done t aberrant t))
-           ;; next non-sibling is lower-depth - not aberrant:
+           ;; next non-sibling is lower-depth -- not aberrant:
            (t (setq done t))))))
     (if aberrant
         aberrant
@@ -2384,6 +2403,8 @@
 (defun allout-depth ()
   "Return depth of topic most immediately containing point.
 
+Does not do doublecheck for aberrant topic header.
+
 Return zero if point is not within any topic.
 
 Like `allout-current-depth', but respects hidden as well as visible topics."
@@ -2490,7 +2511,7 @@
 ;;;_   > allout-end-of-current-line ()
 (defun allout-end-of-current-line ()
   "Move to the end of line, past concealed text if any."
-  ;; XXX This is for symmetry with `allout-beginning-of-current-line' -
+  ;; XXX This is for symmetry with `allout-beginning-of-current-line' --
   ;; `move-end-of-line' doesn't suffer the same problem as
   ;; `move-beginning-of-line'.
   (let ((inhibit-field-text-motion t))
@@ -2564,7 +2585,7 @@
 
 Returns the location of the heading, or nil if none found.
 
-We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
+We skip anomalous low-level topics, a la `allout-aberrant-container-p'."
   (save-match-data
 
     (if (looking-at allout-regexp)
@@ -2572,10 +2593,14 @@
 
     (when (re-search-forward allout-line-boundary-regexp nil 0)
       (allout-prefix-data)
+      (goto-char allout-recent-prefix-beginning)
+      (while (not (bolp))
+        (forward-char -1))
       (and (allout-do-doublecheck)
            ;; this will set allout-recent-* on the first non-aberrant topic,
            ;; whether it's the current one or one that disqualifies it:
            (allout-aberrant-container-p))
+      ;; this may or may not be the same as above depending on doublecheck:
       (goto-char allout-recent-prefix-beginning))))
 ;;;_   > allout-this-or-next-heading
 (defun allout-this-or-next-heading ()
@@ -2589,7 +2614,7 @@
 
 Return the location of the beginning of the heading, or nil if not found.
 
-We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
+We skip anomalous low-level topics, a la `allout-aberrant-container-p'."
 
   (if (bobp)
       nil
@@ -2687,9 +2712,9 @@
 		       ;; Register this one and move on:
 		       (setq chart (cons allout-recent-prefix-beginning chart))
 		       (if (and levels (<= levels 1))
-			   ;; At depth limit - skip sublevels:
+			   ;; At depth limit -- skip sublevels:
 			   (or (allout-next-sibling curr-depth)
-			       ;; or no more siblings - proceed to
+			       ;; or no more siblings -- proceed to
 			       ;; next heading at lesser depth:
 			       (while (and (<= curr-depth
 					       allout-recent-depth)
@@ -2762,7 +2787,7 @@
 	  (let ((further (allout-chart-to-reveal here (if (null depth)
                                                           depth
                                                         (1- depth)))))
-	    ;; We're on the start of a subtree - recurse with it, if there's
+	    ;; We're on the start of a subtree -- recurse with it, if there's
 	    ;; more depth to go:
 	    (if further (setq result (append further result)))
 	    (setq chart (cdr chart)))
@@ -3150,7 +3175,7 @@
           (progn (goto-char start-point)
                  nil)
         ;; rationale: if any intervening items were at a lower depth, we
-        ;; would now be on the first offspring at the target depth - ie,
+        ;; would now be on the first offspring at the target depth -- ie,
         ;; the preceeding item (per the search direction) must be at a
         ;; lesser depth.  that's all we need to check.
         (if backward (allout-next-heading) (allout-previous-heading))
@@ -3228,7 +3253,7 @@
                            (allout-aberrant-container-p))
                       ;; skip this aberrant prospective header line:
                       t
-                    ;; this prospective headerline qualifies - register:
+                    ;; this prospective headerline qualifies -- register:
                     (setq got allout-recent-prefix-beginning)
                     ;; and break the loop:
                     nil)))))
@@ -3396,7 +3421,7 @@
                                                     (>= 122 key-num)) ; "z"
                                                (- key-num 96) key-num)))
                                   t))))
-          ;; Qualified as an allout command - do hot-spot operation.
+          ;; Qualified as an allout command -- do hot-spot operation.
           (setq allout-post-goto-bullet t)
         ;; accept-defaults nil, or else we'll get allout-item-icon-key-handler.
         (setq mapped-binding (key-binding (char-to-string key-num))))
@@ -3498,7 +3523,7 @@
 topic at point, if non-nil.  Default bullet for new topics, eg, may
 be set (contingent to other args) to numbered bullets if previous
 sibling is one.  The implication otherwise is that the current topic
-is being adjusted - shifted or rebulleted - and we don't consider
+is being adjusted -- shifted or rebulleted -- and we don't consider
 bullet or previous sibling.
 
 Third arg DEPTH forces the topic prefix to that depth, regardless of
@@ -3544,11 +3569,11 @@
           ;; Getting value for bullet char is practically the whole job:
 
           (cond
-                                        ; Simplest situation - level 1:
+                                        ; Simplest situation -- level 1:
            ((<= depth 1) (setq header-lead "") allout-primary-bullet)
                                         ; Simple, too: all asterisks:
            (allout-old-style-prefixes
-            ;; Cheat - make body the whole thing, null out header-lead and
+            ;; Cheat -- make body the whole thing, null out header-lead and
             ;; bullet-char:
             (setq body (make-string depth
                                     (string-to-char allout-primary-bullet)))
@@ -3626,8 +3651,8 @@
   "Open a new topic at depth DEPTH.
 
 New topic is situated after current one, unless optional flag BEFORE
-is non-nil, or unless current line is completely empty - lacking even
-whitespace - in which case open is done on the current line.
+is non-nil, or unless current line is completely empty -- lacking even
+whitespace -- in which case open is done on the current line.
 
 When adding an offspring, it will be added immediately after the parent if
 the other offspring are exposed, or after the last child if the offspring
@@ -3692,7 +3717,7 @@
 
       (if (not opening-on-blank)
                                         ; Positioning and vertical
-                                        ; padding - only if not
+                                        ; padding -- only if not
                                         ; opening-on-blank:
           (progn
             (goto-char ref-topic)
@@ -3743,7 +3768,7 @@
                                  (open-line 1)))
                     (allout-end-of-current-subtree)
                     (if (looking-at "\n\n") (forward-char 1))))
-              ;; Going inwards - double-space if first offspring is
+              ;; Going inwards -- double-space if first offspring is
               ;; double-spaced, otherwise snug up.
               (allout-end-of-entry)
               (if (eobp)
@@ -3753,7 +3778,7 @@
               (backward-char 1)
               (if (bolp)
                   ;; Blank lines between current header body and next
-                  ;; header - get to last substantive (non-white-space)
+                  ;; header -- get to last substantive (non-white-space)
                   ;; line in body:
                   (progn (setq dbl-space t)
                          (re-search-backward "[^ \t\n]" nil t)))
@@ -3900,9 +3925,9 @@
 		  (not (looking-at allout-regexp)))
 	   (if (> 0 (setq excess (- (- old-indent-end old-indent-begin)
                                     old-margin)))
-	       ;; Text starts left of old margin - don't adjust:
+	       ;; Text starts left of old margin -- don't adjust:
 	       nil
-	     ;; Text was hanging at or right of old left margin -
+	     ;; Text was hanging at or right of old left margin --
 	     ;; reindent it, preserving its existing indentation
 	     ;; beyond the old margin:
 	     (delete-region old-indent-begin old-indent-end)
@@ -3963,9 +3988,9 @@
 numbered form.  It has effect only if `allout-numbered-bullet' is
 non-nil and soliciting was not explicitly invoked (via first arg).
 Its effect, numbering or denumbering, then depends on the setting
-of the forth arg, INDEX.
-
-If NUMBER-CONTROL is non-nil and forth arg INDEX is nil, then the
+of the fourth arg, INDEX.
+
+If NUMBER-CONTROL is non-nil and fourth arg INDEX is nil, then the
 prefix of the topic is forced to be non-numbered.  Null index and
 non-nil NUMBER-CONTROL forces denumbering.  Non-nil INDEX (and
 non-nil NUMBER-CONTROL) forces a numbered-prefix form.  If non-nil
@@ -4050,7 +4075,7 @@
 
 Descends into invisible as well as visible topics, however.
 
-When optional sans-offspring is non-nil, subtopics are not
+When optional SANS-OFFSPRING is non-nil, subtopics are not
 shifted.  (Shifting a topic outwards without shifting its
 offspring is disallowed, since this would create a \"containment
 discontinuity\", where the depth difference between a topic and
@@ -4095,7 +4120,7 @@
 are not shifted.  (Shifting a topic outwards without shifting
 its offspring is disallowed, since this would create a
 \"containment discontinuity\", where the depth difference between
-a topic and its immediate offspring is greater than one..)"
+a topic and its immediate offspring is greater than one.)"
 
   ;; XXX the recursion here is peculiar, and in general the routine may
   ;; need simplification with refactoring.
@@ -4160,7 +4185,7 @@
                                         nil)))) ;;; do-successors
 
           ((< starting-depth new-depth)
-           ;; Rare case - subtopic more than one level deeper than parent.
+           ;; Rare case -- subtopic more than one level deeper than parent.
            ;; Treat this one at an even deeper level:
            (allout-rebullet-topic-grunt relative-depth
                                          new-depth
@@ -4222,7 +4247,7 @@
 (defun allout-number-siblings (&optional denumber)
   "Assign numbered topic prefix to this topic and its siblings.
 
-With universal argument, denumber - assign default bullet to this
+With universal argument, denumber -- assign default bullet to this
 topic and its siblings.
 
 With repeated universal argument (`^U^U'), solicit bullet for each
@@ -4381,7 +4406,7 @@
    previous one.
 
 Topic exposure is marked with text-properties, to be used by
-allout-yank-processing for exposure recovery."
+`allout-yank-processing' for exposure recovery."
 
   (interactive)
   (let* ((inhibit-field-text-motion t)
@@ -4412,7 +4437,7 @@
     (run-hook-with-args 'allout-structure-deleted-hook depth (point))))
 ;;;_    > allout-copy-topic-as-kill ()
 (defun allout-copy-topic-as-kill ()
-  "Like allout-kill-topic, but save to kill ring instead of deleting."
+  "Like `allout-kill-topic', but save to kill ring instead of deleting."
   (interactive)
   (let ((buffer-read-only t))
     (condition-case nil
@@ -4437,7 +4462,7 @@
                                                            'invisible
                                                            nil end))))
           (if (or (not next) (eq prev next))
-              ;; still not at start of hidden area - must not be any left.
+              ;; still not at start of hidden area -- must not be any left.
               (setq done t)
             (goto-char next)
             (setq prev next)
@@ -4478,7 +4503,7 @@
                                                          'allout-was-hidden
                                                          nil end)))
         (if (or (not next) (eq prev next))
-            ;; no more or not advancing - must not be any left.
+            ;; no more or not advancing -- must not be any left.
             (setq done t)
           (goto-char next)
           (setq prev next)
@@ -4533,10 +4558,9 @@
            ;; `rectify-numbering' if resituating (where several topics may
            ;; be resituating) or yanking a topic into a topic slot (bol):
            (rectify-numbering (or resituate
-                                  (and into-bol
-                                       (looking-at allout-regexp)))))
+                                  (and into-bol (looking-at allout-regexp)))))
       (if resituate
-          ;; Yanking a topic into the start of a topic - reconcile to fit:
+          ;; Yanking a topic into the start of a topic -- reconcile to fit:
           (let* ((inhibit-field-text-motion t)
                  (prefix-len (if (not (match-end 1))
                                  1
@@ -4676,7 +4700,7 @@
 
 Adapts level of popped topics to level of fresh prefix.
 
-Note - prefix changes to distinctive bullets will stick, if followed
+Note -- prefix changes to distinctive bullets will stick, if followed
 by pops to non-distinctive yanks.  Bug..."
 
   (interactive "*p")
@@ -4695,7 +4719,7 @@
   (interactive)
   (if (not allout-file-xref-bullet)
       (error
-       "Outline cross references disabled - no `allout-file-xref-bullet'")
+       "Outline cross references disabled -- no `allout-file-xref-bullet'")
     (if (not (string= (allout-current-bullet) allout-file-xref-bullet))
         (error "Current heading lacks cross-reference bullet `%s'"
                allout-file-xref-bullet)
@@ -4919,16 +4943,16 @@
       )))
 ;;;_   > allout-show-current-subtree (&optional arg)
 (defun allout-show-current-subtree (&optional arg)
-  "Show everything within the current topic.  With a repeat-count,
-expose this topic and its siblings."
+  "Show everything within the current topic.
+With a repeat-count, expose this topic and its siblings."
   (interactive "P")
   (save-excursion
     (if (<= (allout-current-depth) 0)
-	;; Outside any topics - try to get to the first:
+	;; Outside any topics -- try to get to the first:
 	(if (not (allout-next-heading))
 	    (error "No topics")
-	  ;; got to first, outermost topic - set to expose it and siblings:
-	  (message "Above outermost topic - exposing all.")
+	  ;; got to first, outermost topic -- set to expose it and siblings:
+	  (message "Above outermost topic -- exposing all.")
 	  (allout-flag-region (point-min)(point-max) nil))
       (allout-beginning-of-current-line)
       (if (not arg)
@@ -4966,7 +4990,7 @@
 
   (interactive)
   (let* ((from (point))
-         (sibs-msg "Top-level topic already closed - closing siblings...")
+         (sibs-msg "Top-level topic already closed -- closing siblings...")
          (current-exposed (not (allout-current-topic-collapsed-p t))))
     (cond (current-exposed (allout-flag-current-subtree t))
           (just-close nil)
@@ -5065,13 +5089,13 @@
        that level.
      - positive numbers open to the relative depth indicated by the
        number, but do not force already opened subtopics to be closed.
-     - 0 means to close topic - hide all offspring.
+     - 0 means to close topic -- hide all offspring.
   :  - `repeat'
        apply prior element to all siblings at current level, *up to*
        those siblings that would be covered by specs following the `:'
        on the list.  Ie, apply to all topics at level but the last
        ones.  (Only first of multiple colons at same level is
-       respected - subsequent ones are discarded.)
+       respected -- subsequent ones are discarded.)
   *  - completely opens the topic, including bodies.
   +  - shows all the sub headers, but not the bodies
   -  - exposes the body of the corresponding topic.
@@ -5119,11 +5143,11 @@
 		 ;; Expand the `repeat' spec to an explicit version,
 		 ;; w.r.t. remaining siblings:
 		 (let ((residue	   ; = # of sibs not covered by remaining spec
-			;; Dang - could be nice to make use of the chart, sigh:
+			;; Dang, could be nice to make use of the chart, sigh:
 			(- (length (allout-chart-siblings))
 			   (length spec))))
 		   (if (< 0 residue)
-		       ;; Some residue - cover it with prev-elem:
+		       ;; Some residue -- cover it with prev-elem:
 		       (setq spec (append (make-list residue prev-elem)
 					  spec)))))))
 	 ((numberp curr-elem)
@@ -5257,7 +5281,7 @@
 	     (error "allout-new-exposure: Can't find any outline topics"))
 	(list 'allout-expose-topic (list 'quote spec))))
 
-;;;_ #7 Systematic outline presentation - copying, printing, flattening
+;;;_ #7 Systematic outline presentation -- copying, printing, flattening
 
 ;;;_  - Mapping and processing of topics
 ;;;_   ( See also Subtree Charting, in Navigation code.)
@@ -5345,12 +5369,12 @@
 
 Optional START and END indicate bounds of region.
 
-optional arg, FORMAT, designates an alternate presentation form for
+Optional arg, FORMAT, designates an alternate presentation form for
 the prefix:
 
- list - Present prefix as numeric section.subsection..., starting with
+ list -- Present prefix as numeric section.subsection..., starting with
 	section indicated by the list, innermost nesting first.
- `indent' (symbol) -  Convert header prefixes to all white space,
+ `indent' (symbol) --  Convert header prefixes to all white space,
 		       except for distinctive bullets.
 
 The elements of the list produced are lists that represents a topic
@@ -5375,7 +5399,7 @@
       (beginning-of-line)
       ;; Goto initial topic, and register preceeding stuff, if any:
       (if (> (allout-goto-prefix-doublechecked) start)
-	  ;; First topic follows beginning point - register preliminary stuff:
+	  ;; First topic follows beginning point -- register preliminary stuff:
 	  (setq result (list (list 0 "" nil
 				   (buffer-substring start (1- (point)))))))
       (while (and (not done)
@@ -5443,7 +5467,7 @@
 	    (cond ((= new-depth depth)
 		   (setq format (cons (1+ (car format))
 					  (cdr format))))
-		  ((> new-depth depth)	; descending - assume by 1:
+		  ((> new-depth depth)	; descending -- assume by 1:
 		   (setq format (cons 1 format)))
 		  (t
 					; Pop the residue:
@@ -5459,10 +5483,10 @@
       (nreverse result))))
 ;;;_   > allout-region-active-p ()
 (defmacro allout-region-active-p ()
-  (if (fboundp 'use-region-p)
-      '(use-region-p)
-    '(region-active-p)))
-;;;_   > allout-process-exposed (&optional func from to frombuf
+  (cond ((fboundp 'use-region-p) '(use-region-p))
+        ((fboundp 'region-active-p) '(region-active-p))
+        (t 'mark-active)))
+;;_   > allout-process-exposed (&optional func from to frombuf
 ;;;					    tobuf format)
 (defun allout-process-exposed (&optional func from to frombuf tobuf
 					  format start-num)
@@ -5474,12 +5498,12 @@
 FROMBUF to buffer TOBUF.  Sixth optional arg, FORMAT, designates an
 alternate presentation form:
 
- `flat' - Present prefix as numeric section.subsection..., starting with
-	 section indicated by the start-num, innermost nesting first.
- X`flat-indented' - Prefix is like `flat' for first topic at each
+ `flat' -- Present prefix as numeric section.subsection..., starting with
+	 section indicated by the START-NUM, innermost nesting first.
+ X`flat-indented' -- Prefix is like `flat' for first topic at each
  X		   level, but subsequent topics have only leaf topic
  X		   number, padded with blanks to line up with first.
- `indent' (symbol) -  Convert header prefixes to all white space,
+ `indent' (symbol) --  Convert header prefixes to all white space,
 		       except for distinctive bullets.
 
 Defaults:
@@ -5499,19 +5523,19 @@
 	(setq from (point-min) to (point-max))))
   (if frombuf
       (if (not (bufferp frombuf))
-	  ;; Specified but not a buffer - get it:
+	  ;; Specified but not a buffer -- get it:
 	  (let ((got (get-buffer frombuf)))
 	    (if (not got)
 		(error (concat "allout-process-exposed: source buffer "
 			       frombuf
 			       " not found."))
 	      (setq frombuf got))))
-    ;; not specified - default it:
+    ;; not specified -- default it:
     (setq frombuf (current-buffer)))
   (if tobuf
       (if (not (bufferp tobuf))
 	  (setq tobuf (get-buffer-create tobuf)))
-    ;; not specified - default it:
+    ;; not specified -- default it:
     (setq tobuf (concat "*" (buffer-name frombuf) " exposed*")))
   (if (listp format)
       (nreverse format))
@@ -5598,7 +5622,7 @@
 (defun allout-flatten-exposed-to-buffer (&optional arg tobuf)
   "Present numeric outline of outline's exposed portions in another buffer.
 
-The resulting outline is not compatible with outline mode - use
+The resulting outline is not compatible with outline mode -- use
 `allout-copy-exposed-to-buffer' if you want that.
 
 Use `allout-indented-exposed-to-buffer' for indented presentation.
@@ -5614,7 +5638,7 @@
 (defun allout-indented-exposed-to-buffer (&optional arg tobuf)
   "Present indented outline of outline's exposed portions in another buffer.
 
-The resulting outline is not compatible with outline mode - use
+The resulting outline is not compatible with outline mode -- use
 `allout-copy-exposed-to-buffer' if you want that.
 
 Use `allout-flatten-exposed-to-buffer' for numeric sectional presentation.
@@ -5843,7 +5867,7 @@
 auto-encryption specifics.
 
 \*NOTE WELL* that automatic encryption that happens during saves will
-default to symmetric encryption - you must deliberately (re)encrypt key-pair
+default to symmetric encryption -- you must deliberately (re)encrypt key-pair
 encrypted topics if you want them to continue to use the key-pair cipher.
 
 Level-one topics, with prefix consisting solely of an `*' asterisk, cannot be
@@ -5930,7 +5954,7 @@
                                                          subtree-end))
            (subtree-end-char (char-after (1- subtree-end)))
            (subtree-trailing-char (char-after subtree-end))
-           ;; kluge - result-text needs to be nil, but we also want to
+           ;; kluge -- result-text needs to be nil, but we also want to
            ;;         check for the error condition
            (result-text (if (or (string= "" subject-text)
                                 (string= "\n" subject-text))
@@ -6017,18 +6041,19 @@
 
 FETCH-PASS (default false) forces fresh prompting for the passphrase.
 
-KEY-TYPE indicates whether to use a 'symmetric or 'keypair cipher.
+KEY-TYPE, either `symmetric' or `keypair', specifies which type
+of cypher to use.
 
 FOR-KEY is human readable identification of the first of the user's
 eligible secret keys a keypair decryption targets, or else nil.
 
-Optional RETRIED is for internal use - conveys the number of failed keys
+Optional RETRIED is for internal use -- conveys the number of failed keys
 that have been solicited in sequence leading to this current call.
 
 Optional PASSPHRASE enables explicit delivery of the decryption passphrase,
 for verification purposes.
 
-Optional REJECTED is for internal use - conveys the number of
+Optional REJECTED is for internal use -- conveys the number of
 rejections due to matches against
 `allout-encryption-ciphertext-rejection-regexps', as limited by
 `allout-encryption-ciphertext-rejection-ceiling'.
@@ -6126,15 +6151,15 @@
 
             (if status
                 (pgg-situate-output (point-min) (point-max))
-              ;; failed - handle passphrase caching
+              ;; failed -- handle passphrase caching
               (if verifying
                   (throw 'encryption-failed nil)
                 (pgg-remove-passphrase-from-cache target-cache-id t)
-                (error "Symmetric-cipher %scryption failed - %s"
+                (error "Symmetric-cipher %scryption failed -- %s"
                        (if decrypt "de" "en")
-                       "try again with different passphrase."))))
-
-           ;; encrypt 'keypair:
+                       "try again with different passphrase"))))
+
+           ;; encrypt `keypair':
            ((not decrypt)
 
             (setq status
@@ -6147,7 +6172,7 @@
               (error (pgg-remove-passphrase-from-cache target-cache-id t)
                      (error "encryption failed"))))
 
-           ;; decrypt 'keypair:
+           ;; decrypt `keypair':
            (t
 
             (setq status
@@ -6163,7 +6188,7 @@
                  1 (- (point-max) (if decrypt 0 1))))
           )
 
-        ;; validate result - non-empty
+        ;; validate result -- non-empty
         (cond ((not result-text)
                (if verifying
                    nil
@@ -6199,7 +6224,7 @@
                     (string-match "[\C-a\C-k\C-o-\C-z\C-@]"
                                   result-text))
                (error (concat "Encryption produced non-armored text, which"
-                              "conflicts with allout mode - reconfigure!")))
+                              "conflicts with allout mode -- reconfigure!")))
 
               ;; valid result and just verifying or non-symmetric:
               ((or verifying (not (equal key-type 'symmetric)))
@@ -6208,7 +6233,7 @@
                                                 passphrase t))
                result-text)
 
-              ;; valid result and regular symmetric - "register"
+              ;; valid result and regular symmetric -- "register"
               ;; passphrase with mnemonic aids/cache.
               (t
                (set-buffer allout-buffer)
@@ -6239,7 +6264,7 @@
 
 PROMPT-ID is the id for use when prompting the user.
 
-KEY-TYPE is either 'symmetric or 'keypair.
+KEY-TYPE is either `symmetric' or `keypair'.
 
 ALLOUT-BUFFER is the buffer containing the entry being en/decrypted.
 
@@ -6302,7 +6327,7 @@
                  (if (and (not confirmation)
                           (if (yes-or-no-p
                                (concat "Passphrase differs from established"
-                                       " - use new one instead? "))
+                                       " -- use new one instead? "))
                               ;; deactivate password for subsequent
                               ;; confirmation:
                               (progn
@@ -6312,11 +6337,11 @@
                             t))
                      (progn (pgg-remove-passphrase-from-cache cache-id t)
                             (error "Wrong passphrase."))))
-                ;; No verifier string - force confirmation by repetition of
+                ;; No verifier string -- force confirmation by repetition of
                 ;; (new) passphrase:
                 ((or fetch-pass (not cached))
                  (pgg-remove-passphrase-from-cache cache-id t))))
-        ;; confirmation vs new input - doing pgg-read-passphrase will do the
+        ;; confirmation vs new input -- doing pgg-read-passphrase will do the
         ;; right thing, in either case:
         (if (not confirmation)
             (setq confirmation
@@ -6327,7 +6352,7 @@
             (if (equal got-pass confirmation)
                 confirmation
               (if (yes-or-no-p (concat "spelling of original and"
-                                       " confirmation differ - retry? "))
+                                       " confirmation differ -- retry? "))
                   (progn (setq retried (if retried (1+ retried) 1))
                          (pgg-remove-passphrase-from-cache cache-id t)
                          ;; recurse to this routine:
@@ -6349,10 +6374,10 @@
 (defun allout-encrypted-key-info (text)
   "Return a pair of the key type and identity of a recipient's secret key.
 
-The key type is one of 'symmetric or 'keypair.
-
-if 'keypair, and some of the user's secret keys are among those for which
-the message was encoded, return the identity of the first.  otherwise,
+The key type is one of `symmetric' or `keypair'.
+
+If `keypair', and some of the user's secret keys are among those for which
+the message was encoded, return the identity of the first.  Otherwise,
 return nil for the second item of the pair.
 
 An error is raised if the text is not encrypted."
@@ -6397,7 +6422,7 @@
 See `allout-passphrase-verifier-string' and `allout-passphrase-hint-string'
 settings.
 
-PASSPHRASE is the passphrase being mnemonicized
+PASSPHRASE is the passphrase being mnemonicized.
 
 OUTLINE-BUFFER is the buffer of the outline being adjusted.
 
@@ -6475,7 +6500,7 @@
 from encryption.  This supports 'except-current mode of
 `allout-encrypt-unencrypted-on-saves'.
 
-Such a topic has the allout-topic-encryption-bullet without an
+Such a topic has the `allout-topic-encryption-bullet' without an
 immediately following '*' that would mark the topic as being encrypted.  It
 must also have content."
   (let (done got content-beg)
@@ -6529,7 +6554,7 @@
   "Encrypt topics pending encryption except those containing exemption point.
 
 EXCEPT-MARK identifies a point whose containing topics should be excluded
-from encryption.  This supports 'except-current mode of
+from encryption.  This supports the `except-current' mode of
 `allout-encrypt-unencrypted-on-saves'.
 
 If a topic that is currently being edited was encrypted, we return a list
@@ -6597,7 +6622,7 @@
     (if (allout-goto-prefix)
 	t
       (allout-open-topic 2)
-      (insert (concat "Dummy outline topic header - see"
+      (insert (concat "Dummy outline topic header -- see"
                       "`allout-mode' docstring: `^Hm'."))
       (allout-adjust-file-variable
        "allout-layout" (or allout-layout '(-1 : 0))))))
@@ -6605,7 +6630,7 @@
 (defun allout-file-vars-section-data ()
   "Return data identifying the file-vars section, or nil if none.
 
-Returns list `(beginning-point prefix-string suffix-string)'."
+Returns a list of the form (BEGINNING-POINT PREFIX-STRING SUFFIX-STRING)."
   ;; minimally gleaned from emacs 21.4 files.el hack-local-variables function.
   (let (beg prefix suffix)
     (save-excursion
@@ -6707,7 +6732,7 @@
         got)
     (dolist (sym configvar-value)
       (if (not (boundp sym))
-          (if (yes-or-no-p (format "%s entry `%s' is unbound - remove it? "
+          (if (yes-or-no-p (format "%s entry `%s' is unbound -- remove it? "
                                    configvar-name sym))
               (delq sym (symbol-value configvar-name)))
         (push (symbol-value sym) got)))
@@ -6754,7 +6779,7 @@
 					    string
 					    ""))
 		   nil))))
-      ;; got something out of loop - return it:
+      ;; got something out of loop -- return it:
       got)
   )
 ;;;_  : Strings:
@@ -6762,7 +6787,7 @@
 (defun regexp-sans-escapes (regexp &optional successive-backslashes)
   "Return a copy of REGEXP with all character escapes stripped out.
 
-Representations of actual backslashes - '\\\\\\\\' - are left as a
+Representations of actual backslashes -- '\\\\\\\\' -- are left as a
 single backslash.
 
 Optional arg SUCCESSIVE-BACKSLASHES is used internally for recursion."
@@ -6810,7 +6835,7 @@
   (cond ((null list) nil)
         ((atom (car list)) (cons (car list) (allout-flatten (cdr list))))
         (t (append (allout-flatten (car list)) (allout-flatten (cdr list))))))
-;;;_  : Compatability:
+;;;_  : Compatibility:
 ;;;_   > allout-mark-marker to accommodate divergent emacsen:
 (defun allout-mark-marker (&optional force buffer)
   "Accommodate the different signature for `mark-marker' across Emacsen.
@@ -6862,7 +6887,7 @@
                   (move-overlay o end (overlay-end o))
                 (delete-overlay o)))))))
   )
-;;;_   > copy-overlay if necessary - xemacs ~ 21.4
+;;;_   > copy-overlay if necessary -- xemacs ~ 21.4
 (if (not (fboundp 'copy-overlay))
     (defun copy-overlay (o)
       "Return a copy of overlay O."
@@ -6874,7 +6899,7 @@
         (while props
           (overlay-put o1 (pop props) (pop props)))
         o1)))
-;;;_   > add-to-invisibility-spec if necessary - xemacs ~ 21.4
+;;;_   > add-to-invisibility-spec if necessary -- xemacs ~ 21.4
 (if (not (fboundp 'add-to-invisibility-spec))
     (defun add-to-invisibility-spec (element)
       "Add ELEMENT to `buffer-invisibility-spec'.
@@ -6884,14 +6909,14 @@
           (setq buffer-invisibility-spec (list t)))
       (setq buffer-invisibility-spec
             (cons element buffer-invisibility-spec))))
-;;;_   > remove-from-invisibility-spec if necessary - xemacs ~ 21.4
+;;;_   > remove-from-invisibility-spec if necessary -- xemacs ~ 21.4
 (if (not (fboundp 'remove-from-invisibility-spec))
     (defun remove-from-invisibility-spec (element)
       "Remove ELEMENT from `buffer-invisibility-spec'."
       (if (consp buffer-invisibility-spec)
           (setq buffer-invisibility-spec (delete element
                                                  buffer-invisibility-spec)))))
-;;;_   > move-beginning-of-line if necessary - older emacs, xemacs
+;;;_   > move-beginning-of-line if necessary -- older emacs, xemacs
 (if (not (fboundp 'move-beginning-of-line))
     (defun move-beginning-of-line (arg)
       "Move point to beginning of current line as displayed.
@@ -6921,7 +6946,7 @@
         (skip-chars-backward "^\n"))
       (vertical-motion 0))
 )
-;;;_   > move-end-of-line if necessary - older emacs, xemacs
+;;;_   > move-end-of-line if necessary -- older emacs, xemacs
 (if (not (fboundp 'move-end-of-line))
     (defun move-end-of-line (arg)
       "Move point to end of current line as displayed.
@@ -6990,7 +7015,7 @@
     (isearch-repeat 'forward)
     (isearch-mode t)))
 
-;;;_ #11 Unit tests - this should be last item before "Provide"
+;;;_ #11 Unit tests -- this should be last item before "Provide"
 ;;;_  > allout-run-unit-tests ()
 (defun allout-run-unit-tests ()
   "Run the various allout unit tests."
@@ -7006,11 +7031,11 @@
   (while (boundp name) (makunbound name)))
 ;;;_   > allout-test-resumptions ()
 (defvar allout-tests-globally-unbound nil
-  "Fodder for allout resumptions tests - defvar just for byte compiler.")
+  "Fodder for allout resumptions tests -- defvar just for byte compiler.")
 (defvar allout-tests-globally-true nil
-  "Fodder for allout resumptions tests - defvar just just for byte compiler.")
+  "Fodder for allout resumptions tests -- defvar just for byte compiler.")
 (defvar allout-tests-locally-true nil
-  "Fodder for allout resumptions tests - defvar just for byte compiler.")
+  "Fodder for allout resumptions tests -- defvar just for byte compiler.")
 (defun allout-test-resumptions ()
   "Exercise allout resumptions."
   ;; for each resumption case, we also test that the right local/global
@@ -7046,10 +7071,10 @@
     (allout-tests-obliterate-variable 'allout-tests-locally-true)
     (set (make-local-variable 'allout-tests-locally-true) t)
     (assert (not (default-boundp 'allout-tests-locally-true))
-            nil (concat "Test setup mistake - variable supposed to"
+            nil (concat "Test setup mistake -- variable supposed to"
                         " not have global binding, but it does."))
     (assert (local-variable-p 'allout-tests-locally-true)
-            nil (concat "Test setup mistake - variable supposed to have"
+            nil (concat "Test setup mistake -- variable supposed to have"
                         " local binding, but it lacks one."))
     (allout-add-resumptions '(allout-tests-locally-true nil))
     (assert (not (default-boundp 'allout-tests-locally-true)))
--- a/lisp/ansi-color.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ansi-color.el	Wed Jan 30 07:57:28 2008 +0000
@@ -513,7 +513,7 @@
 (defun ansi-color-set-extent-face (extent face)
   "Set the `face' property of EXTENT to FACE.
 XEmacs uses `set-extent-face', Emacs  uses `overlay-put'."
-  (if (fboundp 'set-extent-face)
+  (if (featurep 'xemacs)
       (set-extent-face extent face)
     (overlay-put extent 'face face)))
 
--- a/lisp/arc-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/arc-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1019,7 +1019,8 @@
 	(archive-maybe-update t))
       (or (not (buffer-name buffer))
           (cond
-           (view-p (view-buffer buffer (and just-created 'kill-buffer)))
+           (view-p (view-buffer
+		    buffer (and just-created 'kill-buffer-if-not-modified)))
            ((eq other-window-p 'display) (display-buffer buffer))
            (other-window-p (switch-to-buffer-other-window buffer))
            (t (switch-to-buffer buffer))))))
@@ -1968,7 +1969,7 @@
           (archive-rar-extract tmpfile name))
       (if tmpbuf (kill-buffer tmpbuf))
       (delete-file tmpfile))))
-  
+
 
 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/blank-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,1726 @@
+;;; blank-mode.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE
+
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
+
+;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
+;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
+;; Keywords: data, wp
+;; Version: 9.2
+;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published
+;; by the Free Software Foundation; either version 3, or (at your
+;; option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Introduction
+;; ------------
+;;
+;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE
+;; and NEWLINE).
+;;
+;; blank-mode uses two ways to visualize blanks: faces and display
+;; table.
+;;
+;; * Faces are used to highlight the background with a color.
+;;   blank-mode uses font-lock to highlight blank characters.
+;;
+;; * Display table changes the way a character is displayed, that is,
+;;   it provides a visual mark for characters, for example, at the end
+;;   of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB).
+;;
+;; The `blank-style' and `blank-chars' variables are used to select
+;; which way should be used to visualize blanks.
+;;
+;; Note that when blank-mode is turned on, blank-mode saves the
+;; font-lock state, that is, if font-lock is on or off.  And
+;; blank-mode restores the font-lock state when it is turned off.  So,
+;; if blank-mode is turned on and font-lock is off, blank-mode also
+;; turns on the font-lock to highlight blanks, but the font-lock will
+;; be turned off when blank-mode is turned off.  Thus, turn on
+;; font-lock before blank-mode is on, if you want that font-lock
+;; continues on after blank-mode is turned off.
+;;
+;; When blank-mode is on, it takes care of highlighting some special
+;; characters over the default mechanism of `nobreak-char-display'
+;; (which see) and `show-trailing-whitespace' (which see).
+;;
+;; There are two ways of using blank-mode: local and global.
+;;
+;; * Local blank-mode affects only the current buffer.
+;;
+;; * Global blank-mode affects all current and future buffers.  That
+;;   is, if you turn on global blank-mode and then create a new
+;;   buffer, the new buffer will also have blank-mode on.  The
+;;   `blank-global-modes' variable controls which major-mode will be
+;;   automagically turned on.
+;;
+;; You can mix the local and global usage without any conflict.  But
+;; local blank-mode has priority over global blank-mode.  Blank mode
+;; is active in a buffer if you have enabled it in that buffer or if
+;; you have enabled it globally.
+;;
+;; When global and local blank-mode are on:
+;;
+;; * if local blank-mode is turned off, blank-mode is turned off for
+;;   the current buffer only.
+;;
+;; * if global blank-mode is turned off, blank-mode continues on only
+;;   in the buffers in which local blank-mode is on.
+;;
+;; To use blank-mode, insert in your ~/.emacs:
+;;
+;;    (require 'blank-mode)
+;;
+;; Or autoload at least one of the commands`blank-mode',
+;; `blank-toggle-options', `global-blank-mode' or
+;; `global-blank-toggle-options'.  For example:
+;;
+;;    (autoload 'blank-mode                  "blank-mode"
+;;      "Toggle blank visualization."          t)
+;;    (autoload 'blank-toggle-options        "blank-mode"
+;;      "Toggle local `blank-mode' options."   t)
+;;
+;; blank-mode was inspired by:
+;;
+;;    whitespace.el            Rajesh Vaidheeswarran <rv@gnu.org>
+;;	Warn about and clean bogus whitespaces in the file
+;;	(inspired the idea to warn and clean some blanks)
+;;
+;;    show-whitespace-mode.el  Aurelien Tisne <aurelien.tisne@free.fr>
+;;       Simple mode to highlight whitespaces
+;;       (inspired the idea to use font-lock)
+;;
+;;    whitespace-mode.el       Lawrence Mitchell <wence@gmx.li>
+;;       Major mode for editing Whitespace
+;;       (inspired the idea to use display table)
+;;
+;;    visws.el                 Miles Bader <miles@gnu.org>
+;;       Make whitespace visible
+;;       (handle display table, his code was modified, but the main
+;;       idea was kept)
+;;
+;;
+;; Using blank-mode
+;; ----------------
+;;
+;; There is no problem if you mix local and global minor mode usage.
+;;
+;; * LOCAL blank-mode:
+;;    + To toggle blank-mode options locally, type:
+;;
+;;         M-x blank-toggle-options RET
+;;
+;;    + To activate blank-mode locally, type:
+;;
+;;         C-u 1 M-x blank-mode RET
+;;
+;;    + To deactivate blank-mode locally, type:
+;;
+;;         C-u 0 M-x blank-mode RET
+;;
+;;    + To toggle blank-mode locally, type:
+;;
+;;         M-x blank-mode RET
+;;
+;; * GLOBAL blank-mode:
+;;    + To toggle blank-mode options globally, type:
+;;
+;;         M-x global-blank-toggle-options RET
+;;
+;;    + To activate blank-mode globally, type:
+;;
+;;         C-u 1 M-x global-blank-mode RET
+;;
+;;    + To deactivate blank-mode globally, type:
+;;
+;;         C-u 0 M-x global-blank-mode RET
+;;
+;;    + To toggle blank-mode globally, type:
+;;
+;;         M-x global-blank-mode RET
+;;
+;; There are also the following useful commands:
+;;
+;; `blank-cleanup'
+;;    Cleanup some blank problems in all buffer or at region.
+;;
+;; `blank-cleanup-region'
+;;    Cleanup some blank problems at region.
+;;
+;; The problems, which are cleaned up, are:
+;;
+;; 1. empty lines at beginning of buffer.
+;; 2. empty lines at end of buffer.
+;;    If `blank-chars' has `empty' as an element, remove all empty
+;;    lines at beginning and/or end of buffer.
+;;
+;; 3. 8 or more SPACEs at beginning of line.
+;;    If `blank-chars' has `indentation' as an element, replace 8 or
+;;    more SPACEs at beginning of line by TABs.
+;;
+;; 4. SPACEs before TAB.
+;;    If `blank-chars' has `space-before-tab' as an element, replace
+;;    SPACEs by TABs.
+;;
+;; 5. SPACEs or TABs at end of line.
+;;    If `blank-chars' has `trailing' as an element, remove all
+;;    SPACEs or TABs at end of line."
+;;
+;; 6. 8 or more SPACEs after TAB.
+;;    If `blank-chars' has `space-after-tab' as an element, replace
+;;    SPACEs by TABs.
+;;
+;;
+;; Hooks
+;; -----
+;;
+;; blank-mode has the following hook variables:
+;;
+;; `blank-mode-hook'
+;;    It is evaluated always when blank-mode is turned on locally.
+;;
+;; `global-blank-mode-hook'
+;;    It is evaluated always when blank-mode is turned on globally.
+;;
+;; `blank-load-hook'
+;;    It is evaluated after blank-mode package is loaded.
+;;
+;;
+;; Options
+;; -------
+;;
+;; Below it's shown a brief description of blank-mode options, please,
+;; see the options declaration in the code for a long documentation.
+;;
+;; `blank-style'		Specify the visualization style.
+;;
+;; `blank-chars'		Specify which kind of blank is
+;;				visualized.
+;;
+;; `blank-space'		Face used to visualize SPACE.
+;;
+;; `blank-hspace'		Face used to visualize HARD SPACE.
+;;
+;; `blank-tab'			Face used to visualize TAB.
+;;
+;; `blank-newline'		Face used to visualize NEWLINE char
+;;				mapping.
+;;
+;; `blank-trailing'		Face used to visualize trailing
+;;				blanks.
+;;
+;; `blank-line'			Face used to visualize "long" lines.
+;;
+;; `blank-space-before-tab'	Face used to visualize SPACEs before
+;;				TAB.
+;;
+;; `blank-indentation'		Face used to visualize 8 or more
+;;				SPACEs at beginning of line.
+;;
+;; `blank-empty'		Face used to visualize empty lines at
+;;				beginning and/or end of buffer.
+;;
+;; `blank-space-after-tab'	Face used to visualize 8 or more
+;;				SPACEs after TAB.
+;;
+;; `blank-space-regexp'		Specify SPACE characters regexp.
+;;
+;; `blank-hspace-regexp'	Specify HARD SPACE characters regexp.
+;;
+;; `blank-tab-regexp'		Specify TAB characters regexp.
+;;
+;; `blank-trailing-regexp'	Specify trailing characters regexp.
+;;
+;; `blank-space-before-tab-regexp'	Specify SPACEs before TAB
+;;					regexp.
+;;
+;; `blank-indentation-regexp'	Specify regexp for 8 or more SPACEs at
+;;				beginning of line.
+;;
+;; `blank-empty-at-bob-regexp'	Specify regexp for empty lines at
+;;				beginning of buffer.
+;;
+;; `blank-empty-at-eob-regexp'	Specify regexp for empty lines at end
+;;				of buffer.
+;;
+;; `blank-space-after-tab-regexp'	Specify regexp for 8 or more
+;;					SPACEs after TAB.
+;;
+;; `blank-line-column'		Specify column beyond which the line
+;;				is highlighted.
+;;
+;; `blank-display-mappings'	Specify an alist of mappings for
+;;				displaying characters.
+;;
+;; `blank-global-modes'		Modes for which global `blank-mode' is
+;;				automagically turned on.
+;;
+;;
+;; Acknowledgements
+;; ----------------
+;;
+;; Thanks to nschum (EmacsWiki) for the idea about highlight "long"
+;; lines tail.  See EightyColumnRule (EmacsWiki).
+;;
+;; Thanks to Juri Linkov <juri@jurta.org> for suggesting:
+;;    * `define-minor-mode'.
+;;    * `global-blank-*' name for global commands.
+;;
+;; Thanks to Robert J. Chassell <bob@gnu.org> for doc fix and testing.
+;;
+;; Thanks to Drew Adams <drew.adams@oracle.com> for toggle commands
+;; suggestion.
+;;
+;; Thanks to Antti Kaihola <antti.kaihola@linux-aktivaattori.org> for
+;; helping to fix `find-file-hooks' reference.
+;;
+;; Thanks to Andreas Roehler <andreas.roehler@easy-emacs.de> for
+;; indicating defface byte-compilation warnings.
+;;
+;; Thanks to TimOCallaghan (EmacsWiki) for the idea about highlight
+;; "long" lines.  See EightyColumnRule (EmacsWiki).
+;;
+;; Thanks to Yanghui Bian <yanghuibian@gmail.com> for indicating a new
+;; newline character mapping.
+;;
+;; Thanks to Pete Forman <pete.forman@westgeo.com> for indicating
+;; whitespace-mode on XEmacs.
+;;
+;; Thanks to Miles Bader <miles@gnu.org> for handling display table via
+;; visws.el (his code was modified, but the main idea was kept).
+;;
+;; Thanks to:
+;;    Rajesh Vaidheeswarran <rv@gnu.org>	whitespace.el
+;;    Aurelien Tisne <aurelien.tisne@free.fr>	show-whitespace-mode.el
+;;    Lawrence Mitchell <wence@gmx.li>		whitespace-mode.el
+;;    Miles Bader <miles@gnu.org>		visws.el
+;; And to all people who contributed with them.
+;;
+;;
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; code:
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; User Variables:
+
+
+;;; Interface to the command system
+
+
+(defgroup blank nil
+  "Visualize blanks (TAB, (HARD) SPACE and NEWLINE)."
+  :link '(emacs-library-link :tag "Source Lisp File" "blank-mode.el")
+  :version "22.2"
+  :group 'wp
+  :group 'data)
+
+
+(defcustom blank-style '(mark color)
+  "*Specify the visualization style.
+
+It's a list which element value can be:
+
+   mark		display mappings are visualized.
+
+   color	faces are visualized.
+
+Any other value is ignored.
+
+If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs.
+
+See also `blank-display-mappings' for documentation."
+  :type '(repeat :tag "Style of Blank"
+		 (choice :tag "Style of Blank"
+			 (const :tag "Display Table" mark)
+			 (const :tag "Faces" color)))
+  :group 'blank)
+
+
+(defcustom blank-chars
+  '(tabs spaces trailing lines space-before-tab newline
+	 indentation empty space-after-tab)
+  "*Specify which kind of blank is visualized.
+
+It's a list which element value can be:
+
+   trailing		trailing blanks are visualized.
+
+   tabs			TABs are visualized.
+
+   spaces		SPACEs and HARD SPACEs are visualized.
+
+   lines		lines whose have columns beyond
+			`blank-line-column' are highlighted.
+			Whole line is highlighted.
+			It has precedence over
+			`lines-tail' (see below).
+
+   lines-tail		lines whose have columns beyond
+			`blank-line-column' are highlighted.
+			But only the part of line which goes
+			beyond `blank-line-column' column.
+			It has effect only if `lines' (see above)
+			is not present in `blank-chars'.
+
+   space-before-tab	SPACEs before TAB are visualized.
+
+   newline		NEWLINEs are visualized.
+
+   indentation		8 or more SPACEs at beginning of line are
+			visualized.
+
+   empty		empty lines at beginning and/or end of buffer
+			are visualized.
+
+   space-after-tab	8 or more SPACEs after a TAB are visualized.
+
+Any other value is ignored.
+
+If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs.
+
+Used when `blank-style' has `color' as an element.
+If `blank-chars' has `newline' as an element, used when `blank-style'
+has `mark' as an element."
+  :type '(repeat :tag "Kind of Blank"
+		 (choice :tag "Kind of Blank"
+			 (const :tag "Trailing TABs, SPACEs and HARD SPACEs"
+				trailing)
+			 (const :tag "SPACEs and HARD SPACEs" spaces)
+			 (const :tag "TABs" tabs)
+			 (const :tag "Lines" lines)
+			 (const :tag "SPACEs before TAB"
+				space-before-tab)
+			 (const :tag "NEWLINEs" newline)
+			 (const :tag "Indentation SPACEs" indentation)
+			 (const :tag "Empty Lines At BOB And/Or EOB"
+				empty)
+			 (const :tag "SPACEs after TAB"
+				space-after-tab)))
+  :group 'blank)
+
+
+(defcustom blank-space 'blank-space
+  "*Symbol face used to visualize SPACE.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-space
+  '((((class color) (background dark))
+     (:background "grey20"      :foreground "aquamarine3"))
+    (((class color) (background light))
+     (:background "LightYellow" :foreground "aquamarine3"))
+    (t (:inverse-video t)))
+  "Face used to visualize SPACE."
+  :group 'blank)
+
+
+(defcustom blank-hspace 'blank-hspace
+  "*Symbol face used to visualize HARD SPACE.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-hspace			; 'nobreak-space
+  '((((class color) (background dark))
+     (:background "grey24"        :foreground "aquamarine3"))
+    (((class color) (background light))
+     (:background "LemonChiffon3" :foreground "aquamarine3"))
+    (t (:inverse-video t)))
+  "Face used to visualize HARD SPACE."
+  :group 'blank)
+
+
+(defcustom blank-tab 'blank-tab
+  "*Symbol face used to visualize TAB.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-tab
+  '((((class color) (background dark))
+     (:background "grey22" :foreground "aquamarine3"))
+    (((class color) (background light))
+     (:background "beige"  :foreground "aquamarine3"))
+    (t (:inverse-video t)))
+  "Face used to visualize TAB."
+  :group 'blank)
+
+
+(defcustom blank-newline 'blank-newline
+  "*Symbol face used to visualize NEWLINE char mapping.
+
+See `blank-display-mappings'.
+
+Used when `blank-style' has `mark' and `color' as elements
+and `blank-chars' has `newline' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-newline
+  '((((class color) (background dark))
+     (:background "grey26" :foreground "aquamarine3" :bold t))
+    (((class color) (background light))
+     (:background "linen"  :foreground "aquamarine3" :bold t))
+    (t (:bold t :underline t)))
+  "Face used to visualize NEWLINE char mapping.
+
+See `blank-display-mappings'."
+  :group 'blank)
+
+
+(defcustom blank-trailing 'blank-trailing
+  "*Symbol face used to visualize traling blanks.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-trailing			; 'trailing-whitespace
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "red1" :foreground "yellow" :bold t)))
+  "Face used to visualize trailing blanks."
+  :group 'blank)
+
+
+(defcustom blank-line 'blank-line
+  "*Symbol face used to visualize \"long\" lines.
+
+See `blank-line-column'.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-line
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "gray20" :foreground "violet")))
+  "Face used to visualize \"long\" lines.
+
+See `blank-line-column'."
+  :group 'blank)
+
+
+(defcustom blank-space-before-tab 'blank-space-before-tab
+  "*Symbol face used to visualize SPACEs before TAB.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-space-before-tab
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "DarkOrange" :foreground "firebrick")))
+  "Face used to visualize SPACEs before TAB."
+  :group 'blank)
+
+
+(defcustom blank-indentation 'blank-indentation
+  "*Symbol face used to visualize 8 or more SPACEs at beginning of line.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-indentation
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "yellow" :foreground "firebrick")))
+  "Face used to visualize 8 or more SPACEs at beginning of line."
+  :group 'blank)
+
+
+(defcustom blank-empty 'blank-empty
+  "*Symbol face used to visualize empty lines at beginning and/or end of buffer.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-empty
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "yellow" :foreground "firebrick")))
+  "Face used to visualize empty lines at beginning and/or end of buffer."
+  :group 'blank)
+
+
+(defcustom blank-space-after-tab 'blank-space-after-tab
+  "*Symbol face used to visualize 8 or more SPACEs after TAB.
+
+Used when `blank-style' has `color' as an element."
+  :type 'face
+  :group 'blank)
+
+
+(defface blank-space-after-tab
+  '((((class mono)) (:inverse-video t :bold t :underline t))
+    (t (:background "yellow" :foreground "firebrick")))
+  "Face used to visualize 8 or more SPACEs after TAB."
+  :group 'blank)
+
+
+(defcustom blank-hspace-regexp
+  "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)"
+  "*Specify HARD SPACE characters regexp.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \"\\xA0\"   \"\\x8A0\"   \"\\x920\"   \"\\xE20\"   \"\\xF20\"
+
+that should be considered HARD SPACE.
+
+Here are some examples:
+
+   \"\\\\(^\\xA0+\\\\)\"		\
+visualize only leading HARD SPACEs.
+   \"\\\\(\\xA0+$\\\\)\"		\
+visualize only trailing HARD SPACEs.
+   \"\\\\(^\\xA0+\\\\|\\xA0+$\\\\)\"	\
+visualize leading and/or trailing HARD SPACEs.
+   \"\\t\\\\(\\xA0+\\\\)\\t\"		\
+visualize only HARD SPACEs between TABs.
+
+NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
+      Use exactly one pair of enclosing \\\\( and \\\\).
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `spaces' as an element."
+  :type '(regexp :tag "HARD SPACE Chars")
+  :group 'blank)
+
+
+(defcustom blank-space-regexp "\\( +\\)"
+  "*Specify SPACE characters regexp.
+
+If you're using `mule' package, it may exist other characters
+besides \" \" that should be considered SPACE.
+
+Here are some examples:
+
+   \"\\\\(^ +\\\\)\"		visualize only leading SPACEs.
+   \"\\\\( +$\\\\)\"		visualize only trailing SPACEs.
+   \"\\\\(^ +\\\\| +$\\\\)\"	\
+visualize leading and/or trailing SPACEs.
+   \"\\t\\\\( +\\\\)\\t\"	visualize only SPACEs between TABs.
+
+NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
+      Use exactly one pair of enclosing \\\\( and \\\\).
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `spaces' as an element."
+  :type '(regexp :tag "SPACE Chars")
+  :group 'blank)
+
+
+(defcustom blank-tab-regexp "\\(\t+\\)"
+  "*Specify TAB characters regexp.
+
+If you're using `mule' package, it may exist other characters
+besides \"\\t\" that should be considered TAB.
+
+Here are some examples:
+
+   \"\\\\(^\\t+\\\\)\"		visualize only leading TABs.
+   \"\\\\(\\t+$\\\\)\"		visualize only trailing TABs.
+   \"\\\\(^\\t+\\\\|\\t+$\\\\)\"	\
+visualize leading and/or trailing TABs.
+   \" \\\\(\\t+\\\\) \"	visualize only TABs between SPACEs.
+
+NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
+      Use exactly one pair of enclosing \\\\( and \\\\).
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `tabs' as an element."
+  :type '(regexp :tag "TAB Chars")
+  :group 'blank)
+
+
+(defcustom blank-trailing-regexp
+  "\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20"
+  "*Specify trailing characters regexp.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+NOTE: DO NOT enclose by \\\\( and \\\\) the elements to highlight.
+      `blank-mode' surrounds this regexp by \"\\\\(\\\\(\" and
+      \"\\\\)+\\\\)$\".
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `trailing' as an element."
+  :type '(regexp :tag "Trailing Chars")
+  :group 'blank)
+
+
+(defcustom blank-space-before-tab-regexp "\\( +\\)\t"
+  "*Specify SPACEs before TAB regexp.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `space-before-tab' as an element."
+  :type '(regexp :tag "SPACEs Before TAB")
+  :group 'blank)
+
+
+(defcustom blank-indentation-regexp "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]"
+  "*Specify regexp for 8 or more SPACEs at beginning of line.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `indentation' as an element."
+  :type '(regexp :tag "Indentation SPACEs")
+  :group 'blank)
+
+
+(defcustom blank-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
+  "*Specify regexp for empty lines at beginning of buffer.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `empty' as an element."
+  :type '(regexp :tag "Empty Lines At Beginning Of Buffer")
+  :group 'blank)
+
+
+(defcustom blank-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'"
+  "*Specify regexp for empty lines at end of buffer.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `empty' as an element."
+  :type '(regexp :tag "Empty Lines At End Of Buffer")
+  :group 'blank)
+
+
+(defcustom blank-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)"
+  "*Specify regexp for 8 or more SPACEs after TAB.
+
+If you're using `mule' package, it may exist other characters besides:
+
+   \" \"  \"\\t\"  \"\\xA0\"  \"\\x8A0\"  \"\\x920\"  \"\\xE20\"  \
+\"\\xF20\"
+
+that should be considered blank.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `space-after-tab' as an element."
+  :type '(regexp :tag "SPACEs After TAB")
+  :group 'blank)
+
+
+(defcustom blank-line-column 80
+  "*Specify column beyond which the line is highlighted.
+
+Used when `blank-style' has `color' as an element, and
+`blank-chars' has `lines' or `lines-tail' as an element."
+  :type '(integer :tag "Line Length")
+  :group 'blank)
+
+
+;; Hacked from `visible-whitespace-mappings' in visws.el
+(defcustom blank-display-mappings
+  ;; Due to limitations of glyph representation, the char code can not
+  ;; be above ?\x1FFFF.  Probably, this will be fixed after Emacs
+  ;; unicode merging.
+  '(
+    (?\     [?\xB7]       [?.])		; space - centered dot
+    (?\xA0  [?\xA4]       [?_])		; hard space - currency
+    (?\x8A0 [?\x8A4]      [?_])		; hard space - currency
+    (?\x920 [?\x924]      [?_])		; hard space - currency
+    (?\xE20 [?\xE24]      [?_])		; hard space - currency
+    (?\xF20 [?\xF24]      [?_])		; hard space - currency
+    ;; NEWLINE is displayed using the face `blank-newline'
+    (?\n    [?$ ?\n])			; end-of-line - dollar sign
+    ;; (?\n    [?\u21B5 ?\n] [?$ ?\n])	; end-of-line - downwards arrow
+    ;; (?\n    [?\xB6 ?\n]   [?$ ?\n])	; end-of-line - pilcrow
+    ;; (?\n    [?\x8AF ?\n]  [?$ ?\n])	; end-of-line - overscore
+    ;; (?\n    [?\x8AC ?\n]  [?$ ?\n])	; end-of-line - negation
+    ;; (?\n    [?\x8B0 ?\n]  [?$ ?\n])	; end-of-line - grade
+    ;;
+    ;; WARNING: the mapping below has a problem.
+    ;; When a TAB occupies exactly one column, it will display the
+    ;; character ?\xBB at that column followed by a TAB which goes to
+    ;; the next TAB column.
+    ;; If this is a problem for you, please, comment the line below.
+    (?\t    [?\xBB ?\t]   [?\\ ?\t])	; tab - left quote mark
+    )
+  "*Specify an alist of mappings for displaying characters.
+
+Each element has the following form:
+
+   (CHAR VECTOR...)
+
+Where:
+
+CHAR	is the character to be mapped.
+
+VECTOR	is a vector of characters to be displayed in place of CHAR.
+	The first display vector that can be displayed is used;
+	if no display vector for a mapping can be displayed, then
+	that character is displayed unmodified.
+
+The NEWLINE character is displayed using the face given by
+`blank-newline' variable.  The characters in the vector to be
+displayed will not have this face applied if the character code
+is above #x1FFFF.
+
+Used when `blank-style' has `mark' as an element."
+  :type '(repeat
+	  (list :tag "Character Mapping"
+		(character :tag "Char")
+		(repeat :inline t :tag "Vector List"
+			(vector :tag ""
+				(repeat :inline t
+					:tag "Vector Characters"
+					(character :tag "Char"))))))
+  :group 'blank)
+
+
+(defcustom blank-global-modes t
+  "*Modes for which global `blank-mode' is automagically turned on.
+
+Global `blank-mode' is controlled by the command `global-blank-mode'.
+
+If nil, means no modes have `blank-mode' automatically turned on.
+If t, all modes that support `blank-mode' have it automatically
+turned on.
+Else it should be a list of `major-mode' symbol names for
+which `blank-mode' should be automatically turned on.  The sense
+of the list is negated if it begins with `not'.  For example:
+
+   (c-mode c++-mode)
+
+means that `blank-mode' is turned on for buffers in C and C++
+modes only."
+  :type '(choice (const :tag "None" nil)
+		 (const :tag "All" t)
+		 (set :menu-tag "Mode Specific" :tag "Modes"
+		      :value (not)
+		      (const :tag "Except" not)
+		      (repeat :inline t
+			      (symbol :tag "Mode"))))
+  :group 'blank)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; User commands - Local mode
+
+
+;;;###autoload
+(define-minor-mode blank-mode
+  "Toggle blank minor mode visualization (\"bl\" on modeline).
+
+If ARG is null, toggle blank visualization.
+If ARG is a number greater than zero, turn on visualization;
+otherwise, turn off visualization.
+Only useful with a windowing system."
+  :lighter    " bl"
+  :init-value nil
+  :global     nil
+  :group      'blank
+  (cond
+   (noninteractive			; running a batch job
+    (setq blank-mode nil))
+   (blank-mode				; blank-mode on
+    (blank-turn-on))
+   (t					; blank-mode off
+    (blank-turn-off))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; User commands - Global mode
+
+
+(define-minor-mode global-blank-mode
+  "Toggle blank global minor mode visualization (\"BL\" on modeline).
+
+If ARG is null, toggle blank visualization.
+If ARG is a number greater than zero, turn on visualization;
+otherwise, turn off visualization.
+Only useful with a windowing system."
+  :lighter    " BL"
+  :init-value nil
+  :global     t
+  :group      'blank
+  (cond
+   (noninteractive			; running a batch job
+    (setq global-blank-mode nil))
+   (global-blank-mode			; global-blank-mode on
+    (save-excursion
+      (if (boundp 'find-file-hook)
+	  (add-hook 'find-file-hook 'blank-turn-on-if-enabled t)
+	(add-hook 'find-file-hooks 'blank-turn-on-if-enabled t))
+      (dolist (buffer (buffer-list))	; adjust all local mode
+	(set-buffer buffer)
+	(unless blank-mode
+	  (blank-turn-on-if-enabled)))))
+   (t					; global-blank-mode off
+    (save-excursion
+      (if (boundp 'find-file-hook)
+	  (remove-hook 'find-file-hook 'blank-turn-on-if-enabled)
+	(remove-hook 'find-file-hooks 'blank-turn-on-if-enabled))
+      (dolist (buffer (buffer-list))	; adjust all local mode
+	(set-buffer buffer)
+	(unless blank-mode
+	  (blank-turn-off)))))))
+
+
+(defun blank-turn-on-if-enabled ()
+  (when (cond
+	 ((eq blank-global-modes t))
+	 ((listp blank-global-modes)
+	  (if (eq (car-safe blank-global-modes) 'not)
+	      (not (memq major-mode (cdr blank-global-modes)))
+	    (memq major-mode blank-global-modes)))
+	 (t nil))
+    (let (inhibit-quit)
+      ;; Don't turn on blank mode if...
+      (or
+       ;; ...we don't have a display (we're running a batch job)
+       noninteractive
+       ;; ...or if the buffer is invisible (name starts with a space)
+       (eq (aref (buffer-name) 0) ?\ )
+       ;; ...or if the buffer is temporary (name starts with *)
+       (and (eq (aref (buffer-name) 0) ?*)
+	    ;; except the scratch buffer.
+	    (not (string= (buffer-name) "*scratch*")))
+       ;; Otherwise, turn on blank mode.
+       (blank-turn-on)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; User commands - Toggle
+
+
+(defconst blank-chars-value-list
+  '(tabs
+    spaces
+    trailing
+    space-before-tab
+    lines
+    lines-tail
+    newline
+    indentation
+    empty
+    space-after-tab
+    )
+  "List of valid `blank-chars' values.")
+
+
+(defconst blank-style-value-list
+  '(color
+    mark
+    )
+  "List of valid `blank-style' values.")
+
+
+(defconst blank-toggle-option-alist
+  '((?t . tabs)
+    (?s . spaces)
+    (?r . trailing)
+    (?b . space-before-tab)
+    (?l . lines)
+    (?L . lines-tail)
+    (?n . newline)
+    (?i . indentation)
+    (?e . empty)
+    (?a . space-after-tab)
+    (?c . color)
+    (?m . mark)
+    (?x . blank-chars)
+    (?z . blank-style)
+    )
+  "Alist of toggle options.
+
+Each element has the form:
+
+   (CHAR . SYMBOL)
+
+Where:
+
+CHAR	is a char which the user will have to type.
+
+SYMBOL	is a valid symbol associated with CHAR.
+	See `blank-chars-value-list' and `blank-style-value-list'.")
+
+
+(defvar blank-active-chars nil
+  "Used to save locally `blank-chars' value.")
+(make-variable-buffer-local 'blank-active-chars)
+
+(defvar blank-active-style nil
+  "Used to save locally `blank-style' value.")
+(make-variable-buffer-local 'blank-active-style)
+
+
+;;;###autoload
+(defun blank-toggle-options (arg)
+  "Toggle local `blank-mode' options.
+
+If local blank-mode is off, toggle the option given by ARG and
+turn on local blank-mode.
+
+If local blank-mode is on, toggle the option given by ARG and
+restart local blank-mode.
+
+Interactively, it reads one of the following chars:
+
+  CHAR	MEANING
+   t	toggle TAB visualization
+   s	toggle SPACE and HARD SPACE visualization
+   r	toggle trailing blanks visualization
+   b	toggle SPACEs before TAB visualization
+   l	toggle \"long lines\" visualization
+   L	toggle \"long lines\" tail visualization
+   n	toggle NEWLINE visualization
+   i	toggle indentation SPACEs visualization
+   e	toggle empty line at bob and/or eob visualization
+   a	toggle SPACEs after TAB visualization
+   c	toggle color faces
+   m	toggle visual mark
+   x	restore `blank-chars' value
+   z	restore `blank-style' value
+   ?	display brief help
+
+Non-interactively, ARG should be a symbol or a list of symbols.
+The valid symbols are:
+
+   tabs			toggle TAB visualization
+   spaces		toggle SPACE and HARD SPACE visualization
+   trailing		toggle trailing blanks visualization
+   space-before-tab	toggle SPACEs before TAB visualization
+   lines		toggle \"long lines\" visualization
+   lines-tail		toggle \"long lines\" tail visualization
+   newline		toggle NEWLINE visualization
+   indentation		toggle indentation SPACEs visualization
+   empty		toggle empty line at bob and/or eob visualization
+   space-after-tab	toggle SPACEs after TAB visualization
+   color		toggle color faces
+   mark			toggle visual mark
+   blank-chars		restore `blank-chars' value
+   blank-style		restore `blank-style' value
+
+Only useful with a windowing system."
+  (interactive (blank-interactive-char t))
+  (let ((blank-chars
+	 (blank-toggle-list t arg blank-active-chars blank-chars
+			    'blank-chars blank-chars-value-list))
+	(blank-style
+	 (blank-toggle-list t arg blank-active-style blank-style
+			    'blank-style blank-style-value-list)))
+    (blank-mode 0)
+    (blank-mode 1)))
+
+
+(defvar blank-toggle-chars nil
+  "Used to toggle the global `blank-chars' value.")
+(defvar blank-toggle-style nil
+  "Used to toggle the global `blank-style' value.")
+
+
+;;;###autoload
+(defun global-blank-toggle-options (arg)
+  "Toggle global `blank-mode' options.
+
+If global blank-mode is off, toggle the option given by ARG and
+turn on global blank-mode.
+
+If global blank-mode is on, toggle the option given by ARG and
+restart global blank-mode.
+
+Interactively, it reads one of the following chars:
+
+  CHAR	MEANING
+   t	toggle TAB visualization
+   s	toggle SPACE and HARD SPACE visualization
+   r	toggle trailing blanks visualization
+   b	toggle SPACEs before TAB visualization
+   l	toggle \"long lines\" visualization
+   L	toggle \"long lines\" tail visualization
+   n	toggle NEWLINE visualization
+   i	toggle indentation SPACEs visualization
+   e	toggle empty line at bob and/or eob visualization
+   a	toggle SPACEs after TAB visualization
+   c	toggle color faces
+   m	toggle visual mark
+   x	restore `blank-chars' value
+   z	restore `blank-style' value
+   ?	display brief help
+
+Non-interactively, ARG should be a symbol or a list of symbols.
+The valid symbols are:
+
+   tabs			toggle TAB visualization
+   spaces		toggle SPACE and HARD SPACE visualization
+   trailing		toggle trailing blanks visualization
+   space-before-tab	toggle SPACEs before TAB visualization
+   lines		toggle \"long lines\" visualization
+   lines-tail		toggle \"long lines\" tail visualization
+   newline		toggle NEWLINE visualization
+   indentation		toggle indentation SPACEs visualization
+   empty		toggle empty line at bob and/or eob visualization
+   space-after-tab	toggle SPACEs after TAB visualization
+   color		toggle color faces
+   mark			toggle visual mark
+   blank-chars		restore `blank-chars' value
+   blank-style		restore `blank-style' value
+
+Only useful with a windowing system."
+  (interactive (blank-interactive-char nil))
+  (let ((blank-chars
+	 (blank-toggle-list nil arg blank-toggle-chars blank-chars
+			    'blank-chars blank-chars-value-list))
+	(blank-style
+	 (blank-toggle-list nil arg blank-toggle-style blank-style
+			    'blank-style blank-style-value-list)))
+    (setq blank-toggle-chars blank-chars
+	  blank-toggle-style blank-style)
+    (global-blank-mode 0)
+    (global-blank-mode 1)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; User commands - Cleanup
+
+
+;;;###autoload
+(defun blank-cleanup ()
+  "Cleanup some blank problems in all buffer or at region.
+
+It usually applies to the whole buffer, but in transient mark
+mode when the mark is active, it applies to the region.  It also
+applies to the region when it is not in transiente mark mode, the
+mark is active and it was pressed `C-u' just before calling
+`blank-cleanup' interactively.
+
+See also `blank-cleanup-region'.
+
+The problems, which are cleaned up, are:
+
+1. empty lines at beginning of buffer.
+2. empty lines at end of buffer.
+   If `blank-chars' has `empty' as an element, remove all empty
+   lines at beginning and/or end of buffer.
+
+3. 8 or more SPACEs at beginning of line.
+   If `blank-chars' has `indentation' as an element, replace 8 or
+   more SPACEs at beginning of line by TABs.
+
+4. SPACEs before TAB.
+   If `blank-chars' has `space-before-tab' as an element, replace
+   SPACEs by TABs.
+
+5. SPACEs or TABs at end of line.
+   If `blank-chars' has `trailing' as an element, remove all
+   SPACEs or TABs at end of line.
+
+6. 8 or more SPACEs after TAB.
+   If `blank-chars' has `space-after-tab' as an element, replace
+   SPACEs by TABs."
+  (interactive "@*")
+  (if (and (or transient-mark-mode
+	       current-prefix-arg)
+	   mark-active)
+      ;; region active
+      ;; problems 1 and 2 are not handled in region
+      ;; problem 3: 8 or more SPACEs at bol
+      ;; problem 4: SPACEs before TAB
+      ;; problem 5: SPACEs or TABs at eol
+      ;; problem 6: 8 or more SPACEs after TAB
+      (blank-cleanup-region (region-beginning) (region-end))
+    ;; whole buffer
+    (save-excursion
+      (save-match-data
+	;; problem 1: empty lines at bob
+	;; problem 2: empty lines at eob
+	;; action: remove all empty lines at bob and/or eob
+	(when (memq 'empty blank-chars)
+	  (let (overwrite-mode)		; enforce no overwrite
+	    (goto-char (point-min))
+	    (when (re-search-forward blank-empty-at-bob-regexp nil t)
+	      (delete-region (match-beginning 1) (match-end 1)))
+	    (when (re-search-forward blank-empty-at-eob-regexp nil t)
+	      (delete-region (match-beginning 1) (match-end 1)))))))
+    ;; problem 3: 8 or more SPACEs at bol
+    ;; problem 4: SPACEs before TAB
+    ;; problem 5: SPACEs or TABs at eol
+    ;; problem 6: 8 or more SPACEs after TAB
+    (blank-cleanup-region (point-min) (point-max))))
+
+
+;;;###autoload
+(defun blank-cleanup-region (start end)
+  "Cleanup some blank problems at region.
+
+The problems, which are cleaned up, are:
+
+1. 8 or more SPACEs at beginning of line.
+   If `blank-chars' has `indentation' as an element, replace 8 or
+   more SPACEs at beginning of line by TABs.
+
+2. SPACEs before TAB.
+   If `blank-chars' has `space-before-tab' as an element, replace
+   SPACEs by TABs.
+
+3. SPACEs or TABs at end of line.
+   If `blank-chars' has `trailing' as an element, remove all
+   SPACEs or TABs at end of line.
+
+4. 8 or more SPACEs after TAB.
+   If `blank-chars' has `space-after-tab' as an element, replace
+   SPACEs by TABs."
+  (interactive "@*r")
+  (let ((rstart           (min start end))
+	(rend             (copy-marker (max start end)))
+	(tab-width        8)		; assure TAB width
+	(indent-tabs-mode t)		; always insert TABs
+	overwrite-mode			; enforce no overwrite
+	tmp)
+    (save-excursion
+      (save-match-data
+	;; problem 1: 8 or more SPACEs at bol
+	;; action: replace 8 or more SPACEs at bol by TABs
+	(when (memq 'indentation blank-chars)
+	  (goto-char rstart)
+	  (while (re-search-forward blank-indentation-regexp rend t)
+	    (setq tmp (current-indentation))
+	    (delete-horizontal-space)
+	    (unless (eolp)
+	      (indent-to tmp))))
+	;; problem 3: SPACEs or TABs at eol
+	;; action: remove all SPACEs or TABs at eol
+	(when (memq 'trailing blank-chars)
+	  (let ((regexp (concat "\\(\\(" blank-trailing-regexp
+				"\\)+\\)$")))
+	    (goto-char rstart)
+	    (while (re-search-forward regexp rend t)
+	      (delete-region (match-beginning 1) (match-end 1)))))
+	;; problem 4: 8 or more SPACEs after TAB
+	;; action: replace 8 or more SPACEs by TABs
+	(when (memq 'space-after-tab blank-chars)
+	  (blank-replace-spaces-by-tabs
+	   rstart rend blank-space-after-tab-regexp))
+	;; problem 2: SPACEs before TAB
+	;; action: replace SPACEs before TAB by TABs
+	(when (memq 'space-before-tab blank-chars)
+	  (blank-replace-spaces-by-tabs
+	   rstart rend blank-space-before-tab-regexp))))
+    (set-marker rend nil)))		; point marker to nowhere
+
+
+(defun blank-replace-spaces-by-tabs (rstart rend regexp)
+  "Replace all SPACEs by TABs matched by REGEXP between RSTART and REND."
+  (goto-char rstart)
+  (while (re-search-forward regexp rend t)
+    (goto-char (match-beginning 1))
+    (let* ((scol (current-column))
+	   (ecol (save-excursion
+		   (goto-char (match-end 1))
+		   (current-column))))
+      (delete-region (match-beginning 1) (match-end 1))
+      (insert-char ?\t
+		   (/ (- (- ecol (% ecol 8))	    ; prev end col
+			 (- scol (% scol 8)))	    ; prev start col
+		      8)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; Internal functions
+
+
+(defvar blank-font-lock-mode nil
+  "Used to remember whether a buffer had font lock mode on or not.")
+(make-variable-buffer-local 'blank-font-lock-mode)
+
+(defvar blank-font-lock nil
+  "Used to remember whether a buffer initially had font lock on or not.")
+(make-variable-buffer-local 'blank-font-lock)
+
+(defvar blank-font-lock-keywords nil
+  "Used to save locally `font-lock-keywords' value.")
+(make-variable-buffer-local 'blank-font-lock-keywords)
+
+
+(defconst blank-help-text
+  "\
+      blank-mode toggle options:
+
+ []  t - toggle TAB visualization
+ []  s - toggle SPACE and HARD SPACE visualization
+ []  r - toggle trailing blanks visualization
+ []  b - toggle SPACEs before TAB visualization
+ []  l - toggle \"long lines\" visualization
+ []  L - toggle \"long lines\" tail visualization
+ []  n - toggle NEWLINE visualization
+ []  i - toggle indentation SPACEs visualization
+ []  e - toggle empty line at bob and/or eob visualization
+ []  a - toggle SPACEs after TAB visualization
+
+ []  c - toggle color faces
+ []  m - toggle visual mark
+
+      x - restore `blank-chars' value
+      z - restore `blank-style' value
+
+      ? - display this text\n\n"
+  "Text for blank toggle options.")
+
+
+(defconst blank-help-buffer-name "*Blank Toggle Options*"
+  "The buffer name for blank toggle options.")
+
+
+(defun blank-insert-option-mark (the-list the-value)
+  "Insert the option mark ('X' or ' ') in toggle options buffer."
+  (forward-line 1)
+  (dolist (sym  the-list)
+    (forward-line 1)
+    (forward-char 2)
+    (insert (if (memq sym the-value) "X" " "))))
+
+
+(defun blank-help-on (chars style)
+  "Display the blank toggle options."
+  (unless (get-buffer blank-help-buffer-name)
+    (delete-other-windows)
+    (let ((buffer (get-buffer-create blank-help-buffer-name)))
+      (save-excursion
+	(set-buffer buffer)
+	(erase-buffer)
+	(insert blank-help-text)
+	(goto-char (point-min))
+	(blank-insert-option-mark blank-chars-value-list chars)
+	(blank-insert-option-mark blank-style-value-list style)
+	(goto-char (point-min))
+	(set-buffer-modified-p nil)
+	(let ((size (- (window-height)
+		       (max window-min-height
+			    (1+ (count-lines (point-min) (point-max)))))))
+	  (when (<= size 0)
+	    (kill-buffer buffer)
+	    (error "Frame height is too small; \
+can't split window to display blank toggle options"))
+	  (set-window-buffer (split-window nil size) buffer))))))
+
+
+(defun blank-help-off ()
+  "Remove the buffer and window of the blank toggle options."
+  (let ((buffer (get-buffer blank-help-buffer-name)))
+    (when buffer
+      (delete-windows-on buffer)
+      (kill-buffer buffer))))
+
+
+(defun blank-interactive-char (local-p)
+  "Interactive function to read a char and return a symbol.
+
+If LOCAL-P is non-nil, it uses a local context; otherwise, it
+uses a global context.
+
+It reads one of the following chars:
+
+  CHAR	MEANING
+   t	toggle TAB visualization
+   s	toggle SPACE and HARD SPACE visualization
+   r	toggle trailing blanks visualization
+   b	toggle SPACEs before TAB visualization
+   l	toggle \"long lines\" visualization
+   L	toggle \"long lines\" tail visualization
+   n	toggle NEWLINE visualization
+   i	toggle indentation SPACEs visualization
+   e	toggle empty line at bob and/or eob visualization
+   a	toggle SPACEs after TAB visualization
+   c	toggle color faces
+   m	toggle visual mark
+   x	restore `blank-chars' value
+   z	restore `blank-style' value
+   ?	display brief help
+
+See also `blank-toggle-option-alist'."
+  (let* ((is-off (not (if local-p blank-mode global-blank-mode)))
+	 (chars  (cond (is-off  blank-chars) ; use default value
+		       (local-p blank-active-chars)
+		       (t       blank-toggle-chars)))
+	 (style  (cond (is-off  blank-style) ; use default value
+		       (local-p blank-active-style)
+		       (t       blank-toggle-style)))
+	 (prompt
+	  (format "Blank Toggle %s (type ? for further options)-"
+		  (if local-p "Local" "Global")))
+	 ch sym)
+    ;; read a valid option and get the corresponding symbol
+    (save-window-excursion
+      (condition-case data
+	  (progn
+	    (while
+		;; while condition
+		(progn
+		  (setq ch (read-char prompt))
+		  (not
+		   (setq sym
+			 (cdr (assq ch blank-toggle-option-alist)))))
+	      ;; while body
+	      (if (eq ch ?\?)
+		  (blank-help-on chars style)
+		(ding)))
+	    (blank-help-off)
+	    (message " "))		; clean echo area
+	;; handler
+	((quit error)
+	 (blank-help-off)
+	 (error (error-message-string data)))))
+    (list sym)))			; return the apropriate symbol
+
+
+(defun blank-toggle-list (local-p arg the-list default-list
+				  sym-restore sym-list)
+  "Toggle options in THE-LIST based on list ARG.
+
+If LOCAL-P is non-nil, it uses a local context; otherwise, it
+uses a global context.
+
+ARG is a list of options to be toggled.
+
+THE-LIST is a list of options.  This list will be toggled and the
+resultant list will be returned.
+
+DEFAULT-LIST is the default list of options.  It is used to
+restore the options in THE-LIST.
+
+SYM-RESTORE is the symbol which indicates to restore the options
+in THE-LIST.
+
+SYM-LIST is a list of valid options, used to check if the ARG's
+options are valid."
+  (unless (if local-p blank-mode global-blank-mode)
+    (setq the-list default-list))
+  (setq the-list (copy-sequence the-list)) ; keep original list
+  (dolist (sym (if (listp arg) arg (list arg)))
+    (cond
+     ;; restore default values
+     ((eq sym sym-restore)
+      (setq the-list default-list))
+     ;; toggle valid values
+     ((memq sym sym-list)
+      (setq the-list (if (memq sym the-list)
+			 (delq sym the-list)
+		       (cons sym the-list))))))
+  the-list)
+
+
+(defun blank-turn-on ()
+  "Turn on blank visualization."
+  (setq blank-active-style (if (listp blank-style)
+			       blank-style
+			     (list blank-style)))
+  (setq blank-active-chars (if (listp blank-chars)
+			       blank-chars
+			     (list blank-chars)))
+  (when (memq 'color blank-active-style)
+    (blank-color-on))
+  (when (memq 'mark  blank-active-style)
+    (blank-display-char-on)))
+
+
+(defun blank-turn-off ()
+  "Turn off blank visualization."
+  (when (memq 'color blank-active-style)
+    (blank-color-off))
+  (when (memq 'mark  blank-active-style)
+    (blank-display-char-off)))
+
+
+(defun blank-color-on ()
+  "Turn on color visualization."
+  (when blank-active-chars
+    (unless blank-font-lock
+      (setq blank-font-lock t
+	    blank-font-lock-keywords
+	    (copy-sequence font-lock-keywords)))
+    ;; turn off font lock
+    (setq blank-font-lock-mode font-lock-mode)
+    (font-lock-mode 0)
+    ;; add blank-mode color into font lock
+    (when (memq 'spaces blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show SPACEs
+	(list blank-space-regexp  1 blank-space  t)
+	;; Show HARD SPACEs
+	(list blank-hspace-regexp 1 blank-hspace t))
+       t))
+    (when (memq 'tabs blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show TABs
+	(list blank-tab-regexp 1 blank-tab t))
+       t))
+    (when (memq 'trailing blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show trailing blanks
+	(list (concat "\\(\\(" blank-trailing-regexp "\\)+\\)$")
+	      1 blank-trailing t))
+       t))
+    (when (or (memq 'lines      blank-active-chars)
+	      (memq 'lines-tail blank-active-chars))
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show "long" lines
+	(list
+	 (format
+	  "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$"
+	  tab-width (1- tab-width)
+	  (/ blank-line-column tab-width)
+	  (let ((rem (% blank-line-column tab-width)))
+	    (if (zerop rem)
+		""
+	      (format ".\\{%d\\}" rem))))
+	 (if (memq 'lines blank-active-chars)
+	     0				; whole line
+	   2)				; line tail
+	 blank-line t))
+       t))
+    (when (memq 'space-before-tab blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show SPACEs before TAB
+	(list blank-space-before-tab-regexp
+	      1 blank-space-before-tab t))
+       t))
+    (when (memq 'indentation blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show indentation SPACEs
+	(list blank-indentation-regexp
+	      1 blank-indentation t))
+       t))
+    (when (memq 'empty blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show empty lines at beginning of buffer
+	(list blank-empty-at-bob-regexp
+	      1 blank-empty t))
+       t)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show empty lines at end of buffer
+	(list blank-empty-at-eob-regexp
+	      1 blank-empty t))
+       t))
+    (when (memq 'space-after-tab blank-active-chars)
+      (font-lock-add-keywords
+       nil
+       (list
+	;; Show SPACEs after TAB
+	(list blank-space-after-tab-regexp
+	      1 blank-space-after-tab t))
+       t))
+    ;; now turn on font lock and highlight blanks
+    (font-lock-mode 1)))
+
+
+(defun blank-color-off ()
+  "Turn off color visualization."
+  (when blank-active-chars
+    ;; turn off font lock
+    (font-lock-mode 0)
+    (when blank-font-lock
+      (setq blank-font-lock nil
+	    font-lock-keywords blank-font-lock-keywords))
+    ;; restore original font lock state
+    (font-lock-mode blank-font-lock-mode)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>)
+
+
+(defvar blank-display-table nil
+  "Used to save a local display table.")
+(make-variable-buffer-local 'blank-display-table)
+
+(defvar blank-display-table-was-local nil
+  "Used to remember whether a buffer initially had a local display table or not.")
+(make-variable-buffer-local 'blank-display-table-was-local)
+
+
+(defsubst blank-char-valid-p (char)
+  ;; This check should be improved!!!
+  (or (< char 256)
+      (char-valid-p char)))
+
+
+(defun blank-legal-display-vector-p (vec)
+  "Return true if every character in vector VEC can be displayed."
+  (let ((i (length vec)))
+    (when (> i 0)
+      (while (and (>= (setq i (1- i)) 0)
+		  (blank-char-valid-p (aref vec i))))
+      (< i 0))))
+
+
+(defun blank-display-char-on ()
+  "Turn on character display mapping."
+  (when blank-display-mappings
+    (let (vecs vec)
+      ;; Remember whether a buffer has a local display table.
+      (unless blank-display-table-was-local
+	(setq blank-display-table-was-local t
+	      blank-display-table
+	      (copy-sequence buffer-display-table)))
+      (unless buffer-display-table
+	(setq buffer-display-table (make-display-table)))
+      (dolist (entry blank-display-mappings)
+	(setq vecs (cdr entry))
+	;; Get a displayable mapping.
+	(while (and vecs
+		    (not (blank-legal-display-vector-p (car vecs))))
+	  (setq vecs (cdr vecs)))
+	;; Display a valid mapping.
+	(when vecs
+	  (setq vec (copy-sequence (car vecs)))
+	  (cond
+	   ;; Any char except newline
+	   ((not (eq (car entry) ?\n))
+	    (aset buffer-display-table (car entry) vec))
+	   ;; Newline char - display it
+	   ((memq 'newline blank-active-chars)
+	    ;; Only insert face bits on NEWLINE char mapping to avoid
+	    ;; obstruction of other faces like TABs and (HARD) SPACEs
+	    ;; faces, font-lock faces, etc.
+	    (when (memq 'color blank-active-style)
+	      (dotimes (i (length vec))
+		;; Due to limitations of glyph representation, the char
+		;; code can not be above ?\x1FFFF.  Probably, this will
+		;; be fixed after Emacs unicode merging.
+		(or (eq (aref vec i) ?\n)
+		    (> (aref vec i) #x1FFFF)
+		    (aset vec i (make-glyph-code (aref vec i)
+						 blank-newline)))))
+	    ;; Display mapping
+	    (aset buffer-display-table (car entry) vec))
+	   ;; Newline char - don't display it
+	   (t
+	    ;; Do nothing
+	    )))))))
+
+
+(defun blank-display-char-off ()
+  "Turn off character display mapping."
+  (and blank-display-mappings
+       blank-display-table-was-local
+       (setq blank-display-table-was-local nil
+	     buffer-display-table          blank-display-table)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; Aliases for whitespace compatibility
+
+
+;;;###autoload
+(defun whitespace-buffer ()
+  (interactive)
+  (blank-mode 0)			; assure is off
+  ;; keep original values
+  (let ((blank-style (copy-sequence blank-style))
+	(blank-chars (copy-sequence blank-chars)))
+    ;; adjust options for whitespace bogus blanks
+    (add-to-list 'blank-style 'color)
+    (mapc #'(lambda (option)
+	      (add-to-list 'blank-chars option))
+	  '(trailing
+	    indentation
+	    space-before-tab
+	    empty
+	    space-after-tab))
+    (blank-mode 1)))
+
+;;;###autoload
+(defalias 'whitespace-region 'whitespace-buffer) ; there is no `blank-region'
+
+;;;###autoload
+(defalias 'whitespace-cleanup 'blank-cleanup)
+
+;;;###autoload
+(defalias 'whitespace-cleanup-region 'blank-cleanup-region)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(provide 'blank-mode)
+
+
+(run-hooks 'blank-load-hook)
+
+
+;; arch-tag: 1b1e2500-dbd4-4a26-8f7a-5a5edfd3c97e
+;;; blank-mode.el ends here
--- a/lisp/button.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/button.el	Wed Jan 30 07:57:28 2008 +0000
@@ -116,7 +116,7 @@
 
 ;;;###autoload
 (defun define-button-type (name &rest properties)
-  "Define a `button type' called NAME.
+  "Define a `button type' called NAME (a symbol).
 The remaining arguments form a sequence of PROPERTY VALUE pairs,
 specifying properties to use as defaults for buttons with this type
 \(a button's type may be set by giving it a `type' property when
--- a/lisp/calc/calc-menu.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/calc/calc-menu.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; calc-menu.el --- a menu for Calc
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
 
--- a/lisp/calc/calc-nlfit.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/calc/calc-nlfit.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; calc-nlfit.el --- nonlinear curve fitting for Calc
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
 
--- a/lisp/calendar/cal-menu.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/calendar/cal-menu.el	Wed Jan 30 07:57:28 2008 +0000
@@ -141,7 +141,10 @@
     "--"
     ,@(let ((l ()))
         ;; Show 11 years--5 before, 5 after year of middle month.
+        ;; We used to use :suffix rather than :label and bumped into
+        ;; an easymenu bug:
         ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01813.html
+        ;; The bug has since been fixed.
         (dotimes (i 11)
           (push (vector (format "hol-year-%d" i)
                         `(lambda ()
--- a/lisp/calendar/icalendar.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/calendar/icalendar.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,7 @@
 ;;; icalendar.el --- iCalendar implementation -*-coding: utf-8 -*-
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
 ;; Author:         Ulf Jasper <ulf.jasper@web.de>
 ;; Created:        August 2002
@@ -40,33 +41,36 @@
 
 ;;  0.07 onwards: see lisp/ChangeLog
 
-;;  0.06: Bugfixes regarding icalendar-import-format-*.
-;;        Fix in icalendar-convert-diary-to-ical -- thanks to Philipp
-;;        Grau.
+;;  0.06:  (2004-10-06)
+;;  - Bugfixes regarding icalendar-import-format-*.
+;;  - Fix in icalendar-convert-diary-to-ical -- thanks to Philipp Grau.
 
-;;  0.05: New import format scheme: Replaced icalendar-import-prefix-*,
-;;        icalendar-import-ignored-properties, and
-;;        icalendar-import-separator with icalendar-import-format(-*).
-;;        icalendar-import-file and icalendar-convert-diary-to-ical
-;;        have an extra parameter which should prevent them from
-;;        erasing their target files (untested!).
-;;        Tested with Emacs 21.3.2
+;;  0.05: (2003-06-19)
+;;  - New import format scheme: Replaced icalendar-import-prefix-*,
+;;    icalendar-import-ignored-properties, and
+;;    icalendar-import-separator with icalendar-import-format(-*).
+;;  - icalendar-import-file and icalendar-convert-diary-to-ical
+;;    have an extra parameter which should prevent them from
+;;    erasing their target files (untested!).
+;;  - Tested with Emacs 21.3.2
 
-;;  0.04: Bugfix: import: double quoted param values did not work
-;;        Read DURATION property when importing.
-;;        Added parameter icalendar-duration-correction.
+;;  0.04:
+;;  - Bugfix: import: double quoted param values did not work
+;;  - Read DURATION property when importing.
+;;  - Added parameter icalendar-duration-correction.
 
-;;  0.03: Export takes care of european-calendar-style.
-;;        Tested with Emacs 21.3.2 and XEmacs 21.4.12
+;;  0.03: (2003-05-07)
+;;  - Export takes care of european-calendar-style.
+;;  - Tested with Emacs 21.3.2 and XEmacs 21.4.12
 
-;;  0.02: Should work in XEmacs now.  Thanks to Len Trigg for the
-;;        XEmacs patches!
-;;        Added exporting from Emacs diary to ical.
-;;        Some bugfixes, after testing with calendars from
-;;        http://icalshare.com.
-;;        Tested with Emacs 21.3.2 and XEmacs 21.4.12
+;;  0.02:
+;;  - Should work in XEmacs now.  Thanks to Len Trigg for the XEmacs patches!
+;;  - Added exporting from Emacs diary to ical.
+;;  - Some bugfixes, after testing with calendars from http://icalshare.com.
+;;  - Tested with Emacs 21.3.2 and XEmacs 21.4.12
 
-;;  0.01: First published version.  Trial version.  Alpha version.
+;;  0.01: (2003-03-21)
+;;  - First published version.  Trial version.  Alpha version.
 
 ;; ======================================================================
 ;; To Do:
@@ -86,7 +90,7 @@
 ;;    + the parser is too soft
 ;;    + error log is incomplete
 ;;    + nice to have: #include "webcal://foo.com/some-calendar.ics"
-;;    + timezones, currently all times are local!
+;;    + timezones probably still need some improvements.
 
 ;;  * Export from diary to ical
 ;;    + diary-date, diary-float, and self-made sexp entries are not
@@ -101,7 +105,7 @@
 
 ;;; Code:
 
-(defconst icalendar-version "0.15"
+(defconst icalendar-version "0.17"
   "Version number of icalendar.el.")
 
 ;; ======================================================================
@@ -114,17 +118,25 @@
 
 (defcustom icalendar-import-format
   "%s%d%l%o"
-  "Format string for importing events from iCalendar into Emacs diary.
-This string defines how iCalendar events are inserted into diary
-file.  Meaning of the specifiers:
+  "Format for importing events from iCalendar into Emacs diary.
+It defines how iCalendar events are inserted into diary file.
+This may either be a string or a function.
+
+In case of a formatting STRING the following specifiers can be used:
 %c Class, see `icalendar-import-format-class'
 %d Description, see `icalendar-import-format-description'
 %l Location, see `icalendar-import-format-location'
 %o Organizer, see `icalendar-import-format-organizer'
 %s Summary, see `icalendar-import-format-summary'
 %t Status, see `icalendar-import-format-status'
-%u URL, see `icalendar-import-format-url'"
-  :type 'string
+%u URL, see `icalendar-import-format-url'
+
+A formatting FUNCTION will be called with a VEVENT as its only
+argument.  It must return a string.  See
+`icalendar-import-format-sample' for an example."
+  :type '(choice
+          (string :tag "String")
+          (function :tag "Function"))
   :group 'icalendar)
 
 (defcustom icalendar-import-format-summary
@@ -243,7 +255,7 @@
 INVALUE gives the current iCalendar element we are reading.
 INPARAMS gives the current parameters.....
 This function calls itself recursively for each nested calendar element
-it finds"
+it finds."
   (let (element children line name params param param-name param-value
                 value
                 (continue t))
@@ -390,15 +402,90 @@
                 (append result (list (list param-name param-value)))))))
     result))
 
-(defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift)
+(defun icalendar--convert-tz-offset (alist dst-p)
+  "Return a cons of two strings representing a timezone start.
+ALIST is an alist entry from a VTIMEZONE, like STANDARD.
+DST-P is non-nil if this is for daylight savings time.
+The strings are suitable for assembling into a TZ variable."
+  (let ((offset (car (cddr (assq 'TZOFFSETTO alist))))
+	(rrule-value (car (cddr (assq 'RRULE alist))))
+	(dtstart (car (cddr (assq 'DTSTART alist)))))
+    ;; FIXME: for now we only handle RRULE and not RDATE here.
+    (when (and offset rrule-value dtstart)
+      (let* ((rrule (icalendar--split-value rrule-value))
+	     (freq (cadr (assq 'FREQ rrule)))
+	     (bymonth (cadr (assq 'BYMONTH rrule)))
+	     (byday (cadr (assq 'BYDAY rrule))))
+	;; FIXME: we don't correctly handle WKST here.
+	(if (and (string= freq "YEARLY") bymonth)
+	    (cons
+	     (concat
+	      ;; Fake a name.
+	      (if dst-p "(DST?)" "(STD?)")
+	      ;; For TZ, OFFSET is added to the local time.  So,
+	      ;; invert the values.
+	      (if (eq (aref offset 0) ?-) "+" "-")
+	      (substring offset 1 3)
+	      ":"
+	      (substring offset 3 5))
+	     ;; The start time.
+	     (let* ((day (icalendar--get-weekday-number (substring byday -2)))
+		    (week (if (eq day -1)
+			      byday
+			    (substring byday 0 -2))))
+	       (concat "M" bymonth "." week "." (if (eq day -1) "0"
+						  (int-to-string day))
+		       ;; Start time.
+		       "/"
+		       (substring dtstart -6 -4)
+		       ":"
+		       (substring dtstart -4 -2)
+		       ":"
+		       (substring dtstart -2)))))))))
+
+(defun icalendar--parse-vtimezone (alist)
+  "Turn a VTIMEZONE ALIST into a cons (ID . TZ-STRING).
+Return nil if timezone cannot be parsed."
+  (let* ((tz-id (icalendar--get-event-property alist 'TZID))
+	 (daylight (cadr (cdar (icalendar--get-children alist 'DAYLIGHT))))
+	 (day (and daylight (icalendar--convert-tz-offset daylight t)))
+	 (standard (cadr (cdar (icalendar--get-children alist 'STANDARD))))
+	 (std (and standard (icalendar--convert-tz-offset standard nil))))
+    (if (and tz-id std)
+	(cons tz-id
+	      (if day
+		  (concat (car std) (car day)
+			  "," (cdr day) "," (cdr std))
+		(car std))))))
+
+(defun icalendar--convert-all-timezones (icalendar)
+  "Convert all timezones in the ICALENDAR into an alist.
+Each element of the alist is a cons (ID . TZ-STRING),
+like `icalendar--parse-vtimezone'."
+  (let (result)
+    (dolist (zone (icalendar--get-children (car icalendar) 'VTIMEZONE))
+      (setq zone (icalendar--parse-vtimezone zone))
+      (if zone
+	  (setq result (cons zone result))))
+    result))
+
+(defun icalendar--find-time-zone (prop-list zone-map)
+  "Return a timezone string for the time zone in PROP-LIST, or nil if none.
+ZONE-MAP is a timezone alist as returned by `icalendar--convert-all-timezones'."
+  (let ((id (plist-get prop-list 'TZID)))
+    (if id
+	(cdr (assoc id zone-map)))))
+
+(defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift
+                                                        zone)
   "Return ISODATETIMESTRING in format like `decode-time'.
 Converts from ISO-8601 to Emacs representation.  If
 ISODATETIMESTRING specifies UTC time (trailing letter Z) the
 decoded time is given in the local time zone!  If optional
 parameter DAY-SHIFT is non-nil the result is shifted by DAY-SHIFT
 days.
+ZONE, if provided, is the timezone, in any format understood by `encode-time'.
 
-FIXME: TZID-attributes are ignored....!
 FIXME: multiple comma-separated values should be allowed!"
   (icalendar--dmsg isodatetimestring)
   (if isodatetimestring
@@ -433,7 +520,7 @@
         ;; create the decoded date-time
         ;; FIXME!?!
         (condition-case nil
-            (decode-time (encode-time second minute hour day month year))
+            (decode-time (encode-time second minute hour day month year zone))
           (error
            (message "Cannot decode \"%s\"" isodatetimestring)
            ;; hope for the best...
@@ -710,7 +797,7 @@
   "Export diary file to iCalendar format.
 All diary entries in the file DIARY-FILENAME are converted to iCalendar
 format.  The result is appended to the file ICAL-FILENAME."
-  (interactive "FExport diary data from file:
+  (interactive "FExport diary data from file: 
 Finto iCalendar file: ")
   (save-current-buffer
     (set-buffer (find-file diary-filename))
@@ -844,89 +931,95 @@
    (error "Could not parse entry")))
 
 (defun icalendar--parse-summary-and-rest (summary-and-rest)
-  "Parse SUMMARY-AND-REST from a diary to fill iCalendar properties."
+  "Parse SUMMARY-AND-REST from a diary to fill iCalendar properties.
+Returns an alist."
   (save-match-data
-    (let* ((s icalendar-import-format)
-           (p-cla (or (string-match "%c" icalendar-import-format) -1))
-           (p-des (or (string-match "%d" icalendar-import-format) -1))
-           (p-loc (or (string-match "%l" icalendar-import-format) -1))
-           (p-org (or (string-match "%o" icalendar-import-format) -1))
-           (p-sum (or (string-match "%s" icalendar-import-format) -1))
-           (p-sta (or (string-match "%t" icalendar-import-format) -1))
-           (p-url (or (string-match "%u" icalendar-import-format) -1))
-           (p-list (sort (list p-cla p-des p-loc p-org p-sta p-sum p-url) '<))
-           pos-cla pos-des pos-loc pos-org pos-sta pos-sum pos-url)
-      (dotimes (i (length p-list))
-        (cond ((and (>= p-cla 0) (= (nth i p-list) p-cla))
-               (setq pos-cla (+ 2 (* 2 i))))
-              ((and (>= p-des 0) (= (nth i p-list) p-des))
-               (setq pos-des (+ 2 (* 2 i))))
-              ((and (>= p-loc 0) (= (nth i p-list) p-loc))
-               (setq pos-loc (+ 2 (* 2 i))))
-              ((and (>= p-org 0) (= (nth i p-list) p-org))
-               (setq pos-org (+ 2 (* 2 i))))
-              ((and (>= p-sta 0) (= (nth i p-list) p-sta))
-               (setq pos-sta (+ 2 (* 2 i))))
-              ((and (>= p-sum 0) (= (nth i p-list) p-sum))
-               (setq pos-sum (+ 2 (* 2 i))))
-              ((and (>= p-url 0) (= (nth i p-list) p-url))
-               (setq pos-url (+ 2 (* 2 i))))))
-      (mapc (lambda (ij)
-              (setq s (icalendar--rris (car ij) (cadr ij) s t t)))
-            (list
-             ;; summary must be first! because of %s
-             (list "%s"
-                   (concat "\\(" icalendar-import-format-summary "\\)?"))
-             (list "%c"
-                   (concat "\\(" icalendar-import-format-class "\\)?"))
-             (list "%d"
-                   (concat "\\(" icalendar-import-format-description "\\)?"))
-             (list "%l"
-                   (concat "\\(" icalendar-import-format-location "\\)?"))
-             (list "%o"
-                   (concat "\\(" icalendar-import-format-organizer "\\)?"))
-             (list "%t"
-                   (concat "\\(" icalendar-import-format-status "\\)?"))
-             (list "%u"
-                   (concat "\\(" icalendar-import-format-url "\\)?"))))
-      (setq s (concat (icalendar--rris "%s" "\\(.*\\)" s nil t) " "))
-      (if (string-match s summary-and-rest)
-          (let (cla des loc org sta sum url)
-            (if (and pos-sum (match-beginning pos-sum))
-                (setq sum (substring summary-and-rest
-                                     (match-beginning pos-sum)
-                                     (match-end pos-sum))))
-            (if (and pos-cla (match-beginning pos-cla))
-                (setq cla (substring summary-and-rest
-                                     (match-beginning pos-cla)
-                                     (match-end pos-cla))))
-            (if (and pos-des (match-beginning pos-des))
-                (setq des (substring summary-and-rest
-                                     (match-beginning pos-des)
-                                     (match-end pos-des))))
-            (if (and pos-loc (match-beginning pos-loc))
-                (setq loc (substring summary-and-rest
-                                     (match-beginning pos-loc)
-                                     (match-end pos-loc))))
-            (if (and pos-org (match-beginning pos-org))
-                (setq org (substring summary-and-rest
-                                     (match-beginning pos-org)
-                                     (match-end pos-org))))
-            (if (and pos-sta (match-beginning pos-sta))
-                (setq sta (substring summary-and-rest
-                                     (match-beginning pos-sta)
-                                     (match-end pos-sta))))
-            (if (and pos-url (match-beginning pos-url))
-                (setq url (substring summary-and-rest
-                                     (match-beginning pos-url)
-                                     (match-end pos-url))))
-            (list (if cla (cons 'cla cla) nil)
-                  (if des (cons 'des des) nil)
-                  (if loc (cons 'loc loc) nil)
-                  (if org (cons 'org org) nil)
-                  (if sta (cons 'sta sta) nil)
-                  ;;(if sum (cons 'sum sum) nil)
-                  (if url (cons 'url url) nil)))))))
+    (if (functionp icalendar-import-format)
+        ;; can't do anything
+        nil
+      ;; split summary-and-rest
+      (let* ((s icalendar-import-format)
+             (p-cla (or (string-match "%c" icalendar-import-format) -1))
+             (p-des (or (string-match "%d" icalendar-import-format) -1))
+             (p-loc (or (string-match "%l" icalendar-import-format) -1))
+             (p-org (or (string-match "%o" icalendar-import-format) -1))
+             (p-sum (or (string-match "%s" icalendar-import-format) -1))
+             (p-sta (or (string-match "%t" icalendar-import-format) -1))
+             (p-url (or (string-match "%u" icalendar-import-format) -1))
+             (p-list (sort (list p-cla p-des p-loc p-org p-sta p-sum p-url) '<))
+             pos-cla pos-des pos-loc pos-org pos-sta pos-sum pos-url)
+        (dotimes (i (length p-list))
+          (cond ((and (>= p-cla 0) (= (nth i p-list) p-cla))
+                 (setq pos-cla (+ 2 (* 2 i))))
+                ((and (>= p-des 0) (= (nth i p-list) p-des))
+                 (setq pos-des (+ 2 (* 2 i))))
+                ((and (>= p-loc 0) (= (nth i p-list) p-loc))
+                 (setq pos-loc (+ 2 (* 2 i))))
+                ((and (>= p-org 0) (= (nth i p-list) p-org))
+                 (setq pos-org (+ 2 (* 2 i))))
+                ((and (>= p-sta 0) (= (nth i p-list) p-sta))
+                 (setq pos-sta (+ 2 (* 2 i))))
+                ((and (>= p-sum 0) (= (nth i p-list) p-sum))
+                 (setq pos-sum (+ 2 (* 2 i))))
+                ((and (>= p-url 0) (= (nth i p-list) p-url))
+                 (setq pos-url (+ 2 (* 2 i))))))
+        (mapc (lambda (ij)
+                (setq s (icalendar--rris (car ij) (cadr ij) s t t)))
+              (list
+               ;; summary must be first! because of %s
+               (list "%s"
+                     (concat "\\(" icalendar-import-format-summary "\\)??"))
+               (list "%c"
+                     (concat "\\(" icalendar-import-format-class "\\)??"))
+               (list "%d"
+                     (concat "\\(" icalendar-import-format-description "\\)??"))
+               (list "%l"
+                     (concat "\\(" icalendar-import-format-location "\\)??"))
+               (list "%o"
+                     (concat "\\(" icalendar-import-format-organizer "\\)??"))
+               (list "%t"
+                     (concat "\\(" icalendar-import-format-status "\\)??"))
+               (list "%u"
+                     (concat "\\(" icalendar-import-format-url "\\)??"))))
+        (setq s (concat "^" (icalendar--rris "%s" "\\(.*?\\)" s nil t)
+                        " $"))
+        (if (string-match s summary-and-rest)
+            (let (cla des loc org sta sum url)
+              (if (and pos-sum (match-beginning pos-sum))
+                  (setq sum (substring summary-and-rest
+                                       (match-beginning pos-sum)
+                                       (match-end pos-sum))))
+              (if (and pos-cla (match-beginning pos-cla))
+                  (setq cla (substring summary-and-rest
+                                       (match-beginning pos-cla)
+                                       (match-end pos-cla))))
+              (if (and pos-des (match-beginning pos-des))
+                  (setq des (substring summary-and-rest
+                                       (match-beginning pos-des)
+                                       (match-end pos-des))))
+              (if (and pos-loc (match-beginning pos-loc))
+                  (setq loc (substring summary-and-rest
+                                       (match-beginning pos-loc)
+                                       (match-end pos-loc))))
+              (if (and pos-org (match-beginning pos-org))
+                  (setq org (substring summary-and-rest
+                                       (match-beginning pos-org)
+                                       (match-end pos-org))))
+              (if (and pos-sta (match-beginning pos-sta))
+                  (setq sta (substring summary-and-rest
+                                       (match-beginning pos-sta)
+                                       (match-end pos-sta))))
+              (if (and pos-url (match-beginning pos-url))
+                  (setq url (substring summary-and-rest
+                                       (match-beginning pos-url)
+                                       (match-end pos-url))))
+              (list (if cla (cons 'cla cla) nil)
+                    (if des (cons 'des des) nil)
+                    (if loc (cons 'loc loc) nil)
+                    (if org (cons 'org org) nil)
+                    (if sta (cons 'sta sta) nil)
+                    ;;(if sum (cons 'sum sum) nil)
+                    (if url (cons 'url url) nil))))))))
 
 ;; subroutines for icalendar-export-region
 (defun icalendar--convert-ordinary-to-ical (nonmarker entry-main)
@@ -1454,8 +1547,8 @@
 Argument DIARY-FILENAME input `diary-file'.
 Optional argument NON-MARKING determines whether events are created as
 non-marking or not."
-  (interactive "fImport iCalendar data from file:
-Finto diary file:
+  (interactive "fImport iCalendar data from file: 
+Finto diary file: 
 p")
   ;; clean up the diary file
   (save-current-buffer
@@ -1521,7 +1614,9 @@
 
 (defun icalendar--format-ical-event (event)
   "Create a string representation of an iCalendar EVENT."
-  (let ((string icalendar-import-format)
+  (if (functionp icalendar-import-format)
+      (funcall icalendar-import-format event)
+    (let ((string icalendar-import-format)
         (conversion-list
          '(("%c" CLASS       icalendar-import-format-class)
            ("%d" DESCRIPTION icalendar-import-format-description)
@@ -1549,7 +1644,7 @@
 					    string
 					    t t))))
 	  conversion-list)
-    string))
+    string)))
 
 (defun icalendar--convert-ical-to-diary (ical-list diary-file
                                                    &optional do-not-ask
@@ -1566,6 +1661,7 @@
          (error-string "")
          (event-ok t)
          (found-error nil)
+         (zone-map (icalendar--convert-all-timezones ical-list))
          e diary-string)
     ;; step through all events/appointments
     (while ev
@@ -1574,13 +1670,24 @@
       (setq event-ok nil)
       (condition-case error-val
           (let* ((dtstart (icalendar--get-event-property e 'DTSTART))
-                 (dtstart-dec (icalendar--decode-isodatetime dtstart))
+                 (dtstart-zone (icalendar--find-time-zone
+ 				(icalendar--get-event-property-attributes
+ 				 e 'DTSTART)
+ 				zone-map))
+                 (dtstart-dec (icalendar--decode-isodatetime dtstart nil
+                                                             dtstart-zone))
                  (start-d (icalendar--datetime-to-diary-date
                            dtstart-dec))
                  (start-t (icalendar--datetime-to-colontime dtstart-dec))
                  (dtend (icalendar--get-event-property e 'DTEND))
-                 (dtend-dec (icalendar--decode-isodatetime dtend))
-                 (dtend-1-dec (icalendar--decode-isodatetime dtend -1))
+                 (dtend-zone (icalendar--find-time-zone
+ 			      (icalendar--get-event-property-attributes
+ 			       e 'DTEND)
+ 			      zone-map))
+                 (dtend-dec (icalendar--decode-isodatetime dtend
+                                                           nil dtend-zone))
+                 (dtend-1-dec (icalendar--decode-isodatetime dtend -1
+                                                             dtend-zone))
                  end-d
                  end-1-d
                  end-t
@@ -1953,6 +2060,21 @@
   ;; return diary-file in case it has been changed interactively
   diary-file)
 
+;; ======================================================================
+;; Examples
+;; ======================================================================
+(defun icalendar-import-format-sample (event)
+  "Example function for formatting an icalendar EVENT."
+  (format (concat "SUMMARY=`%s' DESCRIPTION=`%s' LOCATION=`%s' ORGANIZER=`%s' "
+                  "STATUS=`%s' URL=`%s' CLASS=`%s'")
+          (or (icalendar--get-event-property event 'SUMMARY) "")
+          (or (icalendar--get-event-property event 'DESCRIPTION) "")
+          (or (icalendar--get-event-property event 'LOCATION) "")
+          (or (icalendar--get-event-property event 'ORGANIZER) "")
+          (or (icalendar--get-event-property event 'STATUS) "")
+          (or (icalendar--get-event-property event 'URL) "")
+          (or (icalendar--get-event-property event 'CLASS) "")))
+
 (provide 'icalendar)
 
 ;; arch-tag: 74fdbe8e-0451-4e38-bb61-4416e822f4fc
--- a/lisp/comint.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/comint.el	Wed Jan 30 07:57:28 2008 +0000
@@ -822,6 +822,7 @@
 If there is no previous input at point, run the command specified
 by the global keymap (usually `mouse-yank-at-point')."
   (interactive "e")
+  (mouse-set-point event)
   (let ((pos (posn-point (event-end event)))
 	field input)
     (with-selected-window (posn-window (event-end event))
@@ -1022,9 +1023,11 @@
 	 (last-command last-command)
 	 (regexp (read-from-minibuffer prompt nil nil nil
 				       'minibuffer-history-search-history)))
+    ;; If the user didn't enter anything, nothing is added to m-h-s-h.
+    ;; Use the previous search regexp, if there is one.
     (list (if (string-equal regexp "")
-	      (setcar minibuffer-history-search-history
-		      (nth 1 minibuffer-history-search-history))
+              (or (car minibuffer-history-search-history)
+                  regexp)
 	    regexp)
 	  (prefix-numeric-value current-prefix-arg))))
 
--- a/lisp/cus-edit.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/cus-edit.el	Wed Jan 30 07:57:28 2008 +0000
@@ -826,16 +826,19 @@
 
 (defun Custom-save (&rest ignore)
   "Set all edited settings, then save all settings that have been set.
-If a setting was edited and set before, this saves it.
-If a setting was merely edited before, this sets it then saves it."
+If a setting was edited and set before, this saves it.  If a
+setting was merely edited before, this sets it then saves it."
   (interactive)
-  (if (custom-command-apply
-       (lambda (child)
-	 (when (memq (widget-get child :custom-state)
-		     '(modified set changed rogue))
-	   (widget-apply child :custom-save)))
-       "Save all settings in this buffer? " t)
-      (custom-save-all)))
+  (when (custom-command-apply
+	 (lambda (child)
+	   (when (memq (widget-get child :custom-state)
+		       '(modified set changed rogue))
+	     (widget-apply child :custom-mark-to-save)))
+	 "Save all settings in this buffer? " t)
+    ;; Save changes to buffer and redraw.
+    (custom-save-all)
+    (dolist (child custom-options)
+      (widget-apply child :custom-state-set-and-redraw))))
 
 (defun custom-reset (widget &optional event)
   "Select item from reset menu."
@@ -865,20 +868,67 @@
 	 (widget-apply widget :custom-reset-saved)))
    "Reset all settings (current values and buffer text) to saved values? "))
 
+;; The next two variables are bound to '(t) by `Custom-reset-standard'
+;; and `custom-group-reset-standard'.  If these variables are nil, both
+;; `custom-variable-reset-standard' and `custom-face-reset-standard'
+;; save, reset and redraw the handled widget immediately.  Otherwise,
+;; they add the widget to the corresponding list and leave it to
+;; `custom-reset-standard-save-and-update' to save, reset and redraw it.
+(defvar custom-reset-standard-variables-list nil)
+(defvar custom-reset-standard-faces-list nil)
+
+;; The next function was excerpted from `custom-variable-reset-standard'
+;; and `custom-face-reset-standard' and is used to avoid calling
+;; `custom-save-all' repeatedly (and thus saving settings to file one by
+;; one) when erasing all customizations.
+(defun custom-reset-standard-save-and-update ()
+  "Save settings and redraw after erasing customizations."
+  (when (or (and custom-reset-standard-variables-list
+		 (not (eq custom-reset-standard-variables-list  '(t))))
+	    (and custom-reset-standard-faces-list
+		 (not (eq custom-reset-standard-faces-list '(t)))))
+    ;; Save settings to file.
+    (custom-save-all)
+    ;; Set state of and redraw variables.
+    (dolist (widget custom-reset-standard-variables-list)
+      (unless (eq widget t)
+	(widget-put widget :custom-state 'unknown)
+	(custom-redraw widget)))
+    ;; Set state of and redraw faces.
+    (dolist (widget custom-reset-standard-faces-list)
+      (unless (eq widget t)
+	(let* ((symbol (widget-value widget))
+	       (child (car (widget-get widget :children)))
+	       (value (get symbol 'face-defface-spec))
+	       (comment-widget (widget-get widget :comment-widget)))
+	  (put symbol 'face-comment nil)
+	  (widget-value-set child
+			    (custom-pre-filter-face-spec
+			     (list (list t (custom-face-attributes-get
+					    symbol nil)))))
+	  ;; This call manages the comment visibility
+	  (widget-value-set comment-widget "")
+	  (custom-face-state-set widget)
+	  (custom-redraw-magic widget))))))
+
 (defun Custom-reset-standard (&rest ignore)
-  "Erase all customization (either current or saved) for the group members.
+  "Erase all customizations (either current or saved) in current buffer.
 The immediate result is to restore them to their standard values.
 This operation eliminates any saved values for the group members,
 making them as if they had never been customized at all."
   (interactive)
-  (custom-command-apply
-   (lambda (widget)
-     (and (or (null (widget-get widget :custom-standard-value))
-	      (widget-apply widget :custom-standard-value))
-	  (memq (widget-get widget :custom-state)
-		'(modified set changed saved rogue))
-	  (widget-apply widget :custom-reset-standard)))
-   "Erase all customizations for settings in this buffer? " t))
+  ;; Bind these temporarily.
+  (let ((custom-reset-standard-variables-list '(t))
+	(custom-reset-standard-faces-list '(t)))
+    (custom-command-apply
+     (lambda (widget)
+       (and (or (null (widget-get widget :custom-standard-value))
+		(widget-apply widget :custom-standard-value))
+	    (memq (widget-get widget :custom-state)
+		  '(modified set changed saved rogue))
+	    (widget-apply widget :custom-mark-to-reset-standard)))
+     "Erase all customizations for settings in this buffer? " t)
+    (custom-reset-standard-save-and-update)))
 
 ;;; The Customize Commands
 
@@ -1535,7 +1585,7 @@
       (widget-insert "Editing a setting changes only the text in this buffer."
 		     (if init-file
 			 "
-To set apply your changes, use the Save or Set buttons.
+To apply your changes, use the Save or Set buttons.
 Saving a change normally works by editing your init file."
 		       "
 Currently, these settings cannot be saved for future Emacs sessions,
@@ -2441,11 +2491,13 @@
   :value-create 'custom-variable-value-create
   :action 'custom-variable-action
   :custom-set 'custom-variable-set
-  :custom-save 'custom-variable-save
+  :custom-mark-to-save 'custom-variable-mark-to-save
   :custom-reset-current 'custom-redraw
   :custom-reset-saved 'custom-variable-reset-saved
   :custom-reset-standard 'custom-variable-reset-standard
-  :custom-standard-value 'custom-variable-standard-value)
+  :custom-mark-to-reset-standard 'custom-variable-mark-to-reset-standard
+  :custom-standard-value 'custom-variable-standard-value
+  :custom-state-set-and-redraw 'custom-variable-state-set-and-redraw)
 
 (defun custom-variable-type (symbol)
   "Return a widget suitable for editing the value of SYMBOL.
@@ -2807,8 +2859,8 @@
     (custom-variable-state-set widget)
     (custom-redraw-magic widget)))
 
-(defun custom-variable-save (widget)
-  "Set and save the value for the variable being edited by WIDGET."
+(defun custom-variable-mark-to-save (widget)
+  "Set value and mark for saving the variable edited by WIDGET."
   (let* ((form (widget-get widget :custom-form))
 	 (state (widget-get widget :custom-state))
 	 (child (car (widget-get widget :children)))
@@ -2846,10 +2898,18 @@
 	   (put symbol 'variable-comment comment)
 	   (put symbol 'saved-variable-comment comment)))
     (put symbol 'customized-value nil)
-    (put symbol 'customized-variable-comment nil)
-    (custom-save-all)
-    (custom-variable-state-set widget)
-    (custom-redraw-magic widget)))
+    (put symbol 'customized-variable-comment nil)))
+
+(defsubst custom-variable-state-set-and-redraw (widget)
+  "Set state of variable widget WIDGET and redraw with current settings."
+  (custom-variable-state-set widget)
+  (custom-redraw-magic widget))
+
+(defun custom-variable-save (widget)
+  "Save value of variable edited by widget WIDGET."
+  (custom-variable-mark-to-save widget)
+  (custom-save-all)
+  (custom-variable-state-set-and-redraw widget))
 
 (defun custom-variable-reset-saved (widget)
   "Restore the saved value for the variable being edited by WIDGET.
@@ -2875,12 +2935,10 @@
     ;; This call will possibly make the comment invisible
     (custom-redraw widget)))
 
-(defun custom-variable-reset-standard (widget)
-  "Restore the standard setting for the variable being edited by WIDGET.
-This operation eliminates any saved setting for the variable,
-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."
+(defun custom-variable-mark-to-reset-standard (widget)
+  "Mark to restore standard setting for the variable edited by widget WIDGET.
+If `custom-reset-standard-variables-list' is nil, save, reset and
+redraw the widget immediately."
   (let* ((symbol (widget-value widget)))
     (if (get symbol 'standard-value)
 	(custom-variable-backup-value widget)
@@ -2890,13 +2948,32 @@
     (put symbol 'customized-variable-comment 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)
-      (put symbol 'saved-variable-comment nil)
-      (custom-save-all))
-    (widget-put widget :custom-state 'unknown)
-    ;; This call will possibly make the comment invisible
-    (custom-redraw widget)))
+    (if (and custom-reset-standard-variables-list
+	     (or (get symbol 'saved-value) (get symbol 'saved-variable-comment)))
+	(progn
+	  (put symbol 'saved-value nil)
+	  (put symbol 'saved-variable-comment nil)
+	  ;; Append this to `custom-reset-standard-variables-list' to
+	  ;; have `custom-reset-standard-save-and-update' save setting
+	  ;; to the file, update the widget's state, and redraw it.
+	  (setq custom-reset-standard-variables-list
+		(cons widget custom-reset-standard-variables-list)))
+      (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
+	(put symbol 'saved-value nil)
+	(put symbol 'saved-variable-comment nil)
+	(custom-save-all))
+      (widget-put widget :custom-state 'unknown)
+      ;; This call will possibly make the comment invisible
+      (custom-redraw widget))))
+
+(defun custom-variable-reset-standard (widget)
+  "Restore standard setting for the variable edited by WIDGET.
+This operation eliminates any saved setting for the variable,
+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 (custom-reset-standard-variables-list)
+    (custom-variable-mark-to-reset-standard widget)))
 
 (defun custom-variable-backup-value (widget)
   "Back up the current value for WIDGET's variable.
@@ -3172,11 +3249,13 @@
   :custom-category 'face
   :custom-form nil ; defaults to value of `custom-face-default-form'
   :custom-set 'custom-face-set
-  :custom-save 'custom-face-save
+  :custom-mark-to-save 'custom-face-mark-to-save
   :custom-reset-current 'custom-redraw
   :custom-reset-saved 'custom-face-reset-saved
   :custom-reset-standard 'custom-face-reset-standard
+  :custom-mark-to-reset-standard 'custom-face-mark-to-reset-standard
   :custom-standard-value 'custom-face-standard-value
+  :custom-state-set-and-redraw 'custom-face-state-set-and-redraw
   :custom-menu 'custom-face-menu-create)
 
 (define-widget 'custom-face-all 'editable-list
@@ -3321,6 +3400,7 @@
 	   ;; Update buttons.
 	   (widget-put widget :buttons buttons)
 	   ;; Insert documentation.
+	   (widget-put widget :documentation-indent 3)
 	   (widget-add-documentation-string-button
 	    widget :visibility-widget 'custom-visibility)
 
@@ -3510,8 +3590,8 @@
     (custom-face-state-set widget)
     (custom-redraw-magic widget)))
 
-(defun custom-face-save (widget)
-  "Save in `.emacs' the face attributes in WIDGET."
+(defun custom-face-mark-to-save (widget)
+  "Mark for saving the face edited by WIDGET."
   (let* ((symbol (widget-value widget))
 	 (child (car (widget-get widget :children)))
 	 (value (custom-post-filter-face-spec (widget-value child)))
@@ -3532,10 +3612,18 @@
     (put symbol 'customized-face nil)
     (put symbol 'face-comment comment)
     (put symbol 'customized-face-comment nil)
-    (put symbol 'saved-face-comment comment)
-    (custom-save-all)
-    (custom-face-state-set widget)
-    (custom-redraw-magic widget)))
+    (put symbol 'saved-face-comment comment)))
+
+(defsubst custom-face-state-set-and-redraw (widget)
+  "Set state of face widget WIDGET and redraw with current settings."
+  (custom-face-state-set widget)
+  (custom-redraw-magic widget))
+
+(defun custom-face-save (widget)
+  "Save the face edited by WIDGET."
+  (custom-face-mark-to-save widget)
+  (custom-save-all)
+  (custom-face-state-set-and-redraw widget))
 
 ;; For backward compatibility.
 (define-obsolete-function-alias 'custom-face-save-command 'custom-face-save
@@ -3564,10 +3652,10 @@
 (defun custom-face-standard-value (widget)
   (get (widget-value widget) 'face-defface-spec))
 
-(defun custom-face-reset-standard (widget)
-  "Restore WIDGET to the face's standard attribute values.
-This operation eliminates any saved attributes for the face,
-restoring it to the state of a face that has never been customized."
+(defun custom-face-mark-to-reset-standard (widget)
+  "Restore widget WIDGET to the face's standard attribute values.
+If `custom-reset-standard-faces-list' is nil, save, reset and
+redraw the widget immediately."
   (let* ((symbol (widget-value widget))
 	 (child (car (widget-get widget :children)))
 	 (value (get symbol 'face-defface-spec))
@@ -3579,19 +3667,37 @@
     (custom-push-theme 'theme-face symbol 'user 'reset)
     (face-spec-set symbol value t)
     (custom-theme-recalc-face symbol)
-    (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
-      (put symbol 'saved-face nil)
-      (put symbol 'saved-face-comment nil)
-      (custom-save-all))
-    (put symbol 'face-comment nil)
-    (widget-value-set child
-		      (custom-pre-filter-face-spec
-		       (list (list t (custom-face-attributes-get
-				      symbol nil)))))
-    ;; This call manages the comment visibility
-    (widget-value-set comment-widget "")
-    (custom-face-state-set widget)
-    (custom-redraw-magic widget)))
+    (if (and custom-reset-standard-faces-list
+	     (or (get symbol 'saved-face) (get symbol 'saved-face-comment)))
+	;; Do this later.
+	(progn
+	  (put symbol 'saved-face nil)
+	  (put symbol 'saved-face-comment nil)
+	  ;; Append this to `custom-reset-standard-faces-list' and have
+	  ;; `custom-reset-standard-save-and-update' save setting to the
+	  ;; file, update the widget's state, and redraw it.
+	  (setq custom-reset-standard-faces-list
+		(cons widget custom-reset-standard-faces-list)))
+      (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
+	(put symbol 'saved-face nil)
+	(put symbol 'saved-face-comment nil)
+	(custom-save-all))
+      (put symbol 'face-comment nil)
+      (widget-value-set child
+			(custom-pre-filter-face-spec
+			 (list (list t (custom-face-attributes-get
+					symbol nil)))))
+      ;; This call manages the comment visibility
+      (widget-value-set comment-widget "")
+      (custom-face-state-set widget)
+      (custom-redraw-magic widget))))
+
+(defun custom-face-reset-standard (widget)
+  "Restore WIDGET to the face's standard attribute values.
+This operation eliminates any saved attributes for the face,
+restoring it to the state of a face that has never been customized."
+  (let (custom-reset-standard-faces-list)
+    (custom-face-mark-to-reset-standard widget)))
 
 ;;; The `face' Widget.
 
@@ -3736,10 +3842,12 @@
   :action 'custom-group-action
   :custom-category 'group
   :custom-set 'custom-group-set
-  :custom-save 'custom-group-save
+  :custom-mark-to-save 'custom-group-mark-to-save
   :custom-reset-current 'custom-group-reset-current
   :custom-reset-saved 'custom-group-reset-saved
   :custom-reset-standard 'custom-group-reset-standard
+  :custom-mark-to-reset-standard 'custom-group-mark-to-reset-standard
+  :custom-state-set-and-redraw 'custom-group-state-set-and-redraw
   :custom-menu 'custom-group-menu-create)
 
 (defun custom-group-sample-face-get (widget)
@@ -4034,11 +4142,23 @@
     (when (eq (widget-get child :custom-state) 'modified)
       (widget-apply child :custom-set))))
 
+(defun custom-group-mark-to-save (widget)
+  "Mark all modified group members for saving."
+  (dolist (child (widget-get widget :children))
+    (when (memq (widget-get child :custom-state) '(modified set))
+      (widget-apply child :custom-mark-to-save))))
+
+(defsubst custom-group-state-set-and-redraw (widget)
+  "Set state of group widget WIDGET and redraw with current settings."
+  (dolist (child (widget-get widget :children))
+    (when (memq (widget-get child :custom-state) '(modified set))
+      (widget-apply child :custom-state-set-and-redraw))))
+
 (defun custom-group-save (widget)
   "Save all modified group members."
-  (dolist (child (widget-get widget :children))
-    (when (memq (widget-get child :custom-state) '(modified set))
-      (widget-apply child :custom-save))))
+  (custom-group-mark-to-save widget)
+  (custom-save-all)
+  (custom-group-state-set-and-redraw widget))
 
 (defun custom-group-reset-current (widget)
   "Reset all modified group members."
@@ -4054,10 +4174,17 @@
 
 (defun custom-group-reset-standard (widget)
   "Reset all modified, set, or saved group members."
+  (let ((custom-reset-standard-variables-list '(t))
+	(custom-reset-standard-faces-list '(t)))
+    (custom-group-mark-to-reset-standard widget)
+    (custom-reset-standard-save-and-update)))
+
+(defun custom-group-mark-to-reset-standard (widget)
+  "Mark to reset all modified, set, or saved group members."
   (dolist (child (widget-get widget :children))
     (when (memq (widget-get child :custom-state)
 		'(modified set saved))
-      (widget-apply child :custom-reset-standard))))
+      (widget-apply child :custom-mark-to-reset-standard))))
 
 (defun custom-group-state-update (widget)
   "Update magic."
--- a/lisp/cus-start.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/cus-start.el	Wed Jan 30 07:57:28 2008 +0000
@@ -95,7 +95,8 @@
 	     (scroll-down-aggressively windows
 				       (choice (const :tag "off" nil) number)
 				       "21.1")
-	     (line-spacing display (choice (const :tag "none" nil) integer))
+	     (line-spacing display (choice (const :tag "none" nil) integer)
+			   "22.1")
 	     ;; callint.c
 	     (mark-even-if-inactive editing-basics boolean)
 	     ;; callproc.c
@@ -128,7 +129,7 @@
 			     :match (lambda (widget value)
 				      (and value (not (functionp value)))))
 			    (function :value ignore))))
-	     (selection-coding-system mule coding-system)
+	     (selection-coding-system mule coding-system "22.1")
 	     ;; dired.c
 	     (completion-ignored-extensions dired
 					    (repeat (string :format "%v")))
@@ -144,7 +145,7 @@
 	     (max-lisp-eval-depth limits integer)
 	     (max-mini-window-height limits
 				     (choice (const :tag "quarter screen" nil)
-					     number))
+					     number) "23.1")
 	     (stack-trace-on-error debug
 				   (choice (const :tag "off")
 					   (repeat :menu-tag "When"
@@ -178,7 +179,8 @@
 			     (sexp :tag "Value"))))
 	     (mouse-highlight mouse (choice (const :tag "disabled" nil)
 					    (const :tag "always shown" t)
-					    (other :tag "hidden by keypress" 1)))
+					    (other :tag "hidden by keypress" 1))
+			      "22.1")
 	     ;; fringe.c
 	     (overflow-newline-into-fringe fringe boolean)
 	     ;; indent.c
@@ -192,7 +194,7 @@
 	     (polling-period keyboard integer)
 	     (double-click-time mouse (restricted-sexp
 				       :match-alternatives (integerp 'nil 't)))
-	     (double-click-fuzz mouse integer)
+	     (double-click-fuzz mouse integer "22.1")
 	     (inhibit-local-menu-bar-menus menu boolean)
 	     (help-char keyboard character)
 	     (help-event-list keyboard (repeat (sexp :format "%v")))
@@ -250,9 +252,9 @@
 	     (completion-auto-help minibuffer boolean)
 	     (enable-recursive-minibuffers minibuffer boolean)
 	     (history-length minibuffer
-			     (choice (const :tag "Infinite" t)
-				     integer))
-	     (history-delete-duplicates minibuffer boolean)
+			     (choice (const :tag "Infinite" t) integer)
+			     "22.1")
+	     (history-delete-duplicates minibuffer boolean "22.1")
 	     (minibuffer-prompt-properties
 	      minibuffer
 	      (list
@@ -351,14 +353,15 @@
                       ;; and shape of the window.
                       (const :tag "horizontally"
                              (lambda (window)
-                               (split-window window nil 'horiz)))))
+                               (split-window window nil 'horiz))))
+	      "23.1")
 	     (window-min-height windows integer)
 	     (window-min-width windows integer)
  	     (scroll-preserve-screen-position
  	      windows (choice
  		       (const :tag "Off (nil)" :value nil)
  		       (const :tag "Full screen (t)" :value t)
- 		       (other :tag "Always" 1)))
+ 		       (other :tag "Always" 1)) "22.1")
 	     (display-buffer-reuse-frames windows boolean "21.1")
 	     ;; xdisp.c
 	     (scroll-step windows integer)
@@ -372,7 +375,7 @@
 	     (line-number-display-limit display
 					(choice integer
 						(const :tag "No limit" nil)))
-	     (line-number-display-limit-width display integer)
+	     (line-number-display-limit-width display integer "22.1")
 	     (highlight-nonselected-windows display boolean)
 	     (message-log-max debug (choice (const :tag "Disable" nil)
 					    (integer :menu-tag "lines"
@@ -387,7 +390,7 @@
 		       (const :tag "Immediate" :value t)
 		       (number :tag "Delay by secs" :value 0.5)) "22.1")
 	     ;; xfaces.c
-	     (scalable-fonts-allowed display boolean)
+	     (scalable-fonts-allowed display boolean "22.1")
 	     ;; xfns.c
 	     (x-bitmap-file-path installation
 				 (repeat (directory :format "%v")))
--- a/lisp/custom.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/custom.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1176,7 +1176,9 @@
 (defun custom-theme-recalc-face (face)
   "Set FACE according to currently enabled custom themes."
   (if (facep face)
-      (face-spec-recalc face)))
+      (face-spec-set face
+                     (get (or (get face 'face-alias) face)
+                          'face-override-spec))))
 
 ;;; XEmacs compability functions
 
--- a/lisp/delsel.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/delsel.el	Wed Jan 30 07:57:28 2008 +0000
@@ -113,7 +113,23 @@
 	 ;; stop safe_run_hooks from clearing out pre-command-hook.
 	 (and (eq inhibit-quit 'pre-command-hook)
 	      (setq inhibit-quit 'delete-selection-dummy))
-	 (signal 'file-supersession (cdr data)))))))
+	 (signal 'file-supersession (cdr data)))
+	(text-read-only
+	 ;; This signal may come either from `delete-active-region' or
+	 ;; `self-insert-command' (when `overwrite-mode' is non-nil).
+	 ;; To avoid clearing out `pre-command-hook' we handle this case
+	 ;; by issuing a simple message.  Note, however, that we do not
+	 ;; handle all related problems: When read-only text ends before
+	 ;; the end of the region, the latter is not deleted but any
+	 ;; subsequent insertion will succeed.  We could avoid this case
+	 ;; by doing a (setq this-command 'ignore) here.  This would,
+	 ;; however, still not handle the case where read-only text ends
+	 ;; precisely where the region starts: In that case the deletion
+	 ;; would succeed but the subsequent insertion would fail with a
+	 ;; text-read-only error.  To handle that case we would have to
+	 ;; investigate text properties at both ends of the region and
+	 ;; skip the deletion when inserting text is forbidden there.
+	 (message "Text is read-only") (ding))))))
 
 (put 'self-insert-command 'delete-selection t)
 (put 'self-insert-iso 'delete-selection t)
@@ -157,7 +173,7 @@
   (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank
 		 insert-register delete-backward-char backward-delete-char-untabify
 		 delete-char newline-and-indent newline open-line))
-    (remprop sym 'delete-selection))
+    (put sym 'delete-selection nil))
   ;; continue standard unloading
   nil)
 
--- a/lisp/diff-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/diff-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -401,13 +401,9 @@
 (defun diff-end-of-hunk (&optional style)
   ;; Especially important for unified (because headers are ambiguous).
   (setq style (diff-hunk-style style))
-  ;; Some versions of diff replace all-blank context lines in unified
-  ;; format with empty lines. The use of \n below avoids matching such
-  ;; lines as headers.
-  ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html
   (let ((end (and (re-search-forward (case style
 				       ;; A `unified' header is ambiguous.
-				       (unified (concat "^[^-+# \\\n]\\|"
+				       (unified (concat "^[^-+# \\]\\|"
 							diff-file-header-re))
 				       (context "^[^-+#! \\]")
 				       (normal "^[^<>#\\]")
--- a/lisp/doc-view.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/doc-view.el	Wed Jan 30 07:57:28 2008 +0000
@@ -99,11 +99,11 @@
 
 ;;; Todo:
 
+;; - share more code with image-mode again.
 ;; - better menu.
-;; - don't use `find-file'.
 ;; - Bind slicing to a drag event.
 ;; - doc-view-fit-doc-to-window and doc-view-fit-window-to-doc.
-;; - zoom a the region around the cursor (like xdvi).
+;; - zoom the region around the cursor (like xdvi).
 ;; - get rid of the silly arrow in the fringe.
 ;; - improve anti-aliasing (pdf-utils gets it better).
 
@@ -247,6 +247,14 @@
 (defvar doc-view-previous-major-mode nil
   "Only used internally.")
 
+(defvar doc-view-buffer-file-name nil
+  "Only used internally.
+The file name used for conversion.  Normally it's the same as
+`buffer-file-name', but for remote files, compressed files and
+files inside an archive it is a temporary copy of
+the (uncompressed, extracted) file residing in
+`doc-view-cache-directory'.")
+
 ;;;; DocView Keymaps
 
 (defvar doc-view-mode-map
@@ -349,12 +357,7 @@
     ;; Update the buffer
     (doc-view-insert-image (nth (1- page) doc-view-current-files)
                            :pointer 'arrow)
-    (overlay-put doc-view-current-overlay 'help-echo doc-view-current-info)
-    (goto-char (point-min))
-    ;; This seems to be needed for set-window-hscroll (in
-    ;; image-forward-hscroll) to do something useful, I don't have time to
-    ;; debug this now.  :-(  --Stef
-    (forward-char)))
+    (overlay-put doc-view-current-overlay 'help-echo doc-view-current-info)))
 
 (defun doc-view-next-page (&optional arg)
   "Browse ARG pages forward."
@@ -450,12 +453,12 @@
     (setq doc-view-current-cache-dir
 	  (file-name-as-directory
 	   (expand-file-name
-            (let ((doc buffer-file-name))
-              (concat (file-name-nondirectory doc)
-                      "-"
-                      (with-temp-buffer
-                        (insert-file-contents-literally doc)
-                        (md5 (current-buffer)))))
+	    (concat (file-name-nondirectory buffer-file-name)
+		    "-"
+		    (let ((file doc-view-buffer-file-name))
+		      (with-temp-buffer
+			(insert-file-contents-literally file)
+			(md5 (current-buffer)))))
             doc-view-cache-directory)))))
 
 (defun doc-view-remove-if (predicate list)
@@ -476,7 +479,7 @@
 	 (and (doc-view-mode-p 'pdf)
 	      doc-view-dvipdfm-program
 	      (executable-find doc-view-dvipdfm-program)))
-	((or (eq type 'postscript) (eq type 'ps)
+	((or (eq type 'postscript) (eq type 'ps) (eq type 'eps)
 	     (eq type 'pdf))
 	 (and doc-view-ghostscript-program
 	      (executable-find doc-view-ghostscript-program)))
@@ -550,13 +553,16 @@
 (defun doc-view-pdf/ps->png (pdf-ps png)
   "Convert PDF-PS to PNG asynchronously."
   (setq doc-view-current-converter-process
-	(apply 'start-process
-	       (append (list "pdf/ps->png" doc-view-conversion-buffer
-			     doc-view-ghostscript-program)
-		       doc-view-ghostscript-options
-                       (list (format "-r%d" (round doc-view-resolution)))
-		       (list (concat "-sOutputFile=" png))
-		       (list pdf-ps)))
+        ;; Make sure the process is started in an existing directory,
+        ;; (rather than some file-name-handler-managed dir, for example).
+        (let ((default-directory (file-name-directory pdf-ps)))
+          (apply 'start-process
+                 (append (list "pdf/ps->png" doc-view-conversion-buffer
+                               doc-view-ghostscript-program)
+                         doc-view-ghostscript-options
+                         (list (format "-r%d" (round doc-view-resolution)))
+                         (list (concat "-sOutputFile=" png))
+                         (list pdf-ps))))
 	mode-line-process (list (format ":%s" doc-view-current-converter-process)))
   (process-put doc-view-current-converter-process
 	       'buffer (current-buffer))
@@ -620,7 +626,7 @@
   (process-put doc-view-current-converter-process 'pdf-file pdf))
 
 (defun doc-view-convert-current-doc ()
-  "Convert `buffer-file-name' to a set of png files, one file per page.
+  "Convert `doc-view-buffer-file-name' to a set of png files, one file per page.
 Those files are saved in the directory given by the function
 `doc-view-current-cache-dir'."
   ;; Let stale files still display while we recompute the new ones, so only
@@ -632,12 +638,12 @@
   (let ((png-file (expand-file-name "page-%d.png"
                                     (doc-view-current-cache-dir))))
     (make-directory (doc-view-current-cache-dir))
-    (if (not (string= (file-name-extension buffer-file-name) "dvi"))
+    (if (not (string= (file-name-extension doc-view-buffer-file-name) "dvi"))
 	;; Convert to PNG images.
-	(doc-view-pdf/ps->png buffer-file-name png-file)
+	(doc-view-pdf/ps->png doc-view-buffer-file-name png-file)
       ;; DVI files have to be converted to PDF before Ghostscript can process
       ;; it.
-      (doc-view-dvi->pdf buffer-file-name
+      (doc-view-dvi->pdf doc-view-buffer-file-name
 			 (expand-file-name "doc.pdf"
                                            doc-view-current-cache-dir)))))
 
@@ -697,13 +703,23 @@
   (when doc-view-pending-cache-flush
     (clear-image-cache)
     (setq doc-view-pending-cache-flush nil))
-  (let ((image (apply 'create-image file 'png nil args)))
-    (setq doc-view-current-image image)
-    (move-overlay doc-view-current-overlay (point-min) (point-max))
-    (overlay-put doc-view-current-overlay 'display
-                 (if doc-view-current-slice
-                     (list (cons 'slice doc-view-current-slice) image)
-                   image))))
+  (if (null file)
+      ;; We're trying to display a page that doesn't exist.  Typically happens
+      ;; if the conversion process somehow failed.  Better not signal an
+      ;; error here because it could prevent a subsequent reconversion from
+      ;; fixing the problem.
+      (progn
+        (setq doc-view-current-image nil)
+        (move-overlay doc-view-current-overlay (point-min) (point-max))
+        (overlay-put doc-view-current-overlay 'display
+                     "Cannot display this page!  Probably a conversion failure!"))
+    (let ((image (apply 'create-image file 'png nil args)))
+      (setq doc-view-current-image image)
+      (move-overlay doc-view-current-overlay (point-min) (point-max))
+      (overlay-put doc-view-current-overlay 'display
+                   (if doc-view-current-slice
+                       (list (cons 'slice doc-view-current-slice) image)
+                     image)))))
 
 (defun doc-view-sort (a b)
   "Return non-nil if A should be sorted before B.
@@ -847,15 +863,15 @@
 	;; We must convert to TXT first!
 	(if doc-view-current-converter-process
 	    (message "DocView: please wait till conversion finished.")
-	  (let ((ext (file-name-extension buffer-file-name)))
+	  (let ((ext (file-name-extension doc-view-buffer-file-name)))
 	    (cond
 	     ((string= ext "pdf")
 	      ;; Doc is a PDF, so convert it to TXT
-	      (doc-view-pdf->txt buffer-file-name txt))
+	      (doc-view-pdf->txt doc-view-buffer-file-name txt))
 	     ((string= ext "ps")
 	      ;; Doc is a PS, so convert it to PDF (which will be converted to
 	      ;; TXT thereafter).
-	      (doc-view-ps->pdf buffer-file-name
+	      (doc-view-ps->pdf doc-view-buffer-file-name
 				(expand-file-name "doc.pdf"
 						  (doc-view-current-cache-dir))))
 	     ((string= ext "dvi")
@@ -900,7 +916,7 @@
 
 (defun doc-view-initiate-display ()
   ;; Switch to image display if possible
-  (if (doc-view-mode-p (intern (file-name-extension buffer-file-name)))
+  (if (doc-view-mode-p (intern (file-name-extension doc-view-buffer-file-name)))
       (progn
 	(doc-view-buffer-message)
 	(setq doc-view-current-page (or doc-view-current-page 1))
@@ -918,7 +934,7 @@
      "%s"
      (substitute-command-keys
       (concat "No image (png) support available or some conversion utility for "
-	      (file-name-extension buffer-file-name)" files is missing.  "
+	      (file-name-extension doc-view-buffer-file-name)" files is missing.  "
 	      "Type \\[doc-view-toggle-display] to switch to an editing mode.")))))
 
 (defvar bookmark-make-cell-function)
@@ -929,49 +945,72 @@
 You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
 toggle between displaying the document or editing it as text."
   (interactive)
-  (if jka-compr-really-do-compress
-      ;; This is a compressed file uncompressed by auto-compression-mode.
-      (when (y-or-n-p (concat "DocView: Cannot convert compressed file.  "
-			      "Save it uncompressed first? "))
-	(let ((file (read-file-name
-		     "File: "
-		     (file-name-directory buffer-file-name))))
-	  (write-region (point-min) (point-max) file)
-	  (kill-buffer nil)
-	  (find-file file)
-	  (doc-view-mode)))
-    (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
-				doc-view-previous-major-mode
-			      major-mode)))
-      (kill-all-local-variables)
-      (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
-    (make-local-variable 'doc-view-current-files)
-    (make-local-variable 'doc-view-current-image)
-    (make-local-variable 'doc-view-current-page)
-    (make-local-variable 'doc-view-current-converter-process)
-    (make-local-variable 'doc-view-current-timer)
-    (make-local-variable 'doc-view-current-slice)
-    (make-local-variable 'doc-view-current-cache-dir)
-    (make-local-variable 'doc-view-current-info)
-    (make-local-variable 'doc-view-current-search-matches)
-    (set (make-local-variable 'doc-view-current-overlay)
-	 (make-overlay (point-min) (point-max) nil t))
-    (add-hook 'change-major-mode-hook
-	      (lambda () (delete-overlay doc-view-current-overlay))
-	      nil t)
-    (set (make-local-variable 'mode-line-position)
-	 '(" P" (:eval (number-to-string doc-view-current-page))
-	   "/" (:eval (number-to-string (length doc-view-current-files)))))
-    (set (make-local-variable 'cursor-type) nil)
-    (use-local-map doc-view-mode-map)
-    (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc)
-    (set (make-local-variable 'bookmark-make-cell-function)
-			      'doc-view-bookmark-make-cell)
-    (setq mode-name "DocView"
-	  buffer-read-only t
-	  major-mode 'doc-view-mode)
-    (doc-view-initiate-display)
-    (run-mode-hooks 'doc-view-mode-hook)))
+
+  (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
+			      doc-view-previous-major-mode
+			    major-mode)))
+    (kill-all-local-variables)
+    (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
+
+  ;; Handle compressed files, remote files, files inside archives
+  (set (make-local-variable 'doc-view-buffer-file-name)
+       (cond
+	(jka-compr-really-do-compress
+	 (expand-file-name
+	  (file-name-nondirectory
+	   (file-name-sans-extension buffer-file-name))
+	  doc-view-cache-directory))
+        ;; Is the file readable by local processes?
+        ;; We used to use `file-remote-p' but it's unclear what it's
+        ;; supposed to return nil for things like local files accessed via
+        ;; `su' or via file://...
+	((let ((file-name-handler-alist nil))
+           (not (file-readable-p buffer-file-name)))
+	 (expand-file-name
+	  (file-name-nondirectory buffer-file-name)
+	  doc-view-cache-directory))
+	(t buffer-file-name)))
+  (when (not (string= doc-view-buffer-file-name buffer-file-name))
+    (write-region nil nil doc-view-buffer-file-name))
+
+  (make-local-variable 'doc-view-current-files)
+  (make-local-variable 'doc-view-current-image)
+  (make-local-variable 'doc-view-current-page)
+  (make-local-variable 'doc-view-current-converter-process)
+  (make-local-variable 'doc-view-current-timer)
+  (make-local-variable 'doc-view-current-slice)
+  (make-local-variable 'doc-view-current-cache-dir)
+  (make-local-variable 'doc-view-current-info)
+  (make-local-variable 'doc-view-current-search-matches)
+  (set (make-local-variable 'doc-view-current-overlay)
+       (make-overlay (point-min) (point-max) nil t))
+  (add-hook 'change-major-mode-hook
+	    (lambda () (delete-overlay doc-view-current-overlay))
+	    nil t)
+
+  ;; Keep track of [vh]scroll when switching buffers
+  (make-local-variable 'image-mode-current-hscroll)
+  (make-local-variable 'image-mode-current-vscroll)
+  (image-set-window-hscroll (selected-window) (window-hscroll))
+  (image-set-window-vscroll (selected-window) (window-vscroll))
+  (add-hook 'window-configuration-change-hook
+	    'image-reset-current-vhscroll nil t)
+
+  (set (make-local-variable 'mode-line-position)
+       '(" P" (:eval (number-to-string doc-view-current-page))
+	 "/" (:eval (number-to-string (length doc-view-current-files)))))
+  ;; Don't scroll unless the user specifically asked for it.
+  (set (make-local-variable 'auto-hscroll-mode) nil)
+  (set (make-local-variable 'cursor-type) nil)
+  (use-local-map doc-view-mode-map)
+  (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc)
+  (set (make-local-variable 'bookmark-make-cell-function)
+       'doc-view-bookmark-make-cell)
+  (setq mode-name "DocView"
+	buffer-read-only t
+	major-mode 'doc-view-mode)
+  (doc-view-initiate-display)
+  (run-mode-hooks 'doc-view-mode-hook))
 
 ;;;###autoload
 (define-minor-mode doc-view-minor-mode
@@ -1003,7 +1042,7 @@
 
 (defun doc-view-bookmark-make-cell (annotation &rest args)
   (let ((the-record
-         `((filename . ,(buffer-file-name))
+         `((filename . ,buffer-file-name)
            (page     . ,doc-view-current-page)
            (handler  . doc-view-bookmark-jump))))
 
--- a/lisp/ediff-diff.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ediff-diff.el	Wed Jan 30 07:57:28 2008 +0000
@@ -948,7 +948,7 @@
       )))
 
 
-(defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num)
+(defun ediff-convert-fine-diffs-to-overlays (diff-list region-num)
   (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num)
   (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num)
   (if ediff-3way-job
--- a/lisp/ediff-util.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ediff-util.el	Wed Jan 30 07:57:28 2008 +0000
@@ -41,6 +41,9 @@
 
 (defvar ediff-after-quit-hook-internal nil)
 
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+
 (eval-when-compile
   (let ((load-path (cons (expand-file-name ".") load-path)))
     (provide 'ediff-util) ; to break recursive load cycle
@@ -2406,7 +2409,9 @@
 temporarily reverses the meaning of this variable."
   (interactive "P")
   (ediff-barf-if-not-control-buffer)
-  (let ((ctl-buf (current-buffer)))
+  (let ((ctl-buf (current-buffer))
+	(ctl-frm (selected-frame))
+	(minibuffer-auto-raise t))
     (if (y-or-n-p (format "Quit this Ediff session%s? "
 			  (if (ediff-buffer-live-p ediff-meta-buffer)
 			      " & show containing session group" "")))
@@ -2414,6 +2419,8 @@
 	  (message "")
 	  (set-buffer ctl-buf)
 	  (ediff-really-quit reverse-default-keep-variants))
+      (select-frame ctl-frm)
+      (raise-frame ctl-frm)
       (message ""))))
 
 
@@ -2816,7 +2823,6 @@
   (message
    "To resume, type M-x eregistry and select the desired Ediff session"))
 
-
 ;; ediff-barf-if-not-control-buffer ensures only called from ediff.
 (declare-function ediff-version "ediff" ())
 
--- a/lisp/ediff-wind.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ediff-wind.el	Wed Jan 30 07:57:28 2008 +0000
@@ -40,6 +40,11 @@
 (defvar frame-icon-title-format)
 (defvar ediff-diff-status)
 
+;; declare-function does not exist in XEmacs
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+
+
 (eval-when-compile
   (let ((load-path (cons (expand-file-name ".") load-path)))
     (or (featurep 'ediff-init)
--- a/lisp/ediff.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ediff.el	Wed Jan 30 07:57:28 2008 +0000
@@ -8,7 +8,7 @@
 ;; Keywords: comparing, merging, patching, tools, unix
 
 (defconst ediff-version "2.81.2" "The current version of Ediff")
-(defconst ediff-date "August 18, 2007" "Date of last update")
+(defconst ediff-date "January 09, 2008" "Date of last update")
 
 
 ;; This file is part of GNU Emacs.
@@ -113,6 +113,9 @@
 (defvar ediff-last-dir-patch)
 (defvar ediff-patch-default-directory)
 
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+
 
 (eval-when-compile
   (and noninteractive
--- a/lisp/emacs-lisp/avl-tree.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/avl-tree.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; avl-tree.el --- balanced binary trees, AVL-trees
 
-;; Copyright (C) 1995, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Per Cederqvist <ceder@lysator.liu.se>
 ;;	Inge Wallin <inge@lysator.liu.se>
--- a/lisp/emacs-lisp/check-declare.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/check-declare.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; check-declare.el --- Check declare-function statements
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Glenn Morris <rgm@gnu.org>
 ;; Keywords: lisp, tools, maint
--- a/lisp/emacs-lisp/cl-loaddefs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/cl-loaddefs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -10,16 +10,16 @@
 ;;;;;;  ceiling* floor* isqrt lcm gcd cl-progv-before cl-set-frame-visible-p
 ;;;;;;  cl-map-overlays cl-map-intervals cl-map-keymap-recursively
 ;;;;;;  notevery notany every some mapcon mapcan mapl maplist map
-;;;;;;  cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" "53c2b3ede19dac62cff13a37f58cdf9c")
+;;;;;;  cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" "2f89c94c42629315419a9d7404469c42")
 ;;; Generated autoloads from cl-extra.el
 
-(autoload (quote coerce) "cl-extra" "\
+(autoload 'coerce "cl-extra" "\
 Coerce OBJECT to type TYPE.
 TYPE is a Common Lisp type specifier.
 
 \(fn OBJECT TYPE)" nil nil)
 
-(autoload (quote equalp) "cl-extra" "\
+(autoload 'equalp "cl-extra" "\
 Return t if two Lisp objects have similar structures and contents.
 This is like `equal', except that it accepts numerically equal
 numbers of different types (float vs. integer), and also compares
@@ -27,246 +27,246 @@
 
 \(fn X Y)" nil nil)
 
-(autoload (quote cl-mapcar-many) "cl-extra" "\
+(autoload 'cl-mapcar-many "cl-extra" "\
 Not documented
 
 \(fn CL-FUNC CL-SEQS)" nil nil)
 
-(autoload (quote map) "cl-extra" "\
+(autoload 'map "cl-extra" "\
 Map a FUNCTION across one or more SEQUENCEs, returning a sequence.
 TYPE is the sequence type to return.
 
 \(fn TYPE FUNCTION SEQUENCE...)" nil nil)
 
-(autoload (quote maplist) "cl-extra" "\
+(autoload 'maplist "cl-extra" "\
 Map FUNCTION to each sublist of LIST or LISTs.
 Like `mapcar', except applies to lists and their cdr's rather than to
 the elements themselves.
 
 \(fn FUNCTION LIST...)" nil nil)
 
-(autoload (quote mapl) "cl-extra" "\
+(autoload 'mapl "cl-extra" "\
 Like `maplist', but does not accumulate values returned by the function.
 
 \(fn FUNCTION LIST...)" nil nil)
 
-(autoload (quote mapcan) "cl-extra" "\
+(autoload 'mapcan "cl-extra" "\
 Like `mapcar', but nconc's together the values returned by the function.
 
 \(fn FUNCTION SEQUENCE...)" nil nil)
 
-(autoload (quote mapcon) "cl-extra" "\
+(autoload 'mapcon "cl-extra" "\
 Like `maplist', but nconc's together the values returned by the function.
 
 \(fn FUNCTION LIST...)" nil nil)
 
-(autoload (quote some) "cl-extra" "\
+(autoload 'some "cl-extra" "\
 Return true if PREDICATE is true of any element of SEQ or SEQs.
 If so, return the true (non-nil) value returned by PREDICATE.
 
 \(fn PREDICATE SEQ...)" nil nil)
 
-(autoload (quote every) "cl-extra" "\
+(autoload 'every "cl-extra" "\
 Return true if PREDICATE is true of every element of SEQ or SEQs.
 
 \(fn PREDICATE SEQ...)" nil nil)
 
-(autoload (quote notany) "cl-extra" "\
+(autoload 'notany "cl-extra" "\
 Return true if PREDICATE is false of every element of SEQ or SEQs.
 
 \(fn PREDICATE SEQ...)" nil nil)
 
-(autoload (quote notevery) "cl-extra" "\
+(autoload 'notevery "cl-extra" "\
 Return true if PREDICATE is false of some element of SEQ or SEQs.
 
 \(fn PREDICATE SEQ...)" nil nil)
 
-(defalias (quote cl-map-keymap) (quote map-keymap))
+(defalias 'cl-map-keymap 'map-keymap)
 
-(autoload (quote cl-map-keymap-recursively) "cl-extra" "\
+(autoload 'cl-map-keymap-recursively "cl-extra" "\
 Not documented
 
 \(fn CL-FUNC-REC CL-MAP &optional CL-BASE)" nil nil)
 
-(autoload (quote cl-map-intervals) "cl-extra" "\
+(autoload 'cl-map-intervals "cl-extra" "\
 Not documented
 
 \(fn CL-FUNC &optional CL-WHAT CL-PROP CL-START CL-END)" nil nil)
 
-(autoload (quote cl-map-overlays) "cl-extra" "\
+(autoload 'cl-map-overlays "cl-extra" "\
 Not documented
 
 \(fn CL-FUNC &optional CL-BUFFER CL-START CL-END CL-ARG)" nil nil)
 
-(autoload (quote cl-set-frame-visible-p) "cl-extra" "\
+(autoload 'cl-set-frame-visible-p "cl-extra" "\
 Not documented
 
 \(fn FRAME VAL)" nil nil)
 
-(autoload (quote cl-progv-before) "cl-extra" "\
+(autoload 'cl-progv-before "cl-extra" "\
 Not documented
 
 \(fn SYMS VALUES)" nil nil)
 
-(autoload (quote gcd) "cl-extra" "\
+(autoload 'gcd "cl-extra" "\
 Return the greatest common divisor of the arguments.
 
 \(fn &rest ARGS)" nil nil)
 
-(autoload (quote lcm) "cl-extra" "\
+(autoload 'lcm "cl-extra" "\
 Return the least common multiple of the arguments.
 
 \(fn &rest ARGS)" nil nil)
 
-(autoload (quote isqrt) "cl-extra" "\
+(autoload 'isqrt "cl-extra" "\
 Return the integer square root of the argument.
 
 \(fn X)" nil nil)
 
-(autoload (quote floor*) "cl-extra" "\
+(autoload 'floor* "cl-extra" "\
 Return a list of the floor of X and the fractional part of X.
 With two arguments, return floor and remainder of their quotient.
 
 \(fn X &optional Y)" nil nil)
 
-(autoload (quote ceiling*) "cl-extra" "\
+(autoload 'ceiling* "cl-extra" "\
 Return a list of the ceiling of X and the fractional part of X.
 With two arguments, return ceiling and remainder of their quotient.
 
 \(fn X &optional Y)" nil nil)
 
-(autoload (quote truncate*) "cl-extra" "\
+(autoload 'truncate* "cl-extra" "\
 Return a list of the integer part of X and the fractional part of X.
 With two arguments, return truncation and remainder of their quotient.
 
 \(fn X &optional Y)" nil nil)
 
-(autoload (quote round*) "cl-extra" "\
+(autoload 'round* "cl-extra" "\
 Return a list of X rounded to the nearest integer and the remainder.
 With two arguments, return rounding and remainder of their quotient.
 
 \(fn X &optional Y)" nil nil)
 
-(autoload (quote mod*) "cl-extra" "\
+(autoload 'mod* "cl-extra" "\
 The remainder of X divided by Y, with the same sign as Y.
 
 \(fn X Y)" nil nil)
 
-(autoload (quote rem*) "cl-extra" "\
+(autoload 'rem* "cl-extra" "\
 The remainder of X divided by Y, with the same sign as X.
 
 \(fn X Y)" nil nil)
 
-(autoload (quote signum) "cl-extra" "\
+(autoload 'signum "cl-extra" "\
 Return 1 if X is positive, -1 if negative, 0 if zero.
 
 \(fn X)" nil nil)
 
-(autoload (quote random*) "cl-extra" "\
+(autoload 'random* "cl-extra" "\
 Return a random nonnegative number less than LIM, an integer or float.
 Optional second arg STATE is a random-state object.
 
 \(fn LIM &optional STATE)" nil nil)
 
-(autoload (quote make-random-state) "cl-extra" "\
+(autoload 'make-random-state "cl-extra" "\
 Return a copy of random-state STATE, or of `*random-state*' if omitted.
 If STATE is t, return a new state object seeded from the time of day.
 
 \(fn &optional STATE)" nil nil)
 
-(autoload (quote random-state-p) "cl-extra" "\
+(autoload 'random-state-p "cl-extra" "\
 Return t if OBJECT is a random-state object.
 
 \(fn OBJECT)" nil nil)
 
-(autoload (quote cl-float-limits) "cl-extra" "\
+(autoload 'cl-float-limits "cl-extra" "\
 Not documented
 
 \(fn)" nil nil)
 
-(autoload (quote subseq) "cl-extra" "\
+(autoload 'subseq "cl-extra" "\
 Return the subsequence of SEQ from START to END.
 If END is omitted, it defaults to the length of the sequence.
 If START or END is negative, it counts from the end.
 
 \(fn SEQ START &optional END)" nil nil)
 
-(autoload (quote concatenate) "cl-extra" "\
+(autoload 'concatenate "cl-extra" "\
 Concatenate, into a sequence of type TYPE, the argument SEQUENCEs.
 
 \(fn TYPE SEQUENCE...)" nil nil)
 
-(autoload (quote revappend) "cl-extra" "\
+(autoload 'revappend "cl-extra" "\
 Equivalent to (append (reverse X) Y).
 
 \(fn X Y)" nil nil)
 
-(autoload (quote nreconc) "cl-extra" "\
+(autoload 'nreconc "cl-extra" "\
 Equivalent to (nconc (nreverse X) Y).
 
 \(fn X Y)" nil nil)
 
-(autoload (quote list-length) "cl-extra" "\
+(autoload 'list-length "cl-extra" "\
 Return the length of list X.  Return nil if list is circular.
 
 \(fn X)" nil nil)
 
-(autoload (quote tailp) "cl-extra" "\
+(autoload 'tailp "cl-extra" "\
 Return true if SUBLIST is a tail of LIST.
 
 \(fn SUBLIST LIST)" nil nil)
 
-(autoload (quote get*) "cl-extra" "\
+(autoload 'get* "cl-extra" "\
 Return the value of SYMBOL's PROPNAME property, or DEFAULT if none.
 
 \(fn SYMBOL PROPNAME &optional DEFAULT)" nil nil)
 
-(autoload (quote getf) "cl-extra" "\
+(autoload 'getf "cl-extra" "\
 Search PROPLIST for property PROPNAME; return its value or DEFAULT.
 PROPLIST is a list of the sort returned by `symbol-plist'.
 
 \(fn PROPLIST PROPNAME &optional DEFAULT)" nil nil)
 
-(autoload (quote cl-set-getf) "cl-extra" "\
+(autoload 'cl-set-getf "cl-extra" "\
 Not documented
 
 \(fn PLIST TAG VAL)" nil nil)
 
-(autoload (quote cl-do-remf) "cl-extra" "\
+(autoload 'cl-do-remf "cl-extra" "\
 Not documented
 
 \(fn PLIST TAG)" nil nil)
 
-(autoload (quote cl-remprop) "cl-extra" "\
+(autoload 'cl-remprop "cl-extra" "\
 Remove from SYMBOL's plist the property PROPNAME and its value.
 
 \(fn SYMBOL PROPNAME)" nil nil)
 
-(defalias (quote remprop) (quote cl-remprop))
+(defalias 'remprop 'cl-remprop)
 
-(defalias (quote cl-gethash) (quote gethash))
+(defalias 'cl-gethash 'gethash)
 
-(defalias (quote cl-puthash) (quote puthash))
+(defalias 'cl-puthash 'puthash)
 
-(defalias (quote cl-remhash) (quote remhash))
+(defalias 'cl-remhash 'remhash)
 
-(defalias (quote cl-clrhash) (quote clrhash))
+(defalias 'cl-clrhash 'clrhash)
 
-(defalias (quote cl-maphash) (quote maphash))
+(defalias 'cl-maphash 'maphash)
 
-(defalias (quote cl-make-hash-table) (quote make-hash-table))
+(defalias 'cl-make-hash-table 'make-hash-table)
 
-(defalias (quote cl-hash-table-p) (quote hash-table-p))
+(defalias 'cl-hash-table-p 'hash-table-p)
 
-(defalias (quote cl-hash-table-count) (quote hash-table-count))
+(defalias 'cl-hash-table-count 'hash-table-count)
 
-(autoload (quote cl-macroexpand-all) "cl-extra" "\
+(autoload 'cl-macroexpand-all "cl-extra" "\
 Expand all macro calls through a Lisp FORM.
 This also does some trivial optimizations to make the form prettier.
 
 \(fn FORM &optional ENV)" nil nil)
 
-(autoload (quote cl-prettyexpand) "cl-extra" "\
+(autoload 'cl-prettyexpand "cl-extra" "\
 Not documented
 
 \(fn FORM &optional FULL)" nil nil)
@@ -745,7 +745,7 @@
 ;;;;;;  find nsubstitute-if-not nsubstitute-if nsubstitute substitute-if-not
 ;;;;;;  substitute-if substitute delete-duplicates remove-duplicates
 ;;;;;;  delete-if-not delete-if delete* remove-if-not remove-if remove*
-;;;;;;  replace fill reduce) "cl-seq" "cl-seq.el" "77bee7df392948b6ab0699e391e8abc1")
+;;;;;;  replace fill reduce) "cl-seq" "cl-seq.el" "e3c349e5231811c1c0482dd378dae56a")
 ;;; Generated autoloads from cl-seq.el
 
 (autoload 'reduce "cl-seq" "\
--- a/lisp/emacs-lisp/cl-macs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/cl-macs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2508,11 +2508,12 @@
 omitted, a default message listing FORM itself is used."
   (and (or (not (cl-compiling-file))
 	   (< cl-optimize-speed 3) (= cl-optimize-safety 3))
-       (let ((sargs (and show-args (delq nil (mapcar
-					      (function
-					       (lambda (x)
-						 (and (not (cl-const-expr-p x))
-						      x))) (cdr form))))))
+       (let ((sargs (and show-args
+			 (delq nil (mapcar
+				     (lambda (x)
+				       (unless (cl-const-expr-p x)
+					 x))
+				    (cdr form))))))
 	 (list 'progn
 	       (list 'or form
 		     (if string
--- a/lisp/emacs-lisp/easymenu.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/easymenu.el	Wed Jan 30 07:57:28 2008 +0000
@@ -216,12 +216,18 @@
    (setq menu (cdr (easy-menu-convert-item menu)))))
  menu)
 
+(defvar easy-menu-avoid-duplicate-keys t
+  "Dynamically scoped var to register already used keys in a menu.
+If it holds a list, this is expected to be a list of keys already seen in the
+menu we're processing.  Else it means we're not processing a menu.")
+
 ;;;###autoload
 (defun easy-menu-create-menu (menu-name menu-items)
   "Create a menu called MENU-NAME with items described in MENU-ITEMS.
 MENU-NAME is a string, the name of the menu.  MENU-ITEMS is a list of items
 possibly preceded by keyword pairs as described in `easy-menu-define'."
   (let ((menu (make-sparse-keymap menu-name))
+        (easy-menu-avoid-duplicate-keys nil)
 	prop keyword arg label enable filter visible help)
     ;; Look for keywords.
     (while (and menu-items
@@ -341,22 +347,22 @@
 		(setq prop (cons :button
 				 (cons (cons (cdr style) selected) prop)))))
 	      (when (stringp keys)
-		 (if (string-match "^[^\\]*\\(\\\\\\[\\([^]]+\\)]\\)[^\\]*$"
-				   keys)
-		     (let ((prefix
-			    (if (< (match-beginning 0) (match-beginning 1))
-				(substring keys 0 (match-beginning 1))))
-			   (postfix
-			    (if (< (match-end 1) (match-end 0))
-				(substring keys (match-end 1))))
-			   (cmd (intern (match-string 2 keys))))
-		       (setq keys (and (or prefix postfix)
-				       (cons prefix postfix)))
-		       (setq keys
-			     (and (or keys (not (eq command cmd)))
-				  (cons cmd keys))))
-		   (setq cache-specified nil))
-		 (if keys (setq prop (cons :keys (cons keys prop)))))
+                (if (string-match "^[^\\]*\\(\\\\\\[\\([^]]+\\)]\\)[^\\]*$"
+                                  keys)
+                    (let ((prefix
+                           (if (< (match-beginning 0) (match-beginning 1))
+                               (substring keys 0 (match-beginning 1))))
+                          (postfix
+                           (if (< (match-end 1) (match-end 0))
+                               (substring keys (match-end 1))))
+                          (cmd (intern (match-string 2 keys))))
+                      (setq keys (and (or prefix postfix)
+                                      (cons prefix postfix)))
+                      (setq keys
+                            (and (or keys (not (eq command cmd)))
+                                 (cons cmd keys))))
+                  (setq cache-specified nil))
+                (if keys (setq prop (cons :keys (cons keys prop)))))
 	      (if (and visible (not (easy-menu-always-true-p visible)))
 		  (if (equal visible ''nil)
 		      ;; Invisible menu item. Don't insert into keymap.
@@ -371,12 +377,27 @@
     ;; `intern' the name so as to merge multiple entries with the same name.
     ;; It also makes it easier/possible to lookup/change menu bindings
     ;; via keymap functions.
-    (cons (easy-menu-intern name)
-	  (and (not remove)
-	       (cons 'menu-item
-		     (cons label
-			   (and name
-				(cons command prop))))))))
+    (let ((key (easy-menu-intern name)))
+      (when (listp easy-menu-avoid-duplicate-keys)
+        ;; Merging multiple entries with the same name is sometimes what we
+        ;; want, but not when the entries are actually different (e.g. same
+        ;; name but different :suffix as seen in cal-menu.el) and appear in
+        ;; the same menu.  So we try to detect and resolve conflicts.
+        (while (and (stringp name)
+                    (memq key easy-menu-avoid-duplicate-keys))
+          ;; We need to use some distinct object, ideally a symbol, ideally
+          ;; related to the `name'.  Uninterned symbols do not work (they
+          ;; are apparently turned into strings and re-interned later on).
+          (setq key (intern (format "%s (%d)" (symbol-name key)
+                                    (length easy-menu-avoid-duplicate-keys)))))
+        (push key easy-menu-avoid-duplicate-keys))
+
+      (cons key
+            (and (not remove)
+                 (cons 'menu-item
+                       (cons label
+                             (and name
+                                  (cons command prop)))))))))
 
 (defun easy-menu-define-key (menu key item &optional before)
   "Add binding in MENU for KEY => ITEM.  Similar to `define-key-after'.
--- a/lisp/emacs-lisp/find-func.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emacs-lisp/find-func.el	Wed Jan 30 07:57:28 2008 +0000
@@ -200,11 +200,17 @@
    (let* ((path (cons (or find-function-source-path load-path)
 		      (find-library-suffixes)))
 	  (def (if (eq (function-called-at-point) 'require)
-		   (save-excursion
-		     (backward-up-list)
-		     (forward-char)
-		     (backward-sexp -2)
-		     (thing-at-point 'symbol))
+		   ;; `function-called-at-point' may return 'require
+		   ;; with `point' anywhere on this line.  So wrap the
+		   ;; `save-excursion' below in a `condition-case' to
+		   ;; avoid reporting a scan-error here.
+		   (condition-case nil
+		       (save-excursion
+			 (backward-up-list)
+			 (forward-char)
+			 (forward-sexp 2)
+			 (thing-at-point 'symbol))
+		     (error nil))
 		 (thing-at-point 'symbol))))
      (when def
        (setq def (and (locate-file-completion def path 'test) def)))
@@ -233,8 +239,12 @@
     (setq symbol (get symbol 'definition-name)))
   (if (string-match "\\`src/\\(.*\\.c\\)\\'" library)
       (find-function-C-source symbol (match-string 1 library) type)
-    (if (string-match "\\.el\\(c\\)\\'" library)
-	(setq library (substring library 0 (match-beginning 1))))
+    (when (string-match "\\.el\\(c\\)\\'" library)
+      (setq library (substring library 0 (match-beginning 1))))
+    ;; Strip extension from .emacs.el to make sure symbol is searched in
+    ;; .emacs too.
+    (when (string-match "\\.emacs\\(.el\\)" library)
+      (setq library (substring library 0 (match-beginning 1))))
     (let* ((filename (find-library-name library))
 	   (regexp-symbol (cdr (assq type find-function-regexp-alist))))
       (with-current-buffer (find-file-noselect filename)
--- a/lisp/emulation/crisp.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/crisp.el	Wed Jan 30 07:57:28 2008 +0000
@@ -148,7 +148,7 @@
 
 (defun crisp-region-active ()
   "Compatibility function to test for an active region."
-  (if (boundp 'zmacs-region-active-p)
+  (if (featurep 'xemacs)
       zmacs-region-active-p
     mark-active))
 
--- a/lisp/emulation/tpu-edt.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/tpu-edt.el	Wed Jan 30 07:57:28 2008 +0000
@@ -751,9 +751,7 @@
 Sets the mark at POS and activates the region according to the
 current version of Emacs."
   (set-mark pos)
-  ;; We use a separate `if' for the fboundp so the byte-compiler notices it
-  ;; and doesn't complain about the subsequent call.
-  (if (fboundp 'zmacs-activate-region) (if pos (zmacs-activate-region))))
+  (when (featurep 'xemacs) (when pos (zmacs-activate-region))))
 
 (defun tpu-string-prompt (prompt history-symbol)
   "Read a string with PROMPT."
@@ -2439,7 +2437,7 @@
 
 
 ;;;### (autoloads (tpu-set-cursor-bound tpu-set-cursor-free tpu-set-scroll-margins
-;;;;;;  tpu-cursor-free-mode) "tpu-extras" "tpu-extras.el" "e0629234f1abe076917a303456b48329")
+;;;;;;  tpu-cursor-free-mode) "tpu-extras" "tpu-extras.el" "c7ce8bad68736a5682eb3f5f5edc48db")
 ;;; Generated autoloads from tpu-extras.el
 
 (autoload 'tpu-cursor-free-mode "tpu-extras" "\
--- a/lisp/emulation/viper-cmd.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/viper-cmd.el	Wed Jan 30 07:57:28 2008 +0000
@@ -47,6 +47,9 @@
 (defvar initial)
 (defvar undo-beg-posn)
 (defvar undo-end-posn)
+
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
 ;; end pacifier
 
 
@@ -2773,7 +2776,9 @@
 (defun viper-next-line-carefully (arg)
   (condition-case nil
       ;; do not use forward-line! need to keep column
-      (with-no-warnings (next-line arg))
+      (if (featurep 'emacs)
+	  (with-no-warnings (next-line arg))
+	(next-line arg))
     (error nil)))
 
 
@@ -3073,7 +3078,9 @@
 	(com (viper-getCom arg)))
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     ;; do not use forward-line! need to keep column
-    (with-no-warnings (next-line val))
+    (if (featurep 'emacs)
+	(with-no-warnings (next-line val))
+      (next-line val))
     (if viper-ex-style-motion
 	(if (and (eolp) (not (bolp))) (backward-char 1)))
     (setq this-command 'next-line)
@@ -3120,7 +3127,9 @@
 	(com (viper-getCom arg)))
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     ;; do not use forward-line! need to keep column
-    (with-no-warnings (previous-line val))
+    (if (featurep 'emacs)
+	(with-no-warnings (previous-line val))
+      (previous-line val))
     (if viper-ex-style-motion
 	(if (and (eolp) (not (bolp))) (backward-char 1)))
     (setq this-command 'previous-line)
--- a/lisp/emulation/viper-ex.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/viper-ex.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2216,9 +2216,11 @@
 	(pos2 (viper-line-pos 'end))
 	lines file info)
     (setq lines (count-lines (point-min) (viper-line-pos 'end))
-	  file (if (buffer-file-name)
-		   (concat (viper-abbreviate-file-name (buffer-file-name)) ":")
-		 (concat (buffer-name) " [Not visiting any file]:"))
+	  file (cond ((buffer-file-name)
+		      (concat (viper-abbreviate-file-name (buffer-file-name)) ":"))
+		     ((buffer-file-name (buffer-base-buffer))
+		      (concat (viper-abbreviate-file-name (buffer-file-name (buffer-base-buffer))) " (indirect buffer):"))
+		     (t (concat (buffer-name) " [Not visiting any file]:")))
 	  info (format "line=%d/%d pos=%d/%d col=%d %s"
 		       (if (= pos1 pos2)
 			   (1+ lines)
--- a/lisp/emulation/viper-keym.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/viper-keym.el	Wed Jan 30 07:57:28 2008 +0000
@@ -33,6 +33,9 @@
 (defvar viper-expert-level)
 (defvar viper-ex-style-editing)
 (defvar viper-ex-style-motion)
+
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
 ;; end pacifier
 
 (require 'viper-util)
--- a/lisp/emulation/viper-util.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/viper-util.el	Wed Jan 30 07:57:28 2008 +0000
@@ -44,6 +44,9 @@
 
 (require 'ring)
 
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+
 ;; end pacifier
 
 (require 'viper-init)
@@ -713,7 +716,7 @@
 	     (not (memq (vc-state file) '(edited needs-merge)))
 	     (not (stringp (vc-state file))))
 	 ;; XEmacs has no vc-state
-	 (if (featurep 'xemacs)(not (vc-locking-user file))))
+	 (if (featurep 'xemacs) (not (vc-locking-user file))))
        ))
 
 ;; checkout if visited file is checked in
--- a/lisp/emulation/viper.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/emulation/viper.el	Wed Jan 30 07:57:28 2008 +0000
@@ -9,7 +9,7 @@
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Keywords: emulations
 
-(defconst viper-version "3.14 of August 18, 2007"
+(defconst viper-version "3.14 of January 09, 2008"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
@@ -857,7 +857,9 @@
 	       (modify-frame-parameters
 		(selected-frame)
 		(list (cons 'viper-vi-state-cursor-color
-			    (viper-get-cursor-color))))))
+			    (viper-get-cursor-color))))
+	       (setq viper-vi-state-cursor-color (viper-get-cursor-color))
+	       ))
 
   ;; Tell vc-diff to put *vc* in Vi mode
   (if (featurep 'vc)
@@ -900,6 +902,7 @@
     (modify-frame-parameters
 	(selected-frame)
 	(list (cons 'viper-vi-state-cursor-color (ad-get-arg 0))))
+    (setq viper-vi-state-cursor-color (ad-get-arg 0))
     )
 
   (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
--- a/lisp/erc/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,828 +1,288 @@
+2008-01-26  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-version-string): Release ERC 5.3.
+
+	* Makefile (VERSION): Update.
+	(EXTRAS): Remove erc-list.el after all, because this is mainly for
+	users of the version that comes with Emacs, and they will have
+	erc-list.el by Emacs 23.
+	(MISC): Add ChangeLog.07.
+
+	* README.extras: Mention Emacs 23.
+
+	* erc.texi (Obtaining ERC): Update extras URLs for 5.3.
+	(Development): Write instructions for git, and remove those for
+	Arch.
+	(History): Mention the switch to git.
+
+2008-01-25  Michael Olson  <mwolson@gnu.org>
+
+	* NEWS: Update.
+
+	* erc-goodies.el (keep-place): New module which keeps your place
+	in unvisited ERC buffers when new messages arrive.  This is mostly
+	taken from Johan Bockgård's init file.
+	(erc-noncommands-list): Move to correct place.
+
+	* erc-networks.el: Add a module definition.
+
+	* erc-services.el (erc-nickserv-identify-mode): Force-enable the
+	networks module, because we need it to set erc-network for us.
+
+	* erc-track.el (erc-track-faces-normal-list): Indicate in the
+	docstring that this variable can be set to nil.
+
+	* erc.el: On second thought, don't load erc-networks.  Just enable
+	the networks module by default.
+	(erc-modules): Add option for keep-place and networks.  Enable
+	networks by default.
+	(erc-version-string): Make release candidate 1 available.
+
+2008-01-24  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el: Load erc-networks.el so that functions get access to the
+	`erc-network-name' function.
+
+	* erc-track.el (erc-track-faces-normal-list): Add
+	erc-dangerous-host-face.
+	(erc-track-exclude-types): Add 333 and 353 to the default list of
+	things to ignore, and explain what they are in the docstring.
+
+2008-01-23  Michael Olson  <mwolson@gnu.org>
+
+	* erc-track.el (erc-track-faces-priority-list): Move
+	erc-nick-default-face higher, so that it can be used for the
+	activity indication effect.  Add erc-current-nick-face,
+	erc-pal-face, erc-dangerous-host-face, and erc-fool-face by
+	themselves.
+	(erc-track-faces-normal-list): New option that contains a list of
+	faces to consider "normal".
+	(erc-track-position-in-mode-line): Minor docfix.
+	(erc-track-find-face): Use erc-track-faces-normal-list to produce
+	a sort of blinking activity effect.
+
+2008-01-22  Michael Olson  <mwolson@gnu.org>
+
+	* erc-button.el (erc-button-add-nickname-buttons): When in a
+	channel buffer, only look at nicks from the current channel.
+	Thanks to e1f for the report.
+
+2008-01-21  Michael Olson  <mwolson@gnu.org>
+
+	* erc-compat.el (erc-const-expr-p, erc-list*, erc-assert): Remove,
+	since we can use the default `assert' function without it causing
+	us any problems, even in Emacs 21.  Thanks to bojohan for the
+	suggestion.
+
+	* erc-goodies.el (move-to-prompt): Use the "XEmacs" method
+	instead, because the [remap ...] method interferes with
+	delete-selection-mode.
+	(erc-move-to-prompt): Rename from erc-move-to-prompt-xemacs.
+	Deactivate mark and call push-mark before moving point.  Thanks to
+	bojohan for the suggestion.
+	(erc-move-to-prompt-setup): Rename from
+	erc-move-to-prompt-init-xemacs.
+
+	* erc-track.el (erc-track-faces-priority-list): Replace erc-button
+	with '(erc-button erc-default-face) so that we only care about
+	buttons that are part of normal text.  Adjust customization type
+	to handle this case.  Make erc-nick-default-face a list.  Handle
+	pals, fools, current nick, and dangerous hosts.
+	(erc-track-find-face): Simplify.  Adapt for list of faces case.
+	(erc-faces-in): Don't deflate lists of faces.  Add them as-is.
+	(erc-track-face-priority): Use equal instead of eq.
+
+2008-01-20  Michael Olson  <mwolson@gnu.org>
+
+	* erc-goodies.el (erc-move-to-prompt, erc-move-to-prompt-xemacs):
+	Fix off-by-one error that caused the point to move when placed at
+	the beginning of some already-typed text.  Thanks to e1f for the
+	report.
+
+	* erc-dcc.el, erc-xdcc.el: Add simple module definitions.
+
+	* erc.el (erc-modules): Add dcc and xdcc.
+
+2008-01-19  Michael Olson  <mwolson@gnu.org>
+
+	* erc-bbdb.el (erc-bbdb-insinuate-and-show-entry): Work around bug
+	in XEmacs 21.4 that throws an error when the first argument to
+	run-at-time is nil.
+
+	* erc-button.el (button): Undo XEmacs-specific change to all ERC
+	buffers when module is removed.
+	(erc-button-setup): Rename from erc-button-add-keys, and move
+	XEmacs-specific stuff here.
+
+	* erc-goodies.el (erc-unmorse): Improve regexp for detecting
+	morse.  Deal with the morse style that has "/ " at the end of
+	every letter.
+	(erc-imenu-setup): New function that sets up Imenu support.  Add
+	it instead of a lambda form to erc-mode-hook.
+	(scrolltobottom): Remove erc-scroll-to-bottom from all ERC buffers
+	when module is removed.  Activate the functionality in all ERC
+	buffers when the module is activated, rather than leaving it up to
+	the user.
+	(move-to-prompt): New module that moves to the ERC prompt if a
+	user tries to type elsewhere in the buffer, and then inserts their
+	keystrokes there.  This is mostly taken from Johan Bockgård's init
+	file.
+	(erc-move-to-prompt): New function that implements this.
+	(erc-move-to-prompt-xemacs): New function that implements this for
+	XEmacs.
+	(erc-move-to-prompt-init-xemacs): New function to perform the
+	extra initialization step needed for XEmacs.
+
+	* erc-page.el, erc-replace.el: Fix header and footer.
+
+	* erc-track.el (erc-track-minor-mode-maybe): Take an optional
+	buffer arg so that we can put this in erc-connect-pre-hook.  If
+	given this argument, include it in the check to determine whether
+	to activate erc-track-minor-mode.
+	(track): Add erc-track-minor-mode-maybe to erc-connect-pre-hook,
+	so that we can use it as soon as a connection is attempted.
+
+	* erc.el (erc-format-network, erc-format-target-and/or-network):
+	Use erc-network-name function instead, and check to see whether
+	that function is bound.  This fixes an error in process filter for
+	people who did not have erc-services or erc-networks loaded.
+	(erc-modules): Add move-to-prompt module and enable it by
+	default.  Thanks to e1f for the suggestion.
+
+2008-01-18  Michael Olson  <mwolson@gnu.org>
+
+	* Makefile (EXTRAS): Include erc-list-old.el.
+
+	* erc-dcc.el (erc-dcc-verbose): Rename from erc-verbose-dcc.
+	(erc-pack-int): Rewrite to not depend on a count argument.
+	(erc-unpack-int): Rewrite to remove 4-character limitation.
+	(erc-dcc-server): Call set-process-coding-system and
+	set-process-filter-multibyte so that the contents get sent out
+	without modification.
+	(erc-dcc-send-filter): Don't take a substring -- just pass the
+	whole string to erc-unpack-int.
+	(erc-dcc-receive-cache): New option that indicates the number of
+	bytes to let the receive buffer grow before flushing it.
+	(erc-dcc-file-name): New buffer-local variable to keep track of
+	the filename of the currently-received file.
+	(erc-dcc-get-file): Disable undo for a speed increase.  Set
+	erc-dcc-file-name.  Truncate the file before writing to it.
+	(erc-dcc-append-contents): New function to append the contents of
+	a buffer to a file and then erase the contents of the buffer.
+	(erc-dcc-get-filter): Flush buffer contents after exceeding
+	erc-dcc-receive-cache.  This allows large files to be downloaded
+	without storing the whole thing in memory.
+	(erc-dcc-get-sentinel): Flush any remaining contents before
+	closing.  No need to save buffer.
+	(erc-dcc-listen-host): New option that determines which IP address
+	to listen on.
+	(erc-dcc-public-host): New option that determines which IP address
+	to advertise when sending a file.  This is useful for people who
+	are on a local subnet.  Together, these two options replace
+	erc-dcc-host.
+
+	* erc.el (erc-mode-line-format): Add %N and %S.  %N is the name of
+	the network, and %S is much like %s but with the network name
+	trumping the server name.  Default to "%S %a".  Thanks to e1f for
+	the suggestion.
+	(erc-format-network): New function that formats the network name.
+	(erc-format-target-and/or-network): New function that formats both
+	the network name and target, falling back on the server name if
+	the network name is not available.
+	(erc-update-mode-line-buffer): Add the new format spec items.
+
+2008-01-17  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-join-buffer): Improve documentation.
+	(erc-query-display): New option indicating how to display a query
+	buffer that is made by using the /QUERY command.  The default is
+	to display the query in a new window.
+	(erc-cmd-QUERY): Use it.  Improve docstring.
+	(erc-auto-query): Default this to 'window-noselect instead,
+	because I've already seen bug reports about new users thinking
+	that ERC didn't display their test messages.  Improve
+	customization type.
+	(erc-notice-face): Make this work with XEmacs.
+	(erc-join-buffer): Mention 'buffer in docstring.  Improve
+	customization type.
+
+	* erc-dcc.el (erc-dcc-send-sentinel): Better handle case where elt
+	is nil, in order to avoid an error.  Thanks to Brent Goodrick for
+	the initial patch.
+	(erc-dcc-display-send): New function split from erc-dcc-send-hook.
+	(erc-dcc-send-connect-hook): Use it -- we don't like lambda forms
+	in hooks.
+	(erc-dcc-send-filter): Display byte count if the client confirmed
+	too much, and kill the buffer.  Otherwise a DoS might be possible
+	by making Emacs run out of RAM.
+
+	* erc-backend.el (erc-server-connect): Detect early on whether the
+	connection attempt has failed in order to avoid confusing error
+	messages.
+
+	* erc-networks.el (erc-server-alist): Add Rizon network.
+
+	* erc-services.el (erc-nickserv-passwords): Add Rizon to options.
+	(erc-nickserv-alist): Add support for Rizon.
+
+	* erc-track.el (erc-track-find-face): Don't let buttons in notices
+	trump default text.  Use catch/throw.  Default to first element of
+	FACES is nothing is found.
+
+	* erc-xdcc.el: Add local variables for proper indentation setup.
+
+2008-01-15  Michael Olson  <mwolson@gnu.org>
+
+	* erc-backend.el (erc-server-coding-system): Docfix.
+	(erc-coding-system-for-target): Pass the `target' argument along
+	as the first and only argument.  It's not good to just depend on a
+	dynamic binding.
+
+2008-01-10  Michael Olson  <mwolson@gnu.org>
+
+	* erc-backend.el (321, 322): Split message-displaying parts into
+	new functions, which are added to each response's respective
+	hook.  This makes them easier to disable.
+
+	* erc-list.el: New file from Tom Tromey.  Use erc-propertize
+	instead of propertize.  Require 'erc.
+	(list): New module definition.  Remove message-displaying
+	functions for 321 and 322 response handlers when enabling the
+	module, and restore them when disabling.  As a sanity check,
+	remove the erc-list-handle-322 function when disabling the module.
+	(erc-list-handle-322): Handle the case where we run the LIST
+	command, but do not go through the normal steps.
+	(erc-cmd-LIST): Add docstring.  Strip initial space from line if
+	it is non-nil.  Use make-local-variable to silence compiler
+	warning.  Capture current buffer and pass it to
+	erc-list-install-322-handler.
+	(erc-list-install-322-handler): Take server-buffer argument, so
+	that we are certain of being in the right buffer.  Use 4th
+	argument to add-hook, so that erc-server-322-functions is only
+	modified in one buffer.
+
+	* erc-list-old.el: Renamed from old erc-list.el.
+
+	* erc.el (erc-modules): Add list-old.
+	(erc-set-topic): Handle case where there are no newlines in the
+	existing topic, which happens when /LIST is run.
+	(erc-notice-face): If we have less than 88 colors, make this
+	blue.  Otherwise the text will be pink in a tty, which looks
+	dreadful.  Thanks to e1f for the report.
+	(erc-remove-parsed-property): New option that determines whether
+	to remove the erc-parsed property after displaying a message.
+	This should have the effect of making ERC take up less memory.
+	(erc-display-line-1): Use it.
+
 2008-01-04  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* erc-ibuffer.el (erc-channel-modes):
 	Pass mode-name through format-mode-line
 
-2007-12-09  Michael Olson  <mwolson@gnu.org>
-
-	* erc-services.el (erc-nickserv-alist): Fix regexps for GRnet.
-
-2007-12-09  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
-
-	* erc-backend.el, erc.el:
-	Parse 275 (secure connection) responses.
-
-	* erc-services.el: Add identification hooks for GRnet, the Greek
-	IRC network <http://www.irc.gr>.
-
-2007-12-08  David Kastrup  <dak@gnu.org>
-
-	* erc-stamp.el (erc-echo-timestamp):
-	* erc-lang.el (language):
-	* erc-backend.el (erc-server-connect): Fix buggy call to `message'.
-
-2007-12-07  Edward O'Connor  <ted@oconnor.cx>
-
-	* erc-services.el: Provide a hook that runs when nickserv confirms
-	that the user has successfully identified.
-	(services, erc-nickserv-identify-mode): Add and remove
-	erc-nickserv-identification-autodetect from
-	erc-server-NOTICE-functions.
-	(erc-nickserv-alist): Add SUCCESS-REGEXP to each entry.
-	(erc-nickserv-alist-identified-regexp)
-	(erc-nickserv-identification-autodetect): New functions.
-	(erc-nickserv-identified-hook): New hook.
-
-2007-12-06  D. Goel  <deego3@gmail.com>
-
-	* erc-match.el (erc-add-entry-to-list): Fix buggy call to `error'.
-
-2007-12-01  Glenn Morris  <rgm@gnu.org>
-
-	* erc-backend.el (erc-server-send-ping): Move after definition of
-	erc-server-send.
-
-	* erc.el (iswitchb-temp-buflist, iswitchb-read-buffer)
-	(erc-controls-strip): Declare for compiler.
-	(erc-iswitchb): Don't require iswitchb when compiling.  Test
-	iswitchb-mode is bound.
-
-2007-11-30  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* erc.el (open-ssl-stream, open-tls-stream, erc-network-name):
-	Declare as functions.
-
-2007-11-29  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
-
-	* erc-backend.el, erc.el:
-	Parse 307 (nick has identified) responses.
-
-2007-11-15  Juanma Barranquero  <lekktu@gmail.com>
-
-	* erc.el (erc-open):
-	* erc-backend.el (define-erc-response-handler):
-	* erc-log.el (log):
-	* erc-match.el (erc-log-matches): Fix typos in docstrings.
-
-2007-11-11  Michael Olson  <mwolson@gnu.org>
-
-	* erc-autoaway.el (erc-autoaway-possibly-set-away):
-	* erc-netsplit.el (erc-netsplit-timer):
-	* erc-notify.el (erc-notify-timer):
-	* erc-track.el (erc-user-is-active): Only run if we have
-	successfully established a connection to the server and have
-	logged in.  I suspect that sending messages too soon may make some
-	IRC servers not respond well, particularly when the network
-	connection is iffy or subject to traffic-shaping.
-
-2007-11-01  Michael Olson  <mwolson@gnu.org>
-
-	* erc-compat.el (erc-set-write-file-functions): New compatibility
-	function to set the write hooks appropriately.
-
-	* erc-log.el (erc-log-setup-logging): Use
-	erc-set-write-file-functions.  This fixes a byte-compiler warning.
-
-	* erc-stamp.el: Silence byte-compiler warning about
-	erc-fill-column.
-
-	* erc.el (erc-with-all-buffers-of-server): Bind the result of
-	mapcar to a variable in order to silence a byte-compiler warning.
-
-2007-10-29  Michael Olson  <mwolson@gnu.org>
-
-	* erc-ibuffer.el (erc-modified-channels-alist): Use
-	eval-when-compile, and explain why we are doing this.
-
-2007-10-25  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* erc-ibuffer.el (erc-modified-channels-alist): Pacify
-	byte-compiler.
-
-2007-10-13  Glenn Morris  <rgm@gnu.org>
-
-	* erc-track.el (erc-modified-channels-update): Use mapc rather
-	than mapcar.
-
-2007-10-12  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc.el (erc-join-channel): Prompt for channel key if C-u or
-	another prefix-arg was typed.
-
-	* NEWS: Noted this change.
-
-2007-10-07  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-cmd-ME'S): New command that handles the case where
-	someone types "/me's".  It concatenates the text " 's" to the
-	beginning of the input and then sends the result like a normal
-	"/me" command.
-	(erc-command-regexp): Permit single-quote character.
-
-2007-09-30  Aidan Kehoe  <kehoea@parhasard.net>  (tiny change)
-
-	* erc-log.el (erc-save-buffer-in-logs): Prevent spurious warnings
-	when looking at a log file and concurrently saving to it.
-
-2007-09-18  Exal de Jesus Garcia Carrillo  <exal@gnu.org>  (tiny change)
-
-	* erc.texi (Special-Features): Fix small typo.
-
-2007-09-16  Michael Olson  <mwolson@gnu.org>
-
-	* erc-track.el (erc-track-switch-direction): Mention
-	erc-track-faces-priority-list.  Thanks to Leo for the suggestion.
-
-2007-09-11  Exal de Jesus Garcia Carrillo  <exal@gnu.org>  (tiny change)
-
-	* erc-sound.el: Fix typo in setting up instructions.
-
-2007-09-10  Michael Olson  <mwolson@gnu.org>
-
-	* Makefile (elpa): Copy dir template rather than echoing a few
-	lines.  The reason for this is that the ELPA package for ERC was
-	getting a corrupt dir entry.
-
-	* dir-template: Template for the ELPA dir file.
-
-2007-09-08  Michael Olson  <mwolson@gnu.org>
-
-	* erc-log.el (erc-log-filter-function): New option that specifies
-	the function to call for filtering text before writing it to a log
-	file.  Thanks to David O'Toole for the suggestion.
-	(erc-save-buffer-in-logs): Use erc-log-filter-function.  Make sure
-	we carry along the value of coding-system-for-write, because this
-	could potentially be shadowed by the temporary buffer.
-
-	* erc.el (erc-version-string): Update to 5.3, development version.
-
-2007-09-07  Glenn Morris  <rgm@gnu.org>
-
-	* erc.el (erc-toggle-debug-irc-protocol): Fix call to
-	erc-view-mode-enter.
-
-2007-08-08  Glenn Morris  <rgm@gnu.org>
-
-	* erc-log.el, erc.el: Replace `iff' in doc-strings and comments.
-
-2007-09-03  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-default-port): Make this an integer value rather
-	than a string.  Thanks to Luca Capello for the report.
-
-2007-08-27  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-cmd-GQUIT): If erc-kill-queries-on-quit is non-nil,
-	kill all query buffers after 4 seconds.
-
-2007-08-16  Michael Olson  <mwolson@gnu.org>
-
-	* NEWS: Add ERC 5.3 changes section, and mention jbms' erc-track
-	compatibility note.
-
-	* erc-track.el (erc-track-list-changed-hook): Turn this into a
-	customizable option.
-	(erc-track-switch-direction): Add 'importance option.
-	(erc-modified-channels-display): If erc-track-switch-direction is
-	'importance, call erc-track-sort-by-importance.
-	(erc-track-face-priority): New function that returns a number
-	indicating the position of a face in erc-track-faces-priority-list.
-	(erc-track-sort-by-importance): New function that sorts
-	erc-modified-channels-list according to erc-track-face-priority.
-	(erc-track-get-active-buffer): Make 'oldest a rough opposite of
-	'importance.
-
-2007-08-14  Jeremy Maitin-Shepard  <jbms@cmu.edu>
-
-	* erc-track.el (erc-track-remove-disconnected-buffers): New
-	variable which controls whether buffers associated with a server
-	that is disconnected should be removed from
-	`erc-modified-channels-alist'.  Existing behavior is to
-	unconditionally remove such buffers, which is achieved by setting
-	`erc-track-removed-disconnected-buffers' to t.  When set to t,
-	which is the new default value, such buffers remain in the list,
-	which I think is often the desired behavior, since the user may
-	likely wish to find out about activity that occurred in a channel
-	prior to it being disconnected.
-	(erc-track-list-changed-hook): New hook that is run whenever the
-	contents of `erc-modified-channels-alist' changes; it is useful
-	for users such as myself that don't use the default mode-line
-	notification but instead use a separate mechanism (which is tied
-	to my window manager) to provide notification of channel activity.
-	(erc-track-get-buffer-window): New function that acts as a wrapper
-	around `get-buffer-window' that handles the `selected-visible'
-	option of `erc-track-visibility'; previously, the value of
-	`erc-track-visibility' was passed directly to `get-buffer-window',
-	which does not support `selected-visible'; consequently,
-	`selected-visible' was not properly supported.
-	(erc-track-modified-channels): Fix a bug in the logic for removing
-	buffers from the list in certain cases.
-	(erc-track-position-in-mode-line): Add a supported value that
-	specifies that the tracking information should not be added to the
-	mode line at all.  The value of nil is used to indicate that the
-	information should not be added at all to the mode line.
-	(erc-track-add-to-mode-line): Check for position eq to t, rather
-	than non-nil.
-	(erc-buffer-visible): Use erc-track-get-buffer-window.
-	(erc-modified-channels-update): Take
-	erc-track-remove-disconnected-buffers into account.
-	(erc-modified-channels-display): Run `erc-track-list-changed-hook'.
-
-	* erc.el (erc-reuse-frames): New option that determines whether
-	new frames are always created.  Defaults to t.  This only has an
-	effect when erc-join-buffer is set to 'frame.
-	(erc-setup-buffer): Use it.
-
-2007-08-14  Michael Olson  <mwolson@gnu.org>
-
-	* erc-backend.el (erc-server-reconnect): If the server buffer has
-	been killed, use the current buffer instead.  If the current
-	buffer is not an ERC buffer, give an error.  This fixes a bug when
-	/reconnect is run from a channel buffer whose server buffer has
-	been deleted.  Thanks to jbms for the report.
-	(erc-process-sentinel-1): Take server buffer as an argument, so
-	that we can make sure that it is current.
-	(erc-process-sentinel): Pass buffer to erc-process-sentinel-1.
-	(erc-process-sentinel-2): New function split from
-	erc-process-sentinel-1.  If server buffer is deleted during a
-	reconnect attempt, stop trying to reconnect.  Fix bug where
-	reconnect was not happening when erc-server-reconnect-attempts was
-	t.  Call erc-server-reconnect-p only once each time.  If we are
-	instructed to try connecting indefinitely, tell the user that they
-	can stop this by killing the server buffer.  Call the process
-	sentinel by means of run-at-time, so that there is time to kill
-	the buffer if need be; this also removes the need for a while
-	loop.  Refuse to reconnect again if erc-server-reconnect-timeout
-	is not an number.
-
-	* erc.el (erc-command-no-process-p): Fix bug: the return value of
-	erc-extract-command-from-line is a list rather than a single
-	symbol.  Thanks to jbms for the report.
-	(erc-cmd-RECONNECT): Use simpler logic, and use buffer-live-p
-	rather than bufferp.
-	(erc-send-current-line, erc-display-command, erc-display-msg):
-	Handle case where erc-server-process is nil, so that /reconnect
-	works.
-
-2007-08-12  Michael Olson  <mwolson@gnu.org>
-
-	* erc-identd.el (erc-identd-filter): Instead of sending an EOF
-	character, which now confuses freenode, stop the server process,
-	so that no new connections are accepted, and kill the current
-	client process.
-
-2007-07-30  Michael Olson  <mwolson@gnu.org>
-
-	* erc-nicklist.el: Remove from the Emacs source tree.  This file
-	is not release quality, and relies heavily on a module which
-	cannot be distributed with ERC due to licensing reasons.
-
-2007-07-29  Michael Olson  <mwolson@gnu.org>
-
-	* erc-list.el: Relicense to GPLv3.  Since the file was already
-	licensed under version 2 or later, it turns out that we do not
-	need the permission of all of the authors in order to proceed.
-
-2007-07-25  Glenn Morris  <rgm@gnu.org>
-
-	* Relicense all FSF files to GPLv3 or later.
-
-2007-07-13  Michael Olson  <mwolson@gnu.org>
-
-	* erc-goodies.el (erc-get-bg-color-face, erc-get-fg-color-face):
-	Use erc-error rather than message and beep.
-
-	* erc-sound.el: Indentation fix.
-
-	* erc.el (erc-command-no-process-p): New function that determines
-	if its argument is an ERC command that can be run when the server
-	process is not alive.
-	(erc-cmd-SET, erc-cmd-CLEAR, erc-cmd-COUNTRY, erc-cmd-HELP)
-	(erc-cmd-LASTLOG, erc-cmd-QUIT, erc-cmd-GQUIT)
-	(erc-cmd-RECONNECT, erc-cmd-SERVER): Denote that these commands
-	can be run even when the server process is not alive.
-	(erc-send-current-line): Call erc-command-no-process-p if the
-	server process is not alive, to determine if we have a command
-	that can be run anyway.  Thanks to Tom Tromey for the bug report.
-	(erc-error): New function that either displays a message or throws
-	an error, depending on whether debug-on-error is non-nil.
-	(erc-cmd-SERVER, erc-send-current-line): Use it.
-
-2007-07-10  Michael Olson  <mwolson@gnu.org>
-
-	* Relicense all FSF-assigned code to GPLv3.
-
-2007-06-25  Michael Olson  <mwolson@gnu.org>
-
-	* erc.texi (Options): Fix typo.
-	(Getting Help and Reporting Bugs): Update webpage URL.  Make Gmane
-	part more readable.
-
-2007-06-20  Michael Olson  <mwolson@gnu.org>
-
-	* erc-stamp.el (erc-timestamp-format-left): New option that
-	specifies the left timestamp to use for
-	erc-insert-timestamp-left-and-right.
-	(erc-timestamp-format-right): New option that specifies the right
-	timestamp to use for erc-insert-timestamp-left-and-right.
-	(erc-insert-timestamp-function): Change default to
-	erc-insert-timestamp-left-and-right.
-	(erc-insert-away-timestamp-function): Ditto.
-	(erc-timestamp-last-inserted-left)
-	(erc-timestamp-last-inserted-right): New variables to keep track
-	of data for erc-insert-timestamp-left-and-right.
-	(erc-insert-timestamp-left-and-right): New function that places
-	timestamps on both the left and right sides of the screen, but
-	only if each timestamp has changed since it was last computed.
-	Thanks to offby1 for urging me to merge this.
-
-	* erc.el (erc-open-ssl-stream): Display informative error when
-	ssl.el not found.
-	(erc-tls): New function to connect using tls.el.
-	(erc-open-tls-stream): New function to initiate tls connection.
-	Display informative error when tls.el not found.
-
-2007-06-19  Michael Olson  <mwolson@gnu.org>
-
-	* erc-log.el: Update header with accurate instructions.
-
-2007-06-17  Michael Olson  <mwolson@gnu.org>
-
-	* erc-pkg.el: Update description to match what is currently in ELPA.
-
-2007-06-14  Juanma Barranquero  <lekktu@gmail.com>
-
-	* erc-goodies.el (erc-scroll-to-bottom): Remove redundant check.
-
-2007-06-13  Michael Olson  <mwolson@gnu.org>
-
-	* erc-compat.el (erc-with-selected-window): New compatibility
-	macro that implements `with-selected-window'.
-
-	* erc-goodies.el (erc-scroll-to-bottom): Use it.  This fixes a bug
-	with buffer ordering where ERC buffers would move to the top.
-	Thanks to Ivan Kanis for the patch.
-
-2007-06-10  Michael Olson  <mwolson@gnu.org>
-
-	* erc-log.el (erc-logging-enabled): Fix a bug that occurred when
-	`erc-log-channels-directory' had the name of a function.
-
-2007-06-06  Juanma Barranquero  <lekktu@gmail.com>
-
-	* erc.el (erc-show-channel-key-p, erc-startup-file-list):
-	Fix typo in docstring.
-
-2007-06-03  Michael Olson  <mwolson@gnu.org>
-
-	* erc-compat.el (erc-view-mode-enter): Make this its own function,
-	in order to document what we do, and provide sane fallback
-	behavior.
-
-	* erc.el (erc-toggle-debug-irc-protocol): Don't pass any arguments
-	to erc-view-mode-enter, since we don't do anything special with
-	the exit function.  This fixes a bug with Emacs 21 and Emacs 22.
-	Thanks to Leo for noticing.
-
-2007-05-30  Michael Olson  <mwolson@gnu.org>
-
-	* erc-compat.el (erc-user-emacs-directory): New variable that
-	determines where to find user-specific Emacs settings.  For Emacs,
-	this is usually ~/.emacs.d, and for XEmacs this is usually
-	~/.xemacs.
-
-	* erc.el (erc-startup-file-list): Use erc-user-emacs-directory.
-
-2007-05-28  Michael Olson  <mwolson@gnu.org>
-
-	* erc-button.el (erc-button-url-regexp): Recognize parentheses as
-	part of URLs.  Thanks to Lawrence Mitchell for the fix.
-
-2007-05-26  Michael Olson  <mwolson@gnu.org>
-
-	* erc.texi (Modules): Fix references to completion modules.
-
-2007-05-21  Michael Olson  <mwolson@gnu.org>
 
-	* Makefile (SOURCE): Remove erc-pkg.el.
-	(debclean): New rule to clean old Debian packages of ERC.
-	(debprepare): Don't modify the released tarball, but copy it as
-	the .orig.tar.gz file.
-	(debrelease, debrevision): Remove.
-	(debinstall): New target that copies the generated Debian file to
-	a distro-specific location.
-	(deb): New rule that chains together the stages in building a
-	Debian package.
-	(EXTRAS): Add erc-nicklist.el, since it is not release-quality.
-	(extras): Copy images directory.
-
-	* erc-nicklist.el (erc-nicklist-icons-directory): Use
-	locate-library to find the "images" directory.  This should be
-	more failsafe.  Thanks to Tom Tromey for the idea.
-
-2007-05-19  Michael Olson  <mwolson@gnu.org>
-
-	* Makefile (ELPA): New variable that contains the location of my
-	local ELPA repository.
-	(elpa): New rule that makes an ELPA package for ERC.
-
-2007-04-19  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-parse-prefix): New function that retrieves the
-	PREFIX server parameter from the current server and returns an
-	alist of prefix type to prefix character.
-	(erc-channel-receive-names): Use `erc-parse-prefix' to determine
-	whether the first character of a nick is a prefix character or
-	not.  This should fix a bug reported by bromine about needing to
-	type "%" first to complete nicks of people who are "hops" on
-	Slashnet.  This should also support for very exotic IRC server
-	setups, if any exist.
-	(erc-update-current-channel-member): Indentation.
-
-2007-04-15  Michael Olson  <mwolson@gnu.org>
-
-	* erc-log.el (erc-generate-log-file-name-function): Docfix.
-	Mention how to deal with the case for putting log files in
-	different directories.  Change a customization type from `symbol'
-	to `function'.
-	(erc-log-channels-directory): Allow this to contain a function
-	name, which is called with the same args as in
-	`erc-generate-log-file-name-function'.  Thanks to andrewy for the
-	report and use case.
-	(erc-current-logfile): Detect if `erc-log-channels-directory' is a
-	function and call it with arguments if so.
-
-2007-04-12  Michael Olson  <mwolson@gnu.org>
-
-	* erc-backend.el (define-erc-response-handler): Mention that hook
-	processing stops when the function returns non-nil.  This should
-	help avoid a nasty "gotcha" when making custom functions.  Thanks
-	to John Sullivan for the report.
-
-2007-04-08  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-nicklist.el (erc-nicklist-voiced-position): Fixed
-	customization mismatch.
-
-2007-04-01  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-version-string): Release ERC 5.2.
-
-	* erc-auto.in, erc-chess.el, erc-list.el, erc-speak.el:
-	* erc-viper.el: Update copyright notices.
-
-	* erc.texi: Make Emacs Lisp source code in this document
-	essentially public domain.  Update version to 5.2.
-	(Obtaining ERC): Mention extras tarball.
-	(Releases): Mention local GNU mirror.
-	(Sample Configuration): Remove notice.
-
-	* FOR-RELEASE (5.3): Add item for erc-nicklist.
-	Mark NEWS as done.  Mark extras tarball as done.
-
-	* Makefile (VERSION): Increment to 5.2.
-	(TESTING): Remove.
-	(EXTRAS): New variable containing the contents of our "Emacs 22
-	extras" tarball.
-	(SOURCE): Remove $(TESTING).
-	(MISC): Add COPYING and ChangeLog.06.  Fix ChangeLog.NNNN ->
-	ChangeLog.NN.
-	(release): Use $(SNAPDIR) instead of erc-$(VERSION).
-	(extras): New rule which implements the building of the extras
-	tarball.
-	(upload-extras): New rule to upload the extras tarball.  It's
-	yucky to replicate upload, but oh well.
-	(DISTRIBUTOR): New variable used to differentiate between building
-	packages for Ubuntu and Debian.
-	(debrelease, debrevision): Use it.
-	(debbuild): Run linda in addition to lintian.
-
-	* NEWS: Mention extras tarball.  Note which files have been
-	renamed.  Note that erc-list is enabled by default, except in
-	Emacs 22.
-
-	* README.extras: New file which serves as a README for the extras
-	tarball.
-
-2007-03-31  Michael Olson  <mwolson@gnu.org>
-
-	* NEWS: Update for the 5.2 release.
-
-	* FOR-RELEASE: Finish up 5.2 manual item.  Add documentation item
-	for 5.3.
-
-	* erc.texi (Sample Session): Flesh out.  Mention #erc.
-	(Modules): Defer to 5.3 release.
-	(Advanced Usage): Move Sample Configuration chapter ahead of
-	unfinished chapters.
-	(Sample Configuration): Write.
-	(Options): Mention how to see available ERC options.  Defer to 5.3
-	release.
-	(Tips and Tricks): Remove, since it seems better to just include
-	tips and tricks in the sample configuration, commented out.
-
-	* erc-bbdb.el (erc-bbdb-search-name-and-create): Make prompt more
-	informative about how to skip merging.
-	(erc-bbdb-insinuate-and-show-entry-1): Move contents of
-	erc-bbdb-insinuate-and-show-entry here.
-	(erc-bbdb-insinuate-and-show-entry): Run
-	erc-bbdb-insinuate-and-show-entry-1 "outside" of the calling
-	function, so that we can avoid triggering a process-filter error
-	if the user hits C-g.
-
-2007-03-30  Michael Olson  <mwolson@gnu.org>
-
-	* FOR-RELEASE: Solve C-c C-SPC keybinding dilemma.
-
-	* erc-autoaway.el (erc-autoaway-idle-method): Use `if' rather than
-	`cond' and `set' rather than `set-default'.
-
-	* erc-log.el: Avoid compiler warning by requiring erc-network
-	during compilation.
-	(erc-generate-log-file-name-function): Add tag to each option.
-	Add erc-generate-log-file-name-network.
-	(erc-generate-log-file-name-network): New function which generates
-	a log file name that uses network name rather than server name,
-	when possible.
-
-	* erc-track.el (track): Assimilate track-when-inactive module,
-	since there's no need to have two modules in one file -- an option
-	will do.  Remove track-modified-channels alias.  Call
-	erc-track-minor-mode-maybe, and tear down the minor mode when
-	disabling.
-	(erc-track-when-inactive): New option which determines whether to
-	track visible buffers when inactive.  The default is not to do so.
-	(erc-track-visibility): Mention erc-track-when-inactive.
-	(erc-buffer-visible): Use erc-track-when-inactive.
-	(erc-track-enable-keybindings): New option which determines
-	whether to enable the global-level tracking keybindings.  The
-	default is to do so, unless they would override another binding,
-	in which case we prompt the user about it.
-	(erc-track-minor-mode-map): Move global keybindings here.
-	(erc-track-minor-mode): New minor mode which only enables the
-	keybindings and does nothing else.
-	(erc-track-minor-mode-maybe): New function which starts
-	erc-track-minor-mode, but only if it hasn't already been started,
-	an ERC buffer exists, and the user OK's it, depending on the value
-	of `erc-track-enable-keybindings'.
-	(erc-track-switch-buffer): Display a message if someone calls this
-	without first enabling erc-track-mode.
-
-2007-03-17  Michael Olson  <mwolson@gnu.org>
-
-	* erc.texi (Development): Mention ErcDevelopment page on
-	emacswiki.
-	(Getting Started): Mention ~/.emacs.d/.ercrc.el and the Customize
-	interface.
-	(Sample Session): New section that has a very rough draft for a
-	sample ERC session.
-	(Special Features): New section that explains some of the special
-	features of ERC.  Taken from ErcFeatures on emacswiki, with
-	enhancements.
-
-2007-03-12  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-autoaway.el (erc-autoaway-idle-method): When setting the new
-	value, disable and re-enable `erc-autoaway-mode' only if it was
-	already enabled.  This fixes a bug where autoaway was enabled just
-	by loading the file.
-
-2007-03-10  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-capab.el: Added more information to the Usage section.
-	(erc-capab-identify-prefix): Doc fix.
-	(erc-capab-identify-unidentified): New face.
-	(290): Removed.  Definition moved to erc-backend.el.
-	(erc-capab-identify-send-messages): Renamed from
-	`erc-capab-send-identify-messages'.
-	(erc-capab-identify-setup): Use it.
-	(erc-capab-identify-get-unidentified-nickname): Renamed from
-	`erc-capab-get-unidentified-nickname'.
-	(erc-capab-identify-add-prefix): Use it.  Use
-	`erc-capab-identify-unidentified' as the face.
-
-	* erc-backend.el (290): Moved here from erc-capab.el.
-
-	* erc.el (erc-select): Added an autoload cookie.
-	(erc-message-type-member, erc-restore-text-properties): Use
-	`erc-get-parsed-vector'.
-	(erc-auto-query): Set the default to 'bury since many new users
-	expect private messages from others to be in dedicated query
-	buffers, not the server buffer.
-	(erc-common-server-suffixes): Use "freenode" for freenode.net, not
-	"OPN".  Added oftc.net.
-
-	* NEWS: Added note about erc-auto-query's new default setting.
+See ChangeLog.07 for earlier changes.
 
-2007-03-03  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-open, erc): Docfixes.
-
-2007-03-02  Michael Olson  <mwolson@gnu.org>
-
-	* FOR-RELEASE: Make section for 5.3 release and move erc-backend
-	cleanup there.  Awaiting discussion before doing other things.
-	Add tasks for merging filename changes from the 5.2 release
-	branch, and for making a tarball of modules not in Emacs 22.  Add
-	item to remind me to update NEWS.  Mark backtab entry as done.
-
-	* erc-button.el (button): Add call to `erc-button-add-keys'.
-	(erc-button-keys-added): New variable tracking whether we've added
-	the keys yet.
-	(erc-button-add-keys): New function that adds the <backtab> key to
-	erc-mode-map.
-
-	* erc.texi: Change version to 5.2 (pre-release).
-
-2007-02-15  Michael Olson  <mwolson@gnu.org>
-
-	* CREDITS: Update.
-
-	* erc-backend.el (erc-server-send-ping-interval): Change to use a
-	default of 30 seconds.  Improve customize interface.
-	(erc-server-send-ping-timeout): New option that determines when to
-	consider a connection stalled and restart it.  The default is
-	after 120 seconds.
-	(erc-server-send-ping): Use erc-server-send-ping-timeout instead
-	of erc-server-send-ping-interval.  If
-	erc-server-send-ping-timeout is nil, do not ever kill and restart
-	a hung IRC process.
-
-	* erc.el (erc-modules): Include the name of the module in its
-	description.  This should make it easier for people to find and
-	enable a particular module.
-
-2007-02-15  Vivek Dasmohapatra  <vivek@etla.org>
-
-	* erc.el (erc-cmd-RECONNECT): Kill old process if it is still
-	alive.
-	(erc-message-english-PART): Properly escape "%" characters in
-	reason.
-
-	* erc-backend.el (erc-server-reconnecting): New variable that is
-	set when the user requests a reconnect, but the old process is
-	still alive.  This forces the reconnect to work even though the
-	process is killed manually during reconnect.
-	(erc-server-connect): Initialize it.
-	(erc-server-reconnect-p): Use it.
-	(erc-process-sentinel-1): Set it to nil after the first reconnect
-	attempt.
-
-2007-02-07  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-menu.el (erc-menu-definition): Fixed so that the separator
-	is between "Current channel" and "Pals, fools and other keywords",
-	not at the bottom of the "Current channel" submenu.
-
-2007-01-25  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-networks.el (erc-server-alist): Removed SSL server for now
-	since `erc-server-select' doesn't know to use `erc-ssl'.
-
-	* erc-networks.el (erc-server-alist, erc-networks-alist): Added
-	definitions for oftc.net.
-
-	* erc-services.el (erc-nickserv-alist): Fixed OFTC message regexp.
-
-2007-01-22  Michael Olson  <mwolson@gnu.org>
-
-	* erc-backend.el (erc-server-error-occurred): New variable that
-	indicates when an error has been signaled by the server.  This
-	should fix an infinite reconnect bug when giving some servers a
-	bogus :full-name.  Thanks to Angelina Carlton for the report.
-	(erc-server-connect): Initialize erc-server-error-occurred.
-	(erc-server-reconnect-p): Use it.
-	(ERROR): Set it.
-
-	* erc-services.el (erc-nickserv-alist): Alphabetize and add Ars
-	and QuakeNet.  Standardize look of entries.  Fix type mismatch
-	error in customize interface.
-	(erc-nickserv-passwords): Alphabetize and add missing entries from
-	erc-nickserv-alist.
-
-2007-01-21  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-header-line-format): Document how to disable the
-	header line, and add a customization type for it.  Also, make the
-	changes take effect immediately.
-
-2007-01-19  Michael Olson  <mwolson@gnu.org>
-
-	* erc.texi (Modules): Document new menu module.  Thanks to Leo
-	for noticing.
-
-2007-01-16  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc-stamp.el (erc-insert-timestamp-left): Fixed so that the
-	whitespace string filler is hidden correctly when timestamps are
-	hidden.
-	(erc-toggle-timestamps): New function to use instead of
-	`erc-show-timestamps' and `erc-hide-timestamps'.
-
-	* erc.el (erc-restore-text-properties): Moved here from
-	erc-fill.el since it could be useful in general.
-
-	* erc-fill.el (erc-restore-text-properties): Removed.
-
-2007-01-13  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-command-regexp): New variable that is used to match
-	a command.
-	(erc-send-input): Use it.  This fixes a bug where paths --
-	"/usr/bin/foo", for example -- were being displayed as commands,
-	but still sent correctly.
-	(erc-extract-command-from-line): Use it.
-
-	* erc.texi (Modules): Document erc-capab-identify.
-
-2007-01-11  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc.el (erc-find-parsed-property): Moved here from erc-track.el
-	since it can be useful in general.
-
-	* erc-track.el (erc-find-parsed-property): Removed.
-
-	* erc-capab.el (erc-capab-find-parsed): Removed.
-	(erc-capab-identify-add-prefix): Use `erc-find-parsed-property'.
-
-	* erc.el (erc-open): Run `erc-before-connect' hook here.  This
-	makes sure the hook always gets called before a connection is
-	made, as some functions, like `erc-handle-irc-url', use `erc-open'
-	instead of `erc'.
-	(erc): Removed `erc-before-connect' hook.
-
-	* erc-menu.el (erc-menu-definition): Put items specific to
-	channels in a "Current channel" submenu.
-
-	* erc-backend.el (321, 323): Display channel list in server buffer
-	when not using the channel list module.
-
-	* erc.el: Updated copyright years.
-	(erc-version-string): Set to 5.2 (devel).
-	(erc-format-lag-time): Fixed to work when `erc-server-lag' is nil.
-	(erc-update-mode-line-buffer): Set the header face.
-
-2007-01-11  Michael Olson  <mwolson@gnu.org>
-
-	* erc-bbdb.el (erc-bbdb-popup-type): Fix customization type and
-	documentation.
-
-	* erc-services.el (erc-nickserv-identify-mode): Improve
-	documentation for nick-change option and move higher to fix
-	compiler warning.  Avoid a recursive load error.
-	(erc-nickserv-alist): Add simple entry for BitlBee, to avoid
-	"NickServ is AWAY: User is offline" error.  Oddly enough, bitlbee
-	was smart enough to recognize that as an authentication request
-	and log in regardless, which is why I didn't notice this earlier.
-	(erc-nickserv-alist-sender, erc-nickserv-alist-regexp)
-	(erc-nickserv-alist-nickserv, erc-nickserv-alist-ident-keyword)
-	(erc-nickserv-alist-use-nick-p)
-	(erc-nickserv-alist-ident-command): New accessors for
-	erc-nickserv-alist.  Using nth is unwieldy.
-	(erc-nickserv-identify-autodetect)
-	(erc-nickserv-identify-on-connect)
-	(erc-nickserv-identify-on-nick-change, erc-nickserv-identify): Use
-	the new accessors.
-
-2007-01-11  Diane Murray  <disumu@x3y2z1.net>
-
-	* NEWS: Added note for `erc-my-nick-face'.  Fixed capab-identify
-	wording.
-
-2007-01-10  Diane Murray  <disumu@x3y2z1.net>
-
-	* erc.el (erc-mode-line-format): Added %l to documentation.
-	(erc-header-line-format): Removed "[IRC]".  Use the new %l
-	replacement character.  Doc fix.
-	(erc-format-channel-modes): Removed lag code.  Removed parentheses
-	from mode string.
-	(erc-format-lag-time): New function.
-	(erc-update-mode-line-buffer): Use it.
-
-2007-01-10  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el: Fix typo in url-irc-function instructions.
-
-2007-01-09  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-system-name): New option that determines the system
-	name to use when logging in.  The default is to figure this out by
-	calling `system-name'.
-	(erc-login): Use it.
-
-2007-01-07  Michael Olson  <mwolson@gnu.org>
-
-	* erc.el (erc-modules): Add the menu module.  This should fix a
-	bug with incorrect ERC submenus being displayed.
-
-	* erc-menu.el: Turn this into a module.
-	(erc-menu-add, erc-menu-remove): New functions that add and remove
-	the ERC menu.
-
-
-See ChangeLog.06 for earlier changes.
-
-    Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+    Copyright (C) 2008 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
@@ -846,4 +306,4 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-;; arch-tag: 3369b6e5-96b1-4b32-96cd-9a905c747496
+;; arch-tag: 15787dfd-e091-4c8c-8b88-747b474e1ac7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/erc/ChangeLog.07	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,839 @@
+2007-12-16  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-services.el (erc-nickserv-alist): Removed autodetect regexp,
+	added identified regexp for OFTC.
+	(erc-nickserv-identification-autodetect): Make sure success-regex
+	is non-nil.
+	(erc-nickserv-identify-autodetect): Make sure identify-regex is
+	non-nil.  Doc fix.
+
+2007-12-13  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-backend.el (PRIVMSG, QUIT, TOPIC, WALLOPS, 376, 004, 221)
+	(312, 315, 319, 330, 331, 333, 367, 368, 391, 405, 406, 412)
+	(421, 432, 433, 437, 442, 461, 474, 477, 482, 431): Doc fix.
+
+2007-12-09  Michael Olson  <mwolson@gnu.org>
+
+	* erc-services.el (erc-nickserv-alist): Fix regexps for GRnet.
+
+2007-12-09  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
+
+	* erc-backend.el, erc.el:
+	Parse 275 (secure connection) responses.
+
+	* erc-services.el: Add identification hooks for GRnet, the Greek
+	IRC network <http://www.irc.gr>.
+
+2007-12-08  David Kastrup  <dak@gnu.org>
+
+	* erc-stamp.el (erc-echo-timestamp):
+	* erc-lang.el (language):
+	* erc-backend.el (erc-server-connect): Fix buggy call to `message'.
+
+2007-12-07  Edward O'Connor  <ted@oconnor.cx>
+
+	* erc-services.el: Provide a hook that runs when nickserv confirms
+	that the user has successfully identified.
+	(services, erc-nickserv-identify-mode): Add and remove
+	erc-nickserv-identification-autodetect from
+	erc-server-NOTICE-functions.
+	(erc-nickserv-alist): Add SUCCESS-REGEXP to each entry.
+	(erc-nickserv-alist-identified-regexp)
+	(erc-nickserv-identification-autodetect): New functions.
+	(erc-nickserv-identified-hook): New hook.
+
+2007-12-06  D. Goel  <deego3@gmail.com>
+
+	* erc-match.el (erc-add-entry-to-list): Fix buggy call to `error'.
+
+2007-12-01  Glenn Morris  <rgm@gnu.org>
+
+	* erc-backend.el (erc-server-send-ping): Move after definition of
+	erc-server-send.
+
+2007-11-29  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
+
+	* erc-backend.el, erc.el:
+	Parse 307 (nick has identified) responses.
+
+2007-11-15  Juanma Barranquero  <lekktu@gmail.com>
+
+	* erc.el (erc-open):
+	* erc-backend.el (define-erc-response-handler):
+	* erc-log.el (log):
+	* erc-match.el (erc-log-matches): Fix typos in docstrings.
+
+2007-11-11  Michael Olson  <mwolson@gnu.org>
+
+	* erc-autoaway.el (erc-autoaway-possibly-set-away):
+	* erc-netsplit.el (erc-netsplit-timer):
+	* erc-notify.el (erc-notify-timer):
+	* erc-track.el (erc-user-is-active): Only run if we have
+	successfully established a connection to the server and have
+	logged in.  I suspect that sending messages too soon may make some
+	IRC servers not respond well, particularly when the network
+	connection is iffy or subject to traffic-shaping.
+
+2007-11-01  Michael Olson  <mwolson@gnu.org>
+
+	* erc-compat.el (erc-set-write-file-functions): New compatibility
+	function to set the write hooks appropriately.
+
+	* erc-log.el (erc-log-setup-logging): Use
+	erc-set-write-file-functions.  This fixes a byte-compiler warning.
+
+	* erc-stamp.el: Silence byte-compiler warning about
+	erc-fill-column.
+
+	* erc.el (erc-with-all-buffers-of-server): Bind the result of
+	mapcar to a variable in order to silence a byte-compiler warning.
+
+2007-10-29  Michael Olson  <mwolson@gnu.org>
+
+	* erc-ibuffer.el (erc-modified-channels-alist): Use
+	eval-when-compile, and explain why we are doing this.
+
+2007-10-25  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* erc-ibuffer.el (erc-modified-channels-alist): Pacify
+	byte-compiler.
+
+2007-10-13  Glenn Morris  <rgm@gnu.org>
+
+	* erc-track.el (erc-modified-channels-update): Use mapc rather
+	than mapcar.
+
+2007-10-12  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc.el (erc-join-channel): Prompt for channel key if C-u or
+	another prefix-arg was typed.
+
+	* NEWS: Noted this change.
+
+2007-10-07  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-cmd-ME'S): New command that handles the case where
+	someone types "/me's".  It concatenates the text " 's" to the
+	beginning of the input and then sends the result like a normal
+	"/me" command.
+	(erc-command-regexp): Permit single-quote character.
+
+2007-09-30  Aidan Kehoe  <kehoea@parhasard.net>  (tiny change)
+
+	* erc-log.el (erc-save-buffer-in-logs): Prevent spurious warnings
+	when looking at a log file and concurrently saving to it.
+
+2007-09-18  Exal de Jesus Garcia Carrillo  <exal@gnu.org>  (tiny change)
+
+	* erc.texi (Special-Features): Fix small typo.
+
+2007-09-16  Michael Olson  <mwolson@gnu.org>
+
+	* erc-track.el (erc-track-switch-direction): Mention
+	erc-track-faces-priority-list.  Thanks to Leo for the suggestion.
+
+2007-09-11  Exal de Jesus Garcia Carrillo  <exal@gnu.org>  (tiny change)
+
+	* erc-sound.el: Fix typo in setting up instructions.
+
+2007-09-10  Michael Olson  <mwolson@gnu.org>
+
+	* Makefile (elpa): Copy dir template rather than echoing a few
+	lines.  The reason for this is that the ELPA package for ERC was
+	getting a corrupt dir entry.
+
+	* dir-template: Template for the ELPA dir file.
+
+2007-09-08  Michael Olson  <mwolson@gnu.org>
+
+	* erc-log.el (erc-log-filter-function): New option that specifies
+	the function to call for filtering text before writing it to a log
+	file.  Thanks to David O'Toole for the suggestion.
+	(erc-save-buffer-in-logs): Use erc-log-filter-function.  Make sure
+	we carry along the value of coding-system-for-write, because this
+	could potentially be shadowed by the temporary buffer.
+
+	* erc.el (erc-version-string): Update to 5.3, development version.
+
+2007-09-07  Glenn Morris  <rgm@gnu.org>
+
+	* erc.el (erc-toggle-debug-irc-protocol): Fix call to
+	erc-view-mode-enter.
+
+2007-08-08  Glenn Morris  <rgm@gnu.org>
+
+	* erc-log.el, erc.el: Replace `iff' in doc-strings and comments.
+
+2007-09-03  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-default-port): Make this an integer value rather
+	than a string.  Thanks to Luca Capello for the report.
+
+2007-08-27  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-cmd-GQUIT): If erc-kill-queries-on-quit is non-nil,
+	kill all query buffers after 4 seconds.
+
+2007-08-16  Michael Olson  <mwolson@gnu.org>
+
+	* NEWS: Add ERC 5.3 changes section, and mention jbms' erc-track
+	compatibility note.
+
+	* erc-track.el (erc-track-list-changed-hook): Turn this into a
+	customizable option.
+	(erc-track-switch-direction): Add 'importance option.
+	(erc-modified-channels-display): If erc-track-switch-direction is
+	'importance, call erc-track-sort-by-importance.
+	(erc-track-face-priority): New function that returns a number
+	indicating the position of a face in erc-track-faces-priority-list.
+	(erc-track-sort-by-importance): New function that sorts
+	erc-modified-channels-list according to erc-track-face-priority.
+	(erc-track-get-active-buffer): Make 'oldest a rough opposite of
+	'importance.
+
+2007-08-14  Jeremy Maitin-Shepard  <jbms@cmu.edu>
+
+	* erc-track.el (erc-track-remove-disconnected-buffers): New
+	variable which controls whether buffers associated with a server
+	that is disconnected should be removed from
+	`erc-modified-channels-alist'.  Existing behavior is to
+	unconditionally remove such buffers, which is achieved by setting
+	`erc-track-removed-disconnected-buffers' to t.  When set to t,
+	which is the new default value, such buffers remain in the list,
+	which I think is often the desired behavior, since the user may
+	likely wish to find out about activity that occurred in a channel
+	prior to it being disconnected.
+	(erc-track-list-changed-hook): New hook that is run whenever the
+	contents of `erc-modified-channels-alist' changes; it is useful
+	for users such as myself that don't use the default mode-line
+	notification but instead use a separate mechanism (which is tied
+	to my window manager) to provide notification of channel activity.
+	(erc-track-get-buffer-window): New function that acts as a wrapper
+	around `get-buffer-window' that handles the `selected-visible'
+	option of `erc-track-visibility'; previously, the value of
+	`erc-track-visibility' was passed directly to `get-buffer-window',
+	which does not support `selected-visible'; consequently,
+	`selected-visible' was not properly supported.
+	(erc-track-modified-channels): Fix a bug in the logic for removing
+	buffers from the list in certain cases.
+	(erc-track-position-in-mode-line): Add a supported value that
+	specifies that the tracking information should not be added to the
+	mode line at all.  The value of nil is used to indicate that the
+	information should not be added at all to the mode line.
+	(erc-track-add-to-mode-line): Check for position eq to t, rather
+	than non-nil.
+	(erc-buffer-visible): Use erc-track-get-buffer-window.
+	(erc-modified-channels-update): Take
+	erc-track-remove-disconnected-buffers into account.
+	(erc-modified-channels-display): Run `erc-track-list-changed-hook'.
+
+	* erc.el (erc-reuse-frames): New option that determines whether
+	new frames are always created.  Defaults to t.  This only has an
+	effect when erc-join-buffer is set to 'frame.
+	(erc-setup-buffer): Use it.
+
+2007-08-14  Michael Olson  <mwolson@gnu.org>
+
+	* erc-backend.el (erc-server-reconnect): If the server buffer has
+	been killed, use the current buffer instead.  If the current
+	buffer is not an ERC buffer, give an error.  This fixes a bug when
+	/reconnect is run from a channel buffer whose server buffer has
+	been deleted.  Thanks to jbms for the report.
+	(erc-process-sentinel-1): Take server buffer as an argument, so
+	that we can make sure that it is current.
+	(erc-process-sentinel): Pass buffer to erc-process-sentinel-1.
+	(erc-process-sentinel-2): New function split from
+	erc-process-sentinel-1.  If server buffer is deleted during a
+	reconnect attempt, stop trying to reconnect.  Fix bug where
+	reconnect was not happening when erc-server-reconnect-attempts was
+	t.  Call erc-server-reconnect-p only once each time.  If we are
+	instructed to try connecting indefinitely, tell the user that they
+	can stop this by killing the server buffer.  Call the process
+	sentinel by means of run-at-time, so that there is time to kill
+	the buffer if need be; this also removes the need for a while
+	loop.  Refuse to reconnect again if erc-server-reconnect-timeout
+	is not an number.
+
+	* erc.el (erc-command-no-process-p): Fix bug: the return value of
+	erc-extract-command-from-line is a list rather than a single
+	symbol.  Thanks to jbms for the report.
+	(erc-cmd-RECONNECT): Use simpler logic, and use buffer-live-p
+	rather than bufferp.
+	(erc-send-current-line, erc-display-command, erc-display-msg):
+	Handle case where erc-server-process is nil, so that /reconnect
+	works.
+
+2007-08-12  Michael Olson  <mwolson@gnu.org>
+
+	* erc-identd.el (erc-identd-filter): Instead of sending an EOF
+	character, which now confuses freenode, stop the server process,
+	so that no new connections are accepted, and kill the current
+	client process.
+
+2007-07-29  Michael Olson  <mwolson@gnu.org>
+
+	* erc-list.el: Relicense to GPLv3.  Since the file was already
+	licensed under version 2 or later, it turns out that we do not
+	need the permission of all of the authors in order to proceed.
+
+2007-07-13  Michael Olson  <mwolson@gnu.org>
+
+	* erc-goodies.el (erc-get-bg-color-face, erc-get-fg-color-face):
+	Use erc-error rather than message and beep.
+
+	* erc-sound.el: Indentation fix.
+
+	* erc.el (erc-command-no-process-p): New function that determines
+	if its argument is an ERC command that can be run when the server
+	process is not alive.
+	(erc-cmd-SET, erc-cmd-CLEAR, erc-cmd-COUNTRY, erc-cmd-HELP)
+	(erc-cmd-LASTLOG, erc-cmd-QUIT, erc-cmd-GQUIT)
+	(erc-cmd-RECONNECT, erc-cmd-SERVER): Denote that these commands
+	can be run even when the server process is not alive.
+	(erc-send-current-line): Call erc-command-no-process-p if the
+	server process is not alive, to determine if we have a command
+	that can be run anyway.  Thanks to Tom Tromey for the bug report.
+	(erc-error): New function that either displays a message or throws
+	an error, depending on whether debug-on-error is non-nil.
+	(erc-cmd-SERVER, erc-send-current-line): Use it.
+
+2007-07-10  Michael Olson  <mwolson@gnu.org>
+
+	* Relicense all FSF-assigned code to GPLv3.
+
+2007-06-25  Michael Olson  <mwolson@gnu.org>
+
+	* erc.texi (Options): Fix typo.
+	(Getting Help and Reporting Bugs): Update webpage URL.  Make Gmane
+	part more readable.
+
+2007-06-20  Michael Olson  <mwolson@gnu.org>
+
+	* erc-stamp.el (erc-timestamp-format-left): New option that
+	specifies the left timestamp to use for
+	erc-insert-timestamp-left-and-right.
+	(erc-timestamp-format-right): New option that specifies the right
+	timestamp to use for erc-insert-timestamp-left-and-right.
+	(erc-insert-timestamp-function): Change default to
+	erc-insert-timestamp-left-and-right.
+	(erc-insert-away-timestamp-function): Ditto.
+	(erc-timestamp-last-inserted-left)
+	(erc-timestamp-last-inserted-right): New variables to keep track
+	of data for erc-insert-timestamp-left-and-right.
+	(erc-insert-timestamp-left-and-right): New function that places
+	timestamps on both the left and right sides of the screen, but
+	only if each timestamp has changed since it was last computed.
+	Thanks to offby1 for urging me to merge this.
+
+	* erc.el (erc-open-ssl-stream): Display informative error when
+	ssl.el not found.
+	(erc-tls): New function to connect using tls.el.
+	(erc-open-tls-stream): New function to initiate tls connection.
+	Display informative error when tls.el not found.
+
+2007-06-19  Michael Olson  <mwolson@gnu.org>
+
+	* erc-log.el: Update header with accurate instructions.
+
+2007-06-17  Michael Olson  <mwolson@gnu.org>
+
+	* erc-pkg.el: Update description to match what is currently in ELPA.
+
+2007-06-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* erc-goodies.el (erc-scroll-to-bottom): Remove redundant check.
+
+2007-06-13  Michael Olson  <mwolson@gnu.org>
+
+	* erc-compat.el (erc-with-selected-window): New compatibility
+	macro that implements `with-selected-window'.
+
+	* erc-goodies.el (erc-scroll-to-bottom): Use it.  This fixes a bug
+	with buffer ordering where ERC buffers would move to the top.
+	Thanks to Ivan Kanis for the patch.
+
+2007-06-10  Michael Olson  <mwolson@gnu.org>
+
+	* erc-log.el (erc-logging-enabled): Fix a bug that occurred when
+	`erc-log-channels-directory' had the name of a function.
+
+2007-06-06  Juanma Barranquero  <lekktu@gmail.com>
+
+	* erc.el (erc-show-channel-key-p, erc-startup-file-list):
+	Fix typo in docstring.
+
+2007-06-03  Michael Olson  <mwolson@gnu.org>
+
+	* erc-compat.el (erc-view-mode-enter): Make this its own function,
+	in order to document what we do, and provide sane fallback
+	behavior.
+
+	* erc.el (erc-toggle-debug-irc-protocol): Don't pass any arguments
+	to erc-view-mode-enter, since we don't do anything special with
+	the exit function.  This fixes a bug with Emacs 21 and Emacs 22.
+	Thanks to Leo for noticing.
+
+2007-05-30  Michael Olson  <mwolson@gnu.org>
+
+	* erc-compat.el (erc-user-emacs-directory): New variable that
+	determines where to find user-specific Emacs settings.  For Emacs,
+	this is usually ~/.emacs.d, and for XEmacs this is usually
+	~/.xemacs.
+
+	* erc.el (erc-startup-file-list): Use erc-user-emacs-directory.
+
+2007-05-28  Michael Olson  <mwolson@gnu.org>
+
+	* erc-button.el (erc-button-url-regexp): Recognize parentheses as
+	part of URLs.  Thanks to Lawrence Mitchell for the fix.
+
+2007-05-26  Michael Olson  <mwolson@gnu.org>
+
+	* erc.texi (Modules): Fix references to completion modules.
+
+2007-05-21  Michael Olson  <mwolson@gnu.org>
+
+	* Makefile (SOURCE): Remove erc-pkg.el.
+	(debclean): New rule to clean old Debian packages of ERC.
+	(debprepare): Don't modify the released tarball, but copy it as
+	the .orig.tar.gz file.
+	(debrelease, debrevision): Remove.
+	(debinstall): New target that copies the generated Debian file to
+	a distro-specific location.
+	(deb): New rule that chains together the stages in building a
+	Debian package.
+	(EXTRAS): Add erc-nicklist.el, since it is not release-quality.
+	(extras): Copy images directory.
+
+	* erc-nicklist.el (erc-nicklist-icons-directory): Use
+	locate-library to find the "images" directory.  This should be
+	more failsafe.  Thanks to Tom Tromey for the idea.
+
+2007-05-19  Michael Olson  <mwolson@gnu.org>
+
+	* Makefile (ELPA): New variable that contains the location of my
+	local ELPA repository.
+	(elpa): New rule that makes an ELPA package for ERC.
+
+2007-04-19  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-parse-prefix): New function that retrieves the
+	PREFIX server parameter from the current server and returns an
+	alist of prefix type to prefix character.
+	(erc-channel-receive-names): Use `erc-parse-prefix' to determine
+	whether the first character of a nick is a prefix character or
+	not.  This should fix a bug reported by bromine about needing to
+	type "%" first to complete nicks of people who are "hops" on
+	Slashnet.  This should also support for very exotic IRC server
+	setups, if any exist.
+	(erc-update-current-channel-member): Indentation.
+
+2007-04-15  Michael Olson  <mwolson@gnu.org>
+
+	* erc-log.el (erc-generate-log-file-name-function): Docfix.
+	Mention how to deal with the case for putting log files in
+	different directories.  Change a customization type from `symbol'
+	to `function'.
+	(erc-log-channels-directory): Allow this to contain a function
+	name, which is called with the same args as in
+	`erc-generate-log-file-name-function'.  Thanks to andrewy for the
+	report and use case.
+	(erc-current-logfile): Detect if `erc-log-channels-directory' is a
+	function and call it with arguments if so.
+
+2007-04-12  Michael Olson  <mwolson@gnu.org>
+
+	* erc-backend.el (define-erc-response-handler): Mention that hook
+	processing stops when the function returns non-nil.  This should
+	help avoid a nasty "gotcha" when making custom functions.  Thanks
+	to John Sullivan for the report.
+
+2007-04-08  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-nicklist.el (erc-nicklist-voiced-position): Fixed
+	customization mismatch.
+
+2007-04-01  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-version-string): Release ERC 5.2.
+
+	* erc-auto.in, erc-chess.el, erc-list.el, erc-speak.el:
+	* erc-viper.el: Update copyright notices.
+
+	* erc.texi: Make Emacs Lisp source code in this document
+	essentially public domain.  Update version to 5.2.
+	(Obtaining ERC): Mention extras tarball.
+	(Releases): Mention local GNU mirror.
+	(Sample Configuration): Remove notice.
+
+	* FOR-RELEASE (5.3): Add item for erc-nicklist.
+	Mark NEWS as done.  Mark extras tarball as done.
+
+	* Makefile (VERSION): Increment to 5.2.
+	(TESTING): Remove.
+	(EXTRAS): New variable containing the contents of our "Emacs 22
+	extras" tarball.
+	(SOURCE): Remove $(TESTING).
+	(MISC): Add COPYING and ChangeLog.06.  Fix ChangeLog.NNNN ->
+	ChangeLog.NN.
+	(release): Use $(SNAPDIR) instead of erc-$(VERSION).
+	(extras): New rule which implements the building of the extras
+	tarball.
+	(upload-extras): New rule to upload the extras tarball.  It's
+	yucky to replicate upload, but oh well.
+	(DISTRIBUTOR): New variable used to differentiate between building
+	packages for Ubuntu and Debian.
+	(debrelease, debrevision): Use it.
+	(debbuild): Run linda in addition to lintian.
+
+	* NEWS: Mention extras tarball.  Note which files have been
+	renamed.  Note that erc-list is enabled by default, except in
+	Emacs 22.
+
+	* README.extras: New file which serves as a README for the extras
+	tarball.
+
+2007-03-31  Michael Olson  <mwolson@gnu.org>
+
+	* NEWS: Update for the 5.2 release.
+
+	* FOR-RELEASE: Finish up 5.2 manual item.  Add documentation item
+	for 5.3.
+
+	* erc.texi (Sample Session): Flesh out.  Mention #erc.
+	(Modules): Defer to 5.3 release.
+	(Advanced Usage): Move Sample Configuration chapter ahead of
+	unfinished chapters.
+	(Sample Configuration): Write.
+	(Options): Mention how to see available ERC options.  Defer to 5.3
+	release.
+	(Tips and Tricks): Remove, since it seems better to just include
+	tips and tricks in the sample configuration, commented out.
+
+	* erc-bbdb.el (erc-bbdb-search-name-and-create): Make prompt more
+	informative about how to skip merging.
+	(erc-bbdb-insinuate-and-show-entry-1): Move contents of
+	erc-bbdb-insinuate-and-show-entry here.
+	(erc-bbdb-insinuate-and-show-entry): Run
+	erc-bbdb-insinuate-and-show-entry-1 "outside" of the calling
+	function, so that we can avoid triggering a process-filter error
+	if the user hits C-g.
+
+2007-03-30  Michael Olson  <mwolson@gnu.org>
+
+	* FOR-RELEASE: Solve C-c C-SPC keybinding dilemma.
+
+	* erc-autoaway.el (erc-autoaway-idle-method): Use `if' rather than
+	`cond' and `set' rather than `set-default'.
+
+	* erc-log.el: Avoid compiler warning by requiring erc-network
+	during compilation.
+	(erc-generate-log-file-name-function): Add tag to each option.
+	Add erc-generate-log-file-name-network.
+	(erc-generate-log-file-name-network): New function which generates
+	a log file name that uses network name rather than server name,
+	when possible.
+
+	* erc-track.el (track): Assimilate track-when-inactive module,
+	since there's no need to have two modules in one file -- an option
+	will do.  Remove track-modified-channels alias.  Call
+	erc-track-minor-mode-maybe, and tear down the minor mode when
+	disabling.
+	(erc-track-when-inactive): New option which determines whether to
+	track visible buffers when inactive.  The default is not to do so.
+	(erc-track-visibility): Mention erc-track-when-inactive.
+	(erc-buffer-visible): Use erc-track-when-inactive.
+	(erc-track-enable-keybindings): New option which determines
+	whether to enable the global-level tracking keybindings.  The
+	default is to do so, unless they would override another binding,
+	in which case we prompt the user about it.
+	(erc-track-minor-mode-map): Move global keybindings here.
+	(erc-track-minor-mode): New minor mode which only enables the
+	keybindings and does nothing else.
+	(erc-track-minor-mode-maybe): New function which starts
+	erc-track-minor-mode, but only if it hasn't already been started,
+	an ERC buffer exists, and the user OK's it, depending on the value
+	of `erc-track-enable-keybindings'.
+	(erc-track-switch-buffer): Display a message if someone calls this
+	without first enabling erc-track-mode.
+
+2007-03-17  Michael Olson  <mwolson@gnu.org>
+
+	* erc.texi (Development): Mention ErcDevelopment page on
+	emacswiki.
+	(Getting Started): Mention ~/.emacs.d/.ercrc.el and the Customize
+	interface.
+	(Sample Session): New section that has a very rough draft for a
+	sample ERC session.
+	(Special Features): New section that explains some of the special
+	features of ERC.  Taken from ErcFeatures on emacswiki, with
+	enhancements.
+
+2007-03-12  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-autoaway.el (erc-autoaway-idle-method): When setting the new
+	value, disable and re-enable `erc-autoaway-mode' only if it was
+	already enabled.  This fixes a bug where autoaway was enabled just
+	by loading the file.
+
+2007-03-10  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-capab.el: Added more information to the Usage section.
+	(erc-capab-identify-prefix): Doc fix.
+	(erc-capab-identify-unidentified): New face.
+	(290): Removed.  Definition moved to erc-backend.el.
+	(erc-capab-identify-send-messages): Renamed from
+	`erc-capab-send-identify-messages'.
+	(erc-capab-identify-setup): Use it.
+	(erc-capab-identify-get-unidentified-nickname): Renamed from
+	`erc-capab-get-unidentified-nickname'.
+	(erc-capab-identify-add-prefix): Use it.  Use
+	`erc-capab-identify-unidentified' as the face.
+
+	* erc-backend.el (290): Moved here from erc-capab.el.
+
+	* erc.el (erc-select): Added an autoload cookie.
+	(erc-message-type-member, erc-restore-text-properties): Use
+	`erc-get-parsed-vector'.
+	(erc-auto-query): Set the default to 'bury since many new users
+	expect private messages from others to be in dedicated query
+	buffers, not the server buffer.
+	(erc-common-server-suffixes): Use "freenode" for freenode.net, not
+	"OPN".  Added oftc.net.
+
+	* NEWS: Added note about erc-auto-query's new default setting.
+
+2007-03-03  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-open, erc): Docfixes.
+
+2007-03-02  Michael Olson  <mwolson@gnu.org>
+
+	* FOR-RELEASE: Make section for 5.3 release and move erc-backend
+	cleanup there.  Awaiting discussion before doing other things.
+	Add tasks for merging filename changes from the 5.2 release
+	branch, and for making a tarball of modules not in Emacs 22.  Add
+	item to remind me to update NEWS.  Mark backtab entry as done.
+
+	* erc-button.el (button): Add call to `erc-button-add-keys'.
+	(erc-button-keys-added): New variable tracking whether we've added
+	the keys yet.
+	(erc-button-add-keys): New function that adds the <backtab> key to
+	erc-mode-map.
+
+	* erc.texi: Change version to 5.2 (pre-release).
+
+2007-02-15  Michael Olson  <mwolson@gnu.org>
+
+	* CREDITS: Update.
+
+	* erc-backend.el (erc-server-send-ping-interval): Change to use a
+	default of 30 seconds.  Improve customize interface.
+	(erc-server-send-ping-timeout): New option that determines when to
+	consider a connection stalled and restart it.  The default is
+	after 120 seconds.
+	(erc-server-send-ping): Use erc-server-send-ping-timeout instead
+	of erc-server-send-ping-interval.  If
+	erc-server-send-ping-timeout is nil, do not ever kill and restart
+	a hung IRC process.
+
+	* erc.el (erc-modules): Include the name of the module in its
+	description.  This should make it easier for people to find and
+	enable a particular module.
+
+2007-02-15  Vivek Dasmohapatra  <vivek@etla.org>
+
+	* erc.el (erc-cmd-RECONNECT): Kill old process if it is still
+	alive.
+	(erc-message-english-PART): Properly escape "%" characters in
+	reason.
+
+	* erc-backend.el (erc-server-reconnecting): New variable that is
+	set when the user requests a reconnect, but the old process is
+	still alive.  This forces the reconnect to work even though the
+	process is killed manually during reconnect.
+	(erc-server-connect): Initialize it.
+	(erc-server-reconnect-p): Use it.
+	(erc-process-sentinel-1): Set it to nil after the first reconnect
+	attempt.
+
+2007-02-07  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-menu.el (erc-menu-definition): Fixed so that the separator
+	is between "Current channel" and "Pals, fools and other keywords",
+	not at the bottom of the "Current channel" submenu.
+
+2007-01-25  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-networks.el (erc-server-alist): Removed SSL server for now
+	since `erc-server-select' doesn't know to use `erc-ssl'.
+
+	* erc-networks.el (erc-server-alist, erc-networks-alist): Added
+	definitions for oftc.net.
+
+	* erc-services.el (erc-nickserv-alist): Fixed OFTC message regexp.
+
+2007-01-22  Michael Olson  <mwolson@gnu.org>
+
+	* erc-backend.el (erc-server-error-occurred): New variable that
+	indicates when an error has been signaled by the server.  This
+	should fix an infinite reconnect bug when giving some servers a
+	bogus :full-name.  Thanks to Angelina Carlton for the report.
+	(erc-server-connect): Initialize erc-server-error-occurred.
+	(erc-server-reconnect-p): Use it.
+	(ERROR): Set it.
+
+	* erc-services.el (erc-nickserv-alist): Alphabetize and add Ars
+	and QuakeNet.  Standardize look of entries.  Fix type mismatch
+	error in customize interface.
+	(erc-nickserv-passwords): Alphabetize and add missing entries from
+	erc-nickserv-alist.
+
+2007-01-21  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-header-line-format): Document how to disable the
+	header line, and add a customization type for it.  Also, make the
+	changes take effect immediately.
+
+2007-01-19  Michael Olson  <mwolson@gnu.org>
+
+	* erc.texi (Modules): Document new menu module.  Thanks to Leo
+	for noticing.
+
+2007-01-16  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc-stamp.el (erc-insert-timestamp-left): Fixed so that the
+	whitespace string filler is hidden correctly when timestamps are
+	hidden.
+	(erc-toggle-timestamps): New function to use instead of
+	`erc-show-timestamps' and `erc-hide-timestamps'.
+
+	* erc.el (erc-restore-text-properties): Moved here from
+	erc-fill.el since it could be useful in general.
+
+	* erc-fill.el (erc-restore-text-properties): Removed.
+
+2007-01-13  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-command-regexp): New variable that is used to match
+	a command.
+	(erc-send-input): Use it.  This fixes a bug where paths --
+	"/usr/bin/foo", for example -- were being displayed as commands,
+	but still sent correctly.
+	(erc-extract-command-from-line): Use it.
+
+	* erc.texi (Modules): Document erc-capab-identify.
+
+2007-01-11  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc.el (erc-find-parsed-property): Moved here from erc-track.el
+	since it can be useful in general.
+
+	* erc-track.el (erc-find-parsed-property): Removed.
+
+	* erc-capab.el (erc-capab-find-parsed): Removed.
+	(erc-capab-identify-add-prefix): Use `erc-find-parsed-property'.
+
+	* erc.el (erc-open): Run `erc-before-connect' hook here.  This
+	makes sure the hook always gets called before a connection is
+	made, as some functions, like `erc-handle-irc-url', use `erc-open'
+	instead of `erc'.
+	(erc): Removed `erc-before-connect' hook.
+
+	* erc-menu.el (erc-menu-definition): Put items specific to
+	channels in a "Current channel" submenu.
+
+	* erc-backend.el (321, 323): Display channel list in server buffer
+	when not using the channel list module.
+
+	* erc.el: Updated copyright years.
+	(erc-version-string): Set to 5.2 (devel).
+	(erc-format-lag-time): Fixed to work when `erc-server-lag' is nil.
+	(erc-update-mode-line-buffer): Set the header face.
+
+2007-01-11  Michael Olson  <mwolson@gnu.org>
+
+	* erc-bbdb.el (erc-bbdb-popup-type): Fix customization type and
+	documentation.
+
+	* erc-services.el (erc-nickserv-identify-mode): Improve
+	documentation for nick-change option and move higher to fix
+	compiler warning.  Avoid a recursive load error.
+	(erc-nickserv-alist): Add simple entry for BitlBee, to avoid
+	"NickServ is AWAY: User is offline" error.  Oddly enough, bitlbee
+	was smart enough to recognize that as an authentication request
+	and log in regardless, which is why I didn't notice this earlier.
+	(erc-nickserv-alist-sender, erc-nickserv-alist-regexp)
+	(erc-nickserv-alist-nickserv, erc-nickserv-alist-ident-keyword)
+	(erc-nickserv-alist-use-nick-p)
+	(erc-nickserv-alist-ident-command): New accessors for
+	erc-nickserv-alist.  Using nth is unwieldy.
+	(erc-nickserv-identify-autodetect)
+	(erc-nickserv-identify-on-connect)
+	(erc-nickserv-identify-on-nick-change, erc-nickserv-identify): Use
+	the new accessors.
+
+2007-01-11  Diane Murray  <disumu@x3y2z1.net>
+
+	* NEWS: Added note for `erc-my-nick-face'.  Fixed capab-identify
+	wording.
+
+2007-01-10  Diane Murray  <disumu@x3y2z1.net>
+
+	* erc.el (erc-mode-line-format): Added %l to documentation.
+	(erc-header-line-format): Removed "[IRC]".  Use the new %l
+	replacement character.  Doc fix.
+	(erc-format-channel-modes): Removed lag code.  Removed parentheses
+	from mode string.
+	(erc-format-lag-time): New function.
+	(erc-update-mode-line-buffer): Use it.
+
+2007-01-10  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el: Fix typo in url-irc-function instructions.
+
+2007-01-09  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-system-name): New option that determines the system
+	name to use when logging in.  The default is to figure this out by
+	calling `system-name'.
+	(erc-login): Use it.
+
+2007-01-07  Michael Olson  <mwolson@gnu.org>
+
+	* erc.el (erc-modules): Add the menu module.  This should fix a
+	bug with incorrect ERC submenus being displayed.
+
+	* erc-menu.el: Turn this into a module.
+	(erc-menu-add, erc-menu-remove): New functions that add and remove
+	the ERC menu.
+
+
+See ChangeLog.06 for earlier changes.
+
+    Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+
+  This file is part of GNU Emacs.
+
+  GNU Emacs is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3, or (at your option)
+  any later version.
+
+  GNU Emacs is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNU Emacs; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+
+;; Local Variables:
+;; coding: utf-8
+;; add-log-time-zone-rule: t
+;; End:
+
+;; arch-tag: 3369b6e5-96b1-4b32-96cd-9a905c747496
--- a/lisp/erc/erc-backend.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-backend.el	Wed Jan 30 07:57:28 2008 +0000
@@ -332,11 +332,10 @@
 
 If a cons, the encoding system for outgoing text is in the car
 and the decoding system for incoming text is in the cdr. The most
-interesting use for this is to put `undecided' in the cdr. If a
-function, it is called with no arguments and should return a
-coding system or a cons as described above. Note that you can use
-the dynamically bound variable `target' to get the current
-target. See `erc-coding-system-for-target'.
+interesting use for this is to put `undecided' in the cdr.
+
+If a function, it is called with the argument `target' and should
+return a coding system or a cons as described above.
 
 If you need to send non-ASCII text to people not using a client that
 does decoding on its own, you must tell ERC what encoding to use.
@@ -491,6 +490,8 @@
     (let ((process (funcall erc-server-connect-function
                             (format "erc-%s-%s" server port)
                             nil server port)))
+      (unless (processp process)
+        (error "Connection attempt failed"))
       (message "%s...done" msg)
       ;; Misc server variables
       (with-current-buffer buffer
@@ -686,7 +687,7 @@
               (when (string-match (car pat) target)
                 (throw 'match (cdr pat)))))))
       (and (functionp erc-server-coding-system)
-           (funcall erc-server-coding-system))
+           (funcall erc-server-coding-system target))
       erc-server-coding-system))
 
 (defun erc-decode-string-from-target (str target)
@@ -1349,7 +1350,7 @@
       (erc-update-mode-line))))
 
 (define-erc-response-handler (PRIVMSG NOTICE)
-  nil nil
+  "Handle private messages, including messages in channels." nil
   (let ((sender-spec (erc-response.sender parsed))
         (cmd (erc-response.command parsed))
         (tgt (car (erc-response.command-args parsed)))
@@ -1413,7 +1414,7 @@
 (add-hook 'erc-server-PRIVMSG-functions 'erc-auto-query)
 
 (define-erc-response-handler (QUIT)
-  nil nil
+  "Another user has quit IRC." nil
   (let ((reason (erc-response.contents parsed))
         bufs)
     (multiple-value-bind (nick login host)
@@ -1426,7 +1427,7 @@
                            ?h host ?r reason))))
 
 (define-erc-response-handler (TOPIC)
-  nil nil
+  "The channel topic has changed." nil
   (let* ((ch (first (erc-response.command-args parsed)))
          (topic (erc-trim-string (erc-response.contents parsed)))
          (time (format-time-string "%T %m/%d/%y" (current-time))))
@@ -1439,7 +1440,7 @@
                            ?c ch ?T topic))))
 
 (define-erc-response-handler (WALLOPS)
-  nil nil
+  "Display a WALLOPS message." nil
   (let ((message (erc-response.contents parsed)))
     (multiple-value-bind (nick login host)
         (erc-parse-user (erc-response.sender parsed))
@@ -1465,12 +1466,12 @@
    (erc-response.contents parsed)))
 
 (define-erc-response-handler (376 422)
-  nil nil
+  "End of MOTD/MOTD is missing." nil
   (erc-server-MOTD proc parsed)
   (erc-connection-established proc parsed))
 
 (define-erc-response-handler (004)
-  nil nil
+  "Display the server's identification." nil
   (multiple-value-bind (server-name server-version)
       (cdr (erc-response.command-args parsed))
     (setq erc-server-version server-version)
@@ -1510,7 +1511,7 @@
     (erc-display-message parsed 'notice proc line)))
 
 (define-erc-response-handler (221)
-  nil nil
+  "Display the current user modes." nil
   (let* ((nick (first (erc-response.command-args parsed)))
          (modes (mapconcat 'identity
                            (cdr (erc-response.command-args parsed)) " ")))
@@ -1596,7 +1597,7 @@
        ?n nick ?f fname ?u user ?h host))))
 
 (define-erc-response-handler (312)
-  nil nil
+  "Server name response in WHOIS." nil
   (multiple-value-bind (nick server-host)
       (cdr (erc-response.command-args parsed))
     (erc-display-message
@@ -1614,7 +1615,7 @@
   ;; 318 - End of WHOIS list
   ;; 323 - End of channel LIST
   ;; 369 - End of WHOWAS
-  nil nil
+  "End of WHO/WHOIS/LIST/WHOWAS notices." nil
   (ignore proc parsed))
 
 (define-erc-response-handler (317)
@@ -1635,7 +1636,7 @@
        ?n nick ?i (erc-sec-to-time (string-to-number seconds-idle))))))
 
 (define-erc-response-handler (319)
-  nil nil
+  "Channel names in WHOIS response." nil
   (erc-display-message
    parsed 'notice 'active 's319
    ?n (second (erc-response.command-args parsed))
@@ -1649,8 +1650,13 @@
 
 (define-erc-response-handler (321)
   "LIST header." nil
-  (setq erc-channel-list nil)
-  (erc-display-message parsed 'notice proc 's321))
+  (setq erc-channel-list nil))
+
+(defun erc-server-321-message (proc parsed)
+  "Display a message for the 321 event."
+  (erc-display-message parsed 'notice proc 's321)
+  nil)
+(add-hook 'erc-server-321-functions 'erc-server-321-message t)
 
 (define-erc-response-handler (322)
   "LIST notice." nil
@@ -1658,10 +1664,17 @@
     (multiple-value-bind (channel num-users)
         (cdr (erc-response.command-args parsed))
       (add-to-list 'erc-channel-list (list channel))
-      (erc-update-channel-topic channel topic)
+      (erc-update-channel-topic channel topic))))
+
+(defun erc-server-322-message (proc parsed)
+  "Display a message for the 322 event."
+  (let ((topic (erc-response.contents parsed)))
+    (multiple-value-bind (channel num-users)
+        (cdr (erc-response.command-args parsed))
       (erc-display-message
        parsed 'notice proc 's322
        ?c channel ?u num-users ?t (or topic "")))))
+(add-hook 'erc-server-322-functions 'erc-server-322-message t)
 
 (define-erc-response-handler (324)
   "Channel or nick modes." nil
@@ -1683,7 +1696,7 @@
      's329 ?c channel ?t (format-time-string "%A %Y/%m/%d %X" time))))
 
 (define-erc-response-handler (330)
-  nil nil
+  "Nick is authed as (on Quakenet network)." nil
   ;; FIXME: I don't know what the magic numbers mean.  Mummy, make
   ;; the magic numbers go away.
   ;; No seriously, I have no clue about the format of this command,
@@ -1699,10 +1712,9 @@
                          ?n nick ?a authmsg ?i authaccount)))
 
 (define-erc-response-handler (331)
-  "Channel topic." nil
+  "No topic set for channel." nil
   (let ((channel (second (erc-response.command-args parsed)))
         (topic (erc-response.contents parsed)))
-    ;; FIXME: why don't we do anything with the topic? -- Lawrence 2004/05/10
     (erc-display-message parsed 'notice (erc-get-buffer channel proc)
                          's331 ?c channel)))
 
@@ -1715,8 +1727,7 @@
                          's332 ?c channel ?T topic)))
 
 (define-erc-response-handler (333)
-  ;; Who set the topic, and when
-  nil nil
+  "Who set the topic, and when." nil
   (multiple-value-bind (channel nick time)
       (cdr (erc-response.command-args parsed))
     (setq time (format-time-string "%T %Y/%m/%d"
@@ -1766,7 +1777,7 @@
     (erc-channel-end-receiving-names)))
 
 (define-erc-response-handler (367)
-  "Channel ban list entries" nil
+  "Channel ban list entries." nil
   (multiple-value-bind (channel banmask setter time)
       (cdr (erc-response.command-args parsed))
     ;; setter and time are not standard
@@ -1781,7 +1792,7 @@
                            ?b banmask))))
 
 (define-erc-response-handler (368)
-  "End of channel ban list" nil
+  "End of channel ban list." nil
   (let ((channel (second (erc-response.command-args parsed))))
     (erc-display-message parsed 'notice 'active 's368
                          ?c channel)))
@@ -1797,7 +1808,7 @@
                          's379 ?c from ?f to)))
 
 (define-erc-response-handler (391)
-  "Server's time string" nil
+  "Server's time string." nil
   (erc-display-message
    parsed 'notice 'active
    's391 ?s (second (erc-response.command-args parsed))
@@ -1824,56 +1835,47 @@
 
 
 (define-erc-response-handler (405)
-  ;; Can't join that many channels.
-  nil nil
+  "Can't join that many channels." nil
   (erc-display-message parsed '(notice error) 'active
                        's405 ?c (second (erc-response.command-args parsed))))
 
 (define-erc-response-handler (406)
-  ;; No such nick
-  nil nil
+  "No such nick." nil
   (erc-display-message parsed '(notice error) 'active
                        's406 ?n (second (erc-response.command-args parsed))))
 
 (define-erc-response-handler (412)
-  ;; No text to send
-  nil nil
+  "No text to send." nil
   (erc-display-message parsed '(notice error) 'active 's412))
 
 (define-erc-response-handler (421)
-  ;; Unknown command
-  nil nil
+  "Unknown command." nil
   (erc-display-message parsed '(notice error) 'active 's421
                        ?c (second (erc-response.command-args parsed))))
 
 (define-erc-response-handler (432)
-  ;; Bad nick.
-  nil nil
+  "Bad nick." nil
   (erc-display-message parsed '(notice error) 'active 's432
                        ?n (second (erc-response.command-args parsed))))
 
 (define-erc-response-handler (433)
-  ;; Login-time "nick in use"
-  nil nil
+  "Login-time \"nick in use\"." nil
   (erc-nickname-in-use (second (erc-response.command-args parsed))
                        "already in use"))
 
 (define-erc-response-handler (437)
-  ;; Nick temporarily unavailable (IRCnet)
-  nil nil
+  "Nick temporarily unavailable (on IRCnet)." nil
   (let ((nick/channel (second (erc-response.command-args parsed))))
     (unless (erc-channel-p nick/channel)
       (erc-nickname-in-use nick/channel "temporarily unavailable"))))
 
 (define-erc-response-handler (442)
-  ;; Not on channel
-  nil nil
+  "Not on channel." nil
   (erc-display-message parsed '(notice error) 'active 's442
                        ?c (second (erc-response.command-args parsed))))
 
 (define-erc-response-handler (461)
-  ;; Not enough params for command.
-  nil nil
+  "Not enough parameters for command." nil
   (erc-display-message parsed '(notice error)  'active 's461
                        ?c (second (erc-response.command-args parsed))
                        ?m (erc-response.contents parsed)))
@@ -1887,7 +1889,7 @@
    (erc-response.contents parsed)))
 
 (define-erc-response-handler (474)
-  "Banned from channel errors" nil
+  "Banned from channel errors." nil
   (erc-display-message parsed '(notice error) nil
                        (intern (format "s%s"
                                        (erc-response.command parsed)))
@@ -1906,14 +1908,14 @@
           (erc-cmd-JOIN channel key)))))
 
 (define-erc-response-handler (477)
-  nil nil
+  "Channel doesn't support modes." nil
   (let ((channel (second (erc-response.command-args parsed)))
         (message (erc-response.contents parsed)))
     (erc-display-message parsed 'notice (erc-get-buffer channel proc)
                          (format "%s: %s" channel message))))
 
 (define-erc-response-handler (482)
-  nil nil
+  "You need to be a channel operator to do that." nil
   (let ((channel (second (erc-response.command-args parsed)))
         (message (erc-response.contents parsed)))
     (erc-display-message parsed '(error notice) 'active 's482
@@ -1935,7 +1937,9 @@
   ;; 491 - No O-lines for your host
   ;; 501 - Unknown MODE flag
   ;; 502 - Cannot change mode for other users
-  nil nil
+  "Generic display of server error messages.
+
+See `erc-display-error-notice'." nil
   (erc-display-error-notice
    parsed
    (intern (format "s%s" (erc-response.command parsed)))))
--- a/lisp/erc/erc-button.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-button.el	Wed Jan 30 07:57:28 2008 +0000
@@ -57,16 +57,15 @@
   ((add-hook 'erc-insert-modify-hook 'erc-button-add-buttons 'append)
    (add-hook 'erc-send-modify-hook 'erc-button-add-buttons 'append)
    (add-hook 'erc-complete-functions 'erc-button-next)
-   (add-hook 'erc-mode-hook 'erc-button-add-keys))
+   (add-hook 'erc-mode-hook 'erc-button-setup))
   ((remove-hook 'erc-insert-modify-hook 'erc-button-add-buttons)
    (remove-hook 'erc-send-modify-hook 'erc-button-add-buttons)
    (remove-hook 'erc-complete-functions 'erc-button-next)
-   (remove-hook 'erc-mode-hook 'erc-button-add-keys)))
-
-;; Make XEmacs use `erc-button-face'.
-(when (featurep 'xemacs)
-  (add-hook 'erc-mode-hook
-            (lambda () (set (make-local-variable 'widget-button-face) nil))))
+   (remove-hook 'erc-mode-hook 'erc-button-setup)
+   (when (featurep 'xemacs)
+     (dolist (buffer (erc-buffer-list))
+       (with-current-buffer buffer
+         (kill-local-variable 'widget-button-face))))))
 
 ;;; Variables
 
@@ -247,8 +246,12 @@
   "Internal variable used to keep track of whether we've added the
 global-level ERC button keys yet.")
 
-(defun erc-button-add-keys ()
+(defun erc-button-setup ()
   "Add ERC mode-level button movement keys.  This is only done once."
+  ;; Make XEmacs use `erc-button-face'.
+  (when (featurep 'xemacs)
+    (set (make-local-variable 'widget-button-face) nil))
+  ;; Add keys.
   (unless erc-button-keys-added
     (define-key erc-mode-map (kbd "<backtab>") 'erc-button-previous)
     (setq erc-button-keys-added t)))
@@ -299,9 +302,10 @@
         (setq bounds (bounds-of-thing-at-point 'word))
         (setq word (buffer-substring-no-properties
                     (car bounds) (cdr bounds)))
-        (if (erc-get-server-user word)
-            (erc-button-add-button (car bounds) (cdr bounds)
-                                   fun t (list word)))))))
+        (when (or (and (erc-server-buffer-p) (erc-get-server-user word))
+                  (and erc-channel-users (erc-get-channel-user word)))
+          (erc-button-add-button (car bounds) (cdr bounds)
+                                 fun t (list word)))))))
 
 (defun erc-button-add-buttons-1 (regexp entry)
   "Search through the buffer for matches to ENTRY and add buttons."
--- a/lisp/erc/erc-compat.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-compat.el	Wed Jan 30 07:57:28 2008 +0000
@@ -88,53 +88,6 @@
 (defalias 'erc-make-obsolete 'make-obsolete)
 (defalias 'erc-make-obsolete-variable 'make-obsolete-variable)
 
-;; Provde an equivalent of `assert', based on the code from cl-macs.el
-(defun erc-const-expr-p (x)
-  (cond ((consp x)
-	 (or (eq (car x) 'quote)
-	     (and (memq (car x) '(function function*))
-		  (or (symbolp (nth 1 x))
-		      (and (eq (and (consp (nth 1 x))
-				    (car (nth 1 x))) 'lambda) 'func)))))
-	((symbolp x) (and (memq x '(nil t)) t))
-	(t t)))
-
-(put 'erc-assertion-failed 'error-conditions '(error))
-(put 'erc-assertion-failed 'error-message "Assertion failed")
-
-(defun erc-list* (arg &rest rest)
-  "Return a new list with specified args as elements, cons'd to last arg.
-Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
-`(cons A (cons B (cons C D)))'."
-  (cond ((not rest) arg)
-	((not (cdr rest)) (cons arg (car rest)))
-	(t (let* ((n (length rest))
-		  (copy (copy-sequence rest))
-		  (last (nthcdr (- n 2) copy)))
-	     (setcdr last (car (cdr last)))
-	     (cons arg copy)))))
-
-(defmacro erc-assert (form &optional show-args string &rest args)
-  "Verify that FORM returns non-nil; signal an error if not.
-Second arg SHOW-ARGS means to include arguments of FORM in message.
-Other args STRING and ARGS... are arguments to be passed to `error'.
-They are not evaluated unless the assertion fails.  If STRING is
-omitted, a default message listing FORM itself is used."
-  (let ((sargs
-	 (and show-args
-	      (delq nil (mapcar
-			 (function
-			  (lambda (x)
-			    (and (not (erc-const-expr-p x)) x)))
-			 (cdr form))))))
-    (list 'progn
-	  (list 'or form
-		(if string
-		    (erc-list* 'error string (append sargs args))
-		  (list 'signal '(quote erc-assertion-failed)
-			(erc-list* 'list (list 'quote form) sargs))))
-	  nil)))
-
 ;; Provide a simpler replacement for `member-if'
 (defun erc-member-if (predicate list)
   "Find the first item satisfying PREDICATE in LIST.
--- a/lisp/erc/erc-dcc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-dcc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -60,6 +60,12 @@
   (require 'cl)
   (require 'pcomplete))
 
+;;;###autoload (autoload 'erc-dcc-mode "erc-dcc")
+(define-erc-module dcc nil
+  "Provide Direct Client-to-Client support for ERC."
+  ((add-hook 'erc-server-401-functions 'erc-dcc-no-such-nick))
+  ((remove-hook 'erc-server-401-functions 'erc-dcc-no-such-nick)))
+
 (defgroup erc-dcc nil
   "DCC stands for Direct Client Communication, where you and your
 friend's client programs connect directly to each other,
@@ -70,7 +76,7 @@
 IRC users."
   :group 'erc)
 
-(defcustom erc-verbose-dcc t
+(defcustom erc-dcc-verbose nil
   "*If non-nil, be verbose about DCC activity reporting."
   :group 'erc-dcc
   :type 'boolean)
@@ -195,20 +201,22 @@
           (setq list (cdr list)))))
     result))
 
-;; msa wrote this nifty little frob to convert an n-byte integer to a packed
-;; string.
-(defun erc-pack-int (value count)
-  (if (> count 0)
-      (concat (erc-pack-int (/ value 256) (1- count))
-              (char-to-string (% value 256)))
-    ""))
+(defun erc-pack-int (value)
+  "Convert an integer into a packed string."
+  (let* ((len (ceiling (/ value 256.0)))
+         (str (make-string len ?a))
+         (i (1- len)))
+    (while (>= i 0)
+      (aset str i (% value 256))
+      (setq value (/ value 256))
+      (setq i (1- i)))
+    str))
 
 (defun erc-unpack-int (str)
-  "Unpack a 1-4 character packed string into an integer."
+  "Unpack a packed string into an integer."
   (let ((len (length str))
         (num 0)
         (count 0))
-    (erc-assert (<= len 4)) ;; this isn't going to fit in elisp bounds
     (while (< count len)
       (setq num (+ num (lsh (aref str (- len count 1)) (* 8 count))))
       (setq count (1+ count)))
@@ -256,15 +264,24 @@
 
 ;;; Server code
 
-(defcustom erc-dcc-host nil
-  "*IP address to use for outgoing DCC offers.
-Should be set to a string or nil, if nil, automatic detection of the
-host interface to use will be attempted."
+(defcustom erc-dcc-listen-host nil
+  "IP address to listen on when offering files.
+Should be set to a string or nil.  If nil, automatic detection of
+the host interface to use will be attempted."
   :group 'erc-dcc
   :type (list 'choice (list 'const :tag "Auto-detect" nil)
               (list 'string :tag "IP-address"
                     :valid-regexp erc-dcc-ipv4-regexp)))
 
+(defcustom erc-dcc-public-host nil
+  "IP address to use for outgoing DCC offers.
+Should be set to a string or nil.  If nil, use the value of
+`erc-dcc-listen-host'."
+  :group 'erc-dcc
+  :type (list 'choice (list 'const :tag "Same as erc-dcc-listen-host" nil)
+              (list 'string :tag "IP-address"
+                    :valid-regexp erc-dcc-ipv4-regexp)))
+
 (defcustom erc-dcc-send-request 'ask
   "*How to treat incoming DCC Send requests.
 'ask - Report the Send request, and wait for the user to manually accept it
@@ -282,7 +299,7 @@
   "Determine the IP address we are using.
 If variable `erc-dcc-host' is non-nil, use it.  Otherwise call
 `erc-dcc-get-host' on the erc-server-process."
-  (or erc-dcc-host (erc-dcc-get-host erc-server-process)
+  (or erc-dcc-listen-host (erc-dcc-get-host erc-server-process)
       (error "Unable to determine local address")))
 
 (defcustom erc-dcc-port-range nil
@@ -311,6 +328,7 @@
         process)
     (while (not process)
       (condition-case err
+          (progn
             (setq process
                   (make-network-process :name name
                                         :buffer nil
@@ -322,6 +340,11 @@
                                         :sentinel sentinel
                                         :log #'erc-dcc-server-accept
                                         :server t))
+            (when (processp process)
+              (when (fboundp 'set-process-coding-system)
+                (set-process-coding-system process 'binary 'binary))
+              (when (fboundp 'set-process-filter-multibyte)
+                (set-process-filter-multibyte process nil))))
         (file-error
          (unless (and (string= "Cannot bind server socket" (cadr err))
                       (string= "address already in use" (caddr err)))
@@ -698,7 +721,7 @@
          (confirmed-marker (plist-get elt :sent))
          (sent-marker (plist-get elt :sent)))
     (with-current-buffer (process-buffer proc)
-      (when erc-verbose-dcc
+      (when erc-dcc-verbose
         (erc-display-message
          nil 'notice (erc-dcc-get-parent proc)
          (format "DCC: Confirmed %d, sent %d, sending block now"
@@ -713,8 +736,7 @@
         (length string)))))
 
 (defun erc-dcc-send-filter (proc string)
-  (erc-assert (= (% (length string) 4) 0))
-  (let* ((size (erc-unpack-int (substring string (- (length string) 4))))
+  (let* ((size (erc-unpack-int string))
          (elt (erc-dcc-member :peer proc))
          (parent (plist-get elt :parent))
          (sent-marker (plist-get elt :sent))
@@ -742,16 +764,21 @@
        ((> confirmed-marker sent-marker)
         (erc-display-message
          nil 'notice parent
-         (format "DCC: Client confirmed too much!"))
+         (format "DCC: Client confirmed too much (%s vs %s)!"
+                 (marker-position confirmed-marker)
+                 (marker-position sent-marker)))
+        (set-buffer-modified-p nil)
+        (kill-buffer (current-buffer))
         (delete-process proc))))))
 
+(defun erc-dcc-display-send (proc)
+  (erc-display-message
+   nil 'notice (erc-dcc-get-parent proc)
+   (format "DCC: SEND connect from %s"
+           (format-network-address (process-contact proc :remote)))))
+
 (defcustom erc-dcc-send-connect-hook
-  '((lambda (proc)
-      (erc-display-message
-       nil 'notice (erc-dcc-get-parent proc)
-       (format "DCC: SEND connect from %s"
-               (format-network-address (process-contact proc :remote)))))
-    erc-dcc-send-block)
+  '(erc-dcc-display-send erc-dcc-send-block)
   "*Hook run whenever the remote end of a DCC SEND offer connected to your
 listening port."
   :group 'erc-dcc
@@ -762,14 +789,14 @@
   (erc-extract-nick (plist-get plist :nick)))
 
 (defun erc-dcc-send-sentinel (proc event)
-  (let* ((elt (erc-dcc-member :peer proc))
-         (buf (marker-buffer (plist-get elt :sent))))
+  (let* ((elt (erc-dcc-member :peer proc)))
     (cond
      ((string-match "^open from " event)
       (when elt
-        (with-current-buffer buf
-          (set-process-buffer proc buf)
-          (setq erc-dcc-entry-data elt))
+        (let ((buf (marker-buffer (plist-get elt :sent))))
+          (with-current-buffer buf
+            (set-process-buffer proc buf)
+            (setq erc-dcc-entry-data elt)))
         (run-hook-with-args 'erc-dcc-send-connect-hook proc))))))
 
 (defun erc-dcc-find-file (file)
@@ -807,15 +834,23 @@
         (process-send-string
          pproc (format "PRIVMSG %s :\C-aDCC SEND %s %s %d %d\C-a\n"
                        nick (erc-dcc-file-to-name file)
-                       (erc-ip-to-decimal (nth 0 contact))
+                       (erc-ip-to-decimal (or erc-dcc-public-host
+                                              (nth 0 contact)))
                        (nth 1 contact)
                        size)))
     (error "`make-network-process' not supported by your Emacs")))
 
 ;;; GET handling
 
+(defcustom erc-dcc-receive-cache (* 1024 512)
+  "Number of bytes to let the receive buffer grow before flushing it."
+  :group 'erc-dcc
+  :type 'integer)
+
 (defvar erc-dcc-byte-count nil)
 (make-variable-buffer-local 'erc-dcc-byte-count)
+(defvar erc-dcc-file-name nil)
+(make-variable-buffer-local 'erc-dcc-file-name)
 
 (defun erc-dcc-get-file (entry file parent-proc)
   "This function does the work of setting up a transfer from the remote client
@@ -825,6 +860,7 @@
          proc)
     (with-current-buffer buffer
       (fundamental-mode)
+      (buffer-disable-undo (current-buffer))
       ;; This is necessary to have the buffer saved as-is in GNU
       ;; Emacs.
       ;; XEmacs change: We don't have `set-buffer-multibyte', setting
@@ -835,7 +871,10 @@
       (setq mode-line-process '(":%s")
             buffer-file-type t
             buffer-read-only t)
-      (set-visited-file-name file)
+      (setq erc-dcc-file-name file)
+
+      ;; Truncate the given file to size 0 before appending to it.
+      (write-region (point) (point) erc-dcc-file-name nil 'nomessage)
 
       (setq erc-server-process parent-proc
             erc-dcc-entry-data entry)
@@ -847,7 +886,6 @@
                      (string-to-number (plist-get entry :port))
                      entry))
       (set-process-buffer proc buffer)
-      ;; The following two lines make saving as-is work under Windows
       (set-process-coding-system proc 'binary 'binary)
       (set-buffer-file-coding-system 'binary t)
 
@@ -856,6 +894,14 @@
       (setq entry (plist-put entry :start-time (erc-current-time)))
       (setq entry (plist-put entry :peer proc)))))
 
+(defun erc-dcc-append-contents (buffer file)
+  "Append the contents of BUFFER to FILE.
+The contents of the BUFFER will then be erased."
+  (with-current-buffer buffer
+    (let ((coding-system-for-write 'binary))
+      (write-region (point-min) (point-max) erc-dcc-file-name t 'nomessage)
+      (erase-buffer))))
+
 (defun erc-dcc-get-filter (proc str)
   "This is the process filter for transfers from other clients to this one.
 It reads incoming bytes from the network and stores them in the DCC
@@ -868,8 +914,10 @@
       (insert (string-make-unibyte str))
 
       (setq erc-dcc-byte-count (+ (length str) erc-dcc-byte-count))
-      (erc-assert (= erc-dcc-byte-count (1- (point-max))))
-      (and erc-verbose-dcc
+      (when (> (point-max) erc-dcc-receive-cache)
+        (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
+
+      (and erc-dcc-verbose
            (erc-display-message
             nil 'notice erc-server-process
             'dcc-get-bytes-received
@@ -885,7 +933,7 @@
         (delete-process proc))
        (t
         (process-send-string
-         proc (erc-pack-int erc-dcc-byte-count 4)))))))
+         proc (erc-pack-int erc-dcc-byte-count)))))))
 
 
 (defun erc-dcc-get-sentinel (proc event)
@@ -895,17 +943,18 @@
   ;; FIXME, we should look at EVENT, and also check size.
   (with-current-buffer (process-buffer proc)
     (delete-process proc)
-    (setq buffer-read-only nil)
     (setq erc-dcc-list (delete erc-dcc-entry-data erc-dcc-list))
+    (unless (= (point-min) (point-max))
+      (setq erc-dcc-byte-count (+ (buffer-size) erc-dcc-byte-count))
+      (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
     (erc-display-message
      nil 'notice erc-server-process
      'dcc-get-complete
-     ?f (file-name-nondirectory buffer-file-name)
-     ?s (number-to-string (buffer-size))
+     ?f erc-dcc-file-name
+     ?s (number-to-string erc-dcc-byte-count)
      ?t (format "%.0f"
                 (erc-time-diff (plist-get erc-dcc-entry-data :start-time)
-                               (erc-current-time))))
-    (save-buffer))
+                               (erc-current-time)))))
   (kill-buffer (process-buffer proc))
   (delete-process proc))
 
@@ -1126,8 +1175,6 @@
       (if (processp peer) (delete-process peer)))
     nil))
 
-(add-hook 'erc-server-401-functions 'erc-dcc-no-such-nick)
-
 (provide 'erc-dcc)
 
 ;;; erc-dcc.el ends here
--- a/lisp/erc/erc-goodies.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-goodies.el	Wed Jan 30 07:57:28 2008 +0000
@@ -33,10 +33,14 @@
 
 (require 'erc)
 
-;; Imenu Autoload
-(add-hook 'erc-mode-hook
-          (lambda ()
-            (setq imenu-create-index-function 'erc-create-imenu-index)))
+;;; Imenu support
+
+(defun erc-imenu-setup ()
+  "Setup Imenu support in an ERC buffer."
+  (set (make-local-variable 'imenu-create-index-function)
+       'erc-create-imenu-index))
+
+(add-hook 'erc-mode-hook 'erc-imenu-setup)
 (autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function")
 
 ;;; Automatically scroll to bottom
@@ -51,11 +55,15 @@
   :type '(choice integer (const nil)))
 
 (define-erc-module scrolltobottom nil
-  "This mode causes the prompt to stay at the end of the window.
-You have to activate or deactivate it in already created windows
-separately."
-  ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom))
-  ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)))
+  "This mode causes the prompt to stay at the end of the window."
+  ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
+   (dolist (buffer (erc-buffer-list))
+     (with-current-buffer buffer
+       (erc-add-scroll-to-bottom))))
+  ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
+   (dolist (buffer (erc-buffer-list))
+     (with-current-buffer buffer
+       (remove-hook 'window-scroll-functions 'erc-scroll-to-bottom t)))))
 
 (defun erc-add-scroll-to-bottom ()
   "A hook function for `erc-mode-hook' to recenter output at bottom of window.
@@ -110,7 +118,46 @@
   (put-text-property (point-min) (point-max) 'front-sticky t)
   (put-text-property (point-min) (point-max) 'rear-nonsticky t))
 
-;; Distinguish non-commands
+;;; Move to prompt when typing text
+(define-erc-module move-to-prompt nil
+  "This mode causes the point to be moved to the prompt when typing text."
+  ((add-hook 'erc-mode-hook 'erc-move-to-prompt-setup)
+   (dolist (buffer (erc-buffer-list))
+     (with-current-buffer buffer
+       (erc-move-to-prompt-setup))))
+  ((remove-hook 'erc-mode-hook 'erc-move-to-prompt-setup)
+   (dolist (buffer (erc-buffer-list))
+     (with-current-buffer buffer
+       (remove-hook 'pre-command-hook 'erc-move-to-prompt t)))))
+
+(defun erc-move-to-prompt ()
+  "Move the point to the ERC prompt if this is a self-inserting command."
+  (when (and erc-input-marker (< (point) erc-input-marker)
+             (eq 'self-insert-command this-command))
+    (deactivate-mark)
+    (push-mark)
+    (goto-char (point-max))))
+
+(defun erc-move-to-prompt-setup ()
+  "Initialize the move-to-prompt module for XEmacs."
+  (add-hook 'pre-command-hook 'erc-move-to-prompt nil t))
+
+;;; Keep place in unvisited channels
+(define-erc-module keep-place nil
+  "Leave point above un-viewed text in other channels."
+  ((add-hook 'erc-insert-pre-hook  'erc-keep-place))
+  ((remove-hook 'erc-insert-pre-hook  'erc-keep-place)))
+
+(defun erc-keep-place (ignored)
+  "Move point away from the last line in a non-selected ERC buffer."
+  (when (and (not (eq (window-buffer (selected-window))
+                      (current-buffer)))
+             (>= (point) erc-insert-marker))
+    (deactivate-mark)
+    (goto-char (erc-beg-of-input-line))
+    (forward-line -1)))
+
+;;; Distinguish non-commands
 (defvar erc-noncommands-list '(erc-cmd-ME
                                erc-cmd-COUNTRY
                                erc-cmd-SV
@@ -496,8 +543,19 @@
 
 See also `unmorse-region'."
   (goto-char (point-min))
-  (when (re-search-forward "[.-]+\\([.-]+[/ ]\\)+[.-]+" nil t)
-    (unmorse-region (match-beginning 0) (match-end 0))))
+  (when (re-search-forward "[.-]+\\([.-]*/? *\\)+[.-]+/?" nil t)
+    (save-restriction
+      (narrow-to-region (match-beginning 0) (match-end 0))
+      ;; Turn " / " into "  "
+      (goto-char (point-min))
+      (while (re-search-forward " / " nil t)
+        (replace-match "  "))
+      ;; Turn "/ " into "/"
+      (goto-char (point-min))
+      (while (re-search-forward "/ " nil t)
+        (replace-match "/"))
+      ;; Unmorse region
+      (unmorse-region (point-min) (point-max)))))
 
 ;;; erc-occur
 (defun erc-occur (string &optional proc)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/erc/erc-list.el	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,229 @@
+;;; erc-list.el --- /list support for ERC
+
+;; Copyright (C) 2008 Free Software Foundation, Inc.
+
+;; Author: Tom Tromey <tromey@redhat.com>
+;; Version: 0.1
+;; Keywords: comm
+
+;; This file is part of ERC.
+
+;; ERC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; ERC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with ERC; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file provides nice support for /list in ERC.
+
+;;; Code:
+
+(require 'erc)
+
+;; This is implicitly the width of the channel name column.  Pick
+;; something small enough that the topic has a chance of being
+;; readable, but long enough that most channel names won't make for
+;; strange formatting.
+(defconst erc-list-nusers-column 25)
+
+;; Width of the number-of-users column.
+(defconst erc-list-topic-column (+ erc-list-nusers-column 10))
+
+;; The list buffer.  This is buffer local in the server buffer.
+(defvar erc-list-buffer nil)
+
+;; The argument to the last "/list".  This is buffer local in the
+;; server buffer.
+(defvar erc-list-last-argument nil)
+
+;; The server buffer corresponding to the list buffer.  This is buffer
+;; local in the list buffer.
+(defvar erc-list-server-buffer nil)
+
+;; Define module:
+;;;###autoload (autoload 'erc-list-mode "erc-list")
+(define-erc-module list nil
+  "List channels nicely in a separate buffer."
+  ((remove-hook 'erc-server-321-functions 'erc-server-321-message)
+   (remove-hook 'erc-server-322-functions 'erc-server-322-message))
+  ((erc-with-all-buffers-of-server nil
+     #'erc-open-server-buffer-p
+     (remove-hook 'erc-server-322-functions 'erc-list-handle-322 t))
+   (add-hook 'erc-server-321-functions 'erc-server-321-message t)
+   (add-hook 'erc-server-322-functions 'erc-server-322-message t)))
+
+;; Format a record for display.
+(defun erc-list-make-string (channel users topic)
+  (concat
+   channel
+   (erc-propertize " "
+		   'display (list 'space :align-to erc-list-nusers-column)
+		   'face 'fixed-pitch)
+   users
+   (erc-propertize " "
+		   'display (list 'space :align-to erc-list-topic-column)
+		   'face 'fixed-pitch)
+   topic))
+
+;; Insert a record into the list buffer.
+(defun erc-list-insert-item (channel users topic)
+  (save-excursion
+    (let ((buffer-read-only nil))
+      (goto-char (point-max))
+      (insert (erc-list-make-string channel users topic) "\n"))))
+
+(defun erc-list-join ()
+  "Join the irc channel named on this line."
+  (interactive)
+  (unless (eobp)
+    (beginning-of-line)
+    (unless (looking-at "\\([&#+!][^ \n]+\\)")
+      (error "Not looking at channel name?"))
+    (let ((chan (match-string 1)))
+      (with-current-buffer erc-list-server-buffer
+	(erc-join-channel chan)))))
+
+(defun erc-list-kill ()
+  "Kill the current ERC list buffer."
+  (interactive)
+  (kill-buffer (current-buffer)))
+
+(defun erc-list-revert ()
+  "Refresh the list of channels."
+  (interactive)
+  (with-current-buffer erc-list-server-buffer
+    (erc-cmd-LIST erc-list-last-argument)))
+
+(defun erc-list-menu-sort-by-column (&optional e)
+  "Sort the channel list by the column clicked on."
+  (interactive (list last-input-event))
+  (if e (mouse-select-window e))
+  (let* ((pos (event-start e))
+	 (obj (posn-object pos))
+	 (col (if obj
+		  (get-text-property (cdr obj) 'column-number (car obj))
+		(get-text-property (posn-point pos) 'column-number))))
+    (let ((buffer-read-only nil))
+      (if (= col 1)
+	  (sort-fields col (point-min) (point-max))
+	(sort-numeric-fields col (point-min) (point-max))))))
+
+(defvar erc-list-menu-mode-map nil
+  "Local keymap for `erc-list-mode' buffers.")
+
+(unless erc-list-menu-mode-map
+  (setq erc-list-menu-mode-map (make-keymap))
+  (suppress-keymap erc-list-menu-mode-map)
+  (define-key erc-list-menu-mode-map "k" 'erc-list-kill)
+  (define-key erc-list-menu-mode-map "j" 'erc-list-join)
+  (define-key erc-list-menu-mode-map "g" 'erc-list-revert)
+  (define-key erc-list-menu-mode-map "n" 'next-line)
+  (define-key erc-list-menu-mode-map "p" 'previous-line)
+  (define-key erc-list-menu-mode-map "q" 'quit-window))
+
+(defvar erc-list-menu-sort-button-map nil
+  "Local keymap for ERC list menu mode sorting buttons.")
+
+(unless erc-list-menu-sort-button-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [header-line mouse-1] 'erc-list-menu-sort-by-column)
+    (define-key map [follow-link] 'mouse-face)
+    (setq erc-list-menu-sort-button-map map)))
+
+;; Helper function that makes a buttonized column header.
+(defun erc-list-button (title column)
+  (erc-propertize title
+		  'column-number column
+		  'help-echo "mouse-1: sort by column"
+		  'mouse-face 'highlight
+		  'keymap erc-list-menu-sort-button-map))
+
+(define-derived-mode erc-list-menu-mode nil "ERC-List"
+  "Major mode for editing a list of irc channels."
+  (setq header-line-format
+	(concat
+	 (erc-propertize " "
+			 'display '(space :align-to 0)
+			 'face 'fixed-pitch)
+	 (erc-list-make-string (erc-list-button "Channel" 1)
+			       (erc-list-button "# Users" 2)
+			       "Topic")))
+  (setq truncate-lines t))
+
+(put 'erc-list-menu-mode 'mode-class 'special)
+
+;; Handle a "322" response.  This response tells us about a single
+;; channel.
+(defun erc-list-handle-322 (proc parsed)
+  (let* ((args (cdr (erc-response.command-args parsed)))
+	 (channel (car args))
+	 (nusers (car (cdr args)))
+	 (topic (erc-response.contents parsed)))
+    (when (buffer-live-p erc-list-buffer)
+      (with-current-buffer erc-list-buffer
+	(erc-list-insert-item channel nusers topic))))
+  ;; Don't let another hook run.
+  t)
+
+;; Helper function to install our 322 handler and make our buffer.
+(defun erc-list-install-322-handler (server-buffer)
+  (with-current-buffer server-buffer
+    ;; Arrange for 322 responses to insert into our buffer.
+    (add-hook 'erc-server-322-functions 'erc-list-handle-322 t t)
+    ;; Arrange for 323 (end of list) to end this.
+    (erc-once-with-server-event
+     323
+     '(progn
+	(remove-hook 'erc-server-322-functions 'erc-list-handle-322 t)))
+    ;; Find the list buffer, empty it, and display it.
+    (set (make-local-variable 'erc-list-buffer)
+	 (get-buffer-create (concat "*Channels of "
+				    erc-server-announced-name
+				    "*")))
+    (with-current-buffer erc-list-buffer
+      (erc-list-menu-mode)
+      (setq buffer-read-only nil)
+      (erase-buffer)
+      (set (make-local-variable 'erc-list-server-buffer) server-buffer)
+      (setq buffer-read-only t))
+    (pop-to-buffer erc-list-buffer))
+  t)
+
+;; The main entry point.
+(defun erc-cmd-LIST (&optional line)
+  "Show a listing of channels on the current server in a separate window.
+
+If LINE is specified, include it with the /LIST command.  It
+should usually be one or more channels, separated by commas.
+
+Please note that this function only works with IRC servers which conform
+to RFC and send the LIST header (#321) at start of list transmission."
+  (erc-with-server-buffer
+    (set (make-local-variable 'erc-list-last-argument) line)
+    (erc-once-with-server-event
+     321
+     (list 'progn
+	   (list 'erc-list-install-322-handler (current-buffer)))))
+  (erc-server-send (concat "LIST :" (or (and line (substring line 1))
+					""))))
+(put 'erc-cmd-LIST 'do-not-parse-args t)
+
+;;; erc-list.el ends here
+;;
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
+
+;; arch-tag: 99c5f9cb-6bac-4224-86bf-e394768cd1d0
--- a/lisp/erc/erc-networks.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-networks.el	Wed Jan 30 07:57:28 2008 +0000
@@ -28,9 +28,7 @@
 ;;
 ;; Usage:
 ;;
-;; Put into your .emacs:
-;;
-;; (require 'erc-networks)
+;; This is the "networks" module.
 ;;
 ;; M-x erc-server-select provides an alternative way to connect to servers by
 ;; choosing networks.
@@ -351,6 +349,7 @@
   ("Relicnet: Random server" Relicnet "irc.relic.net" 6667)
   ("Rezosup: Random server" Rezosup "irc.rezosup.org" 6667)
   ("Risanet: Random server" Risanet "irc.risanet.com" ((6667 6669)))
+  ("Rizon: Random server" Rizon "irc.rizon.net" (6633 (6660 6669) 6697 7000 8080 9999))
   ("Rubiks: Random server" Rubiks "irc.rubiks.net" 6667)
   ("Rusnet: EU, RU, Tomsk" Rusnet "irc.tsk.ru" ((6667 6669) (7770 7775) ))
   ("Rusnet: EU, RU, Vladivostok" Rusnet "irc.vladivostok.ru" ((6667 6669) (7770 7775) ))
@@ -765,9 +764,14 @@
   (setq erc-network nil)
   nil)
 
-(add-hook 'erc-server-375-functions 'erc-set-network-name)
-(add-hook 'erc-server-422-functions 'erc-set-network-name)
-(add-hook 'erc-disconnected-hook 'erc-unset-network-name)
+(define-erc-module networks nil
+  "Provide data about IRC networks."
+  ((add-hook 'erc-server-375-functions 'erc-set-network-name)
+   (add-hook 'erc-server-422-functions 'erc-set-network-name)
+   (add-hook 'erc-disconnected-hook 'erc-unset-network-name))
+  ((remove-hook 'erc-server-375-functions 'erc-set-network-name)
+   (remove-hook 'erc-server-422-functions 'erc-set-network-name)
+   (remove-hook 'erc-disconnected-hook 'erc-unset-network-name)))
 
 (defun erc-ports-list (ports)
   "Return a list of PORTS.
--- a/lisp/erc/erc-page.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-page.el	Wed Jan 30 07:57:28 2008 +0000
@@ -104,5 +104,11 @@
 
 (provide 'erc-page)
 
+;;; erc-page.el ends here
+;;
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
+
 ;; arch-tag: 82fd2e0e-6060-4dd2-9788-8c1411e844de
-;;; erc-page.el ends here
--- a/lisp/erc/erc-replace.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-replace.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,7 @@
 ;; erc-replace.el -- wash and massage messages inserted into the buffer
 
-;; Copyright (C) 2001, 2002, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2004, 2006, 2007,
+;;   2008 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <asf@void.at>
 ;; Maintainer: Mario Lang (mlang@delysid.org)
@@ -88,5 +89,11 @@
 
 (provide 'erc-replace)
 
+;;; erc-replace.el ends here
+;;
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
+
 ;; arch-tag: dd904a59-d8a6-47f8-ac3a-76b698289a18
-;;; erc-replace.el ends here
--- a/lisp/erc/erc-services.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-services.el	Wed Jan 30 07:57:28 2008 +0000
@@ -123,6 +123,10 @@
 		  '(("autodetect") ("nick-change") ("both")) nil t))))
   (add-hook 'erc-server-NOTICE-functions
 	    'erc-nickserv-identification-autodetect)
+  (unless erc-networks-mode
+    ;; Force-enable networks module, because we need it to set
+    ;; erc-network for us.
+    (erc-networks-enable))
   (cond ((eq mode 'autodetect)
 	 (setq erc-nickserv-identify-mode 'autodetect)
 	 (add-hook 'erc-server-NOTICE-functions
@@ -187,6 +191,7 @@
 			(const iip)
 			(const OFTC)
 			(const QuakeNet)
+			(const Rizon)
 			(const SlashNET)
 			(symbol :tag "Network name"))
 		(repeat :tag "Nickname and password"
@@ -227,6 +232,8 @@
      "IDENTIFY" nil nil nil)
     (freenode
      "NickServ!NickServ@services."
+     ;; freenode also accepts a password at login, see the `erc'
+     ;; :password argument.
      "/msg\\s-NickServ\\s-IDENTIFY\\s-<password>"
      "NickServ"
      "IDENTIFY" nil nil
@@ -249,9 +256,17 @@
      "IDENTIFY" nil "SQUERY" nil)
     (OFTC
      "NickServ!services@services.oftc.net"
-     "type\\s-/msg\\s-NickServ\\s-IDENTIFY\\s-password."
+     ;; OFTC's NickServ doesn't ask you to identify anymore.
+     nil
      "NickServ"
-     "IDENTIFY" nil nil nil)
+     "IDENTIFY" nil nil
+     "You\\s-are\\s-successfully\\s-identified\\s-as\\s-")
+    (Rizon
+     "NickServ!service@rizon.net"
+     "This\\s-nickname\\s-is\\s-registered\\s-and\\s-protected."
+     "NickServ"
+     "IDENTIFY" nil nil
+     "Password\\s-accepted\\s--\\s-you\\s-are\\s-now\\s-recognized.")
     (QuakeNet
      nil nil
      "Q@CServe.quakenet.org"
@@ -334,15 +349,15 @@
     ;; continue only if we're sure it's the real nickserv for this network
     ;; and it's told us we've successfully identified
     (when (and sender (equal sspec sender)
+	       success-regex
 	       (string-match success-regex msg))
       (erc-log "NickServ IDENTIFY success notification detected")
       (run-hook-with-args 'erc-nickserv-identified-hook network nick)
       nil)))
 
 (defun erc-nickserv-identify-autodetect (proc parsed)
-  "Check for a NickServ identify request everytime a notice is received.
-Make sure it is the real NickServ for this network and that it has
-specifically asked the user to IDENTIFY.
+  "Identify to NickServ when an identify request is received.
+Make sure it is the real NickServ for this network.
 If `erc-prompt-for-nickserv-password' is non-nil, prompt the user for the
 password for this nickname, otherwise try to send it automatically."
   (unless (and (null erc-nickserv-passwords)
@@ -356,6 +371,7 @@
       ;; continue only if we're sure it's the real nickserv for this network
       ;; and it's asked us to identify
       (when (and sender (equal sspec sender)
+		 identify-regex
 		 (string-match identify-regex msg))
 	(erc-log "NickServ IDENTIFY request detected")
 	(erc-nickserv-call-identify-function nick)
--- a/lisp/erc/erc-track.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-track.el	Wed Jan 30 07:57:28 2008 +0000
@@ -101,9 +101,13 @@
   :group 'erc-track
   :type 'boolean)
 
-(defcustom erc-track-exclude-types '("NICK")
+(defcustom erc-track-exclude-types '("NICK" "333" "353")
   "*List of message types to be ignored.
-This list could look like '(\"JOIN\" \"PART\")."
+This list could look like '(\"JOIN\" \"PART\").
+
+By default, exclude changes of nicknames (NICK), display of who
+set the channel topic (333), and listing of users on the current
+channel (353)."
   :group 'erc-track
   :type 'erc-message-type)
 
@@ -175,15 +179,32 @@
   :type 'boolean)
 
 (defcustom erc-track-faces-priority-list
-  '(erc-error-face erc-current-nick-face erc-keyword-face erc-pal-face
-    erc-nick-msg-face erc-direct-msg-face erc-button erc-dangerous-host-face
-    erc-default-face erc-action-face erc-nick-default-face erc-fool-face
-    erc-notice-face erc-input-face erc-prompt-face)
+  '(erc-error-face
+    (erc-nick-default-face erc-current-nick-face)
+    erc-current-nick-face
+    erc-keyword-face
+    (erc-nick-default-face erc-pal-face)
+    erc-pal-face
+    erc-nick-msg-face
+    erc-direct-msg-face
+    (erc-button erc-default-face)
+    (erc-nick-default-face erc-dangerous-host-face)
+    erc-dangerous-host-face
+    erc-nick-default-face
+    (erc-nick-default-face erc-default-face)
+    erc-default-face
+    erc-action-face
+    (erc-nick-default-face erc-fool-face)
+    erc-fool-face
+    erc-notice-face
+    erc-input-face
+    erc-prompt-face)
   "A list of faces used to highlight active buffer names in the modeline.
 If a message contains one of the faces in this list, the buffer name will
 be highlighted using that face.  The first matching face is used."
   :group 'erc-track
-  :type '(repeat face))
+  :type '(repeat (choice face
+			 (repeat :tag "Combination" face))))
 
 (defcustom erc-track-priority-faces-only nil
   "Only track text highlighted with a priority face.
@@ -193,6 +214,7 @@
 will be ignored while all other channels will be tracked as normal.
 Other options are 'all, to apply this to all channels or nil, to disable
 this feature.
+
 Note: If you have a lot of faces listed in `erc-track-faces-priority-list',
 setting this variable might not be very useful."
   :group 'erc-track
@@ -200,17 +222,38 @@
 		 (repeat string)
 		 (const all)))
 
+(defcustom erc-track-faces-normal-list
+  '((erc-button erc-default-face)
+    (erc-nick-default-face erc-dangerous-host-face)
+    erc-dangerous-host-face
+    erc-nick-default-face
+    (erc-nick-default-face erc-default-face)
+    erc-default-face
+    erc-action-face)
+  "A list of faces considered to be part of normal conversations.
+This list is used to highlight active buffer names in the modeline.
+
+If a message contains one of the faces in this list, and the
+previous modeline face for this buffer is also in this list, then
+the buffer name will be highlighted using the face from the
+message.  This gives a rough indication that active conversations
+are occurring in these channels.
+
+The effect may be disabled by setting this variable to nil."
+  :group 'erc-track
+  :type '(repeat (choice face
+			 (repeat :tag "Combination" face))))
+
 (defcustom erc-track-position-in-mode-line 'before-modes
   "Where to show modified channel information in the mode-line.
 
 Setting this variable only has effects in GNU Emacs versions above 21.3.
 
 Choices are:
-'before-modes - add to the beginning of `mode-line-modes'
-'after-modes  - add to the end of `mode-line-modes'
-t             - add to the end of `global-mode-string'.
-nil           - don't add to mode line
-"
+'before-modes - add to the beginning of `mode-line-modes',
+'after-modes  - add to the end of `mode-line-modes',
+t             - add to the end of `global-mode-string',
+nil           - don't add to mode line."
   :group 'erc-track
   :type '(choice (const :tag "Just before mode information" before-modes)
 		 (const :tag "Just after mode information" after-modes)
@@ -443,7 +486,7 @@
 
 ;;; Test:
 
-(erc-assert
+(assert
  (and
   ;; verify examples from the doc strings
   (equal (let ((erc-track-shorten-aggressively nil))
@@ -560,13 +603,15 @@
   :global t
   :group 'erc-track)
 
-(defun erc-track-minor-mode-maybe ()
+(defun erc-track-minor-mode-maybe (&optional buffer)
   "Enable `erc-track-minor-mode', depending on `erc-track-enable-keybindings'."
-  (unless (or erc-track-minor-mode
-	      ;; don't start the minor mode until we have an ERC
-	      ;; process running, because we don't want to prompt the
-	      ;; user while starting Emacs
-	      (null (erc-buffer-list)))
+  (when (and (not erc-track-minor-mode)
+	     ;; don't start the minor mode until we have an ERC
+	     ;; process running, because we don't want to prompt the
+	     ;; user while starting Emacs
+	     (or (and (buffer-live-p buffer)
+		      (with-current-buffer buffer (eq major-mode 'erc-mode)))
+		 (erc-buffer-list)))
     (cond ((eq erc-track-enable-keybindings 'ask)
 	   (let ((key (or (and (key-binding (kbd "C-c C-SPC")) "C-SPC")
 			  (and (key-binding (kbd "C-c C-@")) "C-@"))))
@@ -616,6 +661,7 @@
        (add-hook 'erc-insert-post-hook 'erc-track-modified-channels)
        (add-hook 'erc-disconnected-hook 'erc-modified-channels-update))
      ;; enable the tracking keybindings
+     (add-hook 'erc-connect-pre-hook 'erc-track-minor-mode-maybe)
      (erc-track-minor-mode-maybe)))
   ;; Disable:
   ((when (boundp 'erc-track-when-inactive)
@@ -637,6 +683,7 @@
        (remove-hook 'erc-disconnected-hook 'erc-modified-channels-update)
        (remove-hook 'erc-insert-post-hook 'erc-track-modified-channels))
      ;; disable the tracking keybindings
+     (remove-hook 'erc-connect-pre-hook 'erc-track-minor-mode-maybe)
      (when erc-track-minor-mode
        (erc-track-minor-mode -1)))))
 
@@ -821,15 +868,36 @@
 (defun erc-track-find-face (faces)
   "Return the face to use in the modeline from the faces in FACES.
 If `erc-track-faces-priority-list' is set, the one from FACES who is
-first in that list will be used."
-  (let ((candidates erc-track-faces-priority-list)
-	candidate face)
-    (while (and candidates (not face))
-      (setq candidate (car candidates)
-	    candidates (cdr candidates))
-      (when (memq candidate faces)
-	(setq face candidate)))
-    face))
+first in that list will be used.
+
+If `erc-track-faces-normal-list' is non-nil, use it to produce a
+blinking effect that indicates channel activity when the first
+element in FACES and the highest-ranking face among the rest of
+FACES are both members of `erc-track-faces-normal-list'.
+
+If `erc-track-faces-priority-list' is not set, the first element
+in FACES will be used.
+
+If one of the faces is a list, then it will be ranked according
+to its highest-tanking face member.  A list of faces including
+that member will take priority over just the single member
+element."
+  (let ((choice (catch 'face
+		  (dolist (candidate erc-track-faces-priority-list)
+		    (when (member candidate faces)
+		      (throw 'face candidate)))))
+	(no-first (and erc-track-faces-normal-list
+		       (catch 'face
+			 (dolist (candidate erc-track-faces-priority-list)
+			   (when (member candidate (cdr faces))
+			     (throw 'face candidate)))))))
+    (cond ((null choice)
+	   (car faces))
+	  ((and (member choice erc-track-faces-normal-list)
+		(member no-first erc-track-faces-normal-list))
+	   no-first)
+	  (t
+	   choice))))
 
 (defun erc-track-modified-channels ()
   "Hook function for `erc-insert-post-hook' to check if the current
@@ -898,14 +966,15 @@
   "Return a list of all faces used in STR."
   (let ((i 0)
 	(m (length str))
-	(faces (erc-list (get-text-property 0 'face str))))
+	(faces (erc-list (get-text-property 0 'face str)))
+	cur)
     (while (and (setq i (next-single-property-change i 'face str m))
 		(not (= i m)))
-      (dolist (face (erc-list (get-text-property i 'face str)))
-	(add-to-list 'faces face)))
+      (when (setq cur (get-text-property i 'face str))
+	(add-to-list 'faces cur)))
     faces))
 
-(erc-assert
+(assert
  (let ((str "is bold"))
    (put-text-property 3 (length str)
 		      'face '(bold erc-current-nick-face)
@@ -935,7 +1004,7 @@
   (let ((count 0))
     (catch 'done
       (dolist (item erc-track-faces-priority-list)
-	(if (eq item face)
+	(if (equal item face)
 	    (throw 'done t)
 	  (setq count (1+ count)))))
     count))
--- a/lisp/erc/erc-xdcc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc-xdcc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -62,6 +62,11 @@
   :group 'erc-dcc
   :type '(repeat (repeat :tag "Message" (choice string sexp))))
 
+;;;###autoload (autoload 'erc-xdcc-mode "erc-xdcc")
+(define-erc-module xdcc nil
+  "Act as an XDCC file-server."
+  nil nil)
+
 ;;;###autoload
 (defun erc-xdcc-add-file (file)
   "Add a file to `erc-xdcc-files'."
@@ -126,5 +131,11 @@
 
 (provide 'erc-xdcc)
 
+;;; erc-xdcc.el ends here
+;;
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
+
 ;; arch-tag: a13b62fe-2399-4562-af4e-f18a8dd4b9c8
-;;; erc-xdcc.el ends here
--- a/lisp/erc/erc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/erc/erc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -66,7 +66,7 @@
 
 ;;; Code:
 
-(defconst erc-version-string "Version 5.3 (devel)"
+(defconst erc-version-string "Version 5.3"
   "ERC version.  This is used by function `erc-version'.")
 
 (eval-when-compile (require 'cl))
@@ -1167,7 +1167,12 @@
 See the variable `erc-command-indicator'."
   :group 'erc-faces)
 
-(defface erc-notice-face '((t (:bold t :foreground "SlateBlue")))
+(defface erc-notice-face
+  (if (featurep 'xemacs)
+      '((t (:bold t :foreground "blue")))
+    '((((class color) (min-colors 88))
+       (:bold t :foreground "SlateBlue"))
+      (t (:bold t :foreground "blue"))))
   "ERC face for notices."
   :group 'erc-faces)
 
@@ -1465,18 +1470,23 @@
   "IRC port to use if it cannot be detected otherwise.")
 
 (defcustom erc-join-buffer 'buffer
-  "Determines how to display the newly created IRC buffer.
-'window - in another window,
-'window-noselect - in another window, but don't select that one,
-'frame - in another frame,
-'bury - bury it in a new buffer,
-any other value - in place of the current buffer."
+  "Determines how to display a newly created IRC buffer.
+
+The available choices are:
+
+  'window          - in another window,
+  'window-noselect - in another window, but don't select that one,
+  'frame           - in another frame,
+  'bury            - bury it in a new buffer,
+  'buffer          - in place of the current buffer,
+  any other value  - in place of the current buffer."
   :group 'erc-buffers
-  :type '(choice (const window)
-		 (const window-noselect)
-		 (const frame)
-		 (const bury)
-		 (const buffer)))
+  :type '(choice (const :tag "Split window and select" window)
+		 (const :tag "Split window, don't select" window-noselect)
+		 (const :tag "New frame" frame)
+		 (const :tag "Bury in new buffer" bury)
+		 (const :tag "Use current buffer" buffer)
+		 (const :tag "Use current buffer" t)))
 
 (defcustom erc-frame-alist nil
   "*Alist of frame parameters for creating erc frames.
@@ -1804,8 +1814,8 @@
 	     mods))))
 
 (defcustom erc-modules '(netsplit fill button match track completion readonly
-				  ring autojoin noncommands irccontrols
-				  stamp menu)
+			 networks ring autojoin noncommands irccontrols
+			 move-to-prompt stamp menu list)
   "A list of modules which ERC should enable.
 If you set the value of this without using `customize' remember to call
 \(erc-update-modules) after you change it.  When using `customize', modules
@@ -1837,14 +1847,20 @@
     (const :tag "completion: Complete nicknames and commands (programmable)"
 	   completion)
     (const :tag "hecomplete: Complete nicknames and commands (old)" hecomplete)
+    (const :tag "dcc: Provide Direct Client-to-Client support" dcc)
     (const :tag "fill: Wrap long lines" fill)
     (const :tag "identd: Launch an identd server on port 8113" identd)
     (const :tag "irccontrols: Highlight or remove IRC control characters"
 	   irccontrols)
+    (const :tag "keep-place: Leave point above un-viewed text" keep-place)
+    (const :tag "list: List channels in a separate buffer" list)
     (const :tag "log: Save buffers in logs" log)
     (const :tag "match: Highlight pals, fools, and other keywords" match)
     (const :tag "menu: Display a menu in ERC buffers" menu)
+    (const :tag "move-to-prompt: Move to the prompt when typing text"
+	   move-to-prompt)
     (const :tag "netsplit: Detect netsplits" netsplit)
+    (const :tag "networks: Provide data about IRC networks" networks)
     (const :tag "noncommands: Don't display non-IRC commands after evaluation"
 	   noncommands)
     (const :tag
@@ -1866,6 +1882,7 @@
     (const :tag "track: Track channel activity in the mode-line" track)
     (const :tag "truncate: Truncate buffers to a certain size" truncate)
     (const :tag "unmorse: Translate morse code in messages" unmorse)
+    (const :tag "xdcc: Act as an XDCC file-server" xdcc)
     (repeat :tag "Others" :inline t symbol))
   :group 'erc)
 
@@ -2324,6 +2341,15 @@
 I.e. any char in it has the `invisible' property set."
   (text-property-any 0 (length string) 'invisible t string))
 
+(defcustom erc-remove-parsed-property t
+  "Whether to remove the erc-parsed text property after displaying a message.
+
+The default is to remove it, since it causes ERC to take up extra
+memory.  If you have code that relies on this property, then set
+this option to nil."
+  :type 'boolean
+  :group 'erc)
+
 (defun erc-display-line-1 (string buffer)
   "Display STRING in `erc-mode' BUFFER.
 Auxiliary function used in `erc-display-line'.  The line gets filtered to
@@ -2364,7 +2390,10 @@
 		(save-restriction
 		  (narrow-to-region insert-position (point))
 		  (run-hooks 'erc-insert-modify-hook)
-		  (run-hooks 'erc-insert-post-hook))))))
+		  (run-hooks 'erc-insert-post-hook)
+		  (when erc-remove-parsed-property
+		    (remove-text-properties (point-min) (point-max)
+					    '(erc-parsed nil))))))))
 	(erc-update-undo-list (- (or (marker-position erc-insert-marker)
 				     (point-max))
 				 insert-position))))))
@@ -3161,14 +3190,35 @@
    (t nil)))
 (put 'erc-cmd-QUOTE 'do-not-parse-args t)
 
+(defcustom erc-query-display 'window
+  "Indicates how to display query buffers when using the /QUERY
+command to talk to someone.
+
+The default behavior is to display the message in a new window
+and bring it to the front.  See the documentation for
+`erc-join-buffer' for a description of the available choices.
+
+See also `erc-auto-query' to decide how private messages from
+other people should be displayed."
+  :group 'erc-query
+  :type '(choice (const :tag "Split window and select" window)
+		 (const :tag "Split window, don't select" window-noselect)
+		 (const :tag "New frame" frame)
+		 (const :tag "Bury in new buffer" bury)
+		 (const :tag "Use current buffer" buffer)
+		 (const :tag "Use current buffer" t)))
+
 (defun erc-cmd-QUERY (&optional user)
   "Open a query with USER.
 The type of query window/frame/etc will depend on the value of
-`erc-join-buffer'.  If USER is omitted, close the current query buffer if one
-exists - except this is broken now ;-)"
+`erc-query-display'.
+
+If USER is omitted, close the current query buffer if one exists
+- except this is broken now ;-)"
   (interactive
    (list (read-from-minibuffer "Start a query with: " nil)))
-  (let ((session-buffer (erc-server-buffer)))
+  (let ((session-buffer (erc-server-buffer))
+	(erc-join-buffer erc-query-display))
     (if user
 	(erc-query user session-buffer)
       ;; currently broken, evil hack to display help anyway
@@ -3707,8 +3757,9 @@
     (read-from-minibuffer
      (concat "Set topic of " (erc-default-target) ": ")
      (when erc-channel-topic
-       (cons (apply 'concat (butlast (split-string erc-channel-topic "\C-o")))
-	     0)))))
+       (let ((ss (split-string erc-channel-topic "\C-o")))
+	 (cons (apply 'concat (if (cdr ss) (butlast ss) ss))
+	       0))))))
   (let ((topic-list (split-string topic "\C-o"))) ; strip off the topic setter
     (erc-cmd-TOPIC (concat (erc-default-target) " " (car topic-list)))))
 
@@ -3841,20 +3892,22 @@
     (erc-update-mode-line)
     buf))
 
-(defcustom erc-auto-query 'bury
+(defcustom erc-auto-query 'window-noselect
   "If non-nil, create a query buffer each time you receive a private message.
-
-If the buffer doesn't already exist it is created.  This can be
-set to a symbol, to control how the new query window should
-appear.  See the documentation for `erc-join-buffer' for
-available choices."
+If the buffer doesn't already exist, it is created.
+
+This can be set to a symbol, to control how the new query window
+should appear.  The default behavior is to display the buffer in
+a new window, but not to select it.  See the documentation for
+`erc-join-buffer' for a description of the available choices."
   :group 'erc-query
-  :type '(choice (const nil)
-		 (const buffer)
-		 (const window)
-		 (const window-noselect)
-		 (const bury)
-		 (const frame)))
+  :type '(choice (const :tag "Don't create query window" nil)
+		 (const :tag "Split window and select" window)
+		 (const :tag "Split window, don't select" window-noselect)
+		 (const :tag "New frame" frame)
+		 (const :tag "Bury in new buffer" bury)
+		 (const :tag "Use current buffer" buffer)
+		 (const :tag "Use current buffer" t)))
 
 (defcustom erc-query-on-unjoined-chan-privmsg t
   "If non-nil create query buffer on receiving any PRIVMSG at all.
@@ -5822,7 +5875,7 @@
 
 ;; Mode line handling
 
-(defcustom erc-mode-line-format "%s %a"
+(defcustom erc-mode-line-format "%S %a"
   "A string to be formatted and shown in the mode-line in `erc-mode'.
 
 The string is formatted using `format-spec' and the result is set as the value
@@ -5833,12 +5886,16 @@
 %l: The estimated lag time to the server
 %m: The modes of the channel
 %n: The current nick name
+%N: The name of the network
 %o: The topic of the channel
 %p: The session port
 %t: The name of the target (channel, nickname, or servername:port)
 %s: In the server-buffer, this gets filled with the value of
     `erc-server-announced-name', in a channel, the value of
-    (erc-default-target) also get concatenated."
+    (erc-default-target) also get concatenated.
+%S: In the server-buffer, this gets filled with the value of
+    `erc-network', in a channel, the value of (erc-default-target)
+    also get concatenated."
   :group 'erc-mode-line-and-header
   :type 'string)
 
@@ -5932,6 +5989,29 @@
 	  (server-name server-name)
 	  (t (buffer-name (current-buffer))))))
 
+(defun erc-format-network ()
+  "Return the name of the network we are currently on."
+  (let ((network (and (fboundp 'erc-network-name) (erc-network-name))))
+    (if (and network (symbolp network))
+	(symbol-name network)
+      "")))
+
+(defun erc-format-target-and/or-network ()
+  "Return the network or the current target and network combined.
+If the name of the network is not available, then use the
+shortened server name instead."
+  (let ((network-name (or (and (fboundp 'erc-network-name) (erc-network-name))
+			  (erc-shorten-server-name
+			   (or erc-server-announced-name
+			       erc-session-server)))))
+    (when (and network-name (symbolp network-name))
+      (setq network-name (symbol-name network-name)))
+    (cond ((erc-default-target)
+	   (concat (erc-string-no-properties (erc-default-target))
+		   "@" network-name))
+	  (network-name network-name)
+	  (t (buffer-name (current-buffer))))))
+
 (defun erc-format-away-status ()
   "Return a formatted `erc-mode-line-away-status-format'
 if `erc-away' is non-nil."
@@ -5975,9 +6055,11 @@
 		 ?l (erc-format-lag-time)
 		 ?m (erc-format-channel-modes)
 		 ?n (or (erc-current-nick) "")
+		 ?N (erc-format-network)
 		 ?o (erc-controls-strip erc-channel-topic)
 		 ?p (erc-port-to-string erc-session-port)
 		 ?s (erc-format-target-and/or-server)
+		 ?S (erc-format-target-and/or-network)
 		 ?t (erc-format-target)))
 	  (process-status (cond ((and (erc-server-process-alive)
 				      (not erc-server-connected))
--- a/lisp/ffap.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ffap.el	Wed Jan 30 07:57:28 2008 +0000
@@ -797,7 +797,10 @@
     ("\\.bib\\'" . ffap-bib)		; search ffap-bib-path
     ("\\`\\." . ffap-home)		; .emacs, .bashrc, .profile
     ("\\`~/" . ffap-lcd)		; |~/misc/ffap.el.Z|
-    ("^[Rr][Ff][Cc][- #]?\\([0-9]+\\)"	; no $
+    ;; This uses to have a blank, but ffap-string-at-point doesn't
+    ;; handle blanks.
+    ;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01058.html
+    ("^[Rr][Ff][Cc][-#]?\\([0-9]+\\)"	; no $
      . ffap-rfc)			; "100% RFC2100 compliant"
     (dired-mode . ffap-dired)		; maybe in a subdirectory
     )
@@ -969,7 +972,7 @@
     ;; Slightly controversial decisions:
     ;; * strip trailing "@" and ":"
     ;; * no commas (good for latex)
-    (file "--:$+<>@-Z_[:lower:]~*?" "<@" "@>;.,!:")
+    (file "--:\\\\$+<>@-Z_[:lower:]~*?" "<@" "@>;.,!:")
     ;; An url, or maybe a email/news message-id:
     (url "--:=&?$+@-Z_[:lower:]~#,%;*" "^[:alnum:]" ":;.,!?")
     ;; Find a string that does *not* contain a colon:
@@ -1263,20 +1266,25 @@
 	  (setq dir (file-name-directory guess))))
     (let ((minibuffer-completing-file-name t)
 	  (completion-ignore-case read-file-name-completion-ignore-case)
-	  ;; because of `rfn-eshadow-update-overlay'.
-	  (file-name-handler-alist
-	   (cons (cons ffap-url-regexp 'url-file-handler)
-		 file-name-handler-alist)))
-      (setq guess
-	    (completing-read
-	     prompt
-	     'ffap-read-file-or-url-internal
-	     dir
-	     nil
-	     (if dir (cons guess (length dir)) guess)
-	     (list 'file-name-history)
-	     (and buffer-file-name
-		  (abbreviate-file-name buffer-file-name)))))
+          (fnh-elem (cons ffap-url-regexp 'url-file-handler)))
+      ;; Explain to `rfn-eshadow' that we can use URLs here.
+      (push fnh-elem file-name-handler-alist)
+      (unwind-protect
+          (setq guess
+                (completing-read
+                 prompt
+                 'ffap-read-file-or-url-internal
+                 dir
+                 nil
+                 (if dir (cons guess (length dir)) guess)
+                 (list 'file-name-history)
+                 (and buffer-file-name
+                      (abbreviate-file-name buffer-file-name))))
+        ;; Remove the special handler manually.  We used to just let-bind
+        ;; file-name-handler-alist to preserve its value, but that caused
+        ;; other modifications to be lost (e.g. when Tramp gets loaded
+        ;; during the completing-read call).
+        (setq file-name-handler-alist (delq fnh-elem file-name-handler-alist))))
     ;; Do file substitution like (interactive "F"), suggested by MCOOK.
     (or (ffap-url-p guess) (setq guess (substitute-in-file-name guess)))
     ;; Should not do it on url's, where $ is a common (VMS?) character.
--- a/lisp/files.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/files.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2488,13 +2488,13 @@
   :group 'find-file
   :type  'alist)
 
-(defcustom safe-local-eval-forms nil
+(defcustom safe-local-eval-forms '((add-hook 'write-file-hooks 'time-stamp))
   "Expressions that are considered safe in an `eval:' local variable.
 Add expressions to this list if you want Emacs to evaluate them, when
 they appear in an `eval' local variable specification, without first
 asking you for confirmation."
   :group 'find-file
-  :version "22.1"
+  :version "22.2"
   :type '(repeat sexp))
 
 ;; Risky local variables:
@@ -2839,7 +2839,8 @@
 	    (dolist (elt result)
 	      (let ((var (car elt))
 		    (val (cdr elt)))
-		(or (eq var 'mode)
+		;; Don't query about the fake variables.
+		(or (memq var '(mode unibyte coding))
 		    (and (eq var 'eval)
 			 (or (eq enable-local-eval t)
 			     (hack-one-local-variable-eval-safep
--- a/lisp/frame.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/frame.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1254,7 +1254,7 @@
 
 (defun display-mm-height (&optional display)
   "Return the height of DISPLAY's screen in millimeters.
-System values can be overriden by `display-mm-dimensions-alist'.
+System values can be overridden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
        (or (cddr (assoc (or display (frame-parameter nil 'display))
@@ -1264,7 +1264,7 @@
 
 (defun display-mm-width (&optional display)
   "Return the width of DISPLAY's screen in millimeters.
-System values can be overriden by `display-mm-dimensions-alist'.
+System values can be overridden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
   (and (memq (framep-on-display display) '(x w32 mac))
        (or (cadr (assoc (or display (frame-parameter nil 'display))
--- a/lisp/fringe.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/fringe.el	Wed Jan 30 07:57:28 2008 +0000
@@ -93,6 +93,10 @@
 
 (defvar fringe-mode)
 
+(defvar fringe-mode-explicit nil
+  "Non-nil means `set-fringe-mode' should really do something.
+This is nil while loading `fringe.el', and t afterward.")
+
 (defun set-fringe-mode-1 (ignore value)
   "Call `set-fringe-mode' with VALUE.
 See `fringe-mode' for valid values and their effect.
@@ -104,13 +108,14 @@
 See `fringe-mode' for possible values and their effect."
   (setq fringe-mode value)
 
-  (modify-all-frames-parameters
-   (list (cons 'left-fringe (if (consp fringe-mode)
-				(car fringe-mode)
-			      fringe-mode))
-	 (cons 'right-fringe (if (consp fringe-mode)
-				 (cdr fringe-mode)
-			       fringe-mode)))))
+  (when fringe-mode-explicit
+    (modify-all-frames-parameters
+     (list (cons 'left-fringe (if (consp fringe-mode)
+				  (car fringe-mode)
+				fringe-mode))
+	   (cons 'right-fringe (if (consp fringe-mode)
+				   (cdr fringe-mode)
+				 fringe-mode))))))
 
 ;; For initialization of fringe-mode, take account of changes
 ;; made explicitly to default-frame-alist.
@@ -159,6 +164,10 @@
   :initialize 'fringe-mode-initialize
   :set 'set-fringe-mode-1)
 
+;; We just set fringe-mode, but that was the default.
+;; If it is set again, that is for real.
+(setq fringe-mode-explicit t)
+
 (defun fringe-query-style (&optional all-frames)
   "Query user for fringe style.
 Returns values suitable for left-fringe and right-fringe frame parameters.
--- a/lisp/gnus/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,107 @@
+2008-01-24  Michael Sperber  <sperber@deinprogramm.de>
+
+	* mail-source.el (mail-sources): Add `group' choice.
+
+	* nnmail.el (nnmail-get-new-mail-1): Abstract this out to add another
+	parameter `in-group' to control into which group the articles go.
+	Add treatment of `group' mail-source.
+
+2008-01-24  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
+	* message.el (message-beginning-of-line): Use featurep instead of bound
+	tests in order to resolve conditionals at compile time.
+
+2008-01-23  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-insert-mime-button): Don't decode description.
+
+	* mm-decode.el (mm-dissect-buffer): Decode description.
+
+	* mml.el (mml-to-mime): Encode message header first.
+
+2008-01-18  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-describe-bindings): Make it possible to use
+	xrefs, i.e. [back] and [forward] buttons, in *Help* buffer.
+
+2008-01-18  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* gnus-registry.el (gnus-registry-trim): Use append, not concat.
+
+2008-01-17  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-read-summary-keys): Work for some `A'
+	prefix keys.
+	(gnus-article-read-summary-send-keys): Use gnus-character-to-event.
+	(gnus-article-describe-bindings): Simplify; move XEmacs stuff to
+	gnus-xmas.el.
+
+2008-01-16  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* gnus-registry.el (gnus-registry-marks, gnus-registry-default-mark):
+	Add new variables for article mark management.
+	(gnus-registry-extra-entries-precious, gnus-registry-trim): Define a
+	list of extra data entries which, when present, will indicate that the
+	article ID should not be trimmed from the registry.
+	(gnus-registry-mark-article, gnus-registry-article-marks): Remove these
+	functions.
+	(gnus-registry-read-mark): New function to read a mark name from the
+	user.
+	(gnus-registry-set-article-mark, gnus-registry-remove-article-mark)
+	(gnus-registry-set-article-mark-internal): New functions to add and
+	remove marks.
+	(gnus-registry-get-article-marks): New function to show the marks for
+	an article, or retrieve them for further use.
+
+2008-01-16  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-describe-bindings): Show all `S' prefix
+	keys when no argument is given.
+
+2008-01-12  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus-sum.el (gnus-article-sort-by-random)
+	(gnus-thread-sort-by-random): Fix doc strings.  Reported by
+	jidanni@jidanni.org.
+
+2008-01-11  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-describe-bindings): New function.
+	(gnus-article-read-summary-keys): Use it.
+	(gnus-article-mode-map): Bind `C-h b' to it.
+
+2008-01-10  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-read-summary-keys): Work for `C-h' on
+	XEmacs.
+	(gnus-article-describe-key, gnus-article-describe-key-briefly): Protect
+	against non-character events.
+
+2008-01-09  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus-group.el (gnus-group-read-ephemeral-gmane-group-url): New
+	command.
+	(gnus-group-read-ephemeral-gmane-group): Use optional argument RANGE
+	instead of END.  Change name of the temp file.
+	(gnus-group-gmane-group-download-format): Add doc string.  Make it
+	customizable.
+
+2008-01-09  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-send-map): New keymap for `S' prefix keys;
+	bind `S W' to gnus-article-wide-reply-with-original; set default
+	binding to gnus-article-read-summary-send-keys.
+	(gnus-article-read-summary-keys): Fix the order of keys; display
+	continuation keys correctly in the echo area; describe bindings
+	correctly when keys end with `C-h'.
+	(gnus-article-read-summary-send-keys): New function.
+	(gnus-article-describe-key, gnus-article-describe-key-briefly): Work
+	for gnus-article-read-summary-send-keys; display continuation keys
+	correctly in the echo area.
+	(gnus-article-reply-with-original): Ignore prefix argument.
+	(gnus-article-wide-reply-with-original): New function.
+
 2008-01-08  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-bookmark.el (gnus-bookmark-mouse-available-p): Don't test for
@@ -19,12 +123,6 @@
 	* mml-sec.el, sieve-manage.el, smime.el: Simplify loading of
 	password-cache or password.  Suggested by Glenn Morris <rgm@gnu.org>.
 
-2007-12-21  Teodor Zlatanov  <tzz@lifelogs.com>
-
-	* imap.el (imap-authenticate): Use current-buffer instead of buffer,
-	for the cases where imap-authenticate is called with a nil buffer
-	parameter.
-
 2007-12-19  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-art.el (gnus-article-browse-html-parts): Work for two or more
@@ -328,12 +426,6 @@
 
 	* message.el (message-ignored-supersedes-headers): Add "X-ID".
 
-2007-12-03  Nathan J. Williams  <nathanw@MIT.EDU>  (tiny change)
-
-	* imap.el (imap-mailbox-status-asynch): Upcase STATUS items.
-	(imap-parse-status): Upcase status-att for servers that sends them
-	lower-case (e.g., MS Exchange 2007).
-
 2007-12-03  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* gnus-sum.el (gnus-uu-extract-map): Add a command for the yenc
@@ -801,9 +893,6 @@
 	* webmail.el (webmail-debug): Replace mapcar called for effect with
 	dolist.
 
-	* gnus-xmas.el (gnus-group-add-icon): Replace mapcar called for effect
-	with mapc.
-
 2007-10-24  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-agent.el (gnus-agent-read-agentview, gnus-agent-save-alist)
--- a/lisp/gnus/ecomplete.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/ecomplete.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; ecomplete.el --- electric completion of addresses and the like
 
-;; Copyright (C) 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: mail
--- a/lisp/gnus/gnus-art.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/gnus-art.el	Wed Jan 30 07:57:28 2008 +0000
@@ -4215,6 +4215,7 @@
   "F" gnus-article-followup-with-original
   "\C-hk" gnus-article-describe-key
   "\C-hc" gnus-article-describe-key-briefly
+  "\C-hb" gnus-article-describe-bindings
 
   "\C-d" gnus-article-read-summary-keys
   "\M-*" gnus-article-read-summary-keys
@@ -4225,6 +4226,13 @@
 (substitute-key-definition
  'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
 
+(gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
+  "W" gnus-article-wide-reply-with-original)
+(if (featurep 'xemacs)
+    (set-keymap-default-binding gnus-article-send-map
+				'gnus-article-read-summary-send-keys)
+  (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
+
 (defun gnus-article-make-menu-bar ()
   (unless (boundp 'gnus-article-commands-menu)
     (gnus-summary-make-menu-bar))
@@ -5447,9 +5455,7 @@
 	     (mail-content-type-get (mm-handle-type handle) 'url)
 	     ""))
 	(gnus-tmp-type (mm-handle-media-type handle))
-	(gnus-tmp-description
-	 (mail-decode-encoded-word-string (or (mm-handle-description handle)
-					      "")))
+	(gnus-tmp-description (or (mm-handle-description handle) ""))
 	(gnus-tmp-dots
 	 (if (if displayed (car displayed)
 	       (mm-handle-displayed-p handle))
@@ -6234,26 +6240,27 @@
 	   "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
 	   "=" "^" "\M-^" "|"))
 	(nosave-but-article
-	 '("A\r"))
+	 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
+	   "An" "Ap" [?A (meta return)] [?A delete]))
 	(nosave-in-article
-	 '("\C-d"))
+	 '("AS" "\C-d"))
 	(up-to-top
 	 '("n" "Gn" "p" "Gp"))
 	keys new-sum-point)
     (save-excursion
       (set-buffer gnus-article-current-summary)
       (let (gnus-pick-mode)
-	(push (or key last-command-event) unread-command-events)
-	(setq keys (if (featurep 'xemacs)
-		       (events-to-keys (read-key-sequence nil))
-		     (read-key-sequence nil)))))
+	(setq unread-command-events (nconc unread-command-events
+					   (list (or key last-command-event)))
+	      keys (if (featurep 'xemacs)
+		       (events-to-keys (read-key-sequence nil t))
+		     (read-key-sequence nil t)))))
 
     (message "")
 
     (cond
      ((eq (aref keys (1- (length keys))) ?\C-h)
-      (with-current-buffer gnus-article-current-summary
-	(describe-bindings (substring keys 0 -1))))
+      (gnus-article-describe-bindings (substring keys 0 -1)))
      ((or (member keys nosaves)
 	  (member keys nosave-but-article)
 	  (member keys nosave-in-article))
@@ -6339,53 +6346,98 @@
 	      (signal (car err) (cdr err))
 	    (ding))))))))
 
+(defun gnus-article-read-summary-send-keys ()
+  (interactive)
+  (let ((unread-command-events (list (gnus-character-to-event ?S))))
+    (gnus-article-read-summary-keys)))
+
 (defun gnus-article-describe-key (key)
-  "Display documentation of the function invoked by KEY.  KEY is a string."
-  (interactive "kDescribe key: ")
+  "Display documentation of the function invoked by KEY.
+KEY is a string or a vector."
+  (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
+		       (read-key-sequence "Describe key: "))))
   (gnus-article-check-buffer)
-  (if (eq (key-binding key) 'gnus-article-read-summary-keys)
+  (if (memq (key-binding key t) '(gnus-article-read-summary-keys
+				  gnus-article-read-summary-send-keys))
       (save-excursion
 	(set-buffer gnus-article-current-summary)
-	(let (gnus-pick-mode)
-	  (if (featurep 'xemacs)
-	      (progn
-		(push (elt key 0) unread-command-events)
-		(setq key (events-to-keys
-			   (read-key-sequence "Describe key: "))))
-	    (setq unread-command-events
-		  (mapcar
-		   (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
-		   (string-to-list key)))
-	    (setq key (read-key-sequence "Describe key: "))))
-	(describe-key key))
+	(setq unread-command-events
+	      (if (featurep 'xemacs)
+		  (append key nil)
+		(mapcar (lambda (x) (if (and (integerp x) (>= x 128))
+					(list 'meta (- x 128))
+				      x))
+			key)))
+	(let ((cursor-in-echo-area t)
+	      gnus-pick-mode)
+	  (describe-key (read-key-sequence nil t))))
     (describe-key key)))
 
 (defun gnus-article-describe-key-briefly (key &optional insert)
-  "Display documentation of the function invoked by KEY.  KEY is a string."
-  (interactive "kDescribe key: \nP")
+  "Display documentation of the function invoked by KEY.
+KEY is a string or a vector."
+  (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
+		       (read-key-sequence "Describe key: "))
+		     current-prefix-arg))
   (gnus-article-check-buffer)
-  (if (eq (key-binding key) 'gnus-article-read-summary-keys)
+  (if (memq (key-binding key t) '(gnus-article-read-summary-keys
+				  gnus-article-read-summary-send-keys))
       (save-excursion
 	(set-buffer gnus-article-current-summary)
-	(let (gnus-pick-mode)
-	  (if (featurep 'xemacs)
-	      (progn
-		(push (elt key 0) unread-command-events)
-		(setq key (events-to-keys
-			   (read-key-sequence "Describe key: "))))
-	    (setq unread-command-events
-		  (mapcar
-		   (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
-		   (string-to-list key)))
-	    (setq key (read-key-sequence "Describe key: "))))
-	(describe-key-briefly key insert))
+	(setq unread-command-events
+	      (if (featurep 'xemacs)
+		  (append key nil)
+		(mapcar (lambda (x) (if (and (integerp x) (>= x 128))
+					(list 'meta (- x 128))
+				      x))
+			key)))
+	(let ((cursor-in-echo-area t)
+	      gnus-pick-mode)
+	  (describe-key-briefly (read-key-sequence nil t) insert)))
     (describe-key-briefly key insert)))
 
+;;`gnus-agent-mode' in gnus-agent.el will define it.
+(defvar gnus-agent-summary-mode)
+
+(defun gnus-article-describe-bindings (&optional prefix)
+  "Show a list of all defined keys, and their definitions.
+The optional argument PREFIX, if non-nil, should be a key sequence;
+then we display only bindings that start with that prefix."
+  (interactive)
+  (gnus-article-check-buffer)
+  (let ((keymap (copy-keymap gnus-article-mode-map))
+	(map (copy-keymap gnus-article-send-map))
+	(sumkeys (where-is-internal 'gnus-article-read-summary-keys))
+	agent)
+    (define-key keymap "S" map)
+    (define-key map [t] nil)
+    (with-current-buffer gnus-article-current-summary
+      (set-keymap-parent map (key-binding "S"))
+      (let (def gnus-pick-mode)
+	(dolist (key sumkeys)
+	  (when (setq def (key-binding key))
+	    (define-key keymap key def))))
+      (when (boundp 'gnus-agent-summary-mode)
+	(setq agent gnus-agent-summary-mode)))
+    (with-temp-buffer
+      (use-local-map keymap)
+      (set (make-local-variable 'gnus-agent-summary-mode) agent)
+      (describe-bindings prefix))
+    (let ((item `((lambda (prefix)
+		    (save-excursion
+		      (set-buffer ,(current-buffer))
+		      (gnus-article-describe-bindings prefix)))
+		  ,prefix)))
+      (with-current-buffer (if (fboundp 'help-buffer)
+			       (let (help-xref-following) (help-buffer))
+			     "*Help*") ;; Emacs 21
+	(setq help-xref-stack-item item)))))
+
 (defun gnus-article-reply-with-original (&optional wide)
   "Start composing a reply mail to the current message.
 The text in the region will be yanked.  If the region isn't active,
 the entire article will be yanked."
-  (interactive "P")
+  (interactive)
   (let ((article (cdr gnus-article-current))
 	contents)
     (if (not (gnus-region-active-p))
@@ -6400,6 +6452,13 @@
 	(gnus-summary-reply
 	 (list (list article contents)) wide)))))
 
+(defun gnus-article-wide-reply-with-original ()
+  "Start composing a wide reply mail to the current message.
+The text in the region will be yanked.  If the region isn't active,
+the entire article will be yanked."
+  (interactive)
+  (gnus-article-reply-with-original t))
+
 (defun gnus-article-followup-with-original ()
   "Compose a followup to the current article.
 The text in the region will be yanked.  If the region isn't active,
--- a/lisp/gnus/gnus-bookmark.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/gnus-bookmark.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; gnus-bookmark.el --- Bookmarks in Gnus
 
-;; Copyright (C) 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: news
--- a/lisp/gnus/gnus-group.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/gnus-group.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2320,44 +2320,94 @@
 	 (message "Quit reading the ephemeral group")
 	 nil)))))
 
-(defvar gnus-group-gmane-group-download-format
-  "http://download.gmane.org/%s/%s/%s")
+(defcustom gnus-group-gmane-group-download-format
+  "http://download.gmane.org/%s/%s/%s"
+  "URL for downloading mbox files.
+It must contain three \"%s\".  They correspond to the group, the
+minimal and maximal article numbers, respectively."
+  :group 'gnus-group-foreign
+  :version "23.0" ;; No Gnus
+  :type 'string)
+
 (autoload 'url-insert-file-contents "url-handlers")
-
-;; FIXME: Make gnus-group-gmane-group-download-format customizable.  Add
-;; documentation, menu, key bindings...
-
-(defun gnus-group-read-ephemeral-gmane-group (group start end)
+;; FIXME:
+;; - Add documentation, menu, key bindings, ...
+
+(defun gnus-group-read-ephemeral-gmane-group (group start &optional range)
   "Read articles from Gmane group GROUP as an ephemeral group.
-START and END specify the articles range.  The articles are
-downloaded via HTTP using the URL specified by
-`gnus-group-gmane-group-download-format'."
+START is the first article.  RANGE specifies how many articles
+are fetched.  The articles are downloaded via HTTP using the URL
+specified by `gnus-group-gmane-group-download-format'."
   ;; See <http://gmane.org/export.php> for more information.
   (interactive
    (list
     (gnus-group-completing-read "Gmane group: ")
     (read-number "Start article number: ")
-    (read-number "End article number: ")))
-  (when (< (- end start) 0)
-    (error "Invalid range."))
-  (when (> (- end start)
-	   (min (or gnus-large-ephemeral-newsgroup 100) 100))
-    (unless (y-or-n-p
-	     (format "Large range (%s to %s), continue anyway? "
-		     start end))
-      (error "Range too large.  Aborted.")))
-  (let ((tmpfile (make-temp-file "gmane.gnus-temp-group-")))
+    (read-number "How many articles: ")))
+  (unless range (setq range 500))
+  (when (< range 1)
+    (error "Invalid range: %s" range))
+  (let ((tmpfile (make-temp-file
+		  (format "%s.start-%s.range-%s." group start range)))
+	(gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
     (with-temp-file tmpfile
       (url-insert-file-contents
        (format gnus-group-gmane-group-download-format
-	       group start end))
+	       group start (+ start range)))
       (write-region (point-min) (point-max) tmpfile)
       (gnus-group-read-ephemeral-group
-       "rs-gnus-read-gmane"
+       (format "%s.start-%s.range-%s" group start range)
        `(nndoc ,tmpfile
 	       (nndoc-article-type guess))))
     (delete-file tmpfile)))
 
+(defun gnus-group-read-ephemeral-gmane-group-url (url)
+  "Create an ephemeral Gmane group from URL.
+
+Valid input formats include:
+\"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
+\"http://thread.gmane.org/gmane.foo.bar/12345/\",
+\"http://article.gmane.org/gmane.foo.bar/12345/\",
+\"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
+  ;; - Feel free to add other useful Gmane URLs here!  Maybe the URLs should
+  ;;   be customizable?
+  ;; - The URLs should be added to `gnus-button-alist'.  Probably we should
+  ;;   prompt the user to decide: "View via `browse-url' or in Gnus? "
+  ;;   (`gnus-group-read-ephemeral-gmane-group-url')
+  (interactive
+   (list (gnus-group-completing-read "Gmane URL: ")))
+  (let (group start range)
+    (cond
+     ;; URLs providing `group', `start' and `range':
+     ((string-match
+       ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
+       "^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
+       url)
+      (setq group (match-string 1 url)
+	    start (string-to-number (match-string 2 url))
+	    ;; Ensure that `range' is large enough to ensure focus article is
+	    ;; included.
+	    range (- (string-to-number (match-string 3 url))
+		     start -1)))
+     ;; URLs providing `group' and `start':
+     ((or (string-match
+	   ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
+	   "^http://\\(?:thread\\|article\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
+	   url)
+	  (string-match
+	   ;; Don't advertize these in the doc string yet:
+	   "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
+	   url)
+	  (string-match
+	   ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
+	   "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
+	   url))
+      (setq group (match-string 1 url)
+	    start (string-to-number (match-string 2 url))))
+     (t
+      (error "Can't parse URL %s" url)))
+    (gnus-group-read-ephemeral-gmane-group group start range)))
+
 (defun gnus-group-jump-to-group (group &optional prompt)
   "Jump to newsgroup GROUP.
 
--- a/lisp/gnus/gnus-registry.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/gnus-registry.el	Wed Jan 30 07:57:28 2008 +0000
@@ -78,6 +78,17 @@
 			      :test 'equal)
   "*The article registry by Message ID.")
 
+(defcustom gnus-registry-marks
+  '(Important Work Personal To-Do Later)
+  "List of marks that `gnus-registry-mark-article' will offer for completion."
+  :group 'gnus-registry
+  :type '(repeat symbol))
+
+(defcustom gnus-registry-default-mark 'To-Do
+  "The default mark."
+  :group 'gnus-registry
+  :type 'symbol)
+
 (defcustom gnus-registry-unfollowed-groups '("delayed$" "drafts$" "queue$" "INBOX$")
   "List of groups that gnus-registry-split-fancy-with-parent won't return.
 The group names are matched, they don't have to be fully
@@ -129,6 +140,16 @@
   :group 'gnus-registry
   :type 'boolean)
 
+(defcustom gnus-registry-extra-entries-precious '(marks)
+  "What extra entries are precious, meaning they won't get trimmed.
+When you save the Gnus registry, it's trimmed to be no longer
+than `gnus-registry-max-entries' (which is nil by default, so no
+trimming happens).  Any entries with extra data in this list (by
+default, marks are included, so articles with marks are
+considered precious) will not be trimmed."
+  :group 'gnus-registry
+  :type '(repeat symbol))
+
 (defcustom gnus-registry-cache-file 
   (nnheader-concat 
    (or gnus-dribble-directory gnus-home-directory "~/") 
@@ -313,30 +334,50 @@
 
 (defun gnus-registry-trim (alist)
   "Trim alist to size, using gnus-registry-max-entries.
-Also, drop all gnus-registry-ignored-groups matches."
-  (if (null gnus-registry-max-entries)
+Also, drop all gnus-registry-ignored-groups matches.
+Any entries with extra data (marks, currently) are left alone."
+  (if (null gnus-registry-max-entries)      
       alist                             ; just return the alist
     ;; else, when given max-entries, trim the alist
     (let* ((timehash (make-hash-table
-		      :size 4096
+		      :size 20000
+		      :test 'equal))
+	   (precious (make-hash-table
+		      :size 20000
 		      :test 'equal))
 	   (trim-length (- (length alist) gnus-registry-max-entries))
-	   (trim-length (if (natnump trim-length) trim-length 0)))
+	   (trim-length (if (natnump trim-length) trim-length 0))
+	   precious-list junk-list)
       (maphash
        (lambda (key value)
-         (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
+	 (let ((extra (gnus-registry-fetch-extra key)))
+	   (dolist (item gnus-registry-extra-entries-precious)
+	     (dolist (e extra)
+	       (when (equal (nth 0 e) item)
+		 (puthash key t precious)
+		 (return))))
+	   (puthash key (gnus-registry-fetch-extra key 'mtime) timehash)))
        gnus-registry-hashtb)
-      
+
+      (dolist (item alist)
+	(let ((key (nth 0 item)))	      
+	  (if (gethash key precious)
+	      (push item precious-list)
+	    (push item junk-list))))
+
+      (sort 
+       junk-list
+       (lambda (a b)
+	 (let ((t1 (or (cdr (gethash (car a) timehash)) 
+		       '(0 0 0)))
+	       (t2 (or (cdr (gethash (car b) timehash)) 
+		       '(0 0 0))))
+	   (time-less-p t1 t2))))
+
       ;; we use the return value of this setq, which is the trimmed alist
-      (setq alist
-	    (nthcdr
-	     trim-length
-	     (sort alist
-		   (lambda (a b)
-		     (time-less-p
-		      (or (cdr (gethash (car a) timehash)) '(0 0 0))
-		      (or (cdr (gethash (car b) timehash)) '(0 0 0))))))))))
-
+      (setq alist (append precious-list
+			  (nthcdr trim-length junk-list))))))
+  
 (defun gnus-registry-action (action data-header from &optional to method)
   (let* ((id (mail-header-id data-header))
 	 (subject (gnus-string-remove-all-properties
@@ -577,6 +618,7 @@
 			  (assoc article (gnus-data-list nil)))))
     nil))
 
+;;; this should be redone with catch/throw
 (defun gnus-registry-grep-in-list (word list)
   (when word
     (memq nil
@@ -586,80 +628,91 @@
 		     (string-match word x))
 		   list)))))
 
-(defun gnus-registry-mark-article (article &optional mark remove)
-  "Mark ARTICLE with MARK in the Gnus registry or remove MARK.
-MARK can be any symbol.  If ARTICLE is nil, then the
-`gnus-current-article' will be marked.  If MARK is nil,
-`gnus-registry-flag-default' will be used."
-  (interactive "nArticle number: ")
-  (let ((article (or article gnus-current-article))
-	(mark (or mark 'gnus-registry-flag-default))
-	article-id)
-    (unless article
-      (error "No article on current line"))
-    (setq article-id 
-	  (gnus-registry-fetch-message-id-fast gnus-current-article))
-    (unless article-id
-      (error "No article ID could be retrieved"))
-    (let* (
-	   ;; all the marks for this article
-	   (marks (gnus-registry-fetch-extra-flags article-id))
-	   ;; the marks without the mark of interest
-	   (cleaned-marks (delq mark marks))
-	   ;; the new marks we want to use
-	   (new-marks (if remove
-			  cleaned-marks
-			(cons mark cleaned-marks))))
-    (apply 'gnus-registry-store-extra-flags ; set the extra flags
-     article-id				    ; for the message ID
-     new-marks)
-    (gnus-registry-fetch-extra-flags article-id))))
+
+(defun gnus-registry-read-mark ()
+  "Read a mark name from the user with completion."
+  (let ((mark (gnus-completing-read-with-default 
+	       (symbol-name gnus-registry-default-mark)
+	       "Label" 
+	       (mapcar (lambda (x)	; completion list
+			 (cons (symbol-name x) x))
+		       gnus-registry-marks))))
+    (when (stringp mark)
+      (intern mark))))
+
+(defun gnus-registry-set-article-mark (&rest articles)
+  "Apply a mark to process-marked ARTICLES."
+  (interactive (gnus-summary-work-articles current-prefix-arg))
+  (gnus-registry-set-article-mark-internal (gnus-registry-read-mark) articles nil t))
+
+(defun gnus-registry-remove-article-mark (&rest articles)
+  "Remove a mark from process-marked ARTICLES."
+  (interactive (gnus-summary-work-articles current-prefix-arg))
+  (gnus-registry-set-article-mark-internal (gnus-registry-read-mark) articles t t))
 
-(defun gnus-registry-article-marks (article)
-  "Get the Gnus registry marks for ARTICLE.
-If ARTICLE is nil, then the `gnus-current-article' will be
-used."
-  (interactive "nArticle number: ")
-  (let ((article (or article gnus-current-article))
-	article-id)
-    (unless article
-      (error "No article on current line"))
-    (setq article-id 
-	  (gnus-registry-fetch-message-id-fast gnus-current-article))
-    (unless article-id
-      (error "No article ID could be retrieved"))
-    (gnus-message 1 
-		  "Message ID %s, Registry flags: %s" 
-		  article-id 
-		  (concat (gnus-registry-fetch-extra-flags article-id)))))
-    
+(defun gnus-registry-set-article-mark-internal (mark articles &optional remove show-message)
+  "Apply a mark to a list of ARTICLES."
+  (let ((article-id-list
+	 (mapcar 'gnus-registry-fetch-message-id-fast articles)))
+    (dolist (id article-id-list)
+      (let* (
+	     ;; all the marks for this article without the mark of
+	     ;; interest
+	     (marks
+	      (delq mark (gnus-registry-fetch-extra-marks id)))
+	     ;; the new marks we want to use
+	     (new-marks (if remove
+			    marks
+			  (cons mark marks))))
+	(when show-message
+	  (gnus-message 1 "%s mark %s with message ID %s, resulting in %S"
+			(if remove "Removing" "Adding")
+			mark id new-marks))
+	
+	(apply 'gnus-registry-store-extra-marks ; set the extra marks
+	       id				; for the message ID
+	       new-marks)))))
 
-;;; if this extends to more than 'flags, it should be improved to be more generic.
-(defun gnus-registry-fetch-extra-flags (id)
-  "Get the flags of a message, based on the message ID.
-Returns a list of symbol flags or nil."
-  (car-safe (cdr (gnus-registry-fetch-extra id 'flags))))
+(defun gnus-registry-get-article-marks (&rest articles)
+  "Get the Gnus registry marks for ARTICLES and show them if interactive.
+Uses process/prefix conventions.  For multiple articles,
+only the last one's marks are returned."
+  (interactive (gnus-summary-work-articles 1))
+  (let (marks)
+    (dolist (article articles)
+      (let ((article-id
+	     (gnus-registry-fetch-message-id-fast article)))
+	(setq marks (gnus-registry-fetch-extra-marks article-id))))
+    (when (interactive-p)
+	(gnus-message 1 "Marks are %S" marks))
+    marks))
 
-(defun gnus-registry-has-extra-flag (id flag)
-  "Checks if a message has `flag', based on the message ID."
-  (memq flag (gnus-registry-fetch-extra-flags id)))
+;;; if this extends to more than 'marks, it should be improved to be more generic.
+(defun gnus-registry-fetch-extra-marks (id)
+  "Get the marks of a message, based on the message ID.
+Returns a list of symbol marks or nil."
+  (car-safe (cdr (gnus-registry-fetch-extra id 'marks))))
 
-(defun gnus-registry-store-extra-flags (id &rest flag-list)
-  "Set the flags of a message, based on the message ID.
-The `flag-list' can be nil, in which case no flags are left."
-  (gnus-registry-store-extra-entry id 'flags (list flag-list)))
+(defun gnus-registry-has-extra-mark (id mark)
+  "Checks if a message has `mark', based on the message ID `id'."
+  (memq mark (gnus-registry-fetch-extra-marks id)))
+
+(defun gnus-registry-store-extra-marks (id &rest mark-list)
+  "Set the marks of a message, based on the message ID.
+The `mark-list' can be nil, in which case no marks are left."
+  (gnus-registry-store-extra-entry id 'marks (list mark-list)))
 
-(defun gnus-registry-delete-extra-flags (id &rest flag-delete-list)
-  "Delete the message flags in `flag-delete-list', based on the message ID."
-  (let ((flags (gnus-registry-fetch-extra-flags id)))
-    (when flags
-      (dolist (flag flag-delete-list)
-	(setq flags (delq flag flags))))
-    (gnus-registry-store-extra-flags id (car flags))))
+(defun gnus-registry-delete-extra-marks (id &rest mark-delete-list)
+  "Delete the message marks in `mark-delete-list', based on the message ID."
+  (let ((marks (gnus-registry-fetch-extra-marks id)))
+    (when marks
+      (dolist (mark mark-delete-list)
+	(setq marks (delq mark marks))))
+    (gnus-registry-store-extra-marks id (car marks))))
 
-(defun gnus-registry-delete-all-extra-flags (id)
-  "Delete all the flags for a message ID."
-  (gnus-registry-store-extra-flags id nil))
+(defun gnus-registry-delete-all-extra-marks (id)
+  "Delete all the marks for a message ID."
+  (gnus-registry-store-extra-marks id nil))
 
 (defun gnus-registry-fetch-extra (id &optional entry)
   "Get the extra data of a message, based on the message ID.
--- a/lisp/gnus/gnus-sum.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/gnus-sum.el	Wed Jan 30 07:57:28 2008 +0000
@@ -4797,11 +4797,11 @@
    (gnus-thread-header h1) (gnus-thread-header h2)))
 
 (defsubst gnus-article-sort-by-random (h1 h2)
-  "Sort articles by article number."
+  "Sort articles randomly."
   (zerop (random 2)))
 
 (defun gnus-thread-sort-by-random (h1 h2)
-  "Sort threads by root article number."
+  "Sort threads randomly."
   (gnus-article-sort-by-random
    (gnus-thread-header h1) (gnus-thread-header h2)))
 
--- a/lisp/gnus/mail-source.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/mail-source.el	Wed Jan 30 07:57:28 2008 +0000
@@ -74,6 +74,8 @@
 	  (repeat :tag "List"
 	   (choice :format "%[Value Menu%] %v"
 		   :value (file)
+		   (cons :tag "Group parameter `mail-source'"
+			 (const :format "" group))
 		   (cons :tag "Spool file"
 			 (const :format "" file)
 			 (checklist :tag "Options" :greedy t
--- a/lisp/gnus/message.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/message.el	Wed Jan 30 07:57:28 2008 +0000
@@ -5952,7 +5952,7 @@
 between beginning of field and beginning of line."
   (interactive "p")
   (let ((zrs 'zmacs-region-stays))
-    (when (and (interactive-p) (boundp zrs))
+    (when (and (featurep 'xemacs) (interactive-p) (boundp zrs))
       (set zrs t)))
   (if (and message-beginning-of-line
 	   (message-point-in-header-p))
--- a/lisp/gnus/mm-decode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/mm-decode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -570,7 +570,10 @@
 	  ;; creates unibyte buffers. This `if', though not a perfect
 	  ;; solution, avoids most of them.
 	  (if from
-	      (setq from (cadr (mail-extract-address-components from))))))
+	      (setq from (cadr (mail-extract-address-components from))))
+	  (if description
+	      (setq description (mail-decode-encoded-word-string
+				 description)))))
       (if (or (not ctl)
 	      (not (string-match "/" (car ctl))))
 	  (mm-dissect-singlepart
--- a/lisp/gnus/mml.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/mml.el	Wed Jan 30 07:57:28 2008 +0000
@@ -874,14 +874,19 @@
 
 (defun mml-to-mime ()
   "Translate the current buffer from MML to MIME."
-  (message-encode-message-body)
+  ;; `message-encode-message-body' will insert an encoded Content-Description
+  ;; header in the message header if the body contains a single part
+  ;; that is specified by a user with a MML tag containing a description
+  ;; token.  So, we encode the message header first to prevent the encoded
+  ;; Content-Description header from being encoded again.
   (save-restriction
     (message-narrow-to-headers-or-head)
     ;; Skip past any From_ headers.
     (while (looking-at "From ")
       (forward-line 1))
     (let ((mail-parse-charset message-default-charset))
-      (mail-encode-encoded-word-buffer))))
+      (mail-encode-encoded-word-buffer)))
+  (message-encode-message-body))
 
 (defun mml-insert-mime (handle &optional no-markup)
   (let (textp buffer mmlp)
--- a/lisp/gnus/nnmail.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/nnmail.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1766,11 +1766,15 @@
       (symbol-value sym))))
 
 (defun nnmail-get-new-mail (method exit-func temp
-				   &optional group spool-func)
+			    &optional group spool-func)
   "Read new incoming mail."
+  (nnmail-get-new-mail-1 method exit-func temp group nil spool-func))
+
+(defun nnmail-get-new-mail-1 (method exit-func temp
+			      group in-group spool-func)
+
   (let* ((sources mail-sources)
 	 fetching-sources
-	 (group-in group)
 	 (i 0)
 	 (new 0)
 	 (total 0)
@@ -1778,6 +1782,18 @@
     (when (and (nnmail-get-value "%s-get-new-mail" method)
 	       sources)
       (while (setq source (pop sources))
+
+	;; Use group's parameter
+	(when (eq (car source) 'group)
+	  (let ((mail-sources
+		 (list
+		  (gnus-group-find-parameter
+		   (concat (symbol-name method) ":" group)
+		   'mail-source t))))
+	    (nnmail-get-new-mail-1 method exit-func temp
+				   group group spool-func))
+	  (setq source nil))
+	  
 	;; Hack to only fetch the contents of a single group's spool file.
 	(when (and (eq (car source) 'directory)
 		   (null nnmail-scan-directory-mail-source-once)
@@ -1816,9 +1832,10 @@
 			 (nnmail-split-incoming
 			  file ',(intern (format "%s-save-mail" method))
 			  ',spool-func
-			  (if (equal file orig-file)
-			      nil
-			    (nnmail-get-split-group orig-file ',source))
+			  (or in-group
+			      (if (equal file orig-file)
+				  nil
+				(nnmail-get-split-group orig-file ',source)))
 			  ',(intern (format "%s-active-number" method)))))))
 	  (incf total new)
 	  (incf i)))
--- a/lisp/gnus/sieve.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/sieve.el	Wed Jan 30 07:57:28 2008 +0000
@@ -290,15 +290,15 @@
   (get-char-property (or pos (point)) 'script-name))
 
 (eval-and-compile
-  (defalias 'sieve-make-overlay (if (fboundp 'make-overlay)
-				    'make-overlay
-				  'make-extent))
-  (defalias 'sieve-overlay-put (if (fboundp 'overlay-put)
-				   'overlay-put
-				 'set-extent-property))
-  (defalias 'sieve-overlays-at (if (fboundp 'overlays-at)
-				   'overlays-at
-				 'extents-at)))
+  (defalias 'sieve-make-overlay (if (featurep 'xemacs)
+				    'make-extent
+				  'make-overlay))
+  (defalias 'sieve-overlay-put (if (featurep 'xemacs)
+				   'set-extent-property
+				 'overlay-put))
+  (defalias 'sieve-overlays-at (if  (featurep 'xemacs)
+				   'extents-at
+				 'overlays-at)))
 
 (defun sieve-highlight (on)
   "Turn ON or off highlighting on the current language overlay."
--- a/lisp/gnus/spam-wash.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/gnus/spam-wash.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; spam-wash.el --- wash spam before analysis
 
-;; Copyright (C) 2004, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Andrew Cohen <cohen@andy.bu.edu>
 ;; Keywords: mail
--- a/lisp/help.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/help.el	Wed Jan 30 07:57:28 2008 +0000
@@ -860,7 +860,7 @@
 	(let ((mode mode-name))
 	  (with-current-buffer standard-output
             (let ((start (point)))
-              (insert (format-mode-line mode))
+              (insert (format-mode-line mode nil nil buffer))
               (add-text-properties start (point) '(face bold)))))
 	(princ " mode:\n")
 	(princ (documentation major-mode))))))
--- a/lisp/ibuf-ext.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ibuf-ext.el	Wed Jan 30 07:57:28 2008 +0000
@@ -228,7 +228,7 @@
       (ignore-errors
 	(with-current-buffer buf
 	  (when (and ibuffer-auto-mode
-		     (eq major-mode 'ibuffer-mode))
+		     (derived-mode-p 'ibuffer-mode))
 	    (ibuffer-update nil t)))))))
 
 ;;;###autoload
@@ -236,15 +236,14 @@
   "Toggle use of Ibuffer's auto-update facility.
 With numeric ARG, enable auto-update if and only if ARG is positive."
   (interactive)
-  (unless (eq major-mode 'ibuffer-mode)
+  (unless (derived-mode-p 'ibuffer-mode)
     (error "This buffer is not in Ibuffer mode"))
   (set (make-local-variable 'ibuffer-auto-mode)
        (if arg
 	   (plusp arg)
 	 (not ibuffer-auto-mode)))
   (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) ; Initialize state vector
-  (add-hook 'post-command-hook 'ibuffer-auto-update-changed)
-  (ibuffer-update-mode-name))
+  (add-hook 'post-command-hook 'ibuffer-auto-update-changed))
 
 ;;;###autoload
 (defun ibuffer-mouse-filter-by-mode (event)
@@ -731,8 +730,7 @@
   (ibuffer-aif (assoc name ibuffer-saved-filter-groups)
       (setcdr it groups)
     (push (cons name groups) ibuffer-saved-filter-groups))
-  (ibuffer-maybe-save-stuff)
-  (ibuffer-update-mode-name))
+  (ibuffer-maybe-save-stuff))
 
 ;;;###autoload
 (defun ibuffer-delete-saved-filter-groups (name)
@@ -897,8 +895,7 @@
   (ibuffer-aif (assoc name ibuffer-saved-filters)
       (setcdr it filters)
     (push (list name filters) ibuffer-saved-filters))
-  (ibuffer-maybe-save-stuff)
-  (ibuffer-update-mode-name))
+  (ibuffer-maybe-save-stuff))
 
 ;;;###autoload
 (defun ibuffer-delete-saved-filters (name)
@@ -1158,6 +1155,20 @@
      (with-current-buffer (car b)
        (buffer-size))))
 
+;;;###autoload (autoload 'ibuffer-do-sort-by-filename/process "ibuf-ext")
+(define-ibuffer-sorter filename/process
+ "Sort the buffers by their file name/process name."
+  (:description "file name")
+  (string-lessp
+   ;; FIXME: For now just compare the file name and the process name
+   ;; (if it exists).  Is there a better way to do this?
+   (or (buffer-file-name (car a)) 
+       (let ((pr-a (get-buffer-process (car a))))
+	 (and (processp pr-a) (process-name pr-a))))
+   (or (buffer-file-name (car b)) 
+       (let ((pr-b (get-buffer-process (car b))))
+	 (and (processp pr-b) (process-name pr-b))))))
+
 ;;; Functions to emulate bs.el
 
 ;;;###autoload
@@ -1386,7 +1397,7 @@
   (ibuffer-mark-on-buffer
    #'(lambda (buf)
        (with-current-buffer buf
-	 (string-match regexp (format-mode-line mode-name))))))
+	 (string-match regexp (format-mode-line mode-name nil nil buf))))))
 
 ;;;###autoload
 (defun ibuffer-mark-by-file-name-regexp (regexp)
@@ -1539,5 +1550,5 @@
 
 (provide 'ibuf-ext)
 
-;;; arch-tag: 9af21953-deda-4c30-b76d-f81d9128e76d
+;; arch-tag: 9af21953-deda-4c30-b76d-f81d9128e76d
 ;;; ibuf-ext.el ends here
--- a/lisp/ibuffer.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ibuffer.el	Wed Jan 30 07:57:28 2008 +0000
@@ -209,6 +209,7 @@
   :type '(choice (const :tag "Last view time" :value recency)
 		 (const :tag "Lexicographic" :value alphabetic)
 		 (const :tag "Buffer size" :value size)
+		 (const :tag "File name" :value filename/process)
 		 (const :tag "Major mode" :value major-mode))
   :group 'ibuffer)
 (defvar ibuffer-sorting-mode nil)
@@ -447,6 +448,7 @@
     (define-key map (kbd "s a") 'ibuffer-do-sort-by-alphabetic)
     (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency)
     (define-key map (kbd "s s") 'ibuffer-do-sort-by-size)
+    (define-key map (kbd "s f") 'ibuffer-do-sort-by-filename/process)
     (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode)
 
     (define-key map (kbd "/ m") 'ibuffer-filter-by-mode)
@@ -828,6 +830,11 @@
     (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu)
     map))
 
+(defvar ibuffer-filename/process-header-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(mouse-1)] 'ibuffer-do-sort-by-filename/process)
+    map))
+
 (defvar ibuffer-mode-name-map
   (let ((map (make-sparse-keymap)))
     (define-key map [(mouse-2)] 'ibuffer-mouse-filter-by-mode)
@@ -1722,7 +1729,7 @@
    ('mouse-face 'highlight
 		'keymap ibuffer-mode-name-map
 		'help-echo "mouse-2: filter by this mode"))
-  (format-mode-line mode-name))
+  (format-mode-line mode-name nil nil (current-buffer)))
 
 (define-ibuffer-column process
   (:summarizer
@@ -1753,6 +1760,7 @@
 
 (define-ibuffer-column filename-and-process
   (:name "Filename/Process"
+   :header-mouse-map ibuffer-filename/process-header-map
    :summarizer
    (lambda (strings)
      (setq strings (delete "" strings))
@@ -2097,29 +2105,6 @@
 	   (point))
 	 `(ibuffer-summary t)))))
 
-(defun ibuffer-update-mode-name ()
-  (setq mode-name (format "Ibuffer by %s" (if ibuffer-sorting-mode
-					      ibuffer-sorting-mode
-					    "view time")))
-  (when ibuffer-sorting-reversep
-    (setq mode-name (concat mode-name " [rev]")))
-  (when (and (featurep 'ibuf-ext)
-	     ibuffer-auto-mode)
-    (setq mode-name (concat mode-name " (Auto)")))
-  (let ((result ""))
-    (when (featurep 'ibuf-ext)
-      (dolist (qualifier ibuffer-filtering-qualifiers)
-	(setq result
-	      (concat result (ibuffer-format-qualifier qualifier))))
-      (if ibuffer-use-header-line
-	  (setq header-line-format
-		(when ibuffer-filtering-qualifiers
-		  (replace-regexp-in-string "%" "%%"
-					    (concat mode-name result))))
-	(progn
-	  (setq mode-name (concat mode-name result))
-	  (when (boundp 'header-line-format)
-	    (setq header-line-format nil)))))))
 
 (defun ibuffer-redisplay (&optional silent)
   "Redisplay the current list of buffers.
@@ -2137,7 +2122,6 @@
 	  (message "No buffers! (note: filtering in effect)")
 	(error "No buffers!")))
     (ibuffer-redisplay-engine blist t)
-    (ibuffer-update-mode-name)
     (unless silent
       (message "Redisplaying current buffer list...done"))
     (ibuffer-forward-line 0)))
@@ -2174,7 +2158,6 @@
     (unless silent
       (message "Updating buffer list..."))
     (ibuffer-redisplay-engine blist arg)
-    (ibuffer-update-mode-name)
     (unless silent
       (message "Updating buffer list...done")))
   (if (eq ibuffer-shrink-to-minimum-size 'onewindow)
@@ -2458,6 +2441,7 @@
   '\\[ibuffer-toggle-sorting-mode]' - Rotate between the various sorting modes.
   '\\[ibuffer-invert-sorting]' - Reverse the current sorting order.
   '\\[ibuffer-do-sort-by-alphabetic]' - Sort the buffers lexicographically.
+  '\\[ibuffer-do-sort-by-filename/process]' - Sort the buffers by the file name.
   '\\[ibuffer-do-sort-by-recency]' - Sort the buffers by last viewing time.
   '\\[ibuffer-do-sort-by-size]' - Sort the buffers by size.
   '\\[ibuffer-do-sort-by-major-mode]' - Sort the buffers by major mode.
@@ -2540,6 +2524,28 @@
   (use-local-map ibuffer-mode-map)
   (setq major-mode 'ibuffer-mode)
   (setq mode-name "Ibuffer")
+  ;; Include state info next to the mode name.
+  (set (make-local-variable 'mode-line-process)
+        '(" by "
+          (ibuffer-sorting-mode (:eval (symbol-name ibuffer-sorting-mode))
+                                "view time")
+          (ibuffer-sorting-reversep " [rev]")
+          (ibuffer-auto-mode " (Auto)")
+          ;; Only list the filters if they're not already in the header-line.
+          (header-line-format
+           ""
+           (:eval (if (functionp 'ibuffer-format-qualifier)
+                      (mapconcat 'ibuffer-format-qualifier
+                                 ibuffer-filtering-qualifiers ""))))))
+  (setq header-line-format
+        (if ibuffer-use-header-line
+            ;; Display the part that won't be in the mode-line.
+            (list* "" mode-name
+                   (mapcar (lambda (elem)
+                             (if (eq (car-safe elem) 'header-line-format)
+                                 (nth 2 elem) elem))
+                           mode-line-process))))
+
   (setq buffer-read-only t)
   (buffer-disable-undo)
   (setq truncate-lines ibuffer-truncate-lines)
@@ -2578,9 +2584,7 @@
   (when ibuffer-default-directory
     (setq default-directory ibuffer-default-directory))
   (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
-  (run-mode-hooks 'ibuffer-mode-hook)
-  ;; called after mode hooks to allow the user to add filters
-  (ibuffer-update-mode-name))
+  (run-mode-hooks 'ibuffer-mode-hook))
 
 (provide 'ibuffer)
 
@@ -2590,5 +2594,5 @@
 ;; coding: iso-8859-1
 ;; End:
 
-;;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8
+;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8
 ;;; ibuffer.el ends here
--- a/lisp/icomplete.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/icomplete.el	Wed Jan 30 07:57:28 2008 +0000
@@ -147,8 +147,7 @@
     (save-excursion
       (let* ((sym (intern func-name))
 	     (buf (other-buffer nil t))
-	     (map (save-excursion (set-buffer buf) (current-local-map)))
-	     (keys (where-is-internal sym map)))
+	     (keys (with-current-buffer buf (where-is-internal sym))))
 	(if keys
 	    (concat "<"
 		    (mapconcat 'key-description
--- a/lisp/image-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/image-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -50,22 +50,49 @@
 
 ;;; Image scrolling functions
 
+(defvar image-mode-current-vscroll nil
+  "An alist with elements (WINDOW . VSCROLL).")
+
+(defvar image-mode-current-hscroll nil
+  "An alist with elements (WINDOW . HSCROLL).")
+
+(defun image-set-window-vscroll (window vscroll &optional pixels-p)
+  (setq image-mode-current-vscroll
+	(append (list (cons window vscroll))
+		(delete (assoc window image-mode-current-vscroll)
+			image-mode-current-vscroll)))
+  (set-window-vscroll window vscroll pixels-p))
+
+(defun image-set-window-hscroll (window ncol)
+  (setq image-mode-current-hscroll
+	(append (list (cons window ncol))
+		(delete (assoc window image-mode-current-hscroll)
+			image-mode-current-hscroll)))
+  (set-window-hscroll window ncol))
+
+(defun image-reset-current-vhscroll ()
+  (let ((win (selected-window)))
+    (when (assoc win image-mode-current-hscroll)
+      (set-window-hscroll win (cdr (assoc win image-mode-current-hscroll))))
+    (when (assoc win image-mode-current-vscroll)
+      (set-window-vscroll win (cdr (assoc win image-mode-current-vscroll))))))
+
 (defun image-forward-hscroll (&optional n)
   "Scroll image in current window to the left by N character widths.
 Stop if the right edge of the image is reached."
   (interactive "p")
   (cond ((= n 0) nil)
 	((< n 0)
-	 (set-window-hscroll (selected-window)
-			     (max 0 (+ (window-hscroll) n))))
+	 (image-set-window-hscroll (selected-window)
+				   (max 0 (+ (window-hscroll) n))))
 	(t
 	 (let* ((image (get-char-property (point-min) 'display))
 		(edges (window-inside-edges))
 		(win-width (- (nth 2 edges) (nth 0 edges)))
 		(img-width (ceiling (car (image-size image)))))
-	   (set-window-hscroll (selected-window)
-			       (min (max 0 (- img-width win-width))
-				    (+ n (window-hscroll))))))))
+	   (image-set-window-hscroll (selected-window)
+				     (min (max 0 (- img-width win-width))
+					  (+ n (window-hscroll))))))))
 
 (defun image-backward-hscroll (&optional n)
   "Scroll image in current window to the right by N character widths.
@@ -79,16 +106,16 @@
   (interactive "p")
   (cond ((= n 0) nil)
 	((< n 0)
-	 (set-window-vscroll (selected-window)
-			     (max 0 (+ (window-vscroll) n))))
+	 (image-set-window-vscroll (selected-window)
+				   (max 0 (+ (window-vscroll) n))))
 	(t
 	 (let* ((image (get-char-property (point-min) 'display))
 		(edges (window-inside-edges))
 		(win-height (- (nth 3 edges) (nth 1 edges)))
 		(img-height (ceiling (cdr (image-size image)))))
-	   (set-window-vscroll (selected-window)
-			       (min (max 0 (- img-height win-height))
-				    (+ n (window-vscroll))))))))
+	   (image-set-window-vscroll (selected-window)
+				     (min (max 0 (- img-height win-height))
+					  (+ n (window-vscroll))))))))
 
 (defun image-previous-line (&optional n)
   "Scroll image in current window downward by N lines.
@@ -146,7 +173,7 @@
   (and arg
        (/= (setq arg (prefix-numeric-value arg)) 1)
        (image-next-line (- arg 1)))
-  (set-window-hscroll (selected-window) 0))
+  (image-set-window-hscroll (selected-window) 0))
 
 (defun image-eol (arg)
   "Scroll horizontally to the right edge of the image in the current window.
@@ -160,14 +187,14 @@
 	 (edges (window-inside-edges))
 	 (win-width (- (nth 2 edges) (nth 0 edges)))
 	 (img-width (ceiling (car (image-size image)))))
-    (set-window-hscroll (selected-window)
-			(max 0 (- img-width win-width)))))
+    (image-set-window-hscroll (selected-window)
+			      (max 0 (- img-width win-width)))))
 
 (defun image-bob ()
   "Scroll to the top-left corner of the image in the current window."
   (interactive)
-  (set-window-hscroll (selected-window) 0)
-  (set-window-vscroll (selected-window) 0))
+  (image-set-window-hscroll (selected-window) 0)
+  (image-set-window-vscroll (selected-window) 0))
 
 (defun image-eob ()
   "Scroll to the bottom-right corner of the image in the current window."
@@ -178,8 +205,8 @@
 	 (img-width (ceiling (car (image-size image))))
 	 (win-height (- (nth 3 edges) (nth 1 edges)))
 	 (img-height (ceiling (cdr (image-size image)))))
-    (set-window-hscroll (selected-window) (max 0 (- img-width win-width)))
-    (set-window-vscroll (selected-window) (max 0 (- img-height win-height)))))
+    (image-set-window-hscroll (selected-window) (max 0 (- img-width win-width)))
+    (image-set-window-vscroll (selected-window) (max 0 (- img-height win-height)))))
 
 ;;; Image Mode setup
 
@@ -224,6 +251,15 @@
   ;; Use our own bookmarking function for images.
   (set (make-local-variable 'bookmark-make-cell-function)
        'image-bookmark-make-cell)
+
+  ;; Keep track of [vh]scroll when switching buffers
+  (make-local-variable 'image-mode-current-hscroll)
+  (make-local-variable 'image-mode-current-vscroll)
+  (image-set-window-hscroll (selected-window) (window-hscroll))
+  (image-set-window-vscroll (selected-window) (window-vscroll))
+  (add-hook 'window-configuration-change-hook
+	    'image-reset-current-vhscroll nil t)
+
   (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
   (if (and (display-images-p)
 	   (not (get-char-property (point-min) 'display)))
@@ -255,9 +291,9 @@
       (setq image-type "text"))
     (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
     (message "%s" (concat (substitute-command-keys
-		      "Type \\[image-toggle-display] to view the image as ")
-		     (if (get-char-property (point-min) 'display)
-			 "text" "an image") "."))))
+			   "Type \\[image-toggle-display] to view the image as ")
+			  (if (get-char-property (point-min) 'display)
+			      "text" "an image") "."))))
 
 ;;;###autoload
 (defun image-mode-maybe ()
@@ -333,9 +369,9 @@
 	   (image (create-image file-or-data type data-p))
 	   (props
 	    `(display ,image
-	      intangible ,image
-	      rear-nonsticky (display intangible)
-	      read-only t front-sticky (read-only)))
+		      intangible ,image
+		      rear-nonsticky (display intangible)
+		      read-only t front-sticky (read-only)))
 	   (inhibit-read-only t)
 	   (buffer-undo-list t)
 	   (modified (buffer-modified-p)))
--- a/lisp/isearch-multi.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/isearch-multi.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; isearch-multi.el --- isearch extensions for multi-buffer search
 
-;; Copyright (C) 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Juri Linkov <juri@jurta.org>
 ;; Keywords: matching
--- a/lisp/ldefs-boot.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ldefs-boot.el	Wed Jan 30 07:57:28 2008 +0000
@@ -249,7 +249,6 @@
 the change log file in another window.
 
 \(fn &optional WHOAMI FILE-NAME)" t nil)
- (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
 
 (autoload 'change-log-mode "add-log" "\
 Major mode for editing change logs; like Indented Text Mode.
@@ -945,48 +944,48 @@
 ;;; Generated autoloads from calendar/appt.el
 
 (defvar appt-issue-message t "\
-*Non-nil means check for appointments in the diary buffer.
+Non-nil means check for appointments in the diary buffer.
 To be detected, the diary entry must have the format described in the
 documentation of the function `appt-check'.")
 
 (custom-autoload 'appt-issue-message "appt" t)
 
 (defvar appt-message-warning-time 12 "\
-*Time in minutes before an appointment that the warning begins.")
+Time in minutes before an appointment that the warning begins.")
 
 (custom-autoload 'appt-message-warning-time "appt" t)
 
 (defvar appt-audible t "\
-*Non-nil means beep to indicate appointment.")
+Non-nil means beep to indicate appointment.")
 
 (custom-autoload 'appt-audible "appt" t)
 
 (defvar appt-visible t "\
-*Non-nil means display appointment message in echo area.
+Non-nil means display appointment message in echo area.
 This variable is only relevant if `appt-msg-window' is nil.")
 
 (custom-autoload 'appt-visible "appt" t)
 
 (defvar appt-msg-window t "\
-*Non-nil means display appointment message in another window.
+Non-nil means display appointment message in another window.
 If non-nil, this variable overrides `appt-visible'.")
 
 (custom-autoload 'appt-msg-window "appt" t)
 
 (defvar appt-display-mode-line t "\
-*Non-nil means display minutes to appointment and time on the mode line.
+Non-nil means display minutes to appointment and time on the mode line.
 This is in addition to any other display of appointment messages.")
 
 (custom-autoload 'appt-display-mode-line "appt" t)
 
 (defvar appt-display-duration 10 "\
-*The number of seconds an appointment message is displayed.
+The number of seconds an appointment message is displayed.
 Only relevant if reminders are to be displayed in their own window.")
 
 (custom-autoload 'appt-display-duration "appt" t)
 
 (defvar appt-display-diary t "\
-*Non-nil displays the diary when the appointment list is first initialized.
+Non-nil displays the diary when the appointment list is first initialized.
 This will occur at midnight when the appointment list is updated.")
 
 (custom-autoload 'appt-display-diary "appt" t)
@@ -1732,7 +1731,7 @@
 
 Vectors work just like lists.  Nested backquotes are permitted.
 
-\(fn ARG)" nil (quote macro))
+\(fn STRUCTURE)" nil (quote macro))
 
 (defalias '\` (symbol-function 'backquote))
 
@@ -1807,6 +1806,19 @@
 ;;;;;;  875))
 ;;; Generated autoloads from textmodes/bibtex.el
 
+(autoload 'bibtex-initialize "bibtex" "\
+(Re)Initialize BibTeX buffers.
+Visit the BibTeX files defined by `bibtex-files' and return a list
+of corresponding buffers.
+Initialize in these buffers `bibtex-reference-keys' if not yet set.
+List of BibTeX buffers includes current buffer if CURRENT is non-nil.
+If FORCE is non-nil, (re)initialize `bibtex-reference-keys' even if
+already set.  If SELECT is non-nil interactively select a BibTeX buffer.
+When called interactively, FORCE is t, CURRENT is t if current buffer uses
+`bibtex-mode', and SELECT is t if current buffer does not use `bibtex-mode',
+
+\(fn &optional CURRENT FORCE SELECT)" t nil)
+
 (autoload 'bibtex-mode "bibtex" "\
 Major mode for editing BibTeX files.
 
@@ -2828,7 +2840,7 @@
 For example, invoke `emacs -batch -f batch-byte-recompile-directory .'.
 
 Optional argument ARG is passed as second argument ARG to
-`batch-recompile-directory'; see there for its possible values
+`byte-recompile-directory'; see there for its possible values
 and corresponding effects.
 
 \(fn &optional ARG)" nil nil)
@@ -3371,7 +3383,7 @@
 As the files are processed for diary entries, these functions are used
 to cull relevant entries.  You can use either or both of
 `list-hebrew-diary-entries', `list-islamic-diary-entries' and
-`list-bahai-diary-entries'.  The documentation for these functions
+`diary-bahai-list-entries'.  The documentation for these functions
 describes the style of such diary entries.")
 
 (custom-autoload 'nongregorian-diary-listing-hook "calendar" t)
@@ -3825,7 +3837,29 @@
 ;;;### (autoloads nil "cc-subword" "progmodes/cc-subword.el" (18177
 ;;;;;;  872))
 ;;; Generated autoloads from progmodes/cc-subword.el
- (autoload 'c-subword-mode "cc-subword" "Mode enabling subword movement and editing keys." t)
+
+(autoload 'c-subword-mode "cc-subword" "\
+Mode enabling subword movement and editing keys.
+In spite of GNU Coding Standards, it is popular to name a symbol by
+mixing uppercase and lowercase letters, e.g. \"GtkWidget\",
+\"EmacsFrameClass\", \"NSGraphicsContext\", etc.  Here we call these
+mixed case symbols `nomenclatures'. Also, each capitalized (or
+completely uppercase) part of a nomenclature is called a `subword'.
+Here are some examples:
+
+  Nomenclature           Subwords
+  ===========================================================
+  GtkWindow          =>  \"Gtk\" and \"Window\"
+  EmacsFrameClass    =>  \"Emacs\", \"Frame\" and \"Class\"
+  NSGraphicsContext  =>  \"NS\", \"Graphics\" and \"Context\"
+
+The subword oriented commands activated in this minor mode recognize
+subwords in a nomenclature to move between subwords and to edit them
+as words.
+
+\\{c-subword-mode-map}
+
+\(fn &optional ARG)" t nil)
 
 ;;;***
 
@@ -4112,6 +4146,26 @@
 
 ;;;***
 
+;;;### (autoloads (check-declare-directory check-declare-file) "check-declare"
+;;;;;;  "emacs-lisp/check-declare.el" (18308 19808))
+;;; Generated autoloads from emacs-lisp/check-declare.el
+
+(autoload 'check-declare-file "check-declare" "\
+Check veracity of all `declare-function' statements in FILE.
+See `check-declare-directory' for more information.
+
+\(fn FILE)" t nil)
+
+(autoload 'check-declare-directory "check-declare" "\
+Check veracity of all `declare-function' statements under directory ROOT.
+Returns non-nil if any false statements are found.  For this to
+work correctly, the statements must adhere to the format
+described in the documentation of `declare-function'.
+
+\(fn ROOT)" t nil)
+
+;;;***
+
 ;;;### (autoloads (checkdoc-minor-mode checkdoc-ispell-defun checkdoc-ispell-comments
 ;;;;;;  checkdoc-ispell-continue checkdoc-ispell-start checkdoc-ispell-message-text
 ;;;;;;  checkdoc-ispell-message-interactive checkdoc-ispell-interactive
@@ -5091,6 +5145,12 @@
 ;;;;;;  "cperl-mode" "progmodes/cperl-mode.el" (18231 31069))
 ;;; Generated autoloads from progmodes/cperl-mode.el
 (put 'cperl-indent-level 'safe-local-variable 'integerp)
+(put 'cperl-brace-offset 'safe-local-variable 'integerp)
+(put 'cperl-continued-brace-offset 'safe-local-variable 'integerp)
+(put 'cperl-label-offset 'safe-local-variable 'integerp)
+(put 'cperl-continued-statement-offset 'safe-local-variable 'integerp)
+(put 'cperl-extra-newline-before-brace 'safe-local-variable 'booleanp)
+(put 'cperl-merge-trailing-else 'safe-local-variable 'booleanp)
 
 (autoload 'cperl-mode "cperl-mode" "\
 Major mode for editing Perl code.
@@ -5628,7 +5688,7 @@
 (autoload 'customize-apropos-options "cus-edit" "\
 Customize all loaded customizable options matching REGEXP.
 With prefix arg, include variables that are not customizable options
-\(but we recommend using `apropos-variable' instead).
+\(but it is better to use `apropos-variable' if you want to find those).
 
 \(fn REGEXP &optional ARG)" t nil)
 
@@ -6230,8 +6290,8 @@
 
 (autoload 'delete-selection-mode "delsel" "\
 Toggle Delete Selection mode.
-With prefix ARG, turn Delete Selection mode on if and only if ARG is
-positive.
+With prefix ARG, turn Delete Selection mode on if ARG is
+positive, off if ARG is not positive.
 
 When Delete Selection mode is enabled, Transient Mark mode is also
 enabled and typed text replaces the selection if the selection is
@@ -6701,7 +6761,7 @@
 
 (custom-autoload 'dired-listing-switches "dired" t)
 
-(defvar dired-chown-program (if (memq system-type '(hpux dgux usg-unix-v irix linux gnu/linux cygwin)) "chown" (if (file-exists-p "/usr/sbin/chown") "/usr/sbin/chown" "/etc/chown")) "\
+(defvar dired-chown-program (if (memq system-type '(hpux usg-unix-v irix linux gnu/linux cygwin)) "chown" (if (file-exists-p "/usr/sbin/chown") "/usr/sbin/chown" "/etc/chown")) "\
 Name of chown command (usually `chown' or `/etc/chown').")
 
 (defvar dired-ls-F-marks-symlinks nil "\
@@ -7564,6 +7624,12 @@
 ;;;;;;  "doc-view.el" (18231 31060))
 ;;; Generated autoloads from doc-view.el
 
+(autoload 'doc-view-mode-p "doc-view" "\
+Return non-nil if image type TYPE is available for `doc-view'.
+Image types are symbols like `dvi', `postscript' or `pdf'.
+
+\(fn TYPE)" nil nil)
+
 (autoload 'doc-view-mode "doc-view" "\
 Major mode in DocView buffers.
 You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
@@ -7796,10 +7862,15 @@
 INCLUDE is an expression; this item is only visible if this
 expression has a non-nil value.  `:included' is an alias for `:visible'.
 
+   :label FORM
+
+FORM is an expression that will be dynamically evaluated and whose
+value will be used for the menu entry's text label (the default is NAME).
+
    :suffix FORM
 
 FORM is an expression that will be dynamically evaluated and whose
-value will be concatenated to the menu entry's NAME.
+value will be concatenated to the menu entry's label.
 
    :style STYLE
 
@@ -9602,12 +9673,7 @@
 
 \(fn COMMAND &optional STATUS-VAR)" nil nil)
 
-(autoload 'eshell-report-bug "eshell" "\
-Report a bug in Eshell.
-Prompts for the TOPIC.  Leaves you in a mail buffer.
-Please include any configuration details that might be involved.
-
-\(fn TOPIC)" t nil)
+(define-obsolete-function-alias 'eshell-report-bug 'report-emacs-bug "23.1")
 
 ;;;***
 
@@ -10773,9 +10839,6 @@
 \(directories) is done.
 
 \(fn ARG)" t nil)
- (define-key minibuffer-local-completion-map [C-tab] 'file-cache-minibuffer-complete)
- (define-key minibuffer-local-map [C-tab] 'file-cache-minibuffer-complete)
- (define-key minibuffer-local-must-match-map [C-tab] 'file-cache-minibuffer-complete)
 
 ;;;***
 
@@ -10825,6 +10888,13 @@
 
 (custom-autoload 'find-grep-options "find-dired" t)
 
+(defvar find-name-arg (if read-file-name-completion-ignore-case "-iname" "-name") "\
+*Argument used to specify file name pattern.
+If `read-file-name-completion-ignore-case' is non-nil, -iname is used so that
+find also ignores case. Otherwise, -name is used.")
+
+(custom-autoload 'find-name-arg "find-dired" t)
+
 (autoload 'find-dired "find-dired" "\
 Run `find' and go into Dired mode on a buffer of the output.
 The command run (after changing into DIR) is
@@ -11551,7 +11621,6 @@
 The directory containing FILE becomes the initial working
 directory and source-file directory for your debugger.
 
-
 If `gdb-many-windows' is nil (the default value) then gdb just
 pops up the GUD buffer unless `gdb-show-main' is t.  In this case
 it starts with two windows: one displaying the GUD buffer and the
@@ -12049,7 +12118,7 @@
 (autoload 'turn-on-gnus-dired-mode "gnus-dired" "\
 Convenience method to turn on gnus-dired-mode.
 
-\(fn)" nil nil)
+\(fn)" t nil)
 
 ;;;***
 
@@ -12622,6 +12691,11 @@
 The default find program for `grep-find-command'.
 This variable's value takes effect when `grep-compute-defaults' is called.")
 
+(defvar xargs-program "xargs" "\
+The default xargs program for `grep-find-command'.
+See `grep-find-use-xargs'.
+This variable's value takes effect when `grep-compute-defaults' is called.")
+
 (defvar grep-find-use-xargs nil "\
 Non-nil means that `grep-find' uses the `xargs' utility by default.
 If `exec', use `find -exec'.
@@ -12653,19 +12727,19 @@
 (autoload 'grep "grep" "\
 Run grep, with user-specified args, and collect output in a buffer.
 While grep runs asynchronously, you can use \\[next-error] (M-x next-error),
-or \\<grep-mode-map>\\[compile-goto-error] in the grep output buffer, to go to the lines
-where grep found matches.
+or \\<grep-mode-map>\\[compile-goto-error] in the grep output buffer, to go to the lines where grep
+found matches.
 
 For doing a recursive `grep', see the `rgrep' command.  For running
 `grep' in a specific directory, see `lgrep'.
 
-This command uses a special history list for its COMMAND-ARGS, so you can
-easily repeat a grep command.
+This command uses a special history list for its COMMAND-ARGS, so you
+can easily repeat a grep command.
 
 A prefix argument says to default the argument based upon the current
 tag the cursor is over, substituting it into the last grep command
-in the grep command history (or into `grep-command'
-if that history list is empty).
+in the grep command history (or into `grep-command' if that history
+list is empty).
 
 \(fn COMMAND-ARGS)" t nil)
 
@@ -12693,8 +12767,8 @@
 With two \\[universal-argument] prefixes, directly edit and run `grep-command'.
 
 Collect output in a buffer.  While grep runs asynchronously, you
-can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error]
-in the grep output buffer, to go to the lines where grep found matches.
+can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] in the grep output buffer,
+to go to the lines where grep found matches.
 
 This command shares argument histories with \\[rgrep] and \\[grep].
 
@@ -12711,8 +12785,8 @@
 With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'.
 
 Collect output in a buffer.  While find runs asynchronously, you
-can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error]
-in the grep output buffer, to go to the lines where grep found matches.
+can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] in the grep output buffer,
+to go to the lines where grep found matches.
 
 This command shares argument histories with \\[lgrep] and \\[grep-find].
 
@@ -13833,6 +13907,8 @@
 
 \(fn Y1 Y2 &optional L LABEL)" t nil)
 
+(defalias 'holiday-list 'list-holidays)
+
 ;;;***
 
 ;;;### (autoloads (html2text) "html2text" "gnus/html2text.el" (18231
@@ -15348,6 +15424,11 @@
 
 \(fn)" t nil)
 
+(autoload 'image-bookmark-jump "image-mode" "\
+Not documented
+
+\(fn BMK)" nil nil)
+
 ;;;***
 
 ;;;### (autoloads (imenu imenu-add-menubar-index imenu-add-to-menubar
@@ -15857,15 +15938,15 @@
 Function to call to get the next buffer to search.
 
 When this variable is set to a function that returns a buffer, then
-after typing another C-s or C-r at a failing search, the search goes
+after typing another \\[isearch-forward] or \\[isearch-backward] at a failing search, the search goes
 to the next buffer in the series and continues searching for the
 next occurrence.
 
 The first argument of this function is the current buffer where the
 search is currently searching.  It defines the base buffer relative to
 which this function should find the next buffer.  When the isearch
-direction is backward (when isearch-forward is nil), this function
-should return the previous buffer to search. If the second argument of
+direction is backward (when `isearch-forward' is nil), this function
+should return the previous buffer to search.  If the second argument of
 this function WRAP is non-nil, then it should return the first buffer
 in the series; and for the backward search, it should return the last
 buffer in the series.")
@@ -16009,14 +16090,14 @@
 
 (autoload 'iso-iso2sgml "iso-cvt" "\
 Translate ISO 8859-1 characters in the region to SGML entities.
-The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
+Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
 Optional arg BUFFER is ignored (for use in `format-alist').
 
 \(fn FROM TO &optional BUFFER)" t nil)
 
 (autoload 'iso-sgml2iso "iso-cvt" "\
 Translate SGML entities in the region to ISO 8859-1 characters.
-The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
+Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
 Optional arg BUFFER is ignored (for use in `format-alist').
 
 \(fn FROM TO &optional BUFFER)" t nil)
@@ -16177,6 +16258,7 @@
 Same format as `ispell-skip-region-alist'
 Note - substrings of other matches must come last
  (e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").")
+(put 'ispell-local-pdict 'safe-local-variable 'stringp)
  (define-key esc-map "$" 'ispell-word)
 
 (autoload 'ispell-word "ispell" "\
@@ -17098,17 +17180,22 @@
 Setup a buffer to enter a log message.
 \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
-Mark and point will be set around the entire contents of the
-buffer so that it is easy to kill the contents of the buffer with \\[kill-region].
+Mark and point will be set around the entire contents of the buffer so
+that it is easy to kill the contents of the buffer with \\[kill-region].
 Once you're done editing the message, pressing \\[log-edit-done] will call
 `log-edit-done' which will end up calling CALLBACK to do the actual commit.
-LISTFUN if non-nil is a function of no arguments returning the list of files
-  that are concerned by the current operation (using relative names).
+
+PARAMS if non-nil is an alist.  Possible keys and associated values:
+ `log-edit-listfun' -- function taking no arguments that returns the list of
+ files that are concerned by the current operation (using relative names);
+ `log-edit-diff-function' -- function taking no arguments that
+ displays a diff of the files concerned by the current operation.
+
 If BUFFER is non-nil `log-edit' will jump to that buffer, use it to edit the
-  log message and go back to the current buffer when done.  Otherwise, it
-  uses the current buffer.
-
-\(fn CALLBACK &optional SETUP LISTFUN BUFFER &rest IGNORE)" nil nil)
+log message and go back to the current buffer when done.  Otherwise, it
+uses the current buffer.
+
+\(fn CALLBACK &optional SETUP PARAMS BUFFER &rest IGNORE)" nil nil)
 
 ;;;***
 
@@ -17151,7 +17238,7 @@
 
 (defvar lpr-windows-system (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt)))
 
-(defvar lpr-lp-system (memq system-type '(usg-unix-v dgux hpux irix)))
+(defvar lpr-lp-system (memq system-type '(usg-unix-v hpux irix)))
 
 (defvar printer-name (and lpr-windows-system "PRN") "\
 *The name of a local printer to which data is sent for printing.
@@ -19388,6 +19475,95 @@
 
 ;;;***
 
+;;;### (autoloads (nxml-glyph-display-string) "nxml-glyph" "nxml/nxml-glyph.el"
+;;;;;;  (18308 19808))
+;;; Generated autoloads from nxml/nxml-glyph.el
+
+(autoload 'nxml-glyph-display-string "nxml-glyph" "\
+Return a string that can display a glyph for Unicode code-point N.
+FACE gives the face that will be used for displaying the string.
+Return nil if the face cannot display a glyph for N.
+
+\(fn N FACE)" nil nil)
+
+;;;***
+
+;;;### (autoloads (nxml-mode) "nxml-mode" "nxml/nxml-mode.el" (18313
+;;;;;;  19474))
+;;; Generated autoloads from nxml/nxml-mode.el
+
+(autoload 'nxml-mode "nxml-mode" "\
+Major mode for editing XML.
+
+Syntax highlighting is performed unless the variable
+`nxml-syntax-highlight-flag' is nil.
+
+\\[nxml-finish-element] finishes the current element by inserting an end-tag.
+C-c C-i closes a start-tag with `>' and then inserts a balancing end-tag
+leaving point between the start-tag and end-tag. 
+\\[nxml-balanced-close-start-tag-block] is similar but for block rather than inline elements:
+the start-tag, point, and end-tag are all left on separate lines.
+If `nxml-slash-auto-complete-flag' is non-nil, then inserting a `</'
+automatically inserts the rest of the end-tag.
+
+\\[nxml-complete] performs completion on the symbol preceding point.
+
+\\[nxml-dynamic-markup-word] uses the contents of the current buffer
+to choose a tag to put around the word preceding point.
+
+Sections of the document can be displayed in outline form.  The
+variable `nxml-section-element-name-regexp' controls when an element
+is recognized as a section.  The same key sequences that change
+visibility in outline mode are used except that they start with C-c C-o
+instead of C-c.
+
+Validation is provided by the related minor-mode `rng-validate-mode'.
+This also makes completion schema- and context- sensitive.  Element
+names, attribute names, attribute values and namespace URIs can all be
+completed. By default, `rng-validate-mode' is automatically enabled. You
+can toggle it using \\[rng-validate-mode] or change the default by
+customizing `rng-nxml-auto-validate-flag'.
+
+\\[indent-for-tab-command] indents the current line appropriately.
+This can be customized using the variable `nxml-child-indent'
+and the variable `nxml-attribute-indent'.
+
+\\[nxml-insert-named-char] inserts a character reference using
+the character's name (by default, the Unicode name). \\[universal-argument] \\[nxml-insert-named-char]
+inserts the character directly.
+
+The Emacs commands that normally operate on balanced expressions will
+operate on XML markup items.  Thus \\[forward-sexp] will move forward
+across one markup item; \\[backward-sexp] will move backward across
+one markup item; \\[kill-sexp] will kill the following markup item;
+\\[mark-sexp] will mark the following markup item.  By default, each
+tag each treated as a single markup item; to make the complete element
+be treated as a single markup item, set the variable
+`nxml-sexp-element-flag' to t.  For more details, see the function
+`nxml-forward-balanced-item'.
+
+\\[nxml-backward-up-element] and \\[nxml-down-element] move up and down the element structure.
+
+Many aspects this mode can be customized using
+\\[customize-group] nxml RET.
+
+\(fn)" t nil)
+
+;;;***
+
+;;;### (autoloads (nxml-enable-unicode-char-name-sets) "nxml-uchnm"
+;;;;;;  "nxml/nxml-uchnm.el" (18312 40673))
+;;; Generated autoloads from nxml/nxml-uchnm.el
+
+(autoload 'nxml-enable-unicode-char-name-sets "nxml-uchnm" "\
+Enable the use of Unicode standard names for characters.
+The Unicode blocks for which names are enabled is controlled by
+the variable `nxml-enabled-unicode-blocks'.
+
+\(fn)" t nil)
+
+;;;***
+
 ;;;### (autoloads (octave-help) "octave-hlp" "progmodes/octave-hlp.el"
 ;;;;;;  (18177 873))
 ;;; Generated autoloads from progmodes/octave-hlp.el
@@ -20286,16 +20462,6 @@
 
 \(fn &optional ARG)" t nil)
 
-(defvar pc-selection-mode nil "\
-Toggle PC Selection mode.
-Change mark behavior to emulate Motif, MAC or MS-Windows cut and paste style,
-and cursor movement commands.
-This mode enables Delete Selection mode and Transient Mark mode.
-Setting this variable directly does not take effect;
-you must modify it using \\[customize] or \\[pc-selection-mode].")
-
-(custom-autoload 'pc-selection-mode "pc-select" nil)
-
 ;;;***
 
 ;;;### (autoloads (pcomplete/cvs) "pcmpl-cvs" "pcmpl-cvs.el" (18177
@@ -20569,6 +20735,11 @@
 ;;;;;;  (18177 873))
 ;;; Generated autoloads from progmodes/perl-mode.el
 (put 'perl-indent-level 'safe-local-variable 'integerp)
+(put 'perl-continued-statement-offset 'safe-local-variable 'integerp)
+(put 'perl-continued-brace-offset 'safe-local-variable 'integerp)
+(put 'perl-brace-offset 'safe-local-variable 'integerp)
+(put 'perl-brace-imaginary-offset 'safe-local-variable 'integerp)
+(put 'perl-label-offset 'safe-local-variable 'integerp)
 
 (autoload 'perl-mode "perl-mode" "\
 Major mode for editing Perl code.
@@ -22736,7 +22907,6 @@
 first comment line visible (if point is in a comment).
 
 \(fn &optional ARG)" t nil)
- (define-key esc-map "\C-l" 'reposition-window)
 
 ;;;***
 
@@ -24812,6 +24982,12 @@
 
 \(fn &optional ARG)" t nil)
 
+(autoload 'smerge-start-session "smerge-mode" "\
+Turn on `smerge-mode' and move point to first conflict marker.
+If no conflict maker is found, turn off `smerge-mode'.
+
+\(fn)" nil nil)
+
 ;;;***
 
 ;;;### (autoloads (smiley-buffer smiley-region) "smiley" "gnus/smiley.el"
@@ -25203,9 +25379,9 @@
 (autoload 'spam-initialize "spam" "\
 Install the spam.el hooks and do other initialization.
 When SYMBOLS is given, set those variables to t.  This is so you
-can call spam-initialize before you set spam-use-* variables on
+can call `spam-initialize' before you set spam-use-* variables on
 explicitly, and matters only if you need the extra headers
-installed through spam-necessary-extra-headers.
+installed through `spam-necessary-extra-headers'.
 
 \(fn &rest SYMBOLS)" t nil)
 
@@ -27624,6 +27800,7 @@
 ;;;;;;  "time-stamp.el" (18177 876))
 ;;; Generated autoloads from time-stamp.el
 (put 'time-stamp-format 'safe-local-variable 'stringp)
+(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p)
 (put 'time-stamp-line-limit 'safe-local-variable 'integerp)
 (put 'time-stamp-start 'safe-local-variable 'stringp)
 (put 'time-stamp-end 'safe-local-variable 'stringp)
@@ -28809,6 +28986,13 @@
 
 \(fn &optional ARG)" t nil)
 
+(autoload 'url-file-handler "url-handlers" "\
+Function called from the `file-name-handler-alist' routines.
+OPERATION is what needs to be done (`file-exists-p', etc).  ARGS are
+the arguments that would have been passed to OPERATION.
+
+\(fn OPERATION &rest ARGS)" nil nil)
+
 (autoload 'url-copy-file "url-handlers" "\
 Copy URL to NEWNAME.  Both args must be strings.
 Signals a `file-already-exists' error if file NEWNAME already exists,
@@ -29364,7 +29548,8 @@
 \(fn VERBOSE)" t nil)
 
 (autoload 'vc-register "vc" "\
-Register the current file into a version control system.
+Register into a version control system.
+If FNAME is given register that file, otherwise register the current file.
 With prefix argument SET-REVISION, allow user to specify initial revision
 level.  If COMMENT is present, use that as an initial comment.
 
@@ -29375,7 +29560,7 @@
 register the file.  If no backend declares itself responsible, the
 first backend that could register the file is used.
 
-\(fn &optional SET-REVISION COMMENT)" t nil)
+\(fn &optional FNAME SET-REVISION COMMENT)" t nil)
 
 (autoload 'vc-version-diff "vc" "\
 Report diffs between revisions of the fileset in the repository history.
@@ -29753,6 +29938,142 @@
 
 ;;;***
 
+;;;### (autoloads (verilog-mode) "verilog-mode" "progmodes/verilog-mode.el"
+;;;;;;  (18307 57872))
+;;; Generated autoloads from progmodes/verilog-mode.el
+
+(autoload 'verilog-mode "verilog-mode" "\
+Major mode for editing Verilog code.
+\\<verilog-mode-map>
+See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how
+AUTOs can improve coding efficiency.
+
+Use \\[verilog-faq] for a pointer to frequently asked questions.
+
+NEWLINE, TAB indents for Verilog code.
+Delete converts tabs to spaces as it moves back.
+
+Supports highlighting.
+
+Turning on Verilog mode calls the value of the variable `verilog-mode-hook'
+with no args, if that value is non-nil.
+
+Variables controlling indentation/edit style:
+
+ variable `verilog-indent-level'      (default 3)
+   Indentation of Verilog statements with respect to containing block.
+ `verilog-indent-level-module'        (default 3)
+   Absolute indentation of Module level Verilog statements.
+   Set to 0 to get initial and always statements lined up
+   on the left side of your screen.
+ `verilog-indent-level-declaration'   (default 3)
+   Indentation of declarations with respect to containing block.
+   Set to 0 to get them list right under containing block.
+ `verilog-indent-level-behavioral'    (default 3)
+   Indentation of first begin in a task or function block
+   Set to 0 to get such code to lined up underneath the task or function keyword
+ `verilog-indent-level-directive'     (default 1)
+   Indentation of `ifdef/`endif blocks
+ `verilog-cexp-indent'              (default 1)
+   Indentation of Verilog statements broken across lines i.e.:
+      if (a)
+        begin
+ `verilog-case-indent'              (default 2)
+   Indentation for case statements.
+ `verilog-auto-newline'             (default nil)
+   Non-nil means automatically newline after semicolons and the punctuation
+   mark after an end.
+ `verilog-auto-indent-on-newline'   (default t)
+   Non-nil means automatically indent line after newline
+ `verilog-tab-always-indent'        (default t)
+   Non-nil means TAB in Verilog mode should always reindent the current line,
+   regardless of where in the line point is when the TAB command is used.
+ `verilog-indent-begin-after-if'    (default t)
+   Non-nil means to indent begin statements following a preceding
+   if, else, while, for and repeat statements, if any.  otherwise,
+   the begin is lined up with the preceding token.  If t, you get:
+      if (a)
+         begin // amount of indent based on `verilog-cexp-indent'
+   otherwise you get:
+      if (a)
+      begin
+ `verilog-auto-endcomments'         (default t)
+   Non-nil means a comment /* ... */ is set after the ends which ends
+   cases, tasks, functions and modules.
+   The type and name of the object will be set between the braces.
+ `verilog-minimum-comment-distance' (default 10)
+   Minimum distance (in lines) between begin and end required before a comment
+   will be inserted.  Setting this variable to zero results in every
+   end acquiring a comment; the default avoids too many redundant
+   comments in tight quarters.
+ `verilog-auto-lineup'              (default `(all))
+   List of contexts where auto lineup of code should be done.
+
+Variables controlling other actions:
+
+ `verilog-linter'                   (default surelint)
+   Unix program to call to run the lint checker.  This is the default
+   command for \\[compile-command] and \\[verilog-auto-save-compile].
+
+See \\[customize] for the complete list of variables.
+
+AUTO expansion functions are, in part:
+
+    \\[verilog-auto]  Expand AUTO statements.
+    \\[verilog-delete-auto]  Remove the AUTOs.
+    \\[verilog-inject-auto]  Insert AUTOs for the first time.
+
+Some other functions are:
+
+    \\[verilog-complete-word]    Complete word with appropriate possibilities.
+    \\[verilog-mark-defun]  Mark function.
+    \\[verilog-beg-of-defun]  Move to beginning of current function.
+    \\[verilog-end-of-defun]  Move to end of current function.
+    \\[verilog-label-be]  Label matching begin ... end, fork ... join, etc statements.
+
+    \\[verilog-comment-region]  Put marked area in a comment.
+    \\[verilog-uncomment-region]  Uncomment an area commented with \\[verilog-comment-region].
+    \\[verilog-insert-block]  Insert begin ... end;.
+    \\[verilog-star-comment]    Insert /* ... */.
+
+    \\[verilog-sk-always]  Insert a always @(AS) begin .. end block.
+    \\[verilog-sk-begin]  Insert a begin .. end block.
+    \\[verilog-sk-case]  Insert a case block, prompting for details.
+    \\[verilog-sk-for]  Insert a for (...) begin .. end block, prompting for details.
+    \\[verilog-sk-generate]  Insert a generate .. endgenerate block.
+    \\[verilog-sk-header]  Insert a nice header block at the top of file.
+    \\[verilog-sk-initial]  Insert an initial begin .. end block.
+    \\[verilog-sk-fork]  Insert a fork begin .. end .. join block.
+    \\[verilog-sk-module]  Insert a module .. (/*AUTOARG*/);.. endmodule block.
+    \\[verilog-sk-primitive]  Insert a primitive .. (.. );.. endprimitive block.
+    \\[verilog-sk-repeat]  Insert a repeat (..) begin .. end block.
+    \\[verilog-sk-specify]  Insert a specify .. endspecify block.
+    \\[verilog-sk-task]  Insert a task .. begin .. end endtask block.
+    \\[verilog-sk-while]  Insert a while (...) begin .. end block, prompting for details.
+    \\[verilog-sk-casex]  Insert a casex (...) item: begin.. end endcase block, prompting for details.
+    \\[verilog-sk-casez]  Insert a casez (...) item: begin.. end endcase block, prompting for details.
+    \\[verilog-sk-if]  Insert an if (..) begin .. end block.
+    \\[verilog-sk-else-if]  Insert an else if (..) begin .. end block.
+    \\[verilog-sk-comment]  Insert a comment block.
+    \\[verilog-sk-assign]  Insert an assign .. = ..; statement.
+    \\[verilog-sk-function]  Insert a function .. begin .. end endfunction block.
+    \\[verilog-sk-input]  Insert an input declaration, prompting for details.
+    \\[verilog-sk-output]  Insert an output declaration, prompting for details.
+    \\[verilog-sk-state-machine]  Insert a state machine definition, prompting for details.
+    \\[verilog-sk-inout]  Insert an inout declaration, prompting for details.
+    \\[verilog-sk-wire]  Insert a wire declaration, prompting for details.
+    \\[verilog-sk-reg]  Insert a register declaration, prompting for details.
+    \\[verilog-sk-define-signal]  Define signal under point as a register at the top of the module.
+
+All key bindings can be seen in a Verilog-buffer with \\[describe-bindings].
+Key bindings specific to `verilog-mode-map' are:
+
+\\{verilog-mode-map}
+
+\(fn)" t nil)
+
+;;;***
+
 ;;;### (autoloads (vhdl-mode) "vhdl-mode" "progmodes/vhdl-mode.el"
 ;;;;;;  (18213 1260))
 ;;; Generated autoloads from progmodes/vhdl-mode.el
@@ -30821,6 +31142,11 @@
 ;;;;;;  whitespace-toggle-leading-check) "whitespace" "whitespace.el"
 ;;;;;;  (18231 31064))
 ;;; Generated autoloads from whitespace.el
+(put 'whitespace-check-buffer-leading 'safe-local-variable 'booleanp)
+(put 'whitespace-check-buffer-trailing 'safe-local-variable 'booleanp)
+(put 'whitespace-check-buffer-indent 'safe-local-variable 'booleanp)
+(put 'whitespace-check-buffer-spacetab 'safe-local-variable 'booleanp)
+(put 'whitespace-check-buffer-ateol 'safe-local-variable 'booleanp)
 
 (autoload 'whitespace-toggle-leading-check "whitespace" "\
 Toggle the check for leading space in the local buffer.
@@ -31371,7 +31697,7 @@
 ;;;;;;  "gnus/gnus-uu.el" "gnus/gnus-vm.el" "gnus/hex-util.el" "gnus/hmac-def.el"
 ;;;;;;  "gnus/hmac-md5.el" "gnus/ietf-drums.el" "gnus/imap.el" "gnus/legacy-gnus-agent.el"
 ;;;;;;  "gnus/mail-parse.el" "gnus/mail-prsvr.el" "gnus/mail-source.el"
-;;;;;;  "gnus/mailcap.el" "gnus/md4.el" "gnus/messcompat.el" "gnus/mm-bodies.el"
+;;;;;;  "gnus/mailcap.el" "gnus/messcompat.el" "gnus/mm-bodies.el"
 ;;;;;;  "gnus/mm-decode.el" "gnus/mm-encode.el" "gnus/mm-util.el"
 ;;;;;;  "gnus/mm-view.el" "gnus/mml-sec.el" "gnus/mml-smime.el" "gnus/mml.el"
 ;;;;;;  "gnus/nnagent.el" "gnus/nnbabyl.el" "gnus/nndb.el" "gnus/nndir.el"
@@ -31380,11 +31706,9 @@
 ;;;;;;  "gnus/nnmail.el" "gnus/nnmaildir.el" "gnus/nnmbox.el" "gnus/nnmh.el"
 ;;;;;;  "gnus/nnnil.el" "gnus/nnoo.el" "gnus/nnrss.el" "gnus/nnslashdot.el"
 ;;;;;;  "gnus/nnspool.el" "gnus/nntp.el" "gnus/nnultimate.el" "gnus/nnvirtual.el"
-;;;;;;  "gnus/nnwarchive.el" "gnus/nnweb.el" "gnus/nnwfm.el" "gnus/ntlm.el"
-;;;;;;  "gnus/password.el" "gnus/pop3.el" "gnus/rfc1843.el" "gnus/rfc2045.el"
-;;;;;;  "gnus/rfc2047.el" "gnus/rfc2104.el" "gnus/rfc2231.el" "gnus/sasl-cram.el"
-;;;;;;  "gnus/sasl-digest.el" "gnus/sasl-ntlm.el" "gnus/sasl.el"
-;;;;;;  "gnus/sieve-manage.el" "gnus/smime-ldap.el" "gnus/smime.el"
+;;;;;;  "gnus/nnwarchive.el" "gnus/nnweb.el" "gnus/nnwfm.el" "gnus/pop3.el"
+;;;;;;  "gnus/rfc1843.el" "gnus/rfc2045.el" "gnus/rfc2047.el" "gnus/rfc2104.el"
+;;;;;;  "gnus/rfc2231.el" "gnus/sieve-manage.el" "gnus/smime.el"
 ;;;;;;  "gnus/spam-stat.el" "gnus/spam-wash.el" "gnus/starttls.el"
 ;;;;;;  "gnus/utf7.el" "gnus/webmail.el" "help.el" "indent.el" "international/characters.el"
 ;;;;;;  "international/charprop.el" "international/cp51932.el" "international/eucjp-ms.el"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/linum.el	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,196 @@
+;;; linum.el --- display line numbers in the left margin
+
+;; Copyright (C) 2008 Free Software Foundation, Inc.
+
+;; Author: Markus Triska <markus.triska@gmx.at>
+;; Maintainer: FSF
+;; Keywords: convenience
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; Display line numbers for the current buffer.
+;;
+;; Toggle display of line numbers with M-x linum-mode.  To enable
+;; line numbering in all buffers, use M-x global-linum-mode.
+
+;;; Code:
+
+(defconst linum-version "0.9wx")
+
+(defvar linum-overlays nil "Overlays used in this buffer.")
+(defvar linum-available nil "Overlays available for reuse.")
+(defvar linum-before-numbering-hook nil
+  "Functions run in each buffer before line numbering starts.")
+
+(mapc #'make-variable-buffer-local '(linum-overlays linum-available))
+
+(defgroup linum nil
+  "Show line numbers in the left margin."
+  :group 'convenience)
+
+;;;###autoload
+(defcustom linum-format 'dynamic
+  "Format used to display line numbers.
+Either a format string like \"%7d\", `dynamic' to adapt the width
+as needed, or a function that is called with a line number as its
+argument and should evaluate to a string to be shown on that line.
+See also `linum-before-numbering-hook'."
+  :group 'linum
+  :type 'sexp)
+
+(defface linum
+  '((t :inherit shadow))
+  "Face for displaying line numbers in the display margin."
+  :group 'linum)
+
+(defcustom linum-eager t
+  "Whether line numbers should be updated after each command.
+The conservative setting `nil' might miss some buffer changes,
+and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
+  :group 'linum
+  :type 'boolean)
+
+(defcustom linum-delay t
+  "Delay updates to give Emacs a chance for other changes."
+  :group 'linum
+  :type 'boolean)
+
+;;;###autoload
+(define-minor-mode linum-mode
+  "Toggle display of line numbers in the left margin."
+  :lighter ""                           ; for desktop.el
+  (if linum-mode
+      (progn
+        (if linum-eager
+            (add-hook 'post-command-hook (if linum-delay
+                                             'linum-schedule
+                                           'linum-update-current) nil t)
+          (add-hook 'after-change-functions 'linum-after-change nil t))
+        (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
+        ;; mistake in Emacs: window-size-change-functions cannot be local
+        (add-hook 'window-size-change-functions 'linum-after-size)
+        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
+        (add-hook 'window-configuration-change-hook
+                  'linum-after-config nil t)
+        (linum-update-current))
+    (remove-hook 'post-command-hook 'linum-update-current t)
+    (remove-hook 'post-command-hook 'linum-schedule t)
+    (remove-hook 'window-size-change-functions 'linum-after-size)
+    (remove-hook 'window-scroll-functions 'linum-after-scroll t)
+    (remove-hook 'after-change-functions 'linum-after-change t)
+    (remove-hook 'window-configuration-change-hook 'linum-after-config t)
+    (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
+    (linum-delete-overlays)))
+
+;;;###autoload
+(define-globalized-minor-mode global-linum-mode linum-mode linum-on)
+
+(defun linum-on ()
+  (unless (minibufferp)
+    (linum-mode 1)))
+
+(defun linum-delete-overlays ()
+  "Delete all overlays displaying line numbers for this buffer."
+  (mapc #'delete-overlay linum-overlays)
+  (setq linum-overlays nil)
+  (dolist (w (get-buffer-window-list (current-buffer) nil t))
+    (set-window-margins w 0)))
+
+(defun linum-update-current ()
+  "Update line numbers for the current buffer."
+  (linum-update (current-buffer)))
+
+(defun linum-update (buffer)
+  "Update line numbers for all windows displaying BUFFER."
+  (with-current-buffer buffer
+    (when linum-mode
+      (setq linum-available linum-overlays)
+      (setq linum-overlays nil)
+      (save-excursion
+        (mapc #'linum-update-window
+              (get-buffer-window-list buffer nil 'visible)))
+      (mapc #'delete-overlay linum-available)
+      (setq linum-available nil))))
+
+(defun linum-update-window (win)
+  "Update line numbers for the portion visible in window WIN."
+  (goto-char (window-start win))
+  (let ((line (line-number-at-pos))
+        (limit (1+ (window-end win t)))
+        (fmt (cond ((stringp linum-format) linum-format)
+                   ((eq linum-format 'dynamic)
+                    (let ((w (length (number-to-string
+                                      (count-lines (point-min) (point-max))))))
+                      (concat "%" (number-to-string w) "d")))))
+        (width 0)
+        visited
+        ov)
+    (run-hooks 'linum-before-numbering-hook)
+    ;; Create an overlay (or reuse an existing one) for each
+    ;; line visible in this window, if necessary.
+    (while (and (not (eobp)) (< (point) limit))
+      (setq visited nil)
+      (dolist (o (overlays-in (point) (point)))
+        (when (eq (overlay-get o 'linum-line) line)
+          (unless (memq o linum-overlays)
+            (push o linum-overlays))
+          (setq linum-available (delete o linum-available))
+          (setq visited t)))
+      (let ((str (if fmt
+                     (propertize (format fmt line) 'face 'linum)
+                   (funcall linum-format line))))
+        (setq width (max width (length str)))
+        (unless visited
+          (if (null linum-available)
+              (setq ov (make-overlay (point) (point)))
+            (setq ov (pop linum-available))
+            (move-overlay ov (point) (point)))
+          (push ov linum-overlays)
+          (setq str (propertize " " 'display `((margin left-margin) ,str)))
+          (overlay-put ov 'before-string str)
+          (overlay-put ov 'linum-line line)))
+      (forward-line)
+      (setq line (1+ line)))
+    (set-window-margins win width)))
+
+(defun linum-after-change (beg end len)
+  ;; update overlays on deletions, and after newlines are inserted
+  (when (or (= beg end)
+            (= end (point-max))
+            (string-match-p "\n" (buffer-substring-no-properties beg end)))
+    (linum-update-current)))
+
+(defun linum-after-scroll (win start)
+  (linum-update (window-buffer win)))
+
+(defun linum-after-size (frame)
+  (linum-after-config))
+
+(defun linum-schedule ()
+  ;; schedule an update; the delay gives Emacs a chance for display changes
+  (run-with-idle-timer 0 nil #'linum-update-current))
+
+(defun linum-after-config ()
+  (walk-windows (lambda (w) (linum-update (window-buffer))) nil 'visible))
+
+(provide 'linum)
+
+;; arch-tag: dea45631-ed3c-4867-8b49-1c41c80aec6a
+;;; linum.el ends here
--- a/lisp/loadhist.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/loadhist.el	Wed Jan 30 07:57:28 2008 +0000
@@ -74,7 +74,7 @@
   (let (provides)
     (dolist (x (file-loadhist-lookup file) provides)
       (when (eq (car-safe x) 'provide)
-	(push x provides)))))
+	(push (cdr x) provides)))))
 
 (defun file-requires (file)
   "Return the list of features required by FILE as it was loaded.
@@ -83,7 +83,7 @@
   (let (requires)
     (dolist (x (file-loadhist-lookup file) requires)
       (when (eq (car-safe x) 'require)
-	(push x requires)))))
+	(push (cdr x) requires)))))
 
 (defsubst file-set-intersect (p q)
   "Return the set intersection of two lists."
--- a/lisp/log-edit.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/log-edit.el	Wed Jan 30 07:57:28 2008 +0000
@@ -309,20 +309,20 @@
   "Setup a buffer to enter a log message.
 \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
-Mark and point will be set around the entire contents of the
-buffer so that it is easy to kill the contents of the buffer with \\[kill-region].
+Mark and point will be set around the entire contents of the buffer so
+that it is easy to kill the contents of the buffer with \\[kill-region].
 Once you're done editing the message, pressing \\[log-edit-done] will call
 `log-edit-done' which will end up calling CALLBACK to do the actual commit.
-PARAMS if non-nil is an alist. The keys for the alist can be:
-`log-edit-listfun' and `log-edit-diff-function'. The associated
-value for `log-edit-listfun' should be a function with not
-arguments that returns the list of files that are concerned by
-the current operation (using relative names). The associated
-value for `log-edit-diff-function' should be a function with no
-arguments that displays a diff of the files concerned by the current operation.
+
+PARAMS if non-nil is an alist.  Possible keys and associated values:
+ `log-edit-listfun' -- function taking no arguments that returns the list of
+ files that are concerned by the current operation (using relative names);
+ `log-edit-diff-function' -- function taking no arguments that
+ displays a diff of the files concerned by the current operation.
+
 If BUFFER is non-nil `log-edit' will jump to that buffer, use it to edit the
-  log message and go back to the current buffer when done.  Otherwise, it
-  uses the current buffer."
+log message and go back to the current buffer when done.  Otherwise, it
+uses the current buffer."
   (let ((parent (current-buffer)))
     (if buffer (pop-to-buffer buffer))
     (when (and log-edit-setup-invert (not (eq setup 'force)))
--- a/lisp/longlines.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/longlines.el	Wed Jan 30 07:57:28 2008 +0000
@@ -136,7 +136,8 @@
         (let ((buffer-undo-list t)
               (inhibit-read-only t)
 	      (after-change-functions nil)
-              (mod (buffer-modified-p)))
+              (mod (buffer-modified-p))
+	      buffer-file-name buffer-file-truename)
           ;; Turning off undo is OK since (spaces + newlines) is
           ;; conserved, except for a corner case in
           ;; longlines-wrap-lines that we'll never encounter from here
@@ -176,7 +177,8 @@
         (longlines-unshow-hard-newlines))
     (let ((buffer-undo-list t)
 	  (after-change-functions nil)
-          (inhibit-read-only t))
+          (inhibit-read-only t)
+	  buffer-file-name buffer-file-truename)
       (if longlines-decoded
 	  (save-restriction
 	    (widen)
@@ -220,7 +222,8 @@
 	 (mod (buffer-modified-p))
 	 (buffer-undo-list t)
 	 (inhibit-read-only t)
-	 (inhibit-modification-hooks t))
+	 (inhibit-modification-hooks t)
+	 buffer-file-name buffer-file-truename)
     (while pos
       (put-text-property pos (1+ pos) 'display
 			 (copy-sequence longlines-show-effect))
@@ -235,7 +238,8 @@
 	(mod (buffer-modified-p))
 	(buffer-undo-list t)
 	(inhibit-read-only t)
-	(inhibit-modification-hooks t))
+	(inhibit-modification-hooks t)
+	buffer-file-name buffer-file-truename)
     (while pos
       (remove-text-properties pos (1+ pos) '(display))
       (setq pos (text-property-not-all (1+ pos) (point-max) 'hard nil)))
--- a/lisp/lpr.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/lpr.el	Wed Jan 30 07:57:28 2008 +0000
@@ -47,7 +47,7 @@
 
 ;;;###autoload
 (defcustom printer-name
-  (and lpr-windows-system "PRN")
+  (and (memq system-type '(emx ms-dos)) "PRN")
   "*The name of a local printer to which data is sent for printing.
 \(Note that PostScript files are sent to `ps-printer-name', which see.\)
 
--- a/lisp/ls-lisp.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/ls-lisp.el	Wed Jan 30 07:57:28 2008 +0000
@@ -209,7 +209,7 @@
 supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards'
 is non-nil; otherwise, it interprets wildcards as regular expressions
 to match file names.  It does not support all `ls' switches -- those
-that work are: A a c i r S s t u U X g G B C R and F partly."
+that work are: A a c i r S s t u U X g G B C R n and F partly."
   (if ls-lisp-use-insert-directory-program
       (funcall original-insert-directory
 	       file switches wildcard full-directory-p)
@@ -286,7 +286,10 @@
       (let* ((dir (file-name-as-directory file))
 	     (default-directory dir)	; so that file-attributes works
 	     (file-alist
-	      (directory-files-and-attributes dir nil wildcard-regexp t 'string))
+	      (directory-files-and-attributes dir nil wildcard-regexp t
+					      (if (memq ?n switches)
+						  'integer
+						'string)))
 	     (now (current-time))
 	     (sum 0)
 	     ;; do all bindings here for speed
--- a/lisp/mail/hashcash.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/mail/hashcash.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; hashcash.el --- Add hashcash payments to email
 
-;; Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation
+;; Copyright (C) 2003, 2004, 2005, 2007, 2008  Free Software Foundation
 
 ;; Written by: Paul Foley <mycroft@actrix.gen.nz> (1997-2002)
 ;; Maintainer: Paul Foley <mycroft@actrix.gen.nz>
--- a/lisp/mail/rmail.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/mail/rmail.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1934,7 +1934,7 @@
     (save-restriction
       (while (not (eobp))
 	(setq start (point))
-	(cond ((looking-at "BABYL OPTIONS:");Babyl header
+	(cond ((looking-at "BABYL OPTIONS:")	;Babyl header
 	       (if (search-forward "\n\^_" nil t)
 		   ;; If we find the proper terminator, delete through there.
 		   (delete-region (point-min) (point))
@@ -1953,75 +1953,80 @@
 			      (save-excursion
 				(skip-chars-forward " \t\n")
 				(point)))
-	       (save-excursion
-		 (let* ((header-end
-			 (progn
-			   (save-excursion
-			     (goto-char start)
-			     (forward-line 1)
-			     (if (looking-at "0")
-				 (forward-line 1)
-			       (forward-line 2))
-			     (save-restriction
-			       (narrow-to-region (point) (point-max))
-			       (rfc822-goto-eoh)
-			       (point)))))
-			(case-fold-search t)
-			(quoted-printable-header-field-end
-			 (save-excursion
-			   (goto-char start)
-			   (re-search-forward
-			    "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
-			    header-end t)))
-			(base64-header-field-end
+	       ;; The following let* form was wrapped in a `save-excursion'
+	       ;; which in one case caused infinite looping, see:
+	       ;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg00968.html
+	       ;; Removing that form leaves `point' at the end of the
+	       ;; region decoded by `rmail-decode-region' which should
+	       ;; be correct.
+	       (let* ((header-end
+		       (progn
 			 (save-excursion
 			   (goto-char start)
-			   ;; Don't try to decode non-text data.
-			   (and (re-search-forward
-				 "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
-				 header-end t)
-				(goto-char start)
-				(re-search-forward
-				 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
-				 header-end t)))))
-		   (if quoted-printable-header-field-end
+			   (forward-line 1)
+			   (if (looking-at "0")
+			       (forward-line 1)
+			     (forward-line 2))
+			   (save-restriction
+			     (narrow-to-region (point) (point-max))
+			     (rfc822-goto-eoh)
+			     (point)))))
+		      (case-fold-search t)
+		      (quoted-printable-header-field-end
 		       (save-excursion
-			 (unless
-			     (mail-unquote-printable-region header-end (point) nil t t)
-			   (message "Malformed MIME quoted-printable message"))
-			 ;; Change "quoted-printable" to "8bit",
-			 ;; to reflect the decoding we just did.
-			 (goto-char quoted-printable-header-field-end)
-			 (delete-region (point) (search-backward ":"))
-			 (insert ": 8bit")))
-		   (if base64-header-field-end
+			 (goto-char start)
+			 (re-search-forward
+			  "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
+			  header-end t)))
+		      (base64-header-field-end
 		       (save-excursion
-			 (when
-			     (condition-case nil
-				 (progn
-				   (base64-decode-region (1+ header-end)
-							 (- (point) 2))
-				   t)
-			       (error nil))
-			   ;; Change "base64" to "8bit", to reflect the
-			   ;; decoding we just did.
-			   (goto-char base64-header-field-end)
-			   (delete-region (point) (search-backward ":"))
-			   (insert ": 8bit"))))
-		   (setq last-coding-system-used nil)
-		   (or rmail-enable-mime
-		       (not rmail-enable-multibyte)
-		       (let ((mime-charset
-			      (if (and rmail-decode-mime-charset
-				       (save-excursion
-					 (goto-char start)
-					 (search-forward "\n\n" nil t)
-					 (let ((case-fold-search t))
-					   (re-search-backward
-					    rmail-mime-charset-pattern
-					    start t))))
-				  (intern (downcase (match-string 1))))))
-			 (rmail-decode-region start (point) mime-charset)))))
+			 (goto-char start)
+			 ;; Don't try to decode non-text data.
+			 (and (re-search-forward
+			       "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
+			       header-end t)
+			      (goto-char start)
+			      (re-search-forward
+			       "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
+			       header-end t)))))
+		 (if quoted-printable-header-field-end
+		     (save-excursion
+		       (unless
+			   (mail-unquote-printable-region header-end (point) nil t t)
+			 (message "Malformed MIME quoted-printable message"))
+		       ;; Change "quoted-printable" to "8bit",
+		       ;; to reflect the decoding we just did.
+		       (goto-char quoted-printable-header-field-end)
+		       (delete-region (point) (search-backward ":"))
+		       (insert ": 8bit")))
+		 (if base64-header-field-end
+		     (save-excursion
+		       (when
+			   (condition-case nil
+			       (progn
+				 (base64-decode-region (1+ header-end)
+						       (- (point) 2))
+				 t)
+			     (error nil))
+			 ;; Change "base64" to "8bit", to reflect the
+			 ;; decoding we just did.
+			 (goto-char base64-header-field-end)
+			 (delete-region (point) (search-backward ":"))
+			 (insert ": 8bit"))))
+		 (setq last-coding-system-used nil)
+		 (or rmail-enable-mime
+		     (not rmail-enable-multibyte)
+		     (let ((mime-charset
+			    (if (and rmail-decode-mime-charset
+				     (save-excursion
+				       (goto-char start)
+				       (search-forward "\n\n" nil t)
+				       (let ((case-fold-search t))
+					 (re-search-backward
+					  rmail-mime-charset-pattern
+					  start t))))
+				(intern (downcase (match-string 1))))))
+		       (rmail-decode-region start (point) mime-charset))))
 	       ;; Add an X-Coding-System: header if we don't have one.
 	       (save-excursion
 		 (goto-char start)
@@ -2051,8 +2056,8 @@
 		 (save-restriction
 		   (narrow-to-region start (1- (point)))
 		   (goto-char (point-min))
-		   (while (search-forward "\n\^_" nil t); single char "\^_"
-		     (replace-match "\n^_")))); 2 chars: "^" and "_"
+		   (while (search-forward "\n\^_" nil t) ; single char "\^_"
+		     (replace-match "\n^_"))))	; 2 chars: "^" and "_"
 	       (setq last-coding-system-used nil)
 	       (or rmail-enable-mime
 		   (not rmail-enable-multibyte)
@@ -2168,8 +2173,8 @@
 		 (save-restriction
 		   (narrow-to-region start (point))
 		   (goto-char (point-min))
-		   (while (search-forward "\n\^_" nil t); single char
-		     (replace-match "\n^_")))); 2 chars: "^" and "_"
+		   (while (search-forward "\n\^_" nil t) ; single char
+		     (replace-match "\n^_"))))	; 2 chars: "^" and "_"
 	       ;; This is for malformed messages that don't end in newline.
 	       ;; There shouldn't be any, but some users say occasionally
 	       ;; there are some.
--- a/lisp/mb-depth.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/mb-depth.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; mb-depth.el --- Indicate minibuffer-depth in prompt
 ;;
-;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008  Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
 ;; Keywords: convenience
--- a/lisp/md4.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/md4.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; md4.el --- MD4 Message Digest Algorithm.
 
-;; Copyright (C) 2001, 2004, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2004, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <tarok@transpulse.org>
 ;; Keywords: MD4
--- a/lisp/mh-e/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/mh-e/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,8 @@
+2008-01-30  Bill Wohler  <wohler@newt.com>
+
+	* mh-mime.el (mh-mml-to-mime): Don't look up sender if From
+	absent. Fixes "Wrong type argument: stringp, nil" error.
+
 2007-12-02  Glenn Morris  <rgm@gnu.org>
 
 	* mh-mime.el (mail-strip-quoted-names): Autoload it.
--- a/lisp/mh-e/mh-mime.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/mh-e/mh-mime.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1621,13 +1621,14 @@
   (require 'message)
   (when mh-pgp-support-flag
     ;; PGP requires actual e-mail addresses, not aliases.
-    ;; Parse the recipients and sender from the message
+    ;; Parse the recipients and sender from the message.
     (message-options-set-recipient)
-    ;; Do an alias lookup on sender
-    (message-options-set 'message-sender
-                     (mail-strip-quoted-names
-                      (mh-alias-expand
-                       (message-options-get 'message-sender))))
+    ;; Do an alias lookup on sender (if From field is present).
+    (when (message-options-get 'message-sender)
+      (message-options-set 'message-sender
+                           (mail-strip-quoted-names
+                            (mh-alias-expand
+                             (message-options-get 'message-sender)))))
     ;; Do an alias lookup on recipients
     (message-options-set 'message-recipients
                          (mapconcat
--- a/lisp/net/dbus.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/dbus.el	Wed Jan 30 07:57:28 2008 +0000
@@ -46,6 +46,17 @@
 (defconst dbus-interface-introspectable "org.freedesktop.DBus.Introspectable"
   "The interface supported by introspectable objects.")
 
+(defmacro dbus-ignore-errors (&rest body)
+  "Execute BODY; signal D-Bus error when `dbus-debug' is non-nil.
+Otherwise, return result of last form in BODY, or all other errors."
+  `(condition-case err
+       (progn ,@body)
+     (dbus-error (when dbus-debug (signal (car err) (cdr err))))))
+
+(put 'dbus-ignore-errors 'lisp-indent-function 0)
+(put 'dbus-ignore-errors 'edebug-form-spec '(form symbolp body))
+(font-lock-add-keywords 'emacs-lisp-mode '("\\<dbus-ignore-errors\\>"))
+
 
 ;;; Hash table of registered functions.
 
@@ -64,6 +75,35 @@
      dbus-registered-functions-table)
     result))
 
+(defun dbus-unregister-object (object)
+  "Unregister OBJECT from D-Bus.
+OBJECT must be the result of a preceding `dbus-register-method'
+or `dbus-register-signal' call.  It returns t if OBJECT has been
+unregistered, nil otherwise."
+  ;; Check parameter.
+  (unless (and (consp object) (not (null (car object))) (consp (cdr object)))
+    (signal 'wrong-type-argument (list 'D-Bus object)))
+
+  ;; Find the corresponding entry in the hash table.
+  (let* ((key (car object))
+	 (value (gethash key dbus-registered-functions-table)))
+    ;; Loop over the registered functions.
+    (while (consp value)
+      ;; (car value) has the structure (UNAME SERVICE PATH HANDLER).
+      ;; (cdr object) has the structure ((SERVICE PATH HANDLER) ...).
+      (if (not (equal (cdr (car value)) (car (cdr object))))
+	  (setq value (cdr value))
+	;; Compute new hash value.  If it is empty, remove it from
+	;; hash table.
+	(unless
+	    (puthash
+	     key
+	     (delete (car value) (gethash key dbus-registered-functions-table))
+	     dbus-registered-functions-table)
+	  (remhash key dbus-registered-functions-table))
+	(setq value t)))
+    value))
+
 (defun dbus-name-owner-changed-handler (&rest args)
   "Reapplies all member registrations to D-Bus.
 This handler is applied when a \"NameOwnerChanged\" signal has
@@ -110,15 +150,13 @@
 	  args))))))
 
 ;; Register the handler.
-(condition-case nil
-    (progn
-      (dbus-register-signal
-       :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus
-       "NameOwnerChanged" 'dbus-name-owner-changed-handler)
-      (dbus-register-signal
-       :session dbus-service-dbus dbus-path-dbus dbus-interface-dbus
-       "NameOwnerChanged" 'dbus-name-owner-changed-handler))
-  (dbus-error))
+(dbus-ignore-errors
+  (dbus-register-signal
+   :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus
+   "NameOwnerChanged" 'dbus-name-owner-changed-handler)
+  (dbus-register-signal
+   :session dbus-service-dbus dbus-path-dbus dbus-interface-dbus
+   "NameOwnerChanged" 'dbus-name-owner-changed-handler))
 
 
 ;;; D-Bus events.
@@ -168,16 +206,15 @@
   (interactive "e")
   ;; We don't want to raise an error, because this function is called
   ;; in the event handling loop.
-  (condition-case err
-      (let (result)
-	(dbus-check-event event)
-	(setq result (apply (nth 7 event) (nthcdr 8 event)))
-	(unless (consp result) (setq result (cons result nil)))
-	;; Return a message when serial is not nil.
-	(when (not (null (nth 2 event)))
-	  (apply 'dbus-method-return
-		 (nth 1 event) (nth 2 event) (nth 3 event) result)))
-    (dbus-error (when dbus-debug (signal (car err) (cdr err))))))
+  (dbus-ignore-errors
+    (let (result)
+      (dbus-check-event event)
+      (setq result (apply (nth 7 event) (nthcdr 8 event)))
+      (unless (consp result) (setq result (cons result nil)))
+      ;; Return a message when serial is not nil.
+      (when (not (null (nth 2 event)))
+	(apply 'dbus-method-return-internal
+	       (nth 1 event) (nth 2 event) (nth 3 event) result)))))
 
 (defun dbus-event-bus-name (event)
   "Return the bus name the event is coming from.
@@ -238,11 +275,10 @@
   "Return the D-Bus service names which can be activated as list.
 The result is a list of strings, which is nil when there are no
 activatable service names at all."
-  (condition-case nil
-      (dbus-call-method
-       :system dbus-service-dbus
-       dbus-path-dbus dbus-interface-dbus "ListActivatableNames")
-    (dbus-error)))
+  (dbus-ignore-errors
+    (dbus-call-method
+     :system dbus-service-dbus
+     dbus-path-dbus dbus-interface-dbus "ListActivatableNames")))
 
 (defun dbus-list-names (bus)
   "Return the service names registered at D-Bus BUS.
@@ -250,10 +286,9 @@
 registered service names at all.  Well known names are strings like
 \"org.freedesktop.DBus\".  Names starting with \":\" are unique names
 for services."
-  (condition-case nil
-      (dbus-call-method
-       bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus "ListNames")
-    (dbus-error)))
+  (dbus-ignore-errors
+    (dbus-call-method
+     bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus "ListNames")))
 
 (defun dbus-list-known-names (bus)
   "Retrieve all services which correspond to a known name in BUS.
@@ -267,20 +302,18 @@
 "Return the unique names registered at D-Bus BUS and queued for SERVICE.
 The result is a list of strings, or nil when there are no queued name
 owners service names at all."
-  (condition-case nil
-      (dbus-call-method
-       bus dbus-service-dbus dbus-path-dbus
-       dbus-interface-dbus "ListQueuedOwners" service)
-    (dbus-error)))
+  (dbus-ignore-errors
+    (dbus-call-method
+     bus dbus-service-dbus dbus-path-dbus
+     dbus-interface-dbus "ListQueuedOwners" service)))
 
 (defun dbus-get-name-owner (bus service)
   "Return the name owner of SERVICE registered at D-Bus BUS.
 The result is either a string, or nil if there is no name owner."
-  (condition-case nil
-      (dbus-call-method
-       bus dbus-service-dbus dbus-path-dbus
-       dbus-interface-dbus "GetNameOwner" service)
-    (dbus-error)))
+  (dbus-ignore-errors
+    (dbus-call-method
+     bus dbus-service-dbus dbus-path-dbus
+     dbus-interface-dbus "GetNameOwner" service)))
 
 (defun dbus-introspect (bus service path)
   "Return the introspection data of SERVICE in D-Bus BUS at object path PATH.
@@ -291,10 +324,9 @@
 \(dbus-introspect
   :system \"org.freedesktop.Hal\"
   \"/org/freedesktop/Hal/devices/computer\")"
-  (condition-case nil
-      (dbus-call-method
-       bus service path dbus-interface-introspectable "Introspect")
-    (dbus-error)))
+  (dbus-ignore-errors
+    (dbus-call-method
+     bus service path dbus-interface-introspectable "Introspect")))
 
 (if nil ;; Must be reworked.  Shall we offer D-Bus signatures at all?
 (defun dbus-get-signatures (bus interface signal)
@@ -310,42 +342,39 @@
 If INTERFACE or SIGNAL do not exist, or if they do not support
 the D-Bus method org.freedesktop.DBus.Introspectable.Introspect,
 the function returns nil."
-  (condition-case nil
-      (let ((introspect-xml
-	     (with-temp-buffer
-	       (insert (dbus-introspect bus interface))
-	       (xml-parse-region (point-min) (point-max))))
-	    node interfaces signals args result)
-	;; Get the root node.
-	(setq node (xml-node-name introspect-xml))
-	;; Get all interfaces.
-	(setq interfaces (xml-get-children node 'interface))
-	(while interfaces
-	  (when (string-equal (xml-get-attribute (car interfaces) 'name)
-			      interface)
-	    ;; That's the requested interface.  Check for signals.
-	    (setq signals (xml-get-children (car interfaces) 'signal))
-	    (while signals
-	      (when (string-equal (xml-get-attribute (car signals) 'name)
-				  signal)
-		;; The signal we are looking for.
-		(setq args (xml-get-children (car signals) 'arg))
-		(while args
-		  (unless (xml-get-attribute (car args) 'type)
-		    ;; This shouldn't happen, let's escape.
-		    (signal 'dbus-error ""))
-		  ;; We append the signature.
-		  (setq
-		   result (append result
-				  (list (xml-get-attribute (car args) 'type))))
-		  (setq args (cdr args)))
-		(setq signals nil))
-	      (setq signals (cdr signals)))
-	    (setq interfaces nil))
-	  (setq interfaces (cdr interfaces)))
-	result)
-    ;; We ignore `dbus-error'.  There might be no introspectable interface.
-    (dbus-error nil)))
+  (dbus-ignore-errors
+    (let ((introspect-xml
+	   (with-temp-buffer
+	     (insert (dbus-introspect bus interface))
+	     (xml-parse-region (point-min) (point-max))))
+	  node interfaces signals args result)
+      ;; Get the root node.
+      (setq node (xml-node-name introspect-xml))
+      ;; Get all interfaces.
+      (setq interfaces (xml-get-children node 'interface))
+      (while interfaces
+	(when (string-equal (xml-get-attribute (car interfaces) 'name)
+			    interface)
+	  ;; That's the requested interface.  Check for signals.
+	  (setq signals (xml-get-children (car interfaces) 'signal))
+	  (while signals
+	    (when (string-equal (xml-get-attribute (car signals) 'name) signal)
+	      ;; The signal we are looking for.
+	      (setq args (xml-get-children (car signals) 'arg))
+	      (while args
+		(unless (xml-get-attribute (car args) 'type)
+		  ;; This shouldn't happen, let's escape.
+		  (signal 'dbus-error nil))
+		;; We append the signature.
+		(setq
+		 result (append result
+				(list (xml-get-attribute (car args) 'type))))
+		(setq args (cdr args)))
+	      (setq signals nil))
+	    (setq signals (cdr signals)))
+	  (setq interfaces nil))
+	(setq interfaces (cdr interfaces)))
+      result)))
 ) ;; (if nil ...
 
 (provide 'dbus)
--- a/lisp/net/hmac-def.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/hmac-def.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; hmac-def.el --- A macro for defining HMAC functions.
 
-;; Copyright (C) 1999, 2001, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
 ;; Keywords: HMAC, RFC 2104
--- a/lisp/net/hmac-md5.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/hmac-md5.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; hmac-md5.el --- Compute HMAC-MD5.
 
-;; Copyright (C) 1999, 2001, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
 ;; Keywords: HMAC, RFC 2104, HMAC-MD5, MD5, KEYED-MD5, CRAM-MD5
--- a/lisp/net/imap.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/imap.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1150,6 +1150,13 @@
       (when imap-stream
 	buffer))))
 
+(defcustom imap-ping-server t
+  "If non-nil, check if IMAP is open.
+See the function `imap-ping-server'."
+  :version "23.0" ;; No Gnus
+  :group 'imap
+  :type 'boolean)
+
 (defun imap-opened (&optional buffer)
   "Return non-nil if connection to imap server in BUFFER is open.
 If BUFFER is nil then the current buffer is used."
@@ -1157,7 +1164,18 @@
        (buffer-live-p buffer)
        (with-current-buffer buffer
 	 (and imap-process
-	      (memq (process-status imap-process) '(open run))))))
+	      (memq (process-status imap-process) '(open run))
+	      (if imap-ping-server
+		  (imap-ping-server)
+		t)))))
+
+(defun imap-ping-server (&optional buffer)
+  "Ping the IMAP server in BUFFER with a \"NOOP\" command.
+Return non-nil if the server responds, and nil if it does not
+respond.  If BUFFER is nil, the current buffer is used."
+  (condition-case ()
+      (imap-ok-p (imap-send-command-wait "NOOP" buffer))
+    (error nil)))
 
 (defun imap-authenticate (&optional user passwd buffer)
   "Authenticate to server in BUFFER, using current buffer if nil.
--- a/lisp/net/ntlm.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/ntlm.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; ntlm.el --- NTLM (NT LanManager) authentication support
 
-;; Copyright (C) 2001, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <tarok@transpulse.org>
 ;; Keywords: NTLM, SASL
--- a/lisp/net/sasl-cram.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/sasl-cram.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework
 
-;; Copyright (C) 2000, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;;	Kenichi OKADA <okada@opaopa.org>
--- a/lisp/net/sasl-digest.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/sasl-digest.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; sasl-digest.el --- DIGEST-MD5 module for the SASL client framework
 
-;; Copyright (C) 2000, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;;	Kenichi OKADA <okada@opaopa.org>
--- a/lisp/net/sasl-ntlm.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/sasl-ntlm.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; sasl-ntlm.el --- NTLM (NT Lan Manager) module for the SASL client framework
 
-;; Copyright (C) 2000, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <tarok@transpulse.org>
 ;; Keywords: SASL, NTLM
--- a/lisp/net/sasl.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/sasl.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; sasl.el --- SASL client framework
 
-;; Copyright (C) 2000, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Keywords: SASL
--- a/lisp/net/tramp-cache.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp-cache.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-cache.el --- file information caching for Tramp
 
-;; Copyright (C) 2000, 2005, 2006, 2007 by Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pittman <daniel@inanna.danann.net>
 ;;         Michael Albinus <michael.albinus@gmx.de>
--- a/lisp/net/tramp-cmds.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp-cmds.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-cmds.el --- Interactive commands for Tramp
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
--- a/lisp/net/tramp-compat.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp-compat.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-compat.el --- Tramp compatibility functions
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
--- a/lisp/net/tramp-fish.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp-fish.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-fish.el --- Tramp access functions for FISH protocol
 
-;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
--- a/lisp/net/tramp-gw.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp-gw.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-gw.el --- Tramp utility functions for HTTP tunnels and SOCKS gateways
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
--- a/lisp/net/tramp.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/tramp.el	Wed Jan 30 07:57:28 2008 +0000
@@ -441,7 +441,7 @@
 	     (tramp-password-end-of-line nil))
     ("sudo"  (tramp-login-program        "sudo")
              (tramp-login-args           (("-u" "%u")
-					  ("-s" "-p" "Password:")))
+					  ("-s") ("-H") ("-p" "Password:")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -519,7 +519,9 @@
 	     (tramp-default-port         22))
     ("plinkx"
              (tramp-login-program        "plink")
-	     (tramp-login-args           (("-load" "%h") ("-t")
+	     ;; ("%h") must be a single element, see
+	     ;; `tramp-compute-multi-hops'.
+	     (tramp-login-args           (("-load") ("%h") ("-t")
 					  (,(format
 					     "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=$ '"
 					     tramp-terminal-type))
@@ -914,7 +916,7 @@
 		  (string :tag "Directory"))))
 
 (defcustom tramp-remote-process-environment
-  `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_CTYPE=C" "LC_TIME=C"
+  `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C"
     ,(concat "TERM=" tramp-terminal-type)
     "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH="
     "autocorrect=" "correct=")
@@ -1433,9 +1435,11 @@
 ;;; Internal Variables:
 
 (defvar tramp-end-of-output
-  (concat
-   "///" (md5 (concat
-	       (prin1-to-string process-environment) (current-time-string))))
+  (format
+   "%s///%s%s"
+   tramp-rsh-end-of-line
+   (md5 (concat (prin1-to-string process-environment) (current-time-string)))
+   tramp-rsh-end-of-line)
   "String used to recognize end of output.")
 
 (defvar tramp-current-method nil
@@ -3032,6 +3036,11 @@
 	  ;; One of them must be a Tramp file.
 	  (error "Tramp implementation says this cannot happen")))
 
+      ;; In case of `rename', we must flush the cache of the source file.
+      (when (and t1 (eq op 'rename))
+	(with-parsed-tramp-file-name filename nil
+	  (tramp-flush-file-property v localname)))
+
       ;; When newname did exist, we have wrong cached values.
       (when t2
 	(with-parsed-tramp-file-name newname nil
@@ -3774,13 +3783,15 @@
   (command &optional output-buffer error-buffer)
   "Like `shell-command' for Tramp files."
   (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
-	 (args (split-string (substring command 0 asynchronous) " "))
+	 ;; We cannot use `shell-file-name' and `shell-command-switch',
+	 ;; they are variables of the local host.
+	 (args (list "/bin/sh" "-c" (substring command 0 asynchronous)))
 	 (output-buffer
 	  (cond
 	   ((bufferp output-buffer) output-buffer)
 	   ((stringp output-buffer) (get-buffer-create output-buffer))
 	   (output-buffer (current-buffer))
-	   (t (generate-new-buffer
+	   (t (get-buffer-create
 	       (if asynchronous
 		   "*Async Shell Command*"
 		 "*Shell Command Output*")))))
@@ -3792,22 +3803,42 @@
 	  (if (and (not asynchronous) error-buffer)
 	      (with-parsed-tramp-file-name default-directory nil
 		(list output-buffer (tramp-make-tramp-temp-file v)))
-	    output-buffer)))
-
-    (prog1
-	;; Run the process.
-	(if (integerp asynchronous)
+	    output-buffer))
+	 (proc (get-buffer-process output-buffer)))
+
+    ;; Check whether there is another process running.  Tramp does not
+    ;; support 2 (asynchronous) processes in parallel.
+    (when proc
+      (if (yes-or-no-p "A command is running.  Kill it? ")
+	  (ignore-errors (kill-process proc))
+	(error "Shell command in progress")))
+
+    (with-current-buffer output-buffer
+      (setq buffer-read-only nil
+	    buffer-undo-list t)
+      (erase-buffer))
+
+    (if (integerp asynchronous)
+	(prog1
+	    ;; Run the process.
 	    (apply 'start-file-process "*Async Shell*" buffer args)
-	  (apply 'process-file (car args) nil buffer nil (cdr args)))
-      ;; Insert error messages if they were separated.
-      (when (listp buffer)
-	(with-current-buffer error-buffer (insert-file-contents (cadr buffer)))
-	(delete-file (cadr buffer)))
-      ;; There's some output, display it.
-      (when (with-current-buffer output-buffer (> (point-max) (point-min)))
-	(if (functionp 'display-message-or-buffer)
-	    (funcall (symbol-function 'display-message-or-buffer) output-buffer)
-	  (pop-to-buffer output-buffer))))))
+	  ;; Display output.
+	  (pop-to-buffer output-buffer))
+
+      (prog1
+	  ;; Run the process.
+	  (apply 'process-file (car args) nil buffer nil (cdr args))
+	;; Insert error messages if they were separated.
+	(when (listp buffer)
+	  (with-current-buffer error-buffer
+	    (insert-file-contents (cadr buffer)))
+	  (delete-file (cadr buffer)))
+	;; There's some output, display it.
+	(when (with-current-buffer output-buffer (> (point-max) (point-min)))
+	  (if (functionp 'display-message-or-buffer)
+	      (funcall (symbol-function 'display-message-or-buffer)
+		       output-buffer)
+	    (pop-to-buffer output-buffer)))))))
 
 ;; File Editing.
 
@@ -5360,22 +5391,14 @@
 	     vec
 	     (format "PROMPT_COMMAND='' PS1='$ ' PS2='' PS3='' exec %s" shell)
 	     t))
+	  ;; Setting prompts.
 	  (tramp-message vec 5 "Setting remote shell prompt...")
-	  ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we
-	  ;; must use "\n" here, not tramp-rsh-end-of-line.  Kai left the
-	  ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
-	  ;; as well.
-	  (tramp-send-command
-	   vec
-	   (format "PS1='%s%s%s'"
-		   tramp-rsh-end-of-line
-		   tramp-end-of-output
-		   tramp-rsh-end-of-line)
-	   t)
+	  (tramp-send-command vec (format "PS1='%s'" tramp-end-of-output) t)
 	  (tramp-send-command vec "PS2=''" t)
 	  (tramp-send-command vec "PS3=''" t)
 	  (tramp-send-command vec "PROMPT_COMMAND=''" t)
 	  (tramp-message vec 5 "Setting remote shell prompt...done"))
+
 	 (t (tramp-message
 	     vec 5 "Remote `%s' groks tilde expansion, good"
 	     (tramp-get-method-parameter
@@ -5668,13 +5691,7 @@
   ;; We can set $PS1 to `tramp-end-of-output' only when the echo has
   ;; been disabled.  Otherwise, the echo of the command would be
   ;; regarded as prompt already.
-  (tramp-send-command
-   vec
-   (format "PS1='%s%s%s'"
-	   tramp-rsh-end-of-line
-           tramp-end-of-output
-	   tramp-rsh-end-of-line)
-   t)
+  (tramp-send-command vec (format "PS1='%s'" tramp-end-of-output) t)
   (tramp-send-command vec "PS2=''" t)
   (tramp-send-command vec "PS3=''" t)
   (tramp-send-command vec "PROMPT_COMMAND=''" t)
@@ -6059,6 +6076,29 @@
 	   "Method `%s' is not supported for multi-hops."
 	   (tramp-file-name-method item)))))
 
+    ;; In case the host name is not used for the remote shell
+    ;; command, the user could be misguided by applying a random
+    ;; hostname.
+    (let* ((v (car target-alist))
+	   (method (tramp-file-name-method v))
+	   (host (tramp-file-name-host v)))
+      (unless
+	  (or
+	   ;; There are multi-hops.
+	   (cdr target-alist)
+	   ;; The host name is used for the remote shell command.
+	   (member
+	    '("%h") (tramp-get-method-parameter method 'tramp-login-args))
+	   ;; The host is local.  We cannot use `tramp-local-host-p'
+	   ;; here, because it opens a connection as well.
+	   (string-match
+	    (concat "^" (regexp-opt (list "localhost" (system-name)) t) "$")
+	    host))
+	(tramp-error
+	 v 'file-error
+	 "Host `%s' looks like a remote host, `%s' can only use the local host"
+	 host method)))
+
     ;; Result.
     target-alist))
 
@@ -6249,7 +6289,11 @@
   (with-current-buffer (process-buffer proc)
     ;; Initially, `tramp-end-of-output' is "$ ".  There might be
     ;; leading escape sequences, which must be ignored.
-    (let* ((regexp (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output)))
+    (let* ((regexp
+	    (if (string-match (regexp-quote "\n") tramp-end-of-output)
+		(mapconcat
+		 'identity (split-string tramp-end-of-output "\n") "\r?\n")
+	      (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output))))
 	   (found (tramp-wait-for-regexp proc timeout regexp)))
       (if found
 	  (let (buffer-read-only)
@@ -6666,6 +6710,10 @@
 	    (user      (match-string (nth 2 tramp-file-name-structure) name))
 	    (host      (match-string (nth 3 tramp-file-name-structure) name))
 	    (localname (match-string (nth 4 tramp-file-name-structure) name)))
+	(when (member method '("multi" "multiu"))
+	  (error
+	   "`%s' method is no longer supported, see (info \"(tramp)Multi-hops\")"
+	   method))
 	(if nodefault
 	    (vector method user host localname)
 	  (vector
@@ -6731,11 +6779,20 @@
 
 (defun tramp-local-host-p (vec)
   "Return t if this points to the local host, nil otherwise."
-  (let ((host (tramp-file-name-real-host vec)))
+  ;; We cannot use `tramp-file-name-real-host'.  A port is an
+  ;; indication for an ssh tunnel or alike.
+  (let ((host (tramp-file-name-host vec)))
     (and
      (stringp host)
      (string-match
-      (concat "^" (regexp-opt (list "localhost" (system-name)) t) "$") host))))
+      (concat "^" (regexp-opt (list "localhost" (system-name)) t) "$") host)
+     ;; The local temp directory must be writable for the other user.
+     (file-writable-p
+      (tramp-make-tramp-file-name
+       (tramp-file-name-method vec)
+       (tramp-file-name-user vec)
+       host
+       (tramp-compat-temporary-file-directory))))))
 
 ;; Variables local to connection.
 
@@ -6831,8 +6888,7 @@
 	vec (format "( %s / -nt / )" (tramp-get-test-command vec)))
        (with-current-buffer (tramp-get-buffer vec)
 	 (goto-char (point-min))
-	 (when (looking-at
-		(format "\n%s\r?\n" (regexp-quote tramp-end-of-output)))
+	 (when (looking-at (regexp-quote tramp-end-of-output))
 	   (format "%s %%s -nt %%s" (tramp-get-test-command vec)))))
      (progn
        (tramp-send-command
--- a/lisp/net/trampver.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/net/trampver.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2,7 +2,8 @@
 ;;; -*- mode: Emacs-Lisp; coding: utf-8; -*-
 ;;; lisp/trampver.el.  Generated from trampver.el.in by configure.
 
-;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007,
+;;   2008 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
 ;; Keywords: comm, processes
@@ -30,14 +31,14 @@
 ;; "autoconf && ./configure" to change them.  (X)Emacs version check is defined
 ;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there.
 
-(defconst tramp-version "2.1.12"
+(defconst tramp-version "2.1.13-pre"
   "This version of Tramp.")
 
 (defconst tramp-bug-report-address "tramp-devel@gnu.org"
   "Email address to send bug reports to.")
 
 ;; Check for (X)Emacs version.
-(let ((x (if (or (< emacs-major-version 21)	(and (featurep 'xemacs)	     (< emacs-minor-version 4)))    (format "Tramp 2.1.12 is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version))))    "ok")))
+(let ((x (if (or (< emacs-major-version 21)	(and (featurep 'xemacs)	     (< emacs-minor-version 4)))    (format "Tramp 2.1.13-pre is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version))))    "ok")))
   (unless (string-match "\\`ok\\'" x) (error "%s" x)))
 
 (provide 'trampver)
--- a/lisp/nxml/nxml-enc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-enc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-enc.el --- XML encoding auto-detection
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-glyph.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-glyph.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-glyph.el --- glyph-handling for nxml-mode
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-maint.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-maint.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-maint.el --- commands for maintainers of nxml-*.el
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-mode.el --- a new XML mode
 
-;; Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
@@ -24,8 +24,6 @@
 
 ;;; Commentary:
 
-;; To use this include rng-auto.el in your .emacs.
-
 ;; See nxml-rap.el for description of parsing strategy.
 
 ;; The font locking here is independent of font-lock.el.  We want to
@@ -45,6 +43,9 @@
 (require 'nxml-rap)
 (require 'nxml-outln)
 
+(declare-function rng-nxml-mode-init "rng-nxml")
+(declare-function nxml-enable-unicode-char-name-sets "nxml-uchnm")
+
 ;;; Customization
 
 (defgroup nxml nil
@@ -479,9 +480,9 @@
 Validation is provided by the related minor-mode `rng-validate-mode'.
 This also makes completion schema- and context- sensitive.  Element
 names, attribute names, attribute values and namespace URIs can all be
-completed. By default, `rng-validate-mode' is automatically enabled by
-`rng-nxml-mode-init' which is normally added to `nxml-mode-hook'. You
-can toggle it using \\[rng-validate-mode].
+completed. By default, `rng-validate-mode' is automatically enabled. You
+can toggle it using \\[rng-validate-mode] or change the default by
+customizing `rng-nxml-auto-validate-flag'.
 
 \\[indent-for-tab-command] indents the current line appropriately.
 This can be customized using the variable `nxml-child-indent'
@@ -509,6 +510,7 @@
   (kill-all-local-variables)
   (setq major-mode 'nxml-mode)
   (setq mode-name "nXML")
+  (set (make-local-variable 'mode-line-process) '((nxml-degraded "/degraded")))
   ;; We'll determine the fill prefix ourselves
   (make-local-variable 'adaptive-fill-mode)
   (setq adaptive-fill-mode nil)
@@ -555,6 +557,8 @@
       (setq buffer-file-coding-system nxml-default-buffer-file-coding-system))
     (when nxml-auto-insert-xml-declaration-flag
       (nxml-insert-xml-declaration)))
+  (rng-nxml-mode-init)
+  (nxml-enable-unicode-char-name-sets)
   (run-hooks 'nxml-mode-hook))
 
 (defun nxml-degrade (context err)
@@ -570,8 +574,7 @@
       (nxml-with-unmodifying-text-property-changes
 	(nxml-clear-face (point-min) (point-max))
 	(nxml-set-fontified (point-min) (point-max))
-	(nxml-clear-inside (point-min) (point-max)))
-      (setq mode-name "nXML/degraded"))))
+	(nxml-clear-inside (point-min) (point-max))))))
 
 ;;; Change management
 
@@ -2433,7 +2436,7 @@
 
 ;;; Character names
 
-(defvar nxml-char-name-ignore-case nil)
+(defvar nxml-char-name-ignore-case t)
 
 (defvar nxml-char-name-alist nil
   "Alist of character names.
--- a/lisp/nxml/nxml-ns.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-ns.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-ns.el --- XML namespace processing
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-outln.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-outln.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-outln.el --- outline support for nXML mode
 
-;; Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-parse.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-parse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-parse.el --- XML parser, sharing infrastructure with nxml-mode
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-rap.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-rap.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-rap.el --- low-level support for random access parsing for nXML mode
 
-;; Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/nxml-uchnm.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-uchnm.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-uchnm.el --- support for Unicode standard cha names in nxml-mode
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
@@ -28,9 +28,6 @@
 ;; Standard.  The use of the names can be controlled on a per-block
 ;; basis, so as both to reduce memory usage and loading time,
 ;; and to make completion work better.
-;; The main entry point is `nxml-enable-unicode-char-name-sets'.  Typically,
-;; this is added to `nxml-mode-hook' (rng-auto.el does this already).
-;; To customize the blocks for which names are used
 
 ;;; Code:
 
@@ -213,7 +210,9 @@
           data-directory)))
       nxml-unicode-blocks)
 
-(defvar nxml-enable-unicode-char-name-sets-flag nil)
+;; Internal flag to control whether customize reloads the character tables.
+;; Should be set the first time the 
+(defvar nxml-internal-unicode-char-name-sets-enabled nil)
 
 (defcustom nxml-enabled-unicode-blocks nxml-enabled-unicode-blocks-default
   "List of Unicode blocks for which Unicode character names are enabled.
@@ -222,8 +221,8 @@
   :group 'nxml
   :set (lambda (sym value)
 	 (set-default 'nxml-enabled-unicode-blocks value)
-	 (when nxml-enable-unicode-char-name-sets-flag
-	   (nxml-enable-unicode-char-name-sets-1)))
+	 (when nxml-internal-unicode-char-name-sets-enabled
+	   (nxml-enable-unicode-char-name-sets)))
   :type (cons 'set
 	      (mapcar (lambda (block)
 			`(const :tag ,(format "%s (%04X-%04X)"
@@ -240,11 +239,7 @@
 The Unicode blocks for which names are enabled is controlled by
 the variable `nxml-enabled-unicode-blocks'."
   (interactive)
-  (setq nxml-char-name-ignore-case t)
-  (setq nxml-enable-unicode-char-name-sets-flag t)
-  (nxml-enable-unicode-char-name-sets-1))
-
-(defun nxml-enable-unicode-char-name-sets-1 ()
+  (setq nxml-internal-unicode-char-name-sets-enabled t)
   (mapc (lambda (block)
           (nxml-disable-char-name-set
            (nxml-unicode-block-char-name-set (car block))))
--- a/lisp/nxml/nxml-util.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/nxml-util.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; nxml-util.el --- utility functions for nxml-*.el
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/rng-cmpct.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-cmpct.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-cmpct.el --- parsing of RELAX NG Compact Syntax schemas
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-dt.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-dt.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-dt.el --- datatype library interface for RELAX NG
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-loc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-loc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-loc.el --- locate the schema to use for validation
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-maint.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-maint.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-maint.el --- commands for RELAX NG maintainers
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-match.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-match.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-match.el --- matching of RELAX NG patterns against XML events
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-nxml.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-nxml.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-nxml.el --- make nxml-mode take advantage of rng-validate-mode
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
@@ -41,10 +41,12 @@
   :type 'boolean
   :group 'relax-ng)
 
-(defvar rng-preferred-prefix-alist-default nil
-  "Default value for variable `rng-preferred-prefix-alist'.")
-
-(defcustom rng-preferred-prefix-alist rng-preferred-prefix-alist-default
+(defcustom rng-preferred-prefix-alist
+  '(("http://www.w3.org/1999/XSL/Transform" . "xsl")
+    ("http://www.w3.org/1999/02/22-rdf-syntax-ns#" . "rdf")
+    ("http://www.w3.org/1999/xlink" . "xlink")
+    ("http://www.w3.org/2001/XmlSchema" . "xsd")
+    ("http://www.w3.org/2001/XMLSchema-instance" . "xsi"))
   "*Alist of namespaces vs preferred prefixes."
   :type '(repeat (cons :tag "With"
 		       (string :tag "this namespace URI")
@@ -100,8 +102,9 @@
   (easy-menu-define rng-nxml-menu nxml-mode-map
     "Menu for nxml-mode used with rng-validate-mode."
     rng-nxml-easy-menu)
-  (setq mode-line-process
-	'(rng-validate-mode (:eval (rng-compute-mode-line-string))))
+  (add-to-list 'mode-line-process
+               '(rng-validate-mode (:eval (rng-compute-mode-line-string)))
+               'append)
   (cond (rng-nxml-auto-validate-flag
 	 (rng-validate-mode 1)
 	 (add-hook 'nxml-completion-hook 'rng-complete nil t)
--- a/lisp/nxml/rng-parse.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-parse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-parse.el --- parse an XML file and validate it against a schema
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-pttrn.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-pttrn.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-pttrn.el --- RELAX NG patterns
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-uri.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-uri.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-uri.el --- URI parsing and manipulation
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/rng-util.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-util.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-util.el --- utility functions for RELAX NG library
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-valid.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-valid.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-valid.el --- real-time validation of XML using RELAX NG
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/rng-xsd.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/rng-xsd.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; rng-xsd.el --- W3C XML Schema datatypes library for RELAX NG
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
--- a/lisp/nxml/xmltok.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/xmltok.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; xmltok.el --- XML tokenization
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
--- a/lisp/nxml/xsd-regexp.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/nxml/xsd-regexp.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; xsd-regexp.el --- translate W3C XML Schema regexps to Emacs regexps
 
-;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, regexp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/obsolete/whitespace.el	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,814 @@
+;;; whitespace.el --- warn about and clean bogus whitespaces in the file
+
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+;; Author: Rajesh Vaidheeswarran <rv@gnu.org>
+;; Keywords: convenience
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;;
+;; URL: http://www.dsmit.com/lisp/
+;;
+;; The whitespace library is intended to find and help fix five different types
+;; of whitespace problems that commonly exist in source code.
+;;
+;; 1. Leading space (empty lines at the top of a file).
+;; 2. Trailing space (empty lines at the end of a file).
+;; 3. Indentation space (8 or more spaces at beginning of line, that should be
+;;		      replaced with TABS).
+;; 4. Spaces followed by a TAB.  (Almost always, we never want that).
+;; 5. Spaces or TABS at the end of a line.
+;;
+;; Whitespace errors are reported in a buffer, and on the modeline.
+;;
+;; Modeline will show a W:<x>!<y> to denote a particular type of whitespace,
+;; where `x' and `y' can be one (or more) of:
+;;
+;; e - End-of-Line whitespace.
+;; i - Indentation whitespace.
+;; l - Leading whitespace.
+;; s - Space followed by Tab.
+;; t - Trailing whitespace.
+;;
+;; If any of the whitespace checks is turned off, the modeline will display a
+;; !<y>.
+;;
+;;     (since (3) is the most controversial one, here is the rationale: Most
+;;     terminal drivers and printer drivers have TAB configured or even
+;;     hardcoded to be 8 spaces.  (Some of them allow configuration, but almost
+;;     always they default to 8.)
+;;
+;;     Changing `tab-width' to other than 8 and editing will cause your code to
+;;     look different from within Emacs, and say, if you cat it or more it, or
+;;     even print it.
+;;
+;;     Almost all the popular programming modes let you define an offset (like
+;;     c-basic-offset or perl-indent-level) to configure the offset, so you
+;;     should never have to set your `tab-width' to be other than 8 in all
+;;     these modes.  In fact, with an indent level of say, 4, 2 TABS will cause
+;;     Emacs to replace your 8 spaces with one \t (try it).  If vi users in
+;;     your office complain, tell them to use vim, which distinguishes between
+;;     tabstop and shiftwidth (vi equivalent of our offsets), and also ask them
+;;     to set smarttab.)
+;;
+;; All the above have caused (and will cause) unwanted codeline integration and
+;; merge problems.
+;;
+;; whitespace.el will complain if it detects whitespaces on opening a file, and
+;; warn you on closing a file also (in case you had inserted any
+;; whitespaces during the process of your editing).
+;;
+;; Exported functions:
+;;
+;; `whitespace-buffer' - To check the current buffer for whitespace problems.
+;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer.
+;; `whitespace-region' - To check between point and mark for whitespace
+;;                       problems.
+;; `whitespace-cleanup-region' - To cleanup all whitespaces between point
+;;                               and mark in the current buffer.
+
+;;; Code:
+
+(defvar whitespace-version "3.5" "Version of the whitespace library.")
+
+(defvar whitespace-all-buffer-files nil
+  "An associated list of buffers and files checked for whitespace cleanliness.
+
+This is to enable periodic checking of whitespace cleanliness in the files
+visited by the buffers.")
+
+(defvar whitespace-rescan-timer nil
+  "Timer object used to rescan the files in buffers that have been modified.")
+
+;; Tell Emacs about this new kind of minor mode
+(defvar whitespace-mode nil
+  "Non-nil when Whitespace mode (a minor mode) is enabled.")
+(make-variable-buffer-local 'whitespace-mode)
+
+(defvar whitespace-mode-line nil
+  "String to display in the mode line for Whitespace mode.")
+(make-variable-buffer-local 'whitespace-mode-line)
+
+(defvar whitespace-check-buffer-leading nil
+  "Test leading whitespace for file in current buffer if t.")
+(make-variable-buffer-local 'whitespace-check-buffer-leading)
+;;;###autoload(put 'whitespace-check-buffer-leading 'safe-local-variable 'booleanp)
+
+(defvar whitespace-check-buffer-trailing nil
+  "Test trailing whitespace for file in current buffer if t.")
+(make-variable-buffer-local 'whitespace-check-buffer-trailing)
+;;;###autoload(put 'whitespace-check-buffer-trailing 'safe-local-variable 'booleanp)
+
+(defvar whitespace-check-buffer-indent nil
+  "Test indentation whitespace for file in current buffer if t.")
+(make-variable-buffer-local 'whitespace-check-buffer-indent)
+;;;###autoload(put 'whitespace-check-buffer-indent 'safe-local-variable 'booleanp)
+
+(defvar whitespace-check-buffer-spacetab nil
+  "Test Space-followed-by-TABS whitespace for file in current buffer if t.")
+(make-variable-buffer-local 'whitespace-check-buffer-spacetab)
+;;;###autoload(put 'whitespace-check-buffer-spacetab 'safe-local-variable 'booleanp)
+
+(defvar whitespace-check-buffer-ateol nil
+  "Test end-of-line whitespace for file in current buffer if t.")
+(make-variable-buffer-local 'whitespace-check-buffer-ateol)
+;;;###autoload(put 'whitespace-check-buffer-ateol 'safe-local-variable 'booleanp)
+
+(defvar whitespace-highlighted-space nil
+  "The variable to store the extent to highlight.")
+(make-variable-buffer-local 'whitespace-highlighted-space)
+
+(defalias 'whitespace-make-overlay
+  (if (featurep 'xemacs) 'make-extent 'make-overlay))
+(defalias 'whitespace-overlay-put
+  (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
+(defalias 'whitespace-delete-overlay
+  (if (featurep 'xemacs) 'delete-extent 'delete-overlay))
+(defalias 'whitespace-overlay-start
+  (if (featurep 'xemacs) 'extent-start 'overlay-start))
+(defalias 'whitespace-overlay-end
+  (if (featurep 'xemacs) 'extent-end 'overlay-end))
+(defalias 'whitespace-mode-line-update
+  (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update))
+
+(defgroup whitespace nil
+  "Check for and fix five different types of whitespaces in source code."
+  :version "21.1"
+  :link '(emacs-commentary-link "whitespace.el")
+  ;; Since XEmacs doesn't have a 'convenience group, use the next best group
+  ;; which is 'editing?
+  :group (if (featurep 'xemacs) 'editing 'convenience))
+
+(defcustom whitespace-check-leading-whitespace t
+  "Flag to check leading whitespace.  This is the global for the system.
+It can be overridden by setting a buffer local variable
+`whitespace-check-buffer-leading'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-check-trailing-whitespace t
+  "Flag to check trailing whitespace.  This is the global for the system.
+It can be overridden by setting a buffer local variable
+`whitespace-check-buffer-trailing'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-check-spacetab-whitespace t
+  "Flag to check space followed by a TAB.  This is the global for the system.
+It can be overridden by setting a buffer local variable
+`whitespace-check-buffer-spacetab'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-spacetab-regexp "[ ]+\t"
+  "Regexp to match one or more spaces followed by a TAB."
+  :type 'regexp
+  :group 'whitespace)
+
+(defcustom whitespace-check-indent-whitespace indent-tabs-mode
+  "Flag to check indentation whitespace.  This is the global for the system.
+It can be overridden by setting a buffer local variable
+`whitespace-check-buffer-indent'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-indent-regexp "^\t*\\(        \\)+"
+  "Regexp to match multiples of eight spaces near line beginnings.
+The default value ignores leading TABs."
+  :type 'regexp
+  :group 'whitespace)
+
+(defcustom whitespace-check-ateol-whitespace t
+  "Flag to check end-of-line whitespace.  This is the global for the system.
+It can be overridden by setting a buffer local variable
+`whitespace-check-buffer-ateol'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-ateol-regexp "[ \t]+$"
+  "Regexp to match one or more TABs or spaces at line ends."
+  :type 'regexp
+  :group 'whitespace)
+
+(defcustom whitespace-errbuf "*Whitespace Errors*"
+  "The name of the buffer where whitespace related messages will be logged."
+  :type 'string
+  :group 'whitespace)
+
+(defcustom whitespace-clean-msg "clean."
+  "If non-nil, this message will be displayed after a whitespace check
+determines a file to be clean."
+  :type 'string
+  :group 'whitespace)
+
+(defcustom whitespace-abort-on-error nil
+  "While writing a file, abort if the file is unclean.
+If `whitespace-auto-cleanup' is set, that takes precedence over
+this variable."
+  :type  'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-auto-cleanup nil
+  "Cleanup a buffer automatically on finding it whitespace unclean."
+  :type  'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-silent nil
+  "All whitespace errors will be shown only in the modeline when t.
+
+Note that setting this may cause all whitespaces introduced in a file to go
+unnoticed when the buffer is killed, unless the user visits the `*Whitespace
+Errors*' buffer before opening (or closing) another file."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-modes '(ada-mode asm-mode autoconf-mode awk-mode
+				       c-mode c++-mode cc-mode
+				       change-log-mode cperl-mode
+				       electric-nroff-mode emacs-lisp-mode
+				       f90-mode fortran-mode html-mode
+				       html3-mode java-mode jde-mode
+				       ksh-mode latex-mode LaTeX-mode
+				       lisp-mode m4-mode makefile-mode
+				       modula-2-mode nroff-mode objc-mode
+				       pascal-mode perl-mode prolog-mode
+				       python-mode scheme-mode sgml-mode
+				       sh-mode shell-script-mode simula-mode
+				       tcl-mode tex-mode texinfo-mode
+				       vrml-mode xml-mode)
+
+  "Major modes in which we turn on whitespace checking.
+
+These are mostly programming and documentation modes.  But you may add other
+modes that you want whitespaces checked in by adding something like the
+following to your `.emacs':
+
+\(setq whitespace-modes (cons 'my-mode (cons 'my-other-mode
+					    whitespace-modes))\)
+
+Or, alternately, you can use the Emacs `customize' command to set this."
+  :type '(repeat symbol)
+  :group 'whitespace)
+
+(defcustom whitespace-rescan-timer-time 600
+  "Period in seconds to rescan modified buffers for whitespace creep.
+
+This is the period after which the timer will fire causing
+`whitespace-rescan-files-in-buffers' to check for whitespace creep in
+modified buffers.
+
+To disable timer scans, set this to zero."
+  :type 'integer
+  :group 'whitespace)
+
+(defcustom whitespace-display-in-modeline t
+  "Display whitespace errors on the modeline."
+  :type 'boolean
+  :group 'whitespace)
+
+(defcustom whitespace-display-spaces-in-color t
+  "Display the bogus whitespaces by coloring them with the face
+`whitespace-highlight'."
+  :type 'boolean
+  :group 'whitespace)
+
+(defgroup whitespace-faces nil
+  "Faces used in whitespace."
+  :prefix "whitespace-"
+  :group 'whitespace
+  :group 'faces)
+
+(defface whitespace-highlight '((((class color) (background light))
+				 (:background "green1"))
+				(((class color) (background dark))
+				 (:background "sea green"))
+				(((class grayscale mono)
+				  (background light))
+				 (:background "black"))
+				(((class grayscale mono)
+				  (background dark))
+				 (:background "white")))
+  "Face used for highlighting the bogus whitespaces that exist in the buffer."
+  :group 'whitespace-faces)
+;; backward-compatibility alias
+(put 'whitespace-highlight-face 'face-alias 'whitespace-highlight)
+
+(if (not (assoc 'whitespace-mode minor-mode-alist))
+    (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line)
+				 minor-mode-alist)))
+
+(set-default 'whitespace-check-buffer-leading
+	     whitespace-check-leading-whitespace)
+(set-default 'whitespace-check-buffer-trailing
+	     whitespace-check-trailing-whitespace)
+(set-default 'whitespace-check-buffer-indent
+	     whitespace-check-indent-whitespace)
+(set-default 'whitespace-check-buffer-spacetab
+	     whitespace-check-spacetab-whitespace)
+(set-default 'whitespace-check-buffer-ateol
+	     whitespace-check-ateol-whitespace)
+
+(defun whitespace-check-whitespace-mode (&optional arg)
+  "Test and set the whitespace-mode in qualifying buffers."
+  (if (null whitespace-mode)
+      (setq whitespace-mode
+	    (if (or arg (member major-mode whitespace-modes))
+		t
+	      nil))))
+
+;;;###autoload
+(defun whitespace-toggle-leading-check ()
+  "Toggle the check for leading space in the local buffer."
+  (interactive)
+  (let ((current-val whitespace-check-buffer-leading))
+    (setq whitespace-check-buffer-leading (not current-val))
+    (message "Will%s check for leading space in buffer."
+	     (if whitespace-check-buffer-leading "" " not"))
+    (if whitespace-check-buffer-leading (whitespace-buffer-leading))))
+
+;;;###autoload
+(defun whitespace-toggle-trailing-check ()
+  "Toggle the check for trailing space in the local buffer."
+  (interactive)
+  (let ((current-val whitespace-check-buffer-trailing))
+    (setq whitespace-check-buffer-trailing (not current-val))
+    (message "Will%s check for trailing space in buffer."
+	     (if whitespace-check-buffer-trailing "" " not"))
+    (if whitespace-check-buffer-trailing (whitespace-buffer-trailing))))
+
+;;;###autoload
+(defun whitespace-toggle-indent-check ()
+  "Toggle the check for indentation space in the local buffer."
+  (interactive)
+  (let ((current-val whitespace-check-buffer-indent))
+    (setq whitespace-check-buffer-indent (not current-val))
+    (message "Will%s check for indentation space in buffer."
+	     (if whitespace-check-buffer-indent "" " not"))
+    (if whitespace-check-buffer-indent
+	(whitespace-buffer-search whitespace-indent-regexp))))
+
+;;;###autoload
+(defun whitespace-toggle-spacetab-check ()
+  "Toggle the check for space-followed-by-TABs in the local buffer."
+  (interactive)
+  (let ((current-val whitespace-check-buffer-spacetab))
+    (setq whitespace-check-buffer-spacetab (not current-val))
+    (message "Will%s check for space-followed-by-TABs in buffer."
+	     (if whitespace-check-buffer-spacetab "" " not"))
+    (if whitespace-check-buffer-spacetab
+	(whitespace-buffer-search whitespace-spacetab-regexp))))
+
+
+;;;###autoload
+(defun whitespace-toggle-ateol-check ()
+  "Toggle the check for end-of-line space in the local buffer."
+  (interactive)
+  (let ((current-val whitespace-check-buffer-ateol))
+    (setq whitespace-check-buffer-ateol (not current-val))
+    (message "Will%s check for end-of-line space in buffer."
+	     (if whitespace-check-buffer-ateol "" " not"))
+    (if whitespace-check-buffer-ateol
+	(whitespace-buffer-search whitespace-ateol-regexp))))
+
+
+;;;###autoload
+(defun whitespace-buffer (&optional quiet)
+  "Find five different types of white spaces in buffer.
+These are:
+1. Leading space \(empty lines at the top of a file\).
+2. Trailing space \(empty lines at the end of a file\).
+3. Indentation space \(8 or more spaces, that should be replaced with TABS\).
+4. Spaces followed by a TAB. \(Almost always, we never want that\).
+5. Spaces or TABS at the end of a line.
+
+Check for whitespace only if this buffer really contains a non-empty file
+and:
+1. the major mode is one of the whitespace-modes, or
+2. `whitespace-buffer' was explicitly called with a prefix argument."
+  (interactive)
+  (let ((whitespace-error nil))
+    (whitespace-check-whitespace-mode current-prefix-arg)
+    (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode)
+	(progn
+	  (whitespace-check-buffer-list (buffer-name) buffer-file-name)
+	  (whitespace-tickle-timer)
+	  (overlay-recenter (point-max))
+	  (remove-overlays nil nil 'face 'whitespace-highlight)
+	  (if whitespace-auto-cleanup
+	      (if buffer-read-only
+		  (if (not quiet)
+		      (message "Can't cleanup: %s is read-only" (buffer-name)))
+		(whitespace-cleanup-internal))
+	    (let ((whitespace-leading (if whitespace-check-buffer-leading
+					  (whitespace-buffer-leading)
+					nil))
+		  (whitespace-trailing (if whitespace-check-buffer-trailing
+					   (whitespace-buffer-trailing)
+					 nil))
+		  (whitespace-indent (if whitespace-check-buffer-indent
+					 (whitespace-buffer-search
+					  whitespace-indent-regexp)
+				       nil))
+		  (whitespace-spacetab (if whitespace-check-buffer-spacetab
+					   (whitespace-buffer-search
+					    whitespace-spacetab-regexp)
+					 nil))
+		  (whitespace-ateol (if whitespace-check-buffer-ateol
+					(whitespace-buffer-search
+					 whitespace-ateol-regexp)
+				      nil))
+		  (whitespace-errmsg nil)
+		  (whitespace-filename buffer-file-name)
+		  (whitespace-this-modeline ""))
+
+	      ;; Now let's complain if we found any of the above.
+	      (setq whitespace-error (or whitespace-leading whitespace-indent
+					 whitespace-spacetab whitespace-ateol
+					 whitespace-trailing))
+
+	      (if whitespace-error
+		  (progn
+		    (setq whitespace-errmsg
+			  (concat whitespace-filename " contains:\n"
+				  (if whitespace-leading
+				      "Leading whitespace\n")
+				  (if whitespace-indent
+				      (concat "Indentation whitespace"
+					      whitespace-indent "\n"))
+				  (if whitespace-spacetab
+				      (concat "Space followed by Tab"
+					      whitespace-spacetab "\n"))
+				  (if whitespace-ateol
+				      (concat "End-of-line whitespace"
+					      whitespace-ateol "\n"))
+				  (if whitespace-trailing
+				      "Trailing whitespace\n")
+				  "\ntype `M-x whitespace-cleanup' to "
+				  "cleanup the file."))
+		    (setq whitespace-this-modeline
+			  (concat (if whitespace-ateol "e")
+				  (if whitespace-indent "i")
+				  (if whitespace-leading "l")
+				  (if whitespace-spacetab "s")
+				  (if whitespace-trailing "t")))))
+	      (whitespace-update-modeline whitespace-this-modeline)
+	      (if (get-buffer whitespace-errbuf)
+		  (kill-buffer whitespace-errbuf))
+	      (with-current-buffer (get-buffer-create whitespace-errbuf)
+		(if whitespace-errmsg
+		    (progn
+		      (insert whitespace-errmsg)
+		      (if (not (or quiet whitespace-silent))
+			  (display-buffer (current-buffer) t))
+		      (if (not quiet)
+			  (message "Whitespaces: [%s%s] in %s"
+				   whitespace-this-modeline
+				   (let ((whitespace-unchecked
+					  (whitespace-unchecked-whitespaces)))
+				     (if whitespace-unchecked
+					 (concat "!" whitespace-unchecked)
+				       ""))
+				   whitespace-filename)))
+		  (if (and (not quiet) (not (equal whitespace-clean-msg "")))
+		      (message "%s %s" whitespace-filename
+			       whitespace-clean-msg))))))))
+    whitespace-error))
+
+;;;###autoload
+(defun whitespace-region (s e)
+  "Check the region for whitespace errors."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region s e)
+      (whitespace-buffer))))
+
+;;;###autoload
+(defun whitespace-cleanup ()
+  "Cleanup the five different kinds of whitespace problems.
+It normally applies to the whole buffer, but in Transient Mark mode
+when the mark is active it applies to the region.
+See `whitespace-buffer' docstring for a summary of the problems."
+  (interactive)
+  (if (and transient-mark-mode mark-active)
+      (whitespace-cleanup-region (region-beginning) (region-end))
+    (whitespace-cleanup-internal)))
+
+(defun whitespace-cleanup-internal (&optional region-only)
+  ;; If this buffer really contains a file, then run, else quit.
+  (whitespace-check-whitespace-mode current-prefix-arg)
+  (if (and buffer-file-name whitespace-mode)
+      (let ((whitespace-any nil)
+	    (whitespace-tabwith 8)
+	    (whitespace-tabwith-saved tab-width))
+
+	;; since all printable TABS should be 8, irrespective of how
+	;; they are displayed.
+	(setq tab-width whitespace-tabwith)
+
+	(if (and whitespace-check-buffer-leading
+		 (whitespace-buffer-leading))
+	    (progn
+	      (whitespace-buffer-leading-cleanup)
+	      (setq whitespace-any t)))
+
+	(if (and whitespace-check-buffer-trailing
+		 (whitespace-buffer-trailing))
+	    (progn
+	      (whitespace-buffer-trailing-cleanup)
+	      (setq whitespace-any t)))
+
+	(if (and whitespace-check-buffer-indent
+		 (whitespace-buffer-search whitespace-indent-regexp))
+	    (progn
+	      (whitespace-indent-cleanup)
+	      (setq whitespace-any t)))
+
+	(if (and whitespace-check-buffer-spacetab
+		 (whitespace-buffer-search whitespace-spacetab-regexp))
+	    (progn
+	      (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t")
+	      (setq whitespace-any t)))
+
+	(if (and whitespace-check-buffer-ateol
+		 (whitespace-buffer-search whitespace-ateol-regexp))
+	    (progn
+	      (whitespace-buffer-cleanup whitespace-ateol-regexp "")
+	      (setq whitespace-any t)))
+
+	;; Call this recursively till everything is taken care of
+	(if whitespace-any
+	    (whitespace-cleanup-internal region-only)
+	  ;; if we are done, talk to the user
+	  (progn
+	    (unless whitespace-silent
+	      (if region-only
+		  (message "The region is now clean")
+		(message "%s is now clean" buffer-file-name)))
+	    (whitespace-update-modeline)))
+	(setq tab-width whitespace-tabwith-saved))))
+
+;;;###autoload
+(defun whitespace-cleanup-region (s e)
+  "Whitespace cleanup on the region."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region s e)
+      (whitespace-cleanup-internal t))
+    (whitespace-buffer t)))
+
+(defun whitespace-buffer-leading ()
+  "Return t if the current buffer has leading newline characters.
+If highlighting is enabled, highlight these characters."
+  (save-excursion
+    (goto-char (point-min))
+    (skip-chars-forward "\n")
+    (unless (bobp)
+      (whitespace-highlight-the-space (point-min) (point))
+      t)))
+
+(defun whitespace-buffer-leading-cleanup ()
+  "Remove any leading newline characters from current buffer."
+  (save-excursion
+    (goto-char (point-min))
+    (skip-chars-forward "\n")
+    (delete-region (point-min) (point))))
+
+(defun whitespace-buffer-trailing ()
+  "Return t if the current buffer has extra trailing newline characters.
+If highlighting is enabled, highlight these characters."
+  (save-excursion
+    (goto-char (point-max))
+    (skip-chars-backward "\n")
+    (forward-line)
+    (unless (eobp)
+      (whitespace-highlight-the-space (point) (point-max))
+      t)))
+
+(defun whitespace-buffer-trailing-cleanup ()
+  "Remove extra trailing newline characters from current buffer."
+  (save-excursion
+    (goto-char (point-max))
+    (skip-chars-backward "\n")
+    (unless (eobp)
+      (forward-line)
+      (delete-region (point) (point-max)))))
+
+(defun whitespace-buffer-search (regexp)
+  "Search for any given whitespace REGEXP."
+  (with-local-quit
+    (let (whitespace-retval)
+      (save-excursion
+	(goto-char (point-min))
+	(while (re-search-forward regexp nil t)
+	  (whitespace-highlight-the-space (match-beginning 0) (match-end 0))
+	  (push (match-beginning 0) whitespace-retval)))
+      (when whitespace-retval
+	(format " %s" (nreverse whitespace-retval))))))
+
+(defun whitespace-buffer-cleanup (regexp newregexp)
+  "Search for any given whitespace REGEXP and replace it with the NEWREGEXP."
+  (save-excursion
+    (goto-char (point-min))
+    (while (re-search-forward regexp nil t)
+      (replace-match newregexp))))
+
+(defun whitespace-indent-cleanup ()
+  "Search for 8/more spaces at the start of a line and replace it with tabs."
+  (save-excursion
+    (goto-char (point-min))
+    (while (re-search-forward whitespace-indent-regexp nil t)
+      (let ((column (current-column))
+	    (indent-tabs-mode t))
+	(delete-region (match-beginning 0) (point))
+	(indent-to column)))))
+
+(defun whitespace-unchecked-whitespaces ()
+  "Return the list of whitespaces whose testing has been suppressed."
+  (let ((unchecked-spaces
+	 (concat (if (not whitespace-check-buffer-ateol) "e")
+		 (if (not whitespace-check-buffer-indent) "i")
+		 (if (not whitespace-check-buffer-leading) "l")
+		 (if (not whitespace-check-buffer-spacetab) "s")
+		 (if (not whitespace-check-buffer-trailing) "t"))))
+    (if (not (equal unchecked-spaces ""))
+	unchecked-spaces
+      nil)))
+
+(defun whitespace-update-modeline (&optional whitespace-err)
+  "Update modeline with whitespace errors.
+Also with whitespaces whose testing has been turned off."
+  (if whitespace-display-in-modeline
+      (progn
+	(setq whitespace-mode-line nil)
+	;; Whitespace errors
+	(if (and whitespace-err (not (equal whitespace-err "")))
+	    (setq whitespace-mode-line whitespace-err))
+	;; Whitespace suppressed errors
+	(let ((whitespace-unchecked (whitespace-unchecked-whitespaces)))
+	  (if whitespace-unchecked
+	      (setq whitespace-mode-line
+		    (concat whitespace-mode-line "!" whitespace-unchecked))))
+	;; Add the whitespace modeline prefix
+	(setq whitespace-mode-line (if whitespace-mode-line
+				       (concat " W:" whitespace-mode-line)
+				     nil))
+	(whitespace-mode-line-update))))
+
+(defun whitespace-highlight-the-space (b e)
+  "Highlight the current line, unhighlighting a previously jumped to line."
+  (if whitespace-display-spaces-in-color
+      (let ((ol (whitespace-make-overlay b e)))
+	(whitespace-overlay-put ol 'face 'whitespace-highlight))))
+
+(defun whitespace-unhighlight-the-space()
+  "Unhighlight the currently highlight line."
+  (if (and whitespace-display-spaces-in-color whitespace-highlighted-space)
+      (progn
+	(mapc 'whitespace-delete-overlay whitespace-highlighted-space)
+	(setq whitespace-highlighted-space nil))))
+
+(defun whitespace-check-buffer-list (buf-name buf-file)
+  "Add a buffer and its file to the whitespace monitor list.
+
+The buffer named BUF-NAME and its associated file BUF-FILE are now monitored
+periodically for whitespace."
+  (if (and whitespace-mode (not (member (list buf-file buf-name)
+					whitespace-all-buffer-files)))
+      (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name))))
+
+(defun whitespace-tickle-timer ()
+  "Tickle timer to periodically to scan qualifying files for whitespace creep.
+
+If timer is not set, then set it to scan the files in
+`whitespace-all-buffer-files' periodically (defined by
+`whitespace-rescan-timer-time') for whitespace creep."
+  (if (and whitespace-rescan-timer-time
+	   (/= whitespace-rescan-timer-time 0)
+	   (not whitespace-rescan-timer))
+      (setq whitespace-rescan-timer
+	    (add-timeout whitespace-rescan-timer-time
+			 'whitespace-rescan-files-in-buffers nil
+			 whitespace-rescan-timer-time))))
+
+(defun whitespace-rescan-files-in-buffers (&optional arg)
+  "Check monitored files for whitespace creep since last scan."
+  (let ((whitespace-all-my-files whitespace-all-buffer-files)
+	buffile bufname thiselt buf)
+    (if (not whitespace-all-my-files)
+	(progn
+	  (disable-timeout whitespace-rescan-timer)
+	  (setq whitespace-rescan-timer nil))
+      (while whitespace-all-my-files
+	(setq thiselt (car whitespace-all-my-files))
+	(setq whitespace-all-my-files (cdr whitespace-all-my-files))
+	(setq buffile (car thiselt))
+	(setq bufname (cadr thiselt))
+	(setq buf (get-buffer bufname))
+	(if (buffer-live-p buf)
+	    (save-excursion
+	      ;;(message "buffer %s live" bufname)
+	      (set-buffer bufname)
+	      (if whitespace-mode
+		  (progn
+		    ;;(message "checking for whitespace in %s" bufname)
+		    (if whitespace-auto-cleanup
+			(progn
+			  ;;(message "cleaning up whitespace in %s" bufname)
+			  (whitespace-cleanup-internal))
+		      (progn
+			;;(message "whitespace-buffer %s." (buffer-name))
+			(whitespace-buffer t))))
+		;;(message "Removing %s from refresh list" bufname)
+		(whitespace-refresh-rescan-list buffile bufname)))
+	  ;;(message "Removing %s from refresh list" bufname)
+	  (whitespace-refresh-rescan-list buffile bufname))))))
+
+(defun whitespace-refresh-rescan-list (buffile bufname)
+  "Refresh the list of files to be rescanned for whitespace creep."
+  (if whitespace-all-buffer-files
+      (setq whitespace-all-buffer-files
+	    (delete (list buffile bufname) whitespace-all-buffer-files))
+    (when whitespace-rescan-timer
+      (disable-timeout whitespace-rescan-timer)
+      (setq whitespace-rescan-timer nil))))
+
+;;;###autoload
+(defalias 'global-whitespace-mode 'whitespace-global-mode)
+
+;;;###autoload
+(define-minor-mode whitespace-global-mode
+  "Toggle using Whitespace mode in new buffers.
+With ARG, turn the mode on if ARG is positive, otherwise turn it off.
+
+When this mode is active, `whitespace-buffer' is added to
+`find-file-hook' and `kill-buffer-hook'."
+  :global t
+  :group 'whitespace
+  (if whitespace-global-mode
+      (progn
+	(add-hook 'find-file-hook 'whitespace-buffer)
+	(add-hook 'write-file-functions 'whitespace-write-file-hook nil t)
+	(add-hook 'kill-buffer-hook 'whitespace-buffer))
+    (remove-hook 'find-file-hook 'whitespace-buffer)
+    (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
+    (remove-hook 'kill-buffer-hook 'whitespace-buffer)))
+
+;;;###autoload
+(defun whitespace-write-file-hook ()
+  "Hook function to be called on the buffer when whitespace check is enabled.
+This is meant to be added buffer-locally to `write-file-functions'."
+  (let ((werr nil))
+    (if whitespace-auto-cleanup
+	(whitespace-cleanup-internal)
+      (setq werr (whitespace-buffer)))
+    (if (and whitespace-abort-on-error werr)
+	(error "Abort write due to whitespaces in %s"
+		       buffer-file-name)))
+  nil)
+
+(defun whitespace-unload-function ()
+  "Unload the whitespace library."
+  (if (unintern "whitespace-unload-hook")
+      ;; if whitespace-unload-hook is defined, let's get rid of it
+      ;; and recursively call `unload-feature'
+      (progn (unload-feature 'whitespace) t)
+    ;; this only happens in the recursive call
+    (whitespace-global-mode -1)
+    (save-current-buffer
+      (dolist (buf (buffer-list))
+	(set-buffer buf)
+	(remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
+    ;; continue standard unloading
+    nil))
+
+(defun whitespace-unload-hook ()
+  (remove-hook 'find-file-hook 'whitespace-buffer)
+  (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
+  (remove-hook 'kill-buffer-hook 'whitespace-buffer))
+
+(add-hook 'whitespace-unload-hook 'whitespace-unload-hook)
+
+(provide 'whitespace)
+
+;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c
+;;; whitespace.el ends here
--- a/lisp/outline.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/outline.el	Wed Jan 30 07:57:28 2008 +0000
@@ -971,8 +971,8 @@
        (or (eq last-command 'outline-up-heading) (push-mark)))
   (outline-back-to-heading invisible-ok)
   (let ((start-level (funcall outline-level)))
-    (if (eq start-level 1)
-	(error "Already at top level of the outline"))
+    (when (<= start-level 1)
+      (error "Already at top level of the outline"))
     (while (and (> start-level 1) (> arg 0) (not (bobp)))
       (let ((level start-level))
 	(while (not (or (< level start-level) (bobp)))
--- a/lisp/password-cache.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/password-cache.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; password-cache.el --- Read passwords, possibly using a password cache.
 
-;; Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007
+;; Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <simon@josefsson.org>
--- a/lisp/pcvs-defs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/pcvs-defs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -404,8 +404,8 @@
 
 (easy-menu-define cvs-menu cvs-mode-map "Menu used in `cvs-mode'."
   '("CVS"
-    ["Open file.."		cvs-mode-find-file	t]
-    [" ..other window"		cvs-mode-find-file-other-window	t]
+    ["Open file"		cvs-mode-find-file	t]
+    ["Open in other window"	cvs-mode-find-file-other-window	t]
     ["Display in other window"  cvs-mode-display-file   t]
     ["Interactive merge"	cvs-mode-imerge		t]
     ("View diff"
@@ -413,6 +413,7 @@
      ["Current diff"		cvs-mode-diff		t]
      ["Diff with head"		cvs-mode-diff-head	t]
      ["Diff with vendor"	cvs-mode-diff-vendor	t]
+     ["Diff against yesterday"	cvs-mode-diff-yesterday	t]
      ["Diff with backup"	cvs-mode-diff-backup	t])
     ["View log"			cvs-mode-log		t]
     ["View status"		cvs-mode-status		t]
@@ -437,6 +438,9 @@
     ["Unmark all"		cvs-mode-unmark-all-files t]
     ["Hide handled"		cvs-mode-remove-handled	t]
     "----"
+    ["PCL-CVS Manual"		(lambda () (interactive)
+				  (info "(pcl-cvs)Top")) t]
+    "----"
     ["Quit"			cvs-mode-quit		t]))
 
 ;;;;
--- a/lisp/pcvs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/pcvs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2311,7 +2311,7 @@
 	    ;; do want to reset the mode for VC, so we do it explicitly.
 	    (vc-find-file-hook)
 	    (when (eq (cvs-fileinfo->type fileinfo) 'CONFLICT)
-	      (smerge-mode 1))))))))
+	      (smerge-start-session))))))))
 
 
 (defun cvs-change-cvsroot (newroot)
--- a/lisp/play/blackbox.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/play/blackbox.el	Wed Jan 30 07:57:28 2008 +0000
@@ -106,7 +106,9 @@
     (blackbox-redefine-key map 'move-end-of-line 'bb-eol)
     (blackbox-redefine-key map 'move-beginning-of-line 'bb-bol)
     (define-key map " " 'bb-romp)
+    (define-key map "q" 'bury-buffer)
     (define-key map [insert] 'bb-romp)
+    (define-key map [return] 'bb-done)
     (blackbox-redefine-key map 'newline 'bb-done)
     map))
 
--- a/lisp/play/bubbles.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/play/bubbles.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; bubbles.el --- Puzzle game for Emacs.
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <ulf.jasper@web.de>
 ;; URL:         http://ulf.epplejasper.de/
--- a/lisp/progmodes/ada-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/ada-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -930,7 +930,8 @@
 	(buffer-undo-list t)
 	(inhibit-read-only t)
 	(inhibit-point-motion-hooks t)
-	(inhibit-modification-hooks t))
+	(inhibit-modification-hooks t)
+	buffer-file-name buffer-file-truename)
     (remove-text-properties (point-min) (point-max) '(syntax-table nil))
     (goto-char (point-min))
     (while (re-search-forward
@@ -4954,11 +4955,11 @@
 ;; cursor at the correct position.
 ;; Standard Ada does not force any relation between unit names and file names,
 ;; so some of these functions can only be a good approximation. However, they
-;; are also overriden in `ada-xref'.el when we know that the user is using
+;; are also overridden in `ada-xref'.el when we know that the user is using
 ;; GNAT.
 ;; ---------------------------------------------------
 
-;; Overriden when we work with GNAT, to use gnatkrunch
+;; Overridden when we work with GNAT, to use gnatkrunch
 (defun ada-make-filename-from-adaname (adaname)
   "Determine the filename in which ADANAME is found.
 This matches the GNAT default naming convention, except for
--- a/lisp/progmodes/ada-xref.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/ada-xref.el	Wed Jan 30 07:57:28 2008 +0000
@@ -617,7 +617,7 @@
 
 (defun ada-convert-file-name (name)
   "Convert from NAME to a name that can be used by the compilation commands.
-This is overriden on VMS to convert from VMS filenames to Unix filenames."
+This is overridden on VMS to convert from VMS filenames to Unix filenames."
   name)
 ;; FIXME: use convert-standard-filename instead
 
--- a/lisp/progmodes/cc-awk.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-awk.el	Wed Jan 30 07:57:28 2008 +0000
@@ -478,7 +478,7 @@
 
 (defun c-awk-get-NL-prop-prev-line (&optional do-lim)
   ;; Get the c-awk-NL-prop text-property from the previous line, calculating
-  ;; it if necessary.  Return nil if we're at BOB.
+  ;; it if necessary.  Return nil if we're already at BOB.
   ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
   ;;
   ;; This function might do hidden buffer changes.
--- a/lisp/progmodes/cc-cmds.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-cmds.el	Wed Jan 30 07:57:28 2008 +0000
@@ -524,7 +524,11 @@
 	;; This is the list of brace syntactic symbols that can hang.
 	;; If any new ones are added to c-offsets-alist, they should be
 	;; added here as well.
-	'(class-open class-close defun-open defun-close
+	;; 
+	;; The order of this list is important; if SYNTAX has several
+	;; elements, the element that "wins" is the earliest in SYMS.
+	'(arglist-cont-nonempty		; e.g. an array literal.
+		     class-open class-close defun-open defun-close
 		     inline-open inline-close
 		     brace-list-open brace-list-close
 		     brace-list-intro brace-entry-open
--- a/lisp/progmodes/cc-defs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-defs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -96,7 +96,7 @@
 
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.31.4"
+(defconst c-version "5.31.5"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -425,6 +425,8 @@
 	  (inhibit-read-only t) (inhibit-point-motion-hooks t)
 	  before-change-functions after-change-functions
 	  deactivate-mark
+	  buffer-file-name buffer-file-truename ; Prevent primitives checking
+						; for file modification
 	  ,@varlist)
      (unwind-protect
 	 (progn ,@body)
--- a/lisp/progmodes/cc-engine.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-engine.el	Wed Jan 30 07:57:28 2008 +0000
@@ -5094,7 +5094,8 @@
   ;;
   ;;   The point is left at the first token after the first complete
   ;;   declarator, if there is one.  The return value is a cons where
-  ;;   the car is the position of the first token in the declarator.
+  ;;   the car is the position of the first token in the declarator.  (See
+  ;;   below for the cdr.)
   ;;   Some examples:
   ;;
   ;; 	 void foo (int a, char *b) stuff ...
@@ -5118,9 +5119,9 @@
   ;;     Foo::Foo (int b) : Base (b) {}
   ;; car ^                ^ point
   ;;
-  ;;   The cdr of the return value is non-nil if a
-  ;;   `c-typedef-decl-kwds' specifier is found in the declaration,
-  ;;   i.e. the declared identifier(s) are types.
+  ;;   The cdr of the return value is non-nil iff a `c-typedef-decl-kwds'
+  ;;   specifier (e.g. class, struct, enum, typedef) is found in the
+  ;;   declaration, i.e. the declared identifier(s) are types.
   ;;
   ;; If a cast is parsed:
   ;;
@@ -5135,7 +5136,7 @@
   ;; the first token in (the visible part of) the buffer.
   ;;
   ;; CONTEXT is a symbol that describes the context at the point:
-  ;; 'decl     In a comma-separatded declaration context (typically
+  ;; 'decl     In a comma-separated declaration context (typically
   ;;           inside a function declaration arglist).
   ;; '<>       In an angle bracket arglist.
   ;; 'arglist  Some other type of arglist.
@@ -8032,12 +8033,15 @@
 
 	     ;; CASE 5A.5: ordinary defun open
 	     (t
-	      (goto-char placeholder)
-	      (if (or containing-decl-open macro-start)
-		  (c-add-syntax 'defun-open (c-point 'boi))
-		;; Bogus to use bol here, but it's the legacy.
-		(c-add-syntax 'defun-open (c-point 'bol)))
-	      )))
+	      (save-excursion
+		(c-beginning-of-decl-1 lim)
+		(while (looking-at c-specifier-key)
+		  (goto-char (match-end 1))
+		  (c-forward-syntactic-ws indent-point))
+		(c-add-syntax 'defun-open (c-point 'boi))
+		;; Bogus to use bol here, but it's the legacy.  (Resolved,
+		;; 2007-11-09)
+		))))
 
 	   ;; CASE 5B: After a function header but before the body (or
 	   ;; the ending semicolon if there's no body).
@@ -8296,6 +8300,7 @@
 
 	   ;; CASE 5H: we could be looking at subsequent knr-argdecls
 	   ((and c-recognize-knr-p
+		 (not containing-sexp)	; can't be knr inside braces.
 		 (not (eq char-before-ip ?}))
 		 (save-excursion
 		   (setq placeholder (cdr (c-beginning-of-decl-1 lim)))
--- a/lisp/progmodes/cc-langs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-langs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1771,11 +1771,13 @@
 (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
 
 (c-lang-defconst c-specifier-key
-  ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that
-  ;; aren't ambiguous with types or type prefixes.
+  ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
+  ;; ambiguous with types or type prefixes.  These are the keywords (like
+  ;; extern, namespace, but NOT template) that can modify a declaration.
   t (c-make-keywords-re t
       (set-difference (c-lang-const c-prefix-spec-kwds)
-		      (c-lang-const c-type-start-kwds)
+		      (append (c-lang-const c-type-start-kwds)
+			      (c-lang-const c-<>-arglist-kwds))
 		      :test 'string-equal)))
 (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key))
 
--- a/lisp/progmodes/cc-styles.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-styles.el	Wed Jan 30 07:57:28 2008 +0000
@@ -58,7 +58,8 @@
   '(("gnu"
      (c-basic-offset . 2)
      (c-comment-only-line-offset . (0 . 0))
-     (c-hanging-braces-alist     . ((substatement-open before after)))
+     (c-hanging-braces-alist     . ((substatement-open before after)
+				    (arglist-cont-nonempty)))
      (c-offsets-alist . ((statement-block-intro . +)
 			 (knr-argdecl-intro . 5)
 			 (substatement-open . +)
@@ -170,7 +171,8 @@
                          (case-label           . +)
                          (access-label         . -)
                          (inclass              . ++)
-			 (inline-open          . 0))))
+			 (inline-open          . 0)
+			 (arglist-cont-nonempty))))
 
     ("linux"
      (c-basic-offset  . 8)
@@ -178,7 +180,8 @@
      (c-hanging-braces-alist . ((brace-list-open)
 				(brace-entry-open)
 				(substatement-open after)
-				(block-close . c-snug-do-while)))
+				(block-close . c-snug-do-while)
+				(arglist-cont-nonempty)))
      (c-cleanup-list . (brace-else-brace))
      (c-offsets-alist . ((statement-block-intro . +)
 			 (knr-argdecl-intro     . 0)
@@ -200,7 +203,8 @@
 				(brace-list-close)
 				(brace-entry-open)
 				(substatement-open after)
-				(block-close . c-snug-do-while)))
+				(block-close . c-snug-do-while)
+				(arglist-cont-nonempty)))
      (c-block-comment-prefix . ""))
 
     ("java"
@@ -230,7 +234,8 @@
      (c-hanging-braces-alist . ((defun-open after)
 				(defun-close . c-snug-1line-defun-close)
 				(substatement-open after)
-				(block-close . c-snug-do-while)))
+				(block-close . c-snug-do-while)
+				(arglist-cont-nonempty)))
      (c-hanging-semi&comma-criteria . nil)
      (c-cleanup-list . nil)		; You might want one-liner-defun here.
      (c-offsets-alist . ((statement-block-intro . +)
--- a/lisp/progmodes/cc-vars.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/cc-vars.el	Wed Jan 30 07:57:28 2008 +0000
@@ -73,8 +73,28 @@
       :format "%t%n"
       :value 'other))
 
+;; The next defun will supersede c-const-symbol.
+(eval-and-compile
+  (defun c-constant-symbol (sym len)
+  "Create an uneditable symbol for customization buffers.
+SYM is the name of the symbol, LEN the length of the field (in
+characters) the symbol will be displayed in.  LEN must be big
+enough.
+
+This returns a (const ....) structure, suitable for embedding
+within a customization type."
+  (or (symbolp sym) (error "c-constant-symbol: %s is not a symbol" sym))
+  (let* ((name (symbol-name sym))
+	 (l (length name))
+	 (disp (concat name ":" (make-string (- len l 1) ?\ ))))
+    `(const
+      :size ,len
+      :format ,disp
+      :value ,sym))))
+
 (define-widget 'c-const-symbol 'item
-  "An uneditable lisp symbol."
+  "An uneditable lisp symbol.  This is obsolete -
+use c-constant-symbol instead."
   :value nil
   :tag "Symbol"
   :format "%t: %v\n%d"
@@ -305,6 +325,7 @@
   :type 'boolean
   :group 'c)
 (make-variable-buffer-local 'c-syntactic-indentation)
+(put 'c-syntactic-indentation 'safe-local-variable 'booleanp)
 
 (defcustom c-syntactic-indentation-in-macros t
   "*Enable syntactic analysis inside macros.
@@ -323,6 +344,7 @@
 better with the \"do { ... } while \(0)\" trick)."
   :type 'boolean
   :group 'c)
+(put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp)
 
 (defcustom-c-stylevar c-comment-only-line-offset 0
   "*Extra offset for line which contains only the start of a comment.
@@ -405,9 +427,7 @@
     `(set ,@(mapcar
 	     (lambda (elt)
 	       `(cons :format "%v"
-		      (c-const-symbol :format "%v: "
-				      :size 20
-				      :value ,elt)
+		      ,(c-constant-symbol elt 20)
 		      (choice
 		       :format "%[Choice%] %v"
 		       :value (column . nil)
@@ -709,7 +729,8 @@
 					       (module-open after)
 					       (composition-open after)
 					       (inexpr-class-open after)
-					       (inexpr-class-close before))
+					       (inexpr-class-close before)
+					       (arglist-cont-nonempty))
   "*Controls the insertion of newlines before and after braces
 when the auto-newline feature is active.  This variable contains an
 association list with elements of the following form:
@@ -743,18 +764,15 @@
   `(set ,@(mapcar
 	   (lambda (elt)
 	     `(cons :format "%v"
-		    (c-const-symbol :format "%v: "
-				    :size 20
-				    :value ,elt)
+		    ,(c-constant-symbol elt 24)
 		    (choice :format "%[Choice%] %v"
 			    :value (before after)
 			    (set :menu-tag "Before/after"
-				 :format "Newline %v brace\n"
-				 (const :format "%v, " before)
-				 (const :format "%v" after))
+				 :format "Newline  %v brace\n"
+				 (const :format "%v,  " before)
+				 (const :format "%v " after))
 			    (function :menu-tag "Function"
-				      :format "Run function: %v"
-				      :value c-))))
+				      :format "Run function: %v"))))
 	   '(defun-open defun-close
 	      class-open class-close
 	      inline-open inline-close
@@ -766,7 +784,8 @@
 	      namespace-open namespace-close
 	      module-open module-close
 	      composition-open composition-close
-	      inexpr-class-open inexpr-class-close)))
+	      inexpr-class-open inexpr-class-close
+	      arglist-cont-nonempty)))
     :group 'c)
 
 (defcustom c-max-one-liner-length 80
@@ -790,11 +809,9 @@
   `(set ,@(mapcar
 	   (lambda (elt)
 	     `(cons :format "%v"
-		    (c-const-symbol :format "%v: "
-				    :size 20
-				    :value ,elt)
-		    (set :format "Newline %v brace\n"
-			 (const :format "%v, " before)
+		    ,(c-constant-symbol elt 20)
+		    (set :format "Newline  %v  colon\n"
+			 (const :format "%v,  " before)
 			 (const :format "%v" after))))
 	   '(case-label label access-label member-init-intro inher-intro)))
   :group 'c)
@@ -1307,8 +1324,7 @@
 	   (lambda (elt)
 	     `(cons :format "%v"
 		    :value ,elt
-		    (c-const-symbol :format "%v: "
-				    :size 25)
+		    ,(c-constant-symbol (car elt) 25)
 		    (sexp :format "%v"
 			  :validate
 			  (lambda (widget)
--- a/lisp/progmodes/compile.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/compile.el	Wed Jan 30 07:57:28 2008 +0000
@@ -272,8 +272,9 @@
      " in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
 
     (msft
+     ;; AFAWK, The message may be a "warning", "error", or "fatal error".
      "^\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
-: \\(?:error\\|warnin\\(g\\)\\) C[0-9]+:" 2 3 nil (4))
+: \\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:" 2 3 nil (4))
 
     (oracle
      "^\\(?:Semantic error\\|Error\\|PCC-[0-9]+:\\).* line \\([0-9]+\\)\
--- a/lisp/progmodes/ebrowse.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/ebrowse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1614,21 +1614,6 @@
     file-name))
 
 
-(defun ebrowse-view-file-other-window (file)
-  "View a file FILE in another window.
-This is a replacement for `view-file-other-window' which does not
-seem to work. It should be removed when `view.el' is fixed."
-  (interactive)
-  (let ((old-arrangement (current-window-configuration))
-	(had-a-buf (get-file-buffer file))
-	(buf-to-view (find-file-noselect file)))
-    (switch-to-buffer-other-window buf-to-view)
-    (view-mode-enter old-arrangement
-		     (and (not had-a-buf)
-			  (not (buffer-modified-p buf-to-view))
-			  'kill-buffer))))
-
-
 (defun ebrowse-view-exit-fn (buffer)
   "Function called when exiting View mode in BUFFER.
 Restore frame configuration active before viewing the file,
@@ -1649,10 +1634,9 @@
 
 (defun ebrowse-view-file-other-frame (file)
   "View a file FILE in another frame.
-The new frame is deleted when it is no longer used."
+The new frame is deleted when you quit viewing the file in that frame."
   (interactive)
   (let ((old-frame-configuration (current-frame-configuration))
-	(old-arrangement (current-window-configuration))
 	(had-a-buf (get-file-buffer file))
 	(buf-to-view (find-file-noselect file)))
     (switch-to-buffer-other-frame buf-to-view)
@@ -1663,8 +1647,8 @@
 	  (and (not had-a-buf)
 	       (not (buffer-modified-p buf-to-view))
 	       'kill-buffer))
-    (view-mode-enter old-arrangement 'ebrowse-view-exit-fn)))
-
+    (view-mode-enter (cons (selected-window) (cons (selected-window) t))
+		     'ebrowse-view-exit-fn)))
 
 (defun ebrowse-view/find-file-and-search-pattern
   (struc info file tags-file-name &optional view where)
@@ -1699,7 +1683,7 @@
 	   (setq view-mode-hook nil))
 	 (push 'ebrowse-find-pattern view-mode-hook)
 	 (case where
-	   (other-window (ebrowse-view-file-other-window file))
+	   (other-window (view-file-other-window file))
 	   (other-frame  (ebrowse-view-file-other-frame file))
 	   (t            (view-file file))))
 	(t
--- a/lisp/progmodes/etags.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/etags.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1815,13 +1815,19 @@
     (tags-loop-continue (or file-list-form t))))
 
 ;;;###autoload
-(defun tags-query-replace (from to &optional delimited file-list-form start end)
+(defun tags-query-replace (from to &optional delimited file-list-form)
   "Do `query-replace-regexp' of FROM with TO on all files listed in tags table.
 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
 with the command \\[tags-loop-continue].
+Fourth arg FILE-LIST-FORM non-nil means initialize the replacement loop.
+Fifth and sixth arguments START and END are accepted, for compatibility
+with `query-replace-regexp', and ignored.
 
-See documentation of variable `tags-file-name'."
+If FILE-LIST-FORM is non-nil, it is a form to evaluate to
+produce the list of files to search.
+
+See also the documentation of the variable `tags-file-name'."
   (interactive (query-replace-read-args "Tags query replace (regexp)" t t))
   (setq tags-loop-scan `(let ,(unless (equal from (downcase from))
 				'((case-fold-search nil)))
--- a/lisp/progmodes/f90.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/f90.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1681,7 +1681,7 @@
     (push-mark)
     (goto-char pos)
     (setq program (f90-beginning-of-subprogram))
-    (if (fboundp 'zmacs-activate-region)
+    (if (featurep 'xemacs)
         (zmacs-activate-region)
       (setq mark-active t
             deactivate-mark nil))
@@ -1866,7 +1866,7 @@
     (goto-char save-point)
     (set-marker end-region-mark nil)
     (set-marker save-point nil)
-    (if (fboundp 'zmacs-deactivate-region)
+    (if (featurep 'xemacs)
         (zmacs-deactivate-region)
       (deactivate-mark))))
 
@@ -1976,7 +1976,7 @@
             f90-cache-position (point)))
     (setq f90-cache-position nil)
     (set-marker end-region-mark nil)
-    (if (fboundp 'zmacs-deactivate-region)
+    (if (featurep 'xemacs)
         (zmacs-deactivate-region)
       (deactivate-mark))))
 
--- a/lisp/progmodes/gdb-ui.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/gdb-ui.el	Wed Jan 30 07:57:28 2008 +0000
@@ -435,11 +435,11 @@
 	 (output
 	  (with-output-to-string
 	    (with-current-buffer standard-output
-	      (call-process shell-file-name
-			    (if (file-exists-p file) file nil)
+	      (and file (file-exists-p file)
+	      (call-process shell-file-name file
 			    (list t nil) nil "-c"
 			    (concat gdb-cpp-define-alist-program " "
-				    gdb-cpp-define-alist-flags)))))
+				    gdb-cpp-define-alist-flags))))))
 	(define-list (split-string output "\n" t)) (name))
     (setq gdb-define-alist nil)
     (dolist (define define-list)
@@ -1214,10 +1214,12 @@
 
 (defun gdb-dequeue-input ()
   (let ((queue gdb-input-queue))
-    (and queue
-	 (let ((last (car (last queue))))
-	   (unless (nbutlast queue) (setq gdb-input-queue '()))
-	   last))))
+    (if queue
+	(let ((last (car (last queue))))
+	  (unless (nbutlast queue) (setq gdb-input-queue '()))
+	  last)
+      ;; This should be nil here anyway but set it just to make sure.
+      (setq gdb-pending-triggers nil))))
 
 (defun gdb-send-item (item)
   (setq gdb-flush-pending-output nil)
@@ -3445,7 +3447,8 @@
       (let ((buffer (marker-buffer gud-overlay-arrow-position))
 	    (position (marker-position gud-overlay-arrow-position)))
 	(when (and buffer
-		   (string-equal (buffer-name buffer)
+		   (string-equal (file-name-nondirectory
+				  (buffer-file-name buffer))
 				 (file-name-nondirectory (match-string 3))))
 	  (with-current-buffer buffer
 	    (setq fringe-indicator-alist
--- a/lisp/progmodes/hideif.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/hideif.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,7 @@
 ;;; hideif.el --- hides selected code within ifdef
 
-;; Copyright (C) 1988, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008  Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
 ;; Maintainer: FSF
@@ -99,12 +99,6 @@
 ;;
 ;; Written by Brian Marick, at Gould, Computer Systems Division, Urbana IL.
 ;; Extensively modified by Daniel LaLiberte (while at Gould).
-;;
-;; You may freely modify and distribute this, but keep a record
-;; of modifications and send comments to:
-;; 	 liberte@a.cs.uiuc.edu  or  ihnp4!uiucdcs!liberte
-;; I will continue to upgrade hide-ifdef-mode
-;; with your contributions.
 
 ;;; Code:
 
@@ -114,6 +108,33 @@
   "Hide selected code within `ifdef'."
   :group 'c)
 
+(defcustom hide-ifdef-initially nil
+  "Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated."
+  :type 'boolean
+  :group 'hide-ifdef)
+
+(defcustom hide-ifdef-read-only nil
+  "Set to non-nil if you want buffer to be read-only while hiding text."
+  :type 'boolean
+  :group 'hide-ifdef)
+
+(defcustom hide-ifdef-lines nil
+  "Non-nil means hide the #ifX, #else, and #endif lines."
+  :type 'boolean
+  :group 'hide-ifdef)
+
+(defcustom hide-ifdef-shadow nil
+  "Non-nil means shadow text instead of hiding it."
+  :type 'boolean
+  :group 'hide-ifdef
+  :version "23.1")
+
+(defface hide-ifdef-shadow '((t (:inherit shadow)))
+  "Face for shadowing ifdef blocks."
+  :group 'hide-ifdef
+  :version "23.1")
+
+
 (defvar hide-ifdef-mode-submap
   ;; Set up the submap that goes after the prefix key.
   (let ((map (make-sparse-keymap)))
@@ -128,6 +149,7 @@
     (define-key map "\C-s" 'show-ifdef-block)
 
     (define-key map "\C-q" 'hide-ifdef-toggle-read-only)
+    (define-key map "\C-w" 'hide-ifdef-toggle-shadowing)
     (substitute-key-definition
      'toggle-read-only 'hide-ifdef-toggle-outside-read-only map)
     map)
@@ -155,7 +177,9 @@
     ["Use an alist" hide-ifdef-use-define-alist t]
     ["Undefine a variable" hide-ifdef-undef t]
     ["Toggle read only" hide-ifdef-toggle-read-only
-              :style toggle :selected hide-ifdef-read-only]))
+     :style toggle :selected hide-ifdef-read-only]
+    ["Toggle shadowing" hide-ifdef-toggle-shadowing
+     :style toggle :selected hide-ifdef-shadow]))
 
 (defvar hide-ifdef-hiding nil
   "Non-nil when text may be hidden.")
@@ -256,9 +280,12 @@
     (end-of-line 2)))
 
 (defun hide-ifdef-region-internal (start end)
-  (remove-overlays start end 'invisible 'hide-ifdef)
+  (remove-overlays start end 'hide-ifdef t)
   (let ((o (make-overlay start end)))
-    (overlay-put o 'invisible 'hide-ifdef)))
+    (overlay-put o 'hide-ifdef t)
+    (if hide-ifdef-shadow
+	(overlay-put o 'face 'hide-ifdef-shadow)
+      (overlay-put o 'invisible 'hide-ifdef))))
 
 (defun hide-ifdef-region (start end)
   "START is the start of a #if or #else form.  END is the ending part.
@@ -270,7 +297,7 @@
 
 (defun hif-show-ifdef-region (start end)
   "Everything between START and END is made visible."
-  (remove-overlays start end 'invisible 'hide-ifdef))
+  (remove-overlays start end 'hide-ifdef t))
 
 
 ;;===%%SF%% evaluation (Start)  ===
@@ -740,11 +767,11 @@
 
 (defun hif-hide-line (point)
   "Hide the line containing point.  Does nothing if `hide-ifdef-lines' is nil."
-  (if hide-ifdef-lines
-      (save-excursion
-	(goto-char point)
-	(hide-ifdef-region-internal (line-beginning-position)
-				    (progn (hif-end-of-line) (point))))))
+  (when hide-ifdef-lines
+    (save-excursion
+      (goto-char point)
+      (hide-ifdef-region-internal
+       (line-beginning-position) (progn (hif-end-of-line) (point))))))
 
 
 ;;;  Hif-Possibly-Hide
@@ -827,24 +854,6 @@
 
 ;;===%%SF%% exports (Start)  ===
 
-;;;###autoload
-(defcustom hide-ifdef-initially nil
-  "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated."
-  :type 'boolean
-  :group 'hide-ifdef)
-
-;;;###autoload
-(defcustom hide-ifdef-read-only nil
-  "*Set to non-nil if you want buffer to be read-only while hiding text."
-  :type 'boolean
-  :group 'hide-ifdef)
-
-;;;###autoload
-(defcustom hide-ifdef-lines nil
-  "*Non-nil means hide the #ifX, #else, and #endif lines."
-  :type 'boolean
-  :group 'hide-ifdef)
-
 (defun hide-ifdef-toggle-read-only ()
   "Toggle `hide-ifdef-read-only'."
   (interactive)
@@ -866,6 +875,21 @@
 	    hif-outside-read-only))
   (force-mode-line-update))
 
+(defun hide-ifdef-toggle-shadowing ()
+  "Toggle shadowing."
+  (interactive)
+  (set (make-local-variable 'hide-ifdef-shadow) (not hide-ifdef-shadow))
+  (message "Shadowing %s" (if hide-ifdef-shadow "ON" "OFF"))
+  (save-restriction
+    (widen)
+    (dolist (overlay (overlays-in (point-min) (point-max)))
+      (when (overlay-get overlay 'hide-ifdef)
+	(if hide-ifdef-shadow
+	    (progn
+	      (overlay-put overlay 'invisible nil)
+	      (overlay-put overlay 'face 'hide-ifdef-shadow))
+	  (overlay-put overlay 'face nil)
+	  (overlay-put overlay 'invisible 'hide-ifdef))))))
 
 (defun hide-ifdef-define (var)
   "Define a VAR so that #ifdef VAR would be included."
--- a/lisp/progmodes/pascal.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/pascal.el	Wed Jan 30 07:57:28 2008 +0000
@@ -523,8 +523,8 @@
   (pascal-end-of-defun)
   (push-mark (point))
   (pascal-beg-of-defun)
-  (if (fboundp 'zmacs-activate-region)
-      (zmacs-activate-region)))
+  (when (featurep 'xemacs)
+    (zmacs-activate-region)))
 
 (defun pascal-comment-area (start end)
   "Put the region into a Pascal comment.
--- a/lisp/progmodes/python.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/python.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1889,7 +1889,8 @@
 
 ;;;; Completion.
 
-(defvar python-imports nil
+;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-01/msg00076.html
+(defvar python-imports "None"
   "String of top-level import statements updated by `python-find-imports'.")
 (make-variable-buffer-local 'python-imports)
 
@@ -2076,7 +2077,7 @@
    <			; Avoid wrong indentation after block opening.
    "elif " str ":" \n
    > _ \n nil)
-  (python-else) | ^)
+  '(python-else) | ^)
 
 (define-skeleton python-else
   "Auxiliary skeleton."
@@ -2090,24 +2091,24 @@
   "Condition: "
   "while " str ":" \n
   > _ \n
-  (python-else) | ^)
+  '(python-else) | ^)
 
 (def-python-skeleton for
   "Target, %s: "
   "for " str " in " (skeleton-read "Expression, %s: ") ":" \n
   > _ \n
-  (python-else) | ^)
+  '(python-else) | ^)
 
 (def-python-skeleton try/except
   nil
   "try:" \n
   > _ \n
   ("Exception, %s: "
-   < "except " str (python-target) ":" \n
+   < "except " str '(python-target) ":" \n
    > _ \n nil)
   < "except:" \n
   > _ \n
-  (python-else) | ^)
+  '(python-else) | ^)
 
 (define-skeleton python-target
   "Auxiliary skeleton."
--- a/lisp/progmodes/sh-script.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/sh-script.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1186,6 +1186,7 @@
 This value is used for the `+' and `-' symbols in an indentation variable."
   :type 'integer
   :group 'sh-indentation)
+(put 'sh-basic-offset 'safe-local-variable 'integerp)
 
 (defcustom sh-indent-comment nil
   "How a comment line is to be indented.
--- a/lisp/progmodes/verilog-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/verilog-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -11,6 +11,12 @@
 ;;	http://www.veripool.com
 ;; Keywords: languages
 
+;;    This code supports Emacs 21.1 and later
+;;    And XEmacs 21.1 and later
+;;    Please do not make changes that break Emacs 21.  Thanks!
+;;
+;;
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -30,12 +36,12 @@
 
 ;;; Commentary:
 
-;; This mode borrows heavily from the Pascal-mode and the cc-mode of emacs
+;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs
 
 ;; USAGE
 ;; =====
 
-;; A major mode for editing Verilog HDL source code. When you have
+;; A major mode for editing Verilog HDL source code.  When you have
 ;; entered Verilog mode, you may get more info by pressing C-h m. You
 ;; may also get online help describing various functions by: C-h f
 ;; <Name of function you want described>
@@ -44,8 +50,8 @@
 ;; =======================
 
 ;; Verilog is a rapidly evolving language, and hence this mode is
-;; under continuous development. Hence this is beta code, and likely
-;; has bugs. Please report any and all bugs to me at mac@verilog.com.
+;; under continuous development.  Hence this is beta code, and likely
+;; has bugs.  Please report any and all bugs to me at mac@verilog.com.
 ;; Please use verilog-submit-bug-report to submit a report; type C-c
 ;; C-b to invoke this and as a result I will have a much easier time
 ;; of reproducing the bug you find, and hence fixing it.
@@ -55,7 +61,7 @@
 
 ;; An older version of this mode may be already installed as a part of
 ;; your environment, and one method of updating would be to update
-;; your emacs environment.  Sometimes this is difficult for local
+;; your Emacs environment.  Sometimes this is difficult for local
 ;; political/control reasons, and hence you can always install a
 ;; private copy (or even a shared copy) which overrides the system
 ;; default.
@@ -74,7 +80,7 @@
 
 ;; If you want to customize Verilog mode to fit your needs better,
 ;; you may add these lines (the values of the variables presented
-;; here are the defaults). Note also that if you use an emacs that
+;; here are the defaults). Note also that if you use an Emacs that
 ;; supports custom, it's probably better to use the custom menu to
 ;; edit these.
 ;;
@@ -102,15 +108,19 @@
 ;; 
 
 ;;; History:
-;;
-;; 
+;; 
+;; See commit history at http://www.veripool.com/verilog-mode.html
+;; (This section is required to appease checkdoc.)
+
 ;;; Code:
 
 ;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "377"
+(defconst verilog-mode-version "383"
   "Version of this verilog mode.")
-(defconst verilog-mode-release-date "2007-12-07"
-  "Version of this verilog mode.")
+(defconst verilog-mode-release-date "2008-01-07-GNU"
+  "Release date of this verilog mode.")
+(defconst verilog-mode-release-emacs t
+  "If non-nil, this version of verilog mode was released with Emacs itself.")
 
 (defun verilog-version ()
   "Inform caller of the version of this file."
@@ -118,7 +128,10 @@
   (message "Using verilog-mode version %s" verilog-mode-version))
 
 ;; Insure we have certain packages, and deal with it if we don't
+;; Be sure to note which Emacs flavor and version added each feature.
 (eval-when-compile
+  ;; The below were disabled when GNU Emacs 22 was released;
+  ;; perhaps some still need to be there to support Emacs 21.
   (when (featurep 'xemacs)
     (condition-case nil
         (require 'easymenu)
@@ -181,8 +194,8 @@
                       result)
                   (buffer-substring-no-properties (match-beginning num)
                                                   (match-end num)
-                                                  (current-buffer)
-                                                  )))))
+                                                  (current-buffer)))))
+	  )
       (error nil))
     (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
         nil ;; We've got what we needed
@@ -210,6 +223,8 @@
 ;; Provide a regular expression optimization routine, using regexp-opt
 ;; if provided by the user's elisp libraries
 (eval-and-compile
+  ;; The below were disabled when GNU Emacs 22 was released;
+  ;; perhaps some still need to be there to support Emacs 21.
   (if (featurep 'xemacs)
       (if (fboundp 'regexp-opt)
           ;; regexp-opt is defined, does it take 3 or 2 arguments?
@@ -222,8 +237,7 @@
                       (defun verilog-regexp-opt (a b)
                         "Deal with differing number of required arguments for  `regexp-opt'.
          Call 'regexp-opt' on A and B."
-                        (regexp-opt a b 't)
-                        )
+                        (regexp-opt a b 't))
                     (error nil))
                   )
                  ((eq args 2) ;; It takes 2
@@ -261,6 +275,12 @@
   (if (fboundp 'customize-apropos)
       (customize-apropos "font-lock-*" 'faces)))
 
+(defun verilog-booleanp (value)
+  "Return t if VALUE is boolean.
+ This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs.
+ This function may be removed when Emacs 21 is no longer supported."
+  (or (equal value t) (equal value nil)))
+
 (defgroup verilog-mode nil
   "Facilitates easy editing of Verilog source text"
   :group 'languages)
@@ -290,6 +310,7 @@
 you to the next lint error."
   :type 'string
   :group 'verilog-mode-actions)
+;; We don't mark it safe, as it's used as a shell command
 
 (defcustom verilog-coverage
   "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'"
@@ -299,6 +320,7 @@
 you to the next lint error."
   :type 'string
   :group 'verilog-mode-actions)
+;; We don't mark it safe, as it's used as a shell command
 
 (defcustom verilog-simulator
   "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'"
@@ -308,6 +330,7 @@
 you to the next lint error."
   :type 'string
   :group 'verilog-mode-actions)
+;; We don't mark it safe, as it's used as a shell command
 
 (defcustom verilog-compiler
   "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'"
@@ -317,6 +340,7 @@
 you to the next lint error."
   :type 'string
   :group 'verilog-mode-actions)
+;; We don't mark it safe, as it's used as a shell command
 
 (defvar verilog-tool 'verilog-linter
   "Which tool to use for building compiler-command.
@@ -336,11 +360,14 @@
 entry \"Fontify Buffer\").  XEmacs: turn off and on font locking."
   :type 'boolean
   :group 'verilog-mode-indent)
+;; Note we don't use :safe, as that would break on Emacsen before 22.0.
+(put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-indent-level 3
   "*Indentation of Verilog statements with respect to containing block."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-indent-level 'safe-local-variable 'integerp)
 
 (defcustom verilog-indent-level-module 3
   "*Indentation of Module level Verilog statements.  (eg always, initial)
@@ -348,12 +375,14 @@
 your screen."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-indent-level-module 'safe-local-variable 'integerp)
 
 (defcustom verilog-indent-level-declaration 3
   "*Indentation of declarations with respect to containing block.
 Set to 0 to get them list right under containing block."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-indent-level-declaration 'safe-local-variable 'integerp)
 
 (defcustom verilog-indent-declaration-macros nil
   "*How to treat macro expansions in a declaration.
@@ -367,6 +396,7 @@
 	output       c;"
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-indent-lists t
   "*How to treat indenting items in a list.
@@ -379,62 +409,73 @@
 	   reset ) begin"
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-indent-level-behavioral 3
   "*Absolute indentation of first begin in a task or function block.
 Set to 0 to get such code to start at the left side of the screen."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp)
 
 (defcustom verilog-indent-level-directive 1
   "*Indentation to add to each level of `ifdef declarations.
 Set to 0 to have all directives start at the left side of the screen."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-indent-level-directive 'safe-local-variable 'integerp)
 
 (defcustom verilog-cexp-indent 2
   "*Indentation of Verilog statements split across lines."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-cexp-indent 'safe-local-variable 'integerp)
 
 (defcustom verilog-case-indent 2
   "*Indentation for case statements."
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-case-indent 'safe-local-variable 'integerp)
 
 (defcustom verilog-auto-newline t
   "*True means automatically newline after semicolons."
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-indent-on-newline t
   "*True means automatically indent line after newline."
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-tab-always-indent t
   "*True means TAB should always re-indent the current line.
 Nil means TAB will only reindent when at the beginning of the line."
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-tab-to-comment nil
   "*True means TAB moves to the right hand column in preparation for a comment."
   :group 'verilog-mode-actions
   :type 'boolean)
+(put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-indent-begin-after-if t
   "*If true, indent begin statements following if, else, while, for and repeat.
 Otherwise, line them up."
   :group 'verilog-mode-indent
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp)
 
 
 (defcustom verilog-align-ifelse nil
   "*If true, align `else' under matching `if'.
 Otherwise else is lined up with first character on line holding matching if."
   :group 'verilog-mode-indent
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-minimum-comment-distance 10
   "*Minimum distance (in lines) between begin and end required before a comment.
@@ -442,6 +483,7 @@
 default avoids too many redundant comments in tight quarters"
   :group 'verilog-mode-indent
   :type 'integer)
+(put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp)
 
 (defcustom verilog-auto-lineup '(declaration)
   "*Algorithm for lining up statements on multiple lines.
@@ -481,23 +523,26 @@
 ;
 
   :group 'verilog-mode-indent
-  :type 'list )
+  :type 'list)
+(put 'verilog-auto-lineup 'safe-local-variable 'listp)
 
 (defcustom verilog-highlight-p1800-keywords nil
-  "*If true highlight words newly reserved by IEEE-1800 in
-verilog-font-lock-p1800-face in order to gently suggest changing where
-these words are used as variables to something else.  Nil means highlight
-these words as appropriate for the SystemVerilog IEEE-1800 standard.  Note
-that changing this will require restarting emacs to see the effect as font
-color choices are cached by emacs"
+  "*True means highlight words newly reserved by IEEE-1800.
+These will appear in `verilog-font-lock-p1800-face' in order to gently
+suggest changing where these words are used as variables to something else.
+Nil means highlight these words as appropriate for the SystemVerilog
+IEEE-1800 standard.  Note that changing this will require restarting Emacs
+to see the effect as font color choices are cached by Emacs"
   :group 'verilog-mode-indent
   :type 'boolean)
+(put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-endcomments t
   "*True means insert a comment /* ... */ after 'end's.
 The name of the function or case will be set between the braces."
   :group 'verilog-mode-actions
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-read-includes nil
   "*True means to automatically read includes before AUTOs.
@@ -506,7 +551,8 @@
 but can result in very slow reading times if there are many or large
 include files."
   :group 'verilog-mode-actions
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-save-policy nil
   "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs.
@@ -527,6 +573,7 @@
 instantiation.  See also `verilog-auto-star' and `verilog-auto-star-save'."
   :group 'verilog-mode-actions
   :type 'boolean)
+(put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-star-save nil
   "*Non-nil indicates to save to disk SystemVerilog .* instance expansions.
@@ -537,6 +584,7 @@
 always be saved."
   :group 'verilog-mode-actions
   :type 'boolean)
+(put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp)
 
 (defvar verilog-auto-update-tick nil
   "Modification tick at which autos were last performed.")
@@ -624,8 +672,7 @@
     ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t)
     ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t)
     )
-  "*Keywords to also highlight in Verilog *compilation* buffers."
-  )
+  "*Keywords to also highlight in Verilog *compilation* buffers.")
 
 (defcustom verilog-library-flags '("")
   "*List of standard Verilog arguments to use for /*AUTOINST*/.
@@ -656,6 +703,7 @@
 See also the variables mentioned above."
   :group 'verilog-mode-auto
   :type '(repeat string))
+(put 'verilog-library-flags 'safe-local-variable 'listp)
 
 (defcustom verilog-library-directories '(".")
   "*List of directories when looking for files for /*AUTOINST*/.
@@ -678,9 +726,11 @@
 and `verilog-library-extensions'."
   :group 'verilog-mode-auto
   :type '(repeat file))
+(put 'verilog-library-directories 'safe-local-variable 'listp)
 
 (defcustom verilog-library-files '()
-  "*List of files to search for modules when looking for AUTOINST files.
+  "*List of files to search for modules.
+AUTOINST will use this when it needs to resolve a module name.
 This is a complete path, usually to a technology file with many standard
 cells defined in it.
 
@@ -698,12 +748,14 @@
 See also `verilog-library-flags', `verilog-library-directories'."
   :group 'verilog-mode-auto
   :type '(repeat directory))
+(put 'verilog-library-files 'safe-local-variable 'listp)
 
 (defcustom verilog-library-extensions '(".v")
   "*List of extensions to use when looking for files for /*AUTOINST*/.
 See also `verilog-library-flags', `verilog-library-directories'."
   :type '(repeat string)
   :group 'verilog-mode-auto)
+(put 'verilog-library-extensions 'safe-local-variable 'listp)
 
 (defcustom verilog-active-low-regexp nil
   "*If set, treat signals matching this regexp as active low.
@@ -711,21 +763,24 @@
 you will probably also need `verilog-auto-reset-widths' set."
   :group 'verilog-mode-auto
   :type 'string)
+(put 'verilog-active-low-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-auto-sense-include-inputs nil
   "*If true, AUTOSENSE should include all inputs.
 If nil, only inputs that are NOT output signals in the same block are
 included."
-  :type 'boolean
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'boolean)
+(put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-sense-defines-constant nil
   "*If true, AUTOSENSE should assume all defines represent constants.
 When true, the defines will not be included in sensitivity lists.  To
 maintain compatibility with other sites, this should be set at the bottom
 of each verilog file that requires it, rather than being set globally."
-  :type 'boolean
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'boolean)
+(put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-reset-widths t
   "*If true, AUTORESET should determine the width of signals.
@@ -735,11 +790,13 @@
 the MSB or LSB of a signal inside a AUTORESET."
   :type 'boolean
   :group 'verilog-mode-auto)
+(put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-assignment-delay ""
   "*Text used for delays in delayed assignments.  Add a trailing space if set."
-  :type 'string
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'string)
+(put 'verilog-assignment-delay 'safe-local-variable 'stringp)
 
 (defcustom verilog-auto-inst-vector t
   "*If true, when creating default ports with AUTOINST, use bus subscripts.
@@ -748,7 +805,8 @@
 declare the wire to have the subscripts removed.)  Nil may speed up some
 simulators, but is less general and harder to read, so avoid."
   :group 'verilog-mode-auto
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp)
 
 (defcustom verilog-auto-inst-template-numbers nil
   "*If true, when creating templated ports with AUTOINST, add a comment.
@@ -756,7 +814,8 @@
 port declaration.  Setting this aids in debugging, but nil is suggested for
 regular use to prevent large numbers of merge conflicts."
   :group 'verilog-mode-auto
-  :type 'boolean )
+  :type 'boolean)
+(put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp)
 
 (defvar verilog-auto-inst-column 40
   "Column number for first part of auto-inst.")
@@ -765,31 +824,36 @@
   "*If set, when creating AUTOINPUT list, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
   :group 'verilog-mode-auto
-  :type 'string )
+  :type 'string)
+(put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-auto-inout-ignore-regexp nil
   "*If set, when creating AUTOINOUT list, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
   :group 'verilog-mode-auto
-  :type 'string )
+  :type 'string)
+(put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-auto-output-ignore-regexp nil
   "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
   :group 'verilog-mode-auto
-  :type 'string )
+  :type 'string)
+(put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-auto-unused-ignore-regexp nil
   "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
   :group 'verilog-mode-auto
-  :type 'string )
+  :type 'string)
+(put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-typedef-regexp nil
   "*If non-nil, regular expression that matches Verilog-2001 typedef names.
 For example, \"_t$\" matches typedefs named with _t, as in the C language."
   :group 'verilog-mode-auto
-  :type 'string )
+  :type 'string)
+(put 'verilog-typedef-regexp 'safe-local-variable 'stringp)
 
 (defcustom verilog-mode-hook   'verilog-set-compile-command
   "*Hook (List of functions) run after verilog mode is loaded."
@@ -798,33 +862,33 @@
 
 (defcustom verilog-auto-hook nil
   "*Hook run after `verilog-mode' updates AUTOs."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defcustom verilog-before-auto-hook nil
   "*Hook run before `verilog-mode' updates AUTOs."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defcustom verilog-delete-auto-hook nil
   "*Hook run after `verilog-mode' deletes AUTOs."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defcustom verilog-before-delete-auto-hook nil
   "*Hook run before `verilog-mode' deletes AUTOs."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defcustom verilog-getopt-flags-hook nil
   "*Hook run after `verilog-getopt-flags' determines the Verilog option lists."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defcustom verilog-before-getopt-flags-hook nil
   "*Hook run before `verilog-getopt-flags' determines the Verilog option lists."
-  :type 'hook
-  :group 'verilog-mode-auto)
+  :group 'verilog-mode-auto
+  :type 'hook)
 
 (defvar verilog-imenu-generic-expression
   '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4)
@@ -843,13 +907,11 @@
 (defvar verilog-company nil
   "*Default name of Company for verilog header.
 If set will become buffer local.")
-
 (make-variable-buffer-local 'verilog-company)
 
 (defvar verilog-project nil
   "*Default name of Project for verilog header.
 If set will become buffer local.")
-
 (make-variable-buffer-local 'verilog-project)
 
 (defvar verilog-mode-map
@@ -871,7 +933,6 @@
     (define-key map "\M-\r"    `electric-verilog-terminate-and-indent)
     (define-key map "\M-\t"    'verilog-complete-word)
     (define-key map "\M-?"     'verilog-show-completions)
-    (define-key map [(meta control h)] 'verilog-mark-defun)
     (define-key map "\C-c\`"   'verilog-lint-off)
     (define-key map "\C-c\*"   'verilog-delete-auto-star-implicit)
     (define-key map "\C-c\C-r" 'verilog-label-be)
@@ -881,8 +942,10 @@
     (define-key map "\M-*"     'verilog-star-comment)
     (define-key map "\C-c\C-c" 'verilog-comment-region)
     (define-key map "\C-c\C-u" 'verilog-uncomment-region)
-    (define-key map "\M-\C-a"  'verilog-beg-of-defun)
-    (define-key map "\M-\C-e"  'verilog-end-of-defun)
+    (when (featurep 'xemacs)
+      (define-key map [(meta control h)] 'verilog-mark-defun)
+      (define-key map "\M-\C-a"  'verilog-beg-of-defun)
+      (define-key map "\M-\C-e"  'verilog-end-of-defun))
     (define-key map "\C-c\C-d" 'verilog-goto-defun)
     (define-key map "\C-c\C-k" 'verilog-delete-auto)
     (define-key map "\C-c\C-a" 'verilog-auto)
@@ -895,7 +958,7 @@
 
 ;; menus
 (defvar verilog-xemacs-menu
-  '("Verilog"
+  `("Verilog"
     ("Choose Compilation Action"
      ["None"
       (progn
@@ -929,9 +992,15 @@
       :selected (equal verilog-tool `verilog-compiler)]
      )
     ("Move"
-     ["Beginning of function"		verilog-beg-of-defun t]
-     ["End of function"			verilog-end-of-defun t]
-     ["Mark function"			verilog-mark-defun t]
+     ,(if (featurep 'xemacs)
+	  (progn 
+	    ["Beginning of function"		verilog-beg-of-defun t]
+	    ["End of function"			verilog-end-of-defun t]
+	    ["Mark function"			verilog-mark-defun t])
+	["Beginning of function"		beginning-of-defun t]
+	["End of function"			end-of-defun t]
+	["Mark function"			mark-defun t])
+	
      ["Goto function/module"		verilog-goto-defun t]
      ["Move to beginning of block"	electric-verilog-backward-sexp t]
      ["Move to end of block"		electric-verilog-forward-sexp t]
@@ -1025,8 +1094,7 @@
     ["Casex"		verilog-sk-casex t]
     ["Casez"		verilog-sk-casez t]
     )
-  "Menu for statement templates in Verilog."
-  )
+  "Menu for statement templates in Verilog.")
 
 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode"
 		  verilog-xemacs-menu)
@@ -1072,8 +1140,7 @@
 		 (store-match-data '(nil nil))
 		 (if BOUND
 		     (< (point) BOUND)
-		   t)
-		 ))))
+		   t)))))
   (match-end 0))
 
 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR)
@@ -1087,8 +1154,7 @@
 		 (store-match-data '(nil nil))
 		 (if BOUND
 		     (> (point) BOUND)
-		   t)
-		 ))))
+		   t)))))
   (match-end 0))
 
 (defsubst verilog-re-search-forward-quick (regexp bound noerror)
@@ -1130,6 +1196,8 @@
   (save-excursion
     (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
 
+(defvar compile-command)
+
 ;; compilation program
 (defun verilog-set-compile-command ()
   "Function to compute shell command to compile verilog.
@@ -1201,8 +1269,7 @@
 	(setq compilation-error-regexp-alist
 	      (default-value 'compilation-error-regexp-alist))
 	(set (make-local-variable 'compilation-error-regexp-alist)
-	     (default-value 'compilation-error-regexp-alist))
-	)))
+	     (default-value 'compilation-error-regexp-alist)))))
 
 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add)
 
@@ -1330,8 +1397,7 @@
        "endprogram"
        "endsequence"
        "endclocking"
-       )
-     )))
+       ))))
 
 
 (defconst verilog-endcomment-reason-re
@@ -1655,157 +1721,37 @@
  )
  "List of Verilog keywords.")
 
-
-(defconst verilog-emacs-features
-  ;; Documentation at the bottom
-  (let ((major (and (boundp 'emacs-major-version)
-		    emacs-major-version))
-	(minor (and (boundp 'emacs-minor-version)
-		    emacs-minor-version))
-	flavor comments flock-syntax)
-    ;; figure out version numbers if not already discovered
-    (and (or (not major) (not minor))
-	 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
-	 (setq major (string-to-number (substring emacs-version
-					       (match-beginning 1)
-					       (match-end 1)))
-	       minor (string-to-number (substring emacs-version
-					       (match-beginning 2)
-					       (match-end 2)))))
-    (if (not (and major minor))
-	(error "Cannot figure out the major and minor version numbers"))
-    ;; calculate the major version
-    (cond
-     ((= major 4)  (setq major 'v18))	;Epoch 4
-     ((= major 18) (setq major 'v18))	;Emacs 18
-     ((= major 19) (setq major 'v19	;Emacs 19
-			 flavor (if (or (string-match "Lucid" emacs-version)
-					(string-match "XEmacs" emacs-version))
-				    'XEmacs 'FSF)))
-     ((> major 19) (setq major 'v20
-			 flavor (if (or (string-match "Lucid" emacs-version)
-					(string-match "XEmacs" emacs-version))
-				    'XEmacs 'FSF)))
-     ;; I don't know
-     (t (error "Cannot recognize major version number: %s" major)))
-    ;; XEmacs 19 uses 8-bit modify-syntax-entry flags, as do all
-    ;; patched Emacs 19, Emacs 18, Epoch 4's.  Only Emacs 19 uses a
-    ;; 1-bit flag.  Let's be as smart as we can about figuring this
-    ;; out.
-    (if (or (eq major 'v20) (eq major 'v19))
-	(let ((table (copy-syntax-table)))
-	  (modify-syntax-entry ?a ". 12345678" table)
-	  (cond
-	   ;; XEmacs pre 20 and Emacs pre 19.30 use vectors for syntax tables.
-	   ((vectorp table)
-	    (if (= (logand (lsh (aref table ?a) -16) 255) 255)
-		(setq comments '8-bit)
-	      (setq comments '1-bit)))
-	   ;; XEmacs 20 is known to be 8-bit
-	   ((eq flavor 'XEmacs) (setq comments '8-bit))
-	   ;; Emacs 19.30 and beyond are known to be 1-bit
-	   ((eq flavor 'FSF) (setq comments '1-bit))
-	   ;; Don't know what this is
-	   (t (error "Couldn't figure out syntax table format"))
-	   ))
-      ;; Emacs 18 has no support for dual comments
-      (setq comments 'no-dual-comments))
-    ;; determine whether to use old or new font lock syntax
-    ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise
-    ;; look for version > 19.30
-    (setq flock-syntax
-        (if (or (equal comments '8-bit)
-                (equal major 'v20)
-                (and (equal major 'v19) (> minor 30)))
-            'flock-syntax-after-1930
-          'flock-syntax-before-1930))
-    ;; lets do some minimal sanity checking.
-    (if (or
-	 ;; Emacs before 19.6 had bugs
-	 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
-	 ;; Emacs 19 before 19.21 has known bugs
-	 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21))
-	 )
-	(with-output-to-temp-buffer "*verilog-mode warnings*"
-	  (print (format
-  "The version of Emacs that you are running, %s,
-has known bugs in its syntax parsing routines which will affect the
-performance of verilog-mode. You should strongly consider upgrading to the
-latest available version.  verilog-mode may continue to work, after a
-fashion, but strange indentation errors could be encountered."
-		     emacs-version))))
-    ;; Emacs 18, with no patch is not too good
-    (if (and (eq major 'v18) (eq comments 'no-dual-comments))
-	(with-output-to-temp-buffer "*verilog-mode warnings*"
-	  (print (format
-  "The version of Emacs 18 you are running, %s,
-has known deficiencies in its ability to handle the dual verilog
-\(and C++) comments, (e.g. the // and /* */ comments). This will
-not be much of a problem for you if you only use the /* */ comments,
-but you really should strongly consider upgrading to one of the latest
-Emacs 19's.  In Emacs 18, you may also experience performance degradations.
-Emacs 19 has some new built-in routines which will speed things up for you.
-Because of these inherent problems, verilog-mode is not supported
-on emacs-18."
-			    emacs-version))))
-    ;; Emacs 18 with the syntax patches are no longer supported
-    (if (and (eq major 'v18) (not (eq comments 'no-dual-comments)))
-	(with-output-to-temp-buffer "*verilog-mode warnings*"
-	  (print (format
-  "You are running a syntax patched Emacs 18 variant.  While this should
-work for you, you may want to consider upgrading to Emacs 19.
-The syntax patches are no longer supported either for verilog-mode."))))
-    (list major comments flock-syntax))
-  "A list of features extant in the Emacs you are using.
-There are many flavors of Emacs out there, each with different
-features supporting those needed by `verilog-mode'.  Here's the current
-supported list, along with the values for this variable:
-
- Vanilla Emacs 18/Epoch 4:   (v18 no-dual-comments flock-syntax-before-1930)
- Emacs 18/Epoch 4 (patch2):  (v18 8-bit flock-syntax-after-1930)
- XEmacs (formerly Lucid) 19: (v19 8-bit flock-syntax-after-1930)
- XEmacs 20:                  (v20 8-bit flock-syntax-after-1930)
- Emacs 19.1-19.30:           (v19 8-bit flock-syntax-before-1930)
- Emacs 19.31-19.xx:          (v19 8-bit flock-syntax-after-1930)
- Emacs20        :            (v20 1-bit flock-syntax-after-1930).")
-
 (defconst verilog-comment-start-regexp "//\\|/\\*"
   "Dual comment value for `comment-start-regexp'.")
 
-(defun verilog-populate-syntax-table (table)
-  "Populate the syntax TABLE."
-  (modify-syntax-entry ?\\ "\\" table)
-  (modify-syntax-entry ?+ "." table)
-  (modify-syntax-entry ?- "." table)
-  (modify-syntax-entry ?= "." table)
-  (modify-syntax-entry ?% "." table)
-  (modify-syntax-entry ?< "." table)
-  (modify-syntax-entry ?> "." table)
-  (modify-syntax-entry ?& "." table)
-  (modify-syntax-entry ?| "." table)
-  (modify-syntax-entry ?` "w" table)
-  (modify-syntax-entry ?_ "w" table)
-  (modify-syntax-entry ?\' "." table)
-)
-
-(defun verilog-setup-dual-comments (table)
-  "Set up TABLE to handle block and line style comments."
-  (cond
-   ((memq '8-bit verilog-emacs-features)
-    ;; XEmacs (formerly Lucid) has the best implementation
-    (modify-syntax-entry ?/  ". 1456" table)
-    (modify-syntax-entry ?*  ". 23"   table)
-    (modify-syntax-entry ?\n "> b"    table)
-    )
-   ((memq '1-bit verilog-emacs-features)
-    ;; Emacs 19 does things differently, but we can work with it
-    (modify-syntax-entry ?/  ". 124b" table)
-    (modify-syntax-entry ?*  ". 23"   table)
-    (modify-syntax-entry ?\n "> b"    table)
-    )
-   ))
-
-(defvar verilog-mode-syntax-table nil
+(defvar verilog-mode-syntax-table
+  (let ((table (make-syntax-table)))
+    ;; Populate the syntax TABLE.
+    (modify-syntax-entry ?\\ "\\" table)
+    (modify-syntax-entry ?+ "." table)
+    (modify-syntax-entry ?- "." table)
+    (modify-syntax-entry ?= "." table)
+    (modify-syntax-entry ?% "." table)
+    (modify-syntax-entry ?< "." table)
+    (modify-syntax-entry ?> "." table)
+    (modify-syntax-entry ?& "." table)
+    (modify-syntax-entry ?| "." table)
+    (modify-syntax-entry ?` "w" table)
+    (modify-syntax-entry ?_ "w" table)
+    (modify-syntax-entry ?\' "." table)
+
+    ;; Set up TABLE to handle block and line style comments.
+    (if (featurep 'xemacs)
+	(progn
+	  ;; XEmacs (formerly Lucid) has the best implementation
+	  (modify-syntax-entry ?/  ". 1456" table)
+	  (modify-syntax-entry ?*  ". 23"   table)
+	  (modify-syntax-entry ?\n "> b"    table))
+      ;; Emacs 19 does things differently, but we can work with it
+      (modify-syntax-entry ?/  ". 124b" table)
+      (modify-syntax-entry ?*  ". 23"   table)
+      (modify-syntax-entry ?\n "> b"    table))
+    table)
   "Syntax table used in `verilog-mode' buffers.")
 
 (defvar verilog-font-lock-keywords nil
@@ -1961,8 +1907,7 @@
 		 'font-lock-type-face))
 	 ;; Fontify Verilog-AMS keywords
 	 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>")
-	       'verilog-font-lock-ams-face)
-	 ))
+	       'verilog-font-lock-ams-face)))
 
   (setq verilog-font-lock-keywords-1
 	(append verilog-font-lock-keywords
@@ -1976,15 +1921,12 @@
 		 (list
 		  (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" )
 		       '(1 font-lock-keyword-face)
-		       '(3 font-lock-reference-face prepend)
-		       )
+		       '(3 font-lock-reference-face prepend))
 		 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)"
 		   (1 font-lock-keyword-face)
-		   (2 font-lock-reference-face append)
-		   )
+		   (2 font-lock-reference-face append))
 		 '("\\<function\\>\\s-+\\(\\sw+\\)"
-		   1 'font-lock-reference-face append)
-		 )))
+		   1 'font-lock-reference-face append))))
 
   (setq verilog-font-lock-keywords-2
 	(append verilog-font-lock-keywords-1
@@ -2002,7 +1944,6 @@
 		   0 font-lock-type-face append)
 		 ;; Fontify instantiation names
 		 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face)
-
 		 )))
 
   (setq verilog-font-lock-keywords-3
@@ -2015,15 +1956,14 @@
 		   )))))
 
 
-
 (defun verilog-inside-comment-p ()
   "Check if point inside a nested comment."
   (save-excursion
     (let ((st-point (point)) hitbeg)
       (or (search-backward "//" (verilog-get-beg-of-line) t)
 	  (if (progn
-		;; This is for tricky case //*, we keep searching if /* is
-		;; proceeded by // on same line.
+		;; This is for tricky case //*, we keep searching if /*
+		;; is proceeded by // on same line.
 		(while
 		    (and (setq hitbeg (search-backward "/*" nil t))
 			 (progn
@@ -2048,14 +1988,14 @@
   "Move backward over a sexp."
   (interactive)
   ;; before that see if we are in a comment
-  (verilog-backward-sexp)
-)
+  (verilog-backward-sexp))
+
 (defun electric-verilog-forward-sexp ()
   "Move backward over a sexp."
   (interactive)
   ;; before that see if we are in a comment
-  (verilog-forward-sexp)
-)
+  (verilog-forward-sexp))
+
 ;;;used by hs-minor-mode
 (defun verilog-forward-sexp-function (arg)
   (if (< arg 0)
@@ -2067,19 +2007,16 @@
   (let ((reg)
 	(elsec 1)
 	(found nil)
-	(st (point))
-	)
+	(st (point)))
     (if (not (looking-at "\\<"))
 	(forward-word -1))
     (cond
-     ((verilog-skip-backward-comment-or-string)
-      )
+     ((verilog-skip-backward-comment-or-string))
      ((looking-at "\\<else\\>")
       (setq reg (concat
 		 verilog-end-block-re
 		 "\\|\\(\\<else\\>\\)"
-		 "\\|\\(\\<if\\>\\)"
-		 ))
+		 "\\|\\(\\<if\\>\\)"))
       (while (and (not found)
 		  (verilog-re-search-backward reg nil 'move))
 	(cond
@@ -2094,11 +2031,7 @@
 	  (setq elsec (1- elsec))
 	  (if (= 0 elsec)
 	      ;; Now previous line describes syntax
-	      (setq found 't)
-	    ))
-	 )
-	)
-      )
+	      (setq found 't))))))
      ((looking-at verilog-end-block-re)
       (verilog-leap-to-head))
      ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)")
@@ -2120,9 +2053,7 @@
 	(backward-sexp 1))))
      (t
       (goto-char st)
-      (backward-sexp))
-     ) ;; cond
-    ))
+      (backward-sexp)))))
 
 (defun verilog-forward-sexp ()
   (let ((reg)
@@ -2132,8 +2063,7 @@
 	(forward-word -1))
     (cond
      ((verilog-skip-forward-comment-or-string)
-      (verilog-forward-syntactic-ws)
-      )
+      (verilog-forward-syntactic-ws))
      ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking
       (cond
        ((match-end 1) ; end
@@ -2141,8 +2071,7 @@
 	(setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
        ((match-end 2) ; endcase
 	;; Search forward for matching case
-	(setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )
-	)
+	(setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
        ((match-end 3) ; join
 	;; Search forward for matching fork
 	(setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
@@ -2173,12 +2102,10 @@
        ((match-end 12) ; endsequence
 	;; Search forward for matching sequence
 	(setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )
-	(setq md 3) ; 3 to get to endsequence in the reg above
-	)
+	(setq md 3)) ; 3 to get to endsequence in the reg above
        ((match-end 13) ; endclocking
 	;; Search forward for matching clocking
-	(setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))
-       )
+	(setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" )))
       (if (forward-word 1)
 	  (catch 'skip
 	    (let ((nest 1))
@@ -2189,9 +2116,7 @@
 		  (if (= 0 nest) ; we are out!
 		      (throw 'skip 1)))
 		 ((match-end 1) ; the opener in reg, so we are deeper now
-		  (setq nest (1+ nest)))))
-	      )))
-      )
+		  (setq nest (1+ nest)))))))))
      ((looking-at (concat
 		   "\\(\\<\\(macro\\)?module\\>\\)\\|"
 		   "\\(\\<primitive\\>\\)\\|"
@@ -2221,9 +2146,7 @@
       (goto-char st)
       (if (= (following-char) ?\) )
 	  (forward-char 1)
-	(forward-sexp 1)))
-     ) ;; cond
-    ))
+	(forward-sexp 1))))))
 
 (defun verilog-declaration-beg ()
   (verilog-re-search-backward verilog-declaration-re (bobp) t))
@@ -2238,8 +2161,7 @@
 		  (list
 		   ;; Fontify things in translate off regions
 		   '(verilog-match-translate-off
-                     (0 'verilog-font-lock-translate-off-face prepend))
-		   ))))
+                     (0 'verilog-font-lock-translate-off-face prepend))))))
   (put 'verilog-mode 'font-lock-defaults
        '((verilog-font-lock-keywords
 	  verilog-font-lock-keywords-1
@@ -2253,23 +2175,7 @@
 
 ;; initialize fontification for Verilog Mode
 (verilog-font-lock-init)
-;; start up message
-(defconst verilog-startup-message-lines
-  '("Please use \\[verilog-submit-bug-report] to report bugs."
-    "Visit http://www.verilog.com to check for updates"
-    ))
-(defvar verilog-startup-message-displayed t)
-(defun verilog-display-startup-message ()
-  (if (not verilog-startup-message-displayed)
-      (if (sit-for 5)
-	  (let ((lines verilog-startup-message-lines))
-	    (message "verilog-mode version %s, released %s; type \\[describe-mode] for help"
-		     verilog-mode-version verilog-mode-release-date)
-	    (setq verilog-startup-message-displayed t)
-	    (while (and (sit-for 4) lines)
-	      (message (substitute-command-keys (car lines)))
-	      (setq lines (cdr lines)))))
-    (message "")))
+
 ;;
 ;;
 ;;  Mode
@@ -2409,14 +2315,10 @@
   (setq major-mode 'verilog-mode)
   (setq mode-name "Verilog")
   (setq local-abbrev-table verilog-mode-abbrev-table)
-  (setq verilog-mode-syntax-table (make-syntax-table))
-  (verilog-populate-syntax-table verilog-mode-syntax-table)
-  (set (make-local-variable 'beginning-of-defun-function) 
+  (set (make-local-variable 'beginning-of-defun-function)
        'verilog-beg-of-defun)
-  (set (make-local-variable 'end-of-defun-function) 
+  (set (make-local-variable 'end-of-defun-function)
        'verilog-end-of-defun)
-  ;; add extra comment syntax
-  (verilog-setup-dual-comments verilog-mode-syntax-table)
   (set-syntax-table verilog-mode-syntax-table)
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'verilog-indent-line-relative)
@@ -2444,8 +2346,8 @@
 	       (not (assoc "Verilog" current-menubar)))
       ;; (set-buffer-menubar (copy-sequence current-menubar))
       (add-submenu nil verilog-xemacs-menu)
-      (add-submenu nil verilog-stmt-menu)
-      ))
+      (add-submenu nil verilog-stmt-menu)))
+
   ;; Stuff for GNU emacs
   (set (make-local-variable 'font-lock-defaults)
        '((verilog-font-lock-keywords verilog-font-lock-keywords-1
@@ -2472,8 +2374,6 @@
 	  (cons '(verilog-mode-mode  "\\<begin\\>" "\\<end\\>" nil
 			     verilog-forward-sexp-function)
 		hs-special-modes-alist)))
-  ;; Display version splash information.
-  (verilog-display-startup-message)
 
   ;; Stuff for autos
   (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local
@@ -2527,27 +2427,19 @@
 	       (progn
 		 (end-of-line)
 		 (delete-horizontal-space)
-		 't
-		 )
-	       )
-	     )
+		 't)))
 	   ;; see if we should line up assignments
 	   (progn
 	     (if (or (memq 'all verilog-auto-lineup)
 		     (memq 'assignments verilog-auto-lineup))
-		 (verilog-pretty-expr)
-	       )
-	     (newline)
-	     )
-	 (forward-line 1)
-	 )
+		 (verilog-pretty-expr))
+	     (newline))
+	 (forward-line 1))
        ;; Indent next line
        (if verilog-auto-indent-on-newline
-	   (verilog-indent-line))
-       )
+	   (verilog-indent-line)))
      (t
-      (newline))
-     )))
+      (newline)))))
 
 (defun electric-verilog-terminate-and-indent ()
   "Insert a newline and indent for the next statement."
@@ -2565,8 +2457,7 @@
     (save-excursion
       (beginning-of-line)
       (verilog-forward-ws&directives)
-      (verilog-indent-line)
-      )
+      (verilog-indent-line))
     (if (and verilog-auto-newline
 	     (not (verilog-parenthesis-depth)))
 	(electric-verilog-terminate-line))))
@@ -2648,9 +2539,7 @@
 		   (re-search-forward comment-start-skip oldpnt 'move)
 		   (goto-char (match-beginning 0))
 		   (skip-chars-backward " \t")
-		   (kill-region (point) oldpnt)
-		   ))))
-	)
+		   (kill-region (point) oldpnt))))))
     (progn (insert "\t"))))
 
 
@@ -2690,7 +2579,7 @@
   (insert " * "))
 
 (defun verilog-insert-1 (fmt max)
-  "Insert integers 0 to MAX-1 according to format string FMT.
+  "Use format string FMT to insert integers 0 to MAX - 1.
 Inserts one integer per line, at the current column.  Stops early
 if it reaches the end of the buffer."
   (let ((col (current-column))
@@ -2724,7 +2613,7 @@
     a = b                           a[  7] = b
     a = b                           a[  8] = b"
 
-  (interactive "NMAX? ")
+  (interactive "NMAX: ")
   (verilog-insert-1 "[%3d]" max))
 
 (defun verilog-generate-numbers (max)
@@ -2744,19 +2633,20 @@
     buf buf                             buf buf007
     buf buf                             buf buf008"
 
-  (interactive "NMAX? ")
+  (interactive "NMAX: ")
   (verilog-insert-1 "%3.3d" max))
 
 (defun verilog-mark-defun ()
   "Mark the current verilog function (or procedure).
 This puts the mark at the end, and point at the beginning."
   (interactive)
-  (push-mark (point))
-  (verilog-end-of-defun)
-  (push-mark (point))
-  (verilog-beg-of-defun)
-  (if (fboundp 'zmacs-activate-region)
-      (zmacs-activate-region)))
+  (when (featurep 'xemacs)
+    (push-mark (point))
+    (verilog-end-of-defun)
+    (push-mark (point))
+    (verilog-beg-of-defun)
+    (if (fboundp 'zmacs-activate-region)
+	(zmacs-activate-region))))
 
 (defun verilog-comment-region (start end)
   ; checkdoc-params: (start end)
@@ -2792,8 +2682,7 @@
     (save-excursion
       (let ((s+1 (1+ start)))
 	(while (re-search-backward "/\\*" s+1 t)
-	  (replace-match "/-*" t t))))
-    ))
+	  (replace-match "/-*" t t))))))
 
 (defun verilog-uncomment-region ()
   "Uncomment a commented area; change deformed comments back to normal.
@@ -2869,8 +2758,7 @@
 	     (point-marker)))
 	(e (progn
 	     (verilog-end-of-defun)
-	     (point-marker)))
-	)
+	     (point-marker))))
     (goto-char (marker-position b))
     (if (> (- e b) 200)
 	(message  "Relabeling module..."))
@@ -2885,18 +2773,15 @@
       (let ((indent-str (verilog-indent-line)))
 	(verilog-set-auto-endcomments indent-str 't)
 	(end-of-line)
-	(delete-horizontal-space)
-	)
+	(delete-horizontal-space))
       (setq cnt (1+ cnt))
       (if (= 9 (% cnt 10))
-	  (message "%d..." cnt))
-      )
+	  (message "%d..." cnt)))
     (goto-char oldpos)
     (if (or
 	 (> (- e b) 200)
 	 (> cnt 20))
-	(message  "%d lines auto commented" cnt))
-    ))
+	(message  "%d lines auto commented" cnt))))
 
 (defun verilog-beg-of-statement ()
   "Move backward to beginning of statement."
@@ -2919,15 +2804,13 @@
 	     (looking-at verilog-extended-complete-re)
 	     (not (save-excursion
 		    (verilog-backward-token)
-		    (looking-at verilog-extended-complete-re)))
-	     )
+		    (looking-at verilog-extended-complete-re))))
 	    (looking-at verilog-basic-complete-re)
 	    (save-excursion
 	      (verilog-backward-token)
 	      (or
 	       (looking-at verilog-end-block-re)
-	       (looking-at verilog-preprocessor-re)))
-	    ))
+	       (looking-at verilog-preprocessor-re)))))
     (verilog-backward-syntactic-ws)
     (verilog-backward-token))
   ;; Now point is where the previous line ended.
@@ -3011,9 +2894,9 @@
 		(throw 'found 1))
 		(setq nest (1- nest)))
 	       (t
-		(throw 'found (= nest 0)))
-	       ))))
+		(throw 'found (= nest 0)))))))
       nil)))
+
 (defun verilog-in-struct-region-p ()
   "Return TRUE if in a struct region;
 more specifically, in a list after a struct|union keyword"
@@ -3024,20 +2907,14 @@
       (if depth
 	  (progn (backward-up-list depth)
 		 (verilog-beg-of-statement)
-		 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")
-		 )
-	)
-      )
-    )
-  )
+		 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>"))))))
 
 (defun verilog-in-generate-region-p ()
   "Return TRUE if in a generate region;
 more specifically, after a generate and before an endgenerate"
   (interactive)
   (let ((lim (save-excursion (verilog-beg-of-defun)  (point)))
-	(nest 1)
-	)
+	(nest 1))
     (save-excursion
       (while (and
 	      (/= nest 0)
@@ -3046,17 +2923,14 @@
 	       ((match-end 1) ; generate
 		(setq nest (1- nest)))
 	       ((match-end 2) ; endgenerate
-		(setq nest (1+ nest)))
-	       ))
-	))
+		(setq nest (1+ nest)))))))
     (= nest 0) )) ; return nest
 
 (defun verilog-in-fork-region-p ()
   "Return true if between a fork and join."
   (interactive)
   (let ((lim (save-excursion (verilog-beg-of-defun)  (point)))
-	(nest 1)
-	)
+	(nest 1))
     (save-excursion
       (while (and
 	      (/= nest 0)
@@ -3065,9 +2939,7 @@
 	       ((match-end 1) ; fork
 		(setq nest (1- nest)))
 	       ((match-end 2) ; join
-		(setq nest (1+ nest)))
-	       ))
-	))
+		(setq nest (1+ nest)))))))
     (= nest 0) )) ; return nest
 
 (defun verilog-backward-case-item (lim)
@@ -3099,8 +2971,7 @@
 	      (setq colon (1- colon)))
 
 	     ((match-end 3) ;; :
-	      (setq colon (1+ colon)))
-	     ))
+	      (setq colon (1+ colon)))))
 	  ;; Skip back to beginning of case item
 	  (skip-chars-backward "\t ")
 	  (verilog-skip-backward-comment-or-string)
@@ -3123,10 +2994,8 @@
 			 (t
 			  (goto-char (match-end 0))
 			  (verilog-forward-ws&directives)
-			  (point))
-			 ))
-		    (error "Malformed case item")
-		    )))
+			  (point))))
+		    (error "Malformed case item"))))
 	  (setq str (buffer-substring b e))
 	  (if
 	      (setq e
@@ -3178,8 +3047,7 @@
 		   (search-backward "//" (verilog-get-beg-of-line) t)))))
       (let ((nest 1) b e
 	    m
-	    (else (if (match-end 2) "!" " "))
-	    )
+	    (else (if (match-end 2) "!" " ")))
 	(end-of-line)
 	(if kill-existing-comment
 	    (verilog-kill-existing-comment))
@@ -3199,8 +3067,7 @@
 	     ((match-end 4) ; `ifdef
 	      (setq nest (1- nest)))
 	     ((match-end 5) ; `ifndef
-	      (setq nest (1- nest)))
-	     ))
+	      (setq nest (1- nest)))))
 	  (if (match-end 0)
 	      (setq
 	       m (buffer-substring
@@ -3212,15 +3079,13 @@
 		   (point))
 	       e (progn
 		   (skip-chars-forward "a-zA-Z0-9_")
-		   (point)
-		   ))))
+		   (point)))))
 	(if b
 	    (if (> (count-lines (point) b) verilog-minimum-comment-distance)
 		(insert (concat " // " else m " " (buffer-substring b e))))
 	  (progn
 	    (insert " // unmatched `else or `endif")
-	    (ding 't))
-	  )))
+	    (ding 't)))))
 
      (; Comment close case/class/function/task/module and named block
       (and (looking-at "\\<end")
@@ -3269,8 +3134,7 @@
 		      (err 't)
 		      (here (point))
 		      there
-		      cntx
-		      )
+		      cntx)
 		  (save-excursion
 		    (verilog-leap-to-head)
 		    (setq there (point))
@@ -3282,12 +3146,10 @@
 			      (verilog-kill-existing-comment))
 			  (delete-horizontal-space)
 			  (insert str)
-			  (ding 't)
-			  )
+			  (ding 't))
 		      (let ((lim
 			     (save-excursion (verilog-beg-of-defun) (point)))
-			    (here (point))
-			    )
+			    (here (point)))
 			(cond
 			 (;-- handle named block differently
 			  (looking-at verilog-named-block-re)
@@ -3336,8 +3198,7 @@
 			     (;- else
 			      (match-end 4)
 			      (let ((nest 0)
-				    ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")
-				    )
+				    ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
 				(catch 'skip
 				  (while (verilog-re-search-backward reg nil 'move)
 				    (cond
@@ -3353,16 +3214,13 @@
 					    (setq err nil)
 					    (setq str (verilog-get-expr))
 					    (setq str (concat " // else: !if" str ))
-					    (throw 'skip 1))
-					)))
-				    ))))
+					    (throw 'skip 1)))))))))
 
 			     (;- end else
 			      (match-end 5)
 			      (goto-char there)
 			      (let ((nest 0)
-				    ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")
-				    )
+				    (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
 				(catch 'skip
 				  (while (verilog-re-search-backward reg nil 'move)
 				    (cond
@@ -3378,9 +3236,7 @@
 					    (setq err nil)
 					    (setq str (verilog-get-expr))
 					    (setq str (concat " // else: !if" str ))
-					    (throw 'skip 1))
-					)))
-				    ))))
+					    (throw 'skip 1)))))))))
 
 			     (;- task/function/initial et cetera
 			      t
@@ -3392,8 +3248,7 @@
 			      (setq str (concat " // " cntx str )))
 
 			     (;-- otherwise...
-			      (setq str " // auto-endcomment confused "))
-			     ))
+			      (setq str " // auto-endcomment confused "))))
 
 			   ((and
 			     (verilog-in-case-region-p) ;-- handle case item differently
@@ -3431,9 +3286,8 @@
 		(match-end 11) ;; of verilog-end-block-ordered-re
 		;;(goto-char there)
 		(let ((nest 0)
-		      ( reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>")
-		      string
-		      )
+		      (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>")
+		      string)
 		  (save-excursion
 		    (catch 'skip
 		      (while (verilog-re-search-backward reg nil 'move)
@@ -3463,8 +3317,7 @@
 				(throw 'skip 1))))
 			 ))))
 		  (end-of-line)
-		  (insert (concat " // " string )))
-		)
+		  (insert (concat " // " string ))))
 
 	       (;- this is end{function,generate,task,module,primitive,table,generate}
 		;- which can not be nested.
@@ -3479,8 +3332,7 @@
 		  (cond
 		   ((match-end 5) ;; of verilog-end-block-ordered-re
 		    (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)")
-		    (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")
-		    )
+		    (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?"))
 		   ((match-end 6) ;; of verilog-end-block-ordered-re
 		    (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)"))
 		   ((match-end 7) ;; of verilog-end-block-ordered-re
@@ -3502,8 +3354,7 @@
 		   ((match-end 15) ;; of verilog-end-block-ordered-re
 		    (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>"))
 
-		   (t (error "Problem in verilog-set-auto-endcomments"))
-		   )
+		   (t (error "Problem in verilog-set-auto-endcomments")))
 		  (let (b e)
 		    (save-excursion
 		      (verilog-re-search-backward reg nil 'move)
@@ -3515,8 +3366,7 @@
 				  (if (and width (looking-at width))
 				      (progn
 					(goto-char (match-end 0))
-					(verilog-forward-ws&directives)
-					))
+					(verilog-forward-ws&directives)))
 				  (point))
 			      e (progn
 				  (skip-chars-forward "a-zA-Z0-9_")
@@ -3577,8 +3427,7 @@
 		b)
 	       ('t
 		(skip-chars-forward "^: \t\n\f")
-		(point)
-		))))
+		(point)))))
 	 (str (buffer-substring b e)))
     (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str))
 	(setq str (concat (substring str 0 e) "...")))
@@ -3601,8 +3450,8 @@
 	   (concat "\\(.*\\)"
 		   (regexp-quote bra)
 		   "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)"
-				(regexp-quote ket)
-				"\\(.*\\)$") signal-string)
+		   (regexp-quote ket)
+		   "\\(.*\\)$") signal-string)
 	  (let* ((sig-head (match-string 1 signal-string))
 		 (vec-start (string-to-number (match-string 2 signal-string)))
 		 (vec-end (if (= (match-beginning 3) (match-end 3))
@@ -3765,8 +3614,7 @@
                   )))
                ((verilog-in-star-comment-p)
                 (re-search-backward "/\*")
-                (insert (format " // surefire lint_off_line %6s" code ))
-                )
+                (insert (format " // surefire lint_off_line %6s" code )))
                (t
                 (insert (format " // surefire lint_off_line %6s" code ))
                 )))))))))
@@ -3823,11 +3671,11 @@
    (setq default-major-mode `verilog-mode)
    ;; Ditto files already read in
    (mapc (lambda (buf)
-           (when (buffer-file-name buf)
-             (save-excursion
-               (set-buffer buf)
-               (verilog-mode))))
-         (buffer-list))
+	   (when (buffer-file-name buf)
+	     (save-excursion
+	       (set-buffer buf)
+	       (verilog-mode))))
+	 (buffer-list))
    ;; Process the files
    (mapcar '(lambda (buf)
 	      (when (buffer-file-name buf)
@@ -3943,8 +3791,7 @@
 			(not (verilog-in-coverage))
 			(verilog-in-paren))
 		       (progn (setq par 1)
-			      (throw 'nesting 'block))
-		     )
+			      (throw 'nesting 'block)))
 
 		   ;; See if we are continuing a previous line
 		   (while t
@@ -4026,8 +3873,7 @@
 				   (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
 				  ((match-end 12) ; covergroup
 				   ;; Search back for matching covergroup
-				   (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
-				  )
+				   (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )))
 				 (catch 'skip
 				   (while (verilog-re-search-backward reg nil 'move)
 				     (cond
@@ -4037,11 +3883,8 @@
 					   (throw 'skip 1)))
 				      ((match-end 2) ; end
 				       (setq nest (1+ nest)))))
-				   )
-				 ))
-			      ))))
-		     (throw 'nesting (verilog-calc-1))
-		     )
+				   )))))))
+		     (throw 'nesting (verilog-calc-1)))
 		   );; catch nesting
 		 );; type
 	   )
@@ -4058,8 +3901,8 @@
 	  ((eq type 'defun)
 	   (list type 0))
 	  (t
-	   (list type (verilog-current-indent-level)))))
-      )))
+	   (list type (verilog-current-indent-level))))))))
+
 (defun verilog-wai ()
   "Show matching nesting block for debugging."
   (interactive)
@@ -4073,8 +3916,7 @@
       (cond
        ((equal (char-after) ?\{)
 	(if (verilog-at-constraint-p)
-	    (throw 'nesting 'block)
-	  ))
+	    (throw 'nesting 'block)))
        ((equal (char-after) ?\})
 
 	(let ((there (verilog-at-close-constraint-p)))
@@ -4133,8 +3975,7 @@
 For speed, the searcher looks at the last directive, not the indent
 of the appropriate enclosing block."
   (let ((base -1)	;; Indent of the line that determines our indentation
-	(ind 0)	        ;; Relative offset caused by other directives (like `endif on same line as `else)
-	)
+	(ind 0))        ;; Relative offset caused by other directives (like `endif on same line as `else)
     ;; Start at current location, scan back for another directive
 
     (save-excursion
@@ -4142,8 +3983,7 @@
       (while (and (< base 0)
 		  (verilog-re-search-backward verilog-directive-re nil t))
 	(cond ((save-excursion (skip-chars-backward " \t") (bolp))
-	       (setq base (current-indentation))
-	       ))
+	       (setq base (current-indentation))))
 	(cond ((and (looking-at verilog-directive-end) (< base 0))  ;; Only matters when not at BOL
 	       (setq ind (- ind verilog-indent-level-directive)))
 	      ((and (looking-at verilog-directive-middle) (>= base 0))  ;; Only matters when at BOL
@@ -4223,8 +4063,7 @@
       (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ))
      ((looking-at "\\<endclocking\\>")
       ;; 12: Search back for matching clocking
-      (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))
-     )
+      (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" )))
     (if reg
 	(catch 'skip
 	  (let (sreg)
@@ -4268,9 +4107,7 @@
 			(save-excursion
 			  (skip-chars-backward " \t")
 			  (not (bolp))))
-	    (setq continued (verilog-backward-token))
-	    ) ;; while
-	    ))
+	    (setq continued (verilog-backward-token)))))
       (setq continued nil))
     continued))
 
@@ -4289,15 +4126,13 @@
     (= (preceding-char) ?\})
     (progn
       (backward-char)
-      (verilog-at-close-constraint-p))
-    )
+      (verilog-at-close-constraint-p)))
    (;-- constraint foo { a = b }
     ;   is a complete statement. *sigh*
     (= (preceding-char) ?\{)
     (progn
       (backward-char)
-      (not (verilog-at-constraint-p)))
-    )
+      (not (verilog-at-constraint-p))))
    (;-- Could be 'case (foo)' or 'always @(bar)' which is complete
     ;   also could be simply '@(foo)'
     ;   or foo u1 #(a=8)
@@ -4322,10 +4157,8 @@
 	      (verilog-backward-token)
 	      (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>"))))
 	   ((= (preceding-char) ?\#)
-	    (backward-char)
-	    )
-	   (t t))
-	  )))))
+	    (backward-char))
+	   (t t)))))))
 
    (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete
     t
@@ -4346,8 +4179,7 @@
 	  (backward-sexp)
 	  (if (looking-at verilog-nameable-item-re )
 	      nil
-	    t)
-	  )
+	    t))
 	 ((= (preceding-char) ?\#)
 	  (backward-char)
 	  t)
@@ -4357,8 +4189,7 @@
 
 	 (t
 	  (goto-char back)
-	  t)
-	 )))))))
+	  t))))))))
 
 (defun verilog-backward-syntactic-ws (&optional bound)
   "Backward skip over syntactic whitespace for Emacs 19.
@@ -4370,9 +4201,7 @@
 	    (narrow-to-region bound (point))
 	    (while (/= here (point))
 	      (setq here (point))
-	      (verilog-skip-backward-comments)
-	      )))
-      ))
+	      (verilog-skip-backward-comments))))))
   t)
 
 (defun verilog-forward-syntactic-ws (&optional bound)
@@ -4380,16 +4209,13 @@
 Optional BOUND limits search."
   (save-restriction
     (let* ((bound (or bound (point-max)))
-	   (here bound)
-	   )
+	   (here bound))
       (if (> bound (point))
 	  (progn
 	    (narrow-to-region (point) bound)
 	    (while (/= here (point))
 	      (setq here (point))
-	      (forward-comment (buffer-size))
-	      )))
-      )))
+	      (forward-comment (buffer-size))))))))
 
 (defun verilog-backward-ws&directives (&optional bound)
   "Backward skip over syntactic whitespace and compiler directives for Emacs 19.
@@ -4423,9 +4249,7 @@
 			(point))
 		       (t
 			nil))))
-	      (if p (goto-char p))
-	      )))
-      )))
+	      (if p (goto-char p))))))))
 
 (defun verilog-forward-ws&directives (&optional bound)
   "Forward skip over syntactic whitespace and compiler directives for Emacs 19.
@@ -4433,8 +4257,7 @@
   (save-restriction
     (let* ((bound (or bound (point-max)))
 	   (here bound)
-	   jump
-	   )
+	   jump)
       (if (> bound (point))
 	  (progn
 	    (let ((state
@@ -4455,9 +4278,7 @@
 		(if (looking-at verilog-directive-re-1)
 		    (setq jump t)))
 	      (if jump
-		  (beginning-of-line 2))
-	      )))
-      )))
+		  (beginning-of-line 2))))))))
 
 (defun verilog-in-comment-p ()
  "Return true if in a star or // comment."
@@ -4537,14 +4358,11 @@
 	 (forward-list)
 	 (progn (backward-char 1)
 		(verilog-backward-ws&directives)
-		(equal (char-before) ?\;))
-	 ))
+		(equal (char-before) ?\;))))
       ;; maybe
       (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move)
     ;; not
-    nil
-    )
-  )
+    nil))
 
 (defun verilog-parenthesis-depth ()
  "Return non zero if in parenthetical-expression."
@@ -4608,8 +4426,7 @@
 	       t)
 	      ((and (not (bobp))
 		    (= (char-before) ?\/)
-		    (= (char-before (1- (point))) ?\*)
-		    )
+		    (= (char-before (1- (point))) ?\*))
 	       (goto-char (- (point) 2))
 	       t)
 	      (t
@@ -4650,8 +4467,8 @@
 	    (if (verilog-continued-line)
 		(progn
 		  (goto-char sp)
-		  (setq
-		   indent-str (list 'statement (verilog-current-indent-level))))
+		  (setq indent-str
+			(list 'statement (verilog-current-indent-level))))
 	      (goto-char sp1)
 	      (setq indent-str (list 'block (verilog-current-indent-level)))))
 	  (goto-char sp))
@@ -4701,16 +4518,13 @@
 			     (progn
 			       (forward-char 1)
 			       (backward-up-list -1)
-			       (skip-chars-forward " \t")))
-			    )
+			       (skip-chars-forward " \t"))))
 			   (current-column))
 		       (progn
 			 (goto-char fst)
-			 (+ (current-column) verilog-cexp-indent))
-		       ))))
+			 (+ (current-column) verilog-cexp-indent))))))
 	    (goto-char here)
-	    (indent-line-to val))
-	  )
+	    (indent-line-to val)))
 	 ((= (preceding-char) ?\) )
 	  (goto-char here)
 	  (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
@@ -4724,8 +4538,7 @@
 		(setq val (current-column))
 	      (setq val (eval (cdr (assoc type verilog-indent-alist)))))
 	    (goto-char here)
-	    (indent-line-to val)))
-	 )))
+	    (indent-line-to val))))))
 
      (; handle inside parenthetical expressions
       (eq type 'cparenexp)
@@ -4737,8 +4550,7 @@
 	(indent-line-to val)
 	(if (and (not (verilog-in-struct-region-p))
 		 (looking-at verilog-declaration-re))
-	    (verilog-indent-declaration ind))
-	))
+	    (verilog-indent-declaration ind))))
 
      (;-- Handle the ends
       (or
@@ -4774,8 +4586,8 @@
      (;-- Everything else
       t
       (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
-	(indent-line-to val)))
-     )
+	(indent-line-to val))))
+
     (if (looking-at "[ \t]+$")
 	(skip-chars-forward " \t"))
     indent-str				; Return indent data
@@ -4823,8 +4635,7 @@
 	   (t
 	    (save-excursion
 	      (re-search-backward "//" nil t)
-	      (current-column)))
-	   )))
+	      (current-column))))))
     (indent-line-to stcol)
     stcol))
 
@@ -4843,8 +4654,7 @@
 	   (t
 	    (save-excursion
 	      (re-search-backward "//" nil t)
-	      (current-column)))
-	   )))
+	      (current-column))))))
     (progn
       (indent-to stcol)
       (if (and star
@@ -4912,8 +4722,7 @@
 		  (goto-char start)
 		  (verilog-do-indent (verilog-calculate-indent))
 		  (verilog-forward-ws&directives)
-		  (current-column)))
-	       )
+		  (current-column))))
 	  (goto-char end)
 	  (goto-char start)
 	  (if (> (- end start) 100)
@@ -4927,15 +4736,12 @@
 	       (verilog-forward-ws&directives)
 	       (indent-line-to base-ind)
 	       (verilog-forward-ws&directives)
-	       (verilog-re-search-forward "[ \t\n\f]" e 'move)
-	       )
+	       (verilog-re-search-forward "[ \t\n\f]" e 'move))
 	     (t
 	      (just-one-space)
-	      (verilog-re-search-forward "[ \t\n\f]" e 'move)
-	      )
-	     )
+	      (verilog-re-search-forward "[ \t\n\f]" e 'move)))
+	    ;;(forward-line)
 	    )
-	    ;;(forward-line))
 	  ;; Now find biggest prefix
 	  (setq ind (verilog-get-lineup-indent start edpos))
 	  ;; Now indent each line.
@@ -4960,21 +4766,19 @@
 		      (indent-to ind))
 		  (progn
 		    (just-one-space)
-		    (indent-to ind))
-		  )))
+		    (indent-to ind)))))
 	     ((verilog-continued-line-1 start)
 	      (goto-char e)
 	      (indent-line-to ind))
 	     (t		; Must be comment or white space
 	      (goto-char e)
 	      (verilog-forward-ws&directives)
-	      (forward-line -1))
-	     )
+	      (forward-line -1)))
 	    (forward-line 1))
 	  (message "")))))
 
 (defun verilog-pretty-expr (&optional myre)
-  "Line up expressions around point."
+  "Line up expressions around point, or optional regexp MYRE."
   (interactive "sRegular Expression: ((<|:)?=) ")
   (save-excursion
     (if (or (eq myre nil)
@@ -4995,8 +4799,7 @@
 		  (beginning-of-line)
 		  (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
 			      (looking-at myre)
-			      (not (bobp))
-			      )
+			      (not (bobp)))
 		    (setq e (point))
 		    (verilog-backward-syntactic-ws)
 		    (beginning-of-line)
@@ -5015,12 +4818,10 @@
 		    (end-of-line)
 		    (setq e (point))
 		    (verilog-forward-syntactic-ws)
-		    (beginning-of-line)
-		    )
+		    (beginning-of-line))
 		  e))
 	       (edpos (set-marker (make-marker) end))
-	       (ind)
-	       )
+	       (ind))
 	  (goto-char start)
 	  (verilog-do-indent (verilog-calculate-indent))
 	  (if (> (- end start) 100)
@@ -5031,8 +4832,7 @@
 	    (beginning-of-line)
 	    (verilog-just-one-space myre)
 	    (end-of-line)
-	    (verilog-forward-syntactic-ws)
-	    )
+	    (verilog-forward-syntactic-ws))
 
 	  ;; Now find biggest prefix
 	  (setq ind (verilog-get-lineup-indent-2 myre start edpos))
@@ -5049,20 +4849,16 @@
 	      (goto-char (match-end 1))
 	      (if (eq (char-after) ?=)
 		  (indent-to (1+ ind))	; line up the = of the <= with surrounding =
-		(indent-to ind)
-		)
-	      )
+		(indent-to ind)))
 	     ((verilog-continued-line-1 start)
 	      (goto-char e)
 	      (indent-line-to ind))
 	     (t		; Must be comment or white space
 	      (goto-char e)
 	      (verilog-forward-ws&directives)
-	      (forward-line -1))
-	     )
+	      (forward-line -1)))
 	    (forward-line 1))
-	  (message "")
-	  ))))
+	  (message "")))))
 
 (defun verilog-just-one-space (myre)
   "Remove extra spaces around regular expression MYRE."
@@ -5073,12 +4869,10 @@
 	    (p2 (match-end 2)))
 	(progn
 	  (goto-char p2)
-	  (if (looking-at "\\s-") (just-one-space) )
+	  (if (looking-at "\\s-") (just-one-space))
 	  (goto-char p1)
 	  (forward-char -1)
-	  (if (looking-at "\\s-") (just-one-space))
-	  )
-	))
+	  (if (looking-at "\\s-") (just-one-space)))))
   (message ""))
 
 (defun verilog-indent-declaration (baseind)
@@ -5093,8 +4887,7 @@
 	       (point)))
 	(ind)
 	(val)
-	(m1 (make-marker))
-	)
+	(m1 (make-marker)))
     (setq val
 	  (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
     (indent-line-to val)
@@ -5125,13 +4918,11 @@
 			  (just-one-space)
 			  (goto-char (marker-position m1))
 			  (just-one-space)
-			  (indent-to ind)
-			  )
+			  (indent-to ind))
 		      (if (/= (current-column) ind)
 			  (progn
 			    (just-one-space)
-			    (indent-to ind))
-			)))
+			    (indent-to ind)))))
 		(if (looking-at verilog-declaration-re-2-no-macro)
 		    (let ((p (match-end 0)))
 		      (set-marker m1 p)
@@ -5362,11 +5153,8 @@
 	    (if (or (null verilog-pred)
 		    (funcall verilog-pred match))
 		(setq verilog-all (cons match verilog-all)))))
-      (forward-line 1)
-      )
-    )
-  verilog-all
-  )
+      (forward-line 1)))
+  verilog-all)
 
 (defun verilog-type-completion ()
   "Calculate all possible completions for types."
@@ -5663,8 +5451,7 @@
 	    (goto-char pt)
 	    (beginning-of-line))
 	  pt)
-	(verilog-goto-defun-file label)
-	)))
+	(verilog-goto-defun-file label))))
 
 ;; Eliminate compile warning
 (eval-when-compile
@@ -5680,8 +5467,7 @@
 	(first 1)
 	(prevpos (point-min))
         (final-context-start (make-marker))
-	(regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")
-	)
+	(regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)"))
     (with-output-to-temp-buffer "*Occur*"
       (save-excursion
 	(message (format "Searching for %s ..." regexp))
@@ -5854,8 +5640,7 @@
       (search-forward "<company>")
       (replace-match string t t)
       (search-backward "<description>")
-      (replace-match "" t t)
-      )))
+      (replace-match "" t t))))
 
 ;; verilog-header Uses the verilog-insert-date function
 
@@ -5994,8 +5779,7 @@
 	      sv-type    (verilog-sig-type sig)
 	      sv-multidim (verilog-sig-multidim sig)
 	      combo ""
-	      buswarn ""
-	      ))
+	      buswarn ""))
       ;; Extract bus details
       (setq bus (verilog-sig-bits sig))
       (cond ((and bus
@@ -6043,16 +5827,15 @@
 			      (if sv-highbit
 				  (concat "[" (int-to-string sv-highbit) ":"
 					  (int-to-string sv-lowbit) "]")))
-			       (concat sv-comment combo buswarn)
-			       sv-memory sv-enum sv-signed sv-type sv-multidim)
-			 out-list)
-		   sv-name nil)))
-      )
+			  (concat sv-comment combo buswarn)
+			  sv-memory sv-enum sv-signed sv-type sv-multidim)
+		    out-list)
+		   sv-name nil))))
     ;;
     out-list))
 
 (defun verilog-sig-tieoff (sig &optional no-width)
-  "Return tieoff expression for given SIGNAL, with appropriate width.
+  "Return tieoff expression for given SIG, with appropriate width.
 Ignore width if optional NO-WIDTH is set."
   (let* ((width (if no-width nil (verilog-sig-width sig))))
     (concat
@@ -6189,8 +5972,7 @@
 		      (forward-char 1)
 		      (when (< paren sig-paren)
 			(setq expect-signal nil))   ; ) that ends variables inside v2k arg list
-		      t)
-		     )))
+		      t))))
 	 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)")
 	  (goto-char (match-end 0))
 	  (cond (newsig	; Memory, not just width.  Patch last signal added's memory (nth 3)
@@ -6272,12 +6054,15 @@
 	      (nreverse sigs-reg)
 	      (nreverse sigs-assign)
 	      (nreverse sigs-const)
-	      (nreverse sigs-gparam)
-	      ))))
-
-(defvar sigs-in)                        ; Prevent compile warning
-(defvar sigs-inout)                     ; Prevent compile warning
-(defvar sigs-out)                       ; Prevent compile warning
+	      (nreverse sigs-gparam)))))
+
+(eval-when-compile
+  ;; Prevent compile warnings; these are let's, not globals
+  ;; Do not remove the eval-when-compile
+  ;; - we want a error when we are debugging this code if they are refed.
+  (defvar sigs-in)
+  (defvar sigs-inout)
+  (defvar sigs-out))
 
 
 (defsubst verilog-modi-get-decls (modi)
@@ -6524,10 +6309,16 @@
 	     (end-pt (point)))
 	(eval-region beg-pt end-pt nil)))))
 
-;; These are passed in a let, not global
-(defvar got-sig)
-(defvar got-rvalue)
-(defvar uses-delayed)
+(eval-when-compile
+  ;; Prevent compile warnings; these are let's, not globals
+  ;; Do not remove the eval-when-compile
+  ;; - we want a error when we are debugging this code if they are refed.
+  (defvar sigs-in)
+  (defvar sigs-out)
+  (defvar got-sig)
+  (defvar got-rvalue)
+  (defvar uses-delayed)
+  (defvar vector-skip-list))
 
 (defun verilog-read-always-signals-recurse
   (exit-keywd rvalue ignore-next)
@@ -6653,8 +6444,7 @@
 	   (t
 	    (forward-char 1)))
 	  ;; End of non-comment token
-	  (setq last-keywd keywd)
-	  ))
+	  (setq last-keywd keywd)))
       (skip-syntax-forward " "))
     ;; Append the final pending signal
     (when got-sig
@@ -6700,8 +6490,7 @@
 		  (instant (match-string 2)))
 	      (if (not (member module verilog-keywords))
 		  (setq instants-list (cons (list module instant) instants-list)))))
-	(forward-line 1)
-	))
+	(forward-line 1)))
     instants-list))
 
 
@@ -6776,8 +6565,7 @@
 		     (t
 		      (error "%s: AUTO_TEMPLATE parsing error: %s"
 			     (verilog-point-text)
-			     (progn (looking-at ".*$") (match-string 0))))
-		     ))
+			     (progn (looking-at ".*$") (match-string 0))))))
 	     ;; Return
 	     (vector tpl-regexp
 		     (list tpl-sig-list tpl-wild-list)))
@@ -6799,8 +6587,7 @@
 	(let ((enumvar (intern (concat "venum-" enumname))))
 	  ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
 	  (make-variable-buffer-local enumvar)
-	  (add-to-list enumvar defname)))
-    ))
+	  (add-to-list enumvar defname)))))
 
 (defun verilog-read-defines (&optional filename recurse subcall)
   "Read `defines and parameters for the current file, or optional FILENAME.
@@ -6884,8 +6671,7 @@
 	  (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*")
 	    (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname)
 	    (goto-char (match-end 0))
-	    (forward-comment 999))))
-      )))
+	    (forward-comment 999)))))))
 
 (defun verilog-read-includes ()
   "Read `includes for the current file.
@@ -6950,8 +6736,7 @@
 	  (or (member keywd verilog-keywords)
 	      (member keywd sigs-all)
 	      (setq sigs-all (cons keywd sigs-all))))
-	 (t (forward-char 1)))
-	)
+	 (t (forward-char 1))))
       ;; Return list
       sigs-all)))
 
@@ -7019,10 +6804,7 @@
        ((string-match "^[^-+]" arg)
 	(verilog-add-list-unique `verilog-library-files arg))
        ;; Default - ignore; no warning
-       )
-      )
-    )
-  )
+       ))))
 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir"))
 
 (defun verilog-getopt-file (filename)
@@ -7096,8 +6878,7 @@
   "Return true if SYMBOL is number-like."
   (or (string-match "^[0-9 \t:]+$" symbol)
       (string-match "^[---]*[0-9]+$" symbol)
-      (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol)
-      ))
+      (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol)))
 
 (defun verilog-symbol-detick (symbol wing-it)
   "Return a expanded SYMBOL name without any defines.
@@ -7185,13 +6966,11 @@
 	       (setq dirfile (expand-file-name (concat (car dirfiles) rest))
 		     dirfiles (cdr dirfiles))
 	       (if (file-directory-p dirfile)
-		   (setq dirlist (cons dirfile dirlist))))
-	     )
+		   (setq dirlist (cons dirfile dirlist)))))
 	    ;; Defaults
 	    (t
 	     (if (file-directory-p dirname)
-		 (setq dirlist (cons dirname dirlist))))
-	    ))
+		 (setq dirlist (cons dirname dirlist))))))
     dirlist))
 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v"))
 
@@ -7295,13 +7074,11 @@
 					     "")
 					   "\n    Check the verilog-library-directories variable."
 					   "\n    I looked in (if not listed, doesn't exist):\n\t"
-					   (mapconcat 'concat orig-filenames "\n\t")))))
-		     )
+					   (mapconcat 'concat orig-filenames "\n\t"))))))
 	       (setq verilog-modi-lookup-last-mod module
 		     verilog-modi-lookup-last-current current
 		     verilog-modi-lookup-last-tick (buffer-modified-tick)))))
-    verilog-modi-lookup-last-modi
-    ))
+    verilog-modi-lookup-last-modi))
 
 (defsubst verilog-modi-name (modi)
   (aref modi 0))
@@ -7370,8 +7147,7 @@
 			       (buffer-modified-tick)
 			       (visited-file-modtime)
 			       func-returns)
-			 verilog-modi-cache-list)))
-	    ))
+			 verilog-modi-cache-list)))))
       ;;
       func-returns))
 
@@ -7483,7 +7259,7 @@
 	(funcall func))))
 
 (defun verilog-insert-one-definition (sig type indent-pt)
-  "Print out a definition for SIGNAL of the given TYPE,
+  "Print out a definition for SIG of the given TYPE,
 with appropriate INDENT-PT indentation."
   (indent-to indent-pt)
   (insert type)
@@ -7594,9 +7370,8 @@
 			     (string-to-number (match-string 2 range-exp)))))))
 	       ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp)
 		(concat "(1+(" (match-string 1 range-exp) ")"
-			(if (equal "0" (match-string 2 range-exp)) 
-			    ;; Don't bother with -(0)
-			    ""
+			(if (equal "0" (match-string 2 range-exp))
+			    ""  ;; Don't bother with -(0)
 			  (concat "-(" (match-string 2 range-exp) ")"))
 			")"))
 	       (t nil)))))
@@ -7621,8 +7396,7 @@
       ;; End exists
       (end-of-line)
       (delete-region pt (point))
-      (forward-line 1))
-  ))
+      (forward-line 1))))
 
 (defun verilog-forward-close-paren ()
   "Find the close parenthesis that match the current point,
@@ -7897,8 +7671,7 @@
 	 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ")
 	   (verilog-auto))
 	 ;; Don't ask again if didn't update
-	 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))
-	 ))
+	 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))))
   (when (not verilog-auto-star-save)
     (verilog-delete-auto-star-implicit))
   nil)	;; Always return nil -- we don't write the file ourselves
@@ -8008,13 +7781,11 @@
       (verilog-repair-close-comma)
       (unless (eq (char-before) ?/ )
 	(insert "\n"))
-      (indent-to verilog-indent-level-declaration)
-      )))
+      (indent-to verilog-indent-level-declaration))))
 
 (defun verilog-auto-inst-port-map (port-st)
   nil)
 
-(defvar vector-skip-list nil) ; Prevent compile warning
 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning
 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
 (defvar vl-name  nil "See `verilog-auto-inst'.") ; Prevent compile warning
@@ -8025,7 +7796,8 @@
   "Print out a instantiation connection for this PORT-ST.
 Insert to INDENT-PT, use template TPL-LIST.
 @ are instantiation numbers, replaced with TPL-NUM.
-@\"(expression @)\" are evaluated, with @ as a variable."
+@\"(expression @)\" are evaluated, with @ as a variable.
+If FOR-STAR add comment it is a .* expansion."
   (let* ((port (verilog-sig-name port-st))
 	 (tpl-ass (or (assoc port (car tpl-list))
 		      (verilog-auto-inst-port-map port-st)))
@@ -8072,13 +7844,11 @@
 			     (prin1 (eval (car (read-from-string expr)))
 				    (lambda (ch) ())))))
 		     (if (numberp value) (setq value (number-to-string value)))
-		     value
-		     ))
+		     value))
 		 (substring tpl-net (match-end 0))))))
       ;; Replace @ and [] magic variables in final output
       (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net))
-      (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))
-      )
+      (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net)))
     (indent-to indent-pt)
     (insert "." port)
     (indent-to verilog-auto-inst-column)
@@ -8462,9 +8232,7 @@
 		 (if (search-forward ")" nil t) ;; From user, moved up a line
 		     (delete-backward-char 1))
 		 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it
-		     (delete-backward-char 1))
-		 )))
-	))))
+		     (delete-backward-char 1)))))))))
 
 (defun verilog-auto-inst-param ()
   "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto].
@@ -8566,9 +8334,7 @@
 		 (search-forward "\n")	;; Added by inst-port
 		 (delete-backward-char 1)
 		 (if (search-forward ")" nil t) ;; From user, moved up a line
-		     (delete-backward-char 1))
-		 )))
-	))))
+		     (delete-backward-char 1)))))))))
 
 (defun verilog-auto-reg ()
   "Expand AUTOREG statements, as part of \\[verilog-auto].
@@ -8612,15 +8378,13 @@
 			      (verilog-modi-get-consts modi)
 			      (verilog-modi-get-gparams modi)
 			      (verilog-modi-get-sub-outputs modi)
-			      (verilog-modi-get-sub-inouts modi)
-			      ))))
+			      (verilog-modi-get-sub-inouts modi)))))
       (forward-line 1)
       (when sig-list
 	(verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n")
 	(verilog-insert-definition sig-list "reg" indent-pt nil)
 	(verilog-modi-cache-add-regs modi sig-list)
-	(verilog-insert-indent "// End of automatics\n"))
-      )))
+	(verilog-insert-indent "// End of automatics\n")))))
 
 (defun verilog-auto-reg-input ()
   "Expand AUTOREGINPUT statements, as part of \\[verilog-auto].
@@ -8665,15 +8429,13 @@
 		      (verilog-signals-not-in
 		       (append (verilog-modi-get-sub-inputs modi)
 			       (verilog-modi-get-sub-inouts modi))
-		       (verilog-modi-get-signals modi)
-		       ))))
+		       (verilog-modi-get-signals modi)))))
       (forward-line 1)
       (when sig-list
 	(verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n")
 	(verilog-insert-definition sig-list "reg" indent-pt nil)
 	(verilog-modi-cache-add-regs modi sig-list)
-	(verilog-insert-indent "// End of automatics\n"))
-      )))
+	(verilog-insert-indent "// End of automatics\n")))))
 
 (defun verilog-auto-wire ()
   "Expand AUTOWIRE statements, as part of \\[verilog-auto].
@@ -8726,8 +8488,7 @@
 		      (verilog-signals-not-in
 		       (append (verilog-modi-get-sub-outputs modi)
 			       (verilog-modi-get-sub-inouts modi))
-		       (verilog-modi-get-signals modi)
-		       ))))
+		       (verilog-modi-get-signals modi)))))
       (forward-line 1)
       (when sig-list
 	(verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n")
@@ -8739,8 +8500,7 @@
 	  (setq pnt (point))
 	  (verilog-pretty-declarations)
 	  (goto-char pnt)
-	  (verilog-pretty-expr "//")))
-      )))
+	  (verilog-pretty-expr "//"))))))
 
 (defun verilog-auto-output ()
   "Expand AUTOOUTPUT statements, as part of \\[verilog-auto].
@@ -8793,8 +8553,7 @@
 		      (append (verilog-modi-get-outputs modi)
 			      (verilog-modi-get-inouts modi)
 			      (verilog-modi-get-sub-inputs modi)
-			      (verilog-modi-get-sub-inouts modi)
-			      ))))
+			      (verilog-modi-get-sub-inouts modi)))))
       (setq sig-list (verilog-signals-not-matching-regexp
 		      sig-list verilog-auto-output-ignore-regexp))
       (forward-line 1)
@@ -8804,8 +8563,7 @@
 	(verilog-insert-definition sig-list "output" indent-pt v2k)
 	(verilog-modi-cache-add-outputs modi sig-list)
 	(verilog-insert-indent "// End of automatics\n"))
-      (when v2k (verilog-repair-close-comma))
-      )))
+      (when v2k (verilog-repair-close-comma)))))
 
 (defun verilog-auto-output-every ()
   "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto].
@@ -8847,8 +8605,7 @@
 	   (sig-list (verilog-signals-combine-bus
 		      (verilog-signals-not-in
 		       (verilog-modi-get-signals modi)
-		       (verilog-modi-get-ports modi)
-		       ))))
+		       (verilog-modi-get-ports modi)))))
       (forward-line 1)
       (when v2k (verilog-repair-open-comma))
       (when sig-list
@@ -8856,8 +8613,7 @@
 	(verilog-insert-definition sig-list "output" indent-pt v2k)
 	(verilog-modi-cache-add-outputs modi sig-list)
 	(verilog-insert-indent "// End of automatics\n"))
-      (when v2k (verilog-repair-close-comma))
-      )))
+      (when v2k (verilog-repair-close-comma)))))
 
 (defun verilog-auto-input ()
   "Expand AUTOINPUT statements, as part of \\[verilog-auto].
@@ -8913,8 +8669,7 @@
 			      (verilog-modi-get-consts modi)
 			      (verilog-modi-get-gparams modi)
 			      (verilog-modi-get-sub-outputs modi)
-			      (verilog-modi-get-sub-inouts modi)
-			      ))))
+			      (verilog-modi-get-sub-inouts modi)))))
       (setq sig-list (verilog-signals-not-matching-regexp
 		      sig-list verilog-auto-input-ignore-regexp))
       (forward-line 1)
@@ -8924,8 +8679,7 @@
 	(verilog-insert-definition sig-list "input" indent-pt v2k)
 	(verilog-modi-cache-add-inputs modi sig-list)
 	(verilog-insert-indent "// End of automatics\n"))
-      (when v2k (verilog-repair-close-comma))
-      )))
+      (when v2k (verilog-repair-close-comma)))))
 
 (defun verilog-auto-inout ()
   "Expand AUTOINOUT statements, as part of \\[verilog-auto].
@@ -8978,8 +8732,7 @@
 			      (verilog-modi-get-inouts modi)
 			      (verilog-modi-get-inputs modi)
 			      (verilog-modi-get-sub-inputs modi)
-			      (verilog-modi-get-sub-outputs modi)
-			      ))))
+			      (verilog-modi-get-sub-outputs modi)))))
       (setq sig-list (verilog-signals-not-matching-regexp
 		      sig-list verilog-auto-inout-ignore-regexp))
       (forward-line 1)
@@ -8989,8 +8742,7 @@
 	(verilog-insert-definition sig-list "inout" indent-pt v2k)
 	(verilog-modi-cache-add-inouts modi sig-list)
 	(verilog-insert-indent "// End of automatics\n"))
-      (when v2k (verilog-repair-close-comma))
-      )))
+      (when v2k (verilog-repair-close-comma)))))
 
 (defun verilog-auto-inout-module ()
   "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto].
@@ -9062,8 +8814,7 @@
 	    (verilog-modi-cache-add-outputs modi sig-list-o)
 	    (verilog-modi-cache-add-inouts modi sig-list-io)
 	    (verilog-insert-indent "// End of automatics\n"))
-	  (when v2k (verilog-repair-close-comma))
-	  )))))
+	  (when v2k (verilog-repair-close-comma)))))))
 
 (defun verilog-auto-sense-sigs (modi presense-sigs)
   "Return list of signals for current AUTOSENSE block."
@@ -9164,8 +8915,7 @@
 	      (not-first (insert " or ")))
 	(insert (verilog-sig-name (car sig-list)))
 	(setq sig-list (cdr sig-list)
-	      not-first t))
-      )))
+	      not-first t)))))
 
 (defun verilog-auto-reset ()
   "Expand AUTORESET statements, as part of \\[verilog-auto].
@@ -9260,8 +9010,7 @@
 		    ";\n")
 	    (indent-to indent-pt)
 	    (setq sig-list (cdr sig-list))))
-	(insert "// End of automatics"))
-      )))
+	(insert "// End of automatics")))))
 
 (defun verilog-auto-tieoff ()
   "Expand AUTOTIEOFF statements, as part of \\[verilog-auto].
@@ -9316,8 +9065,7 @@
 			      (verilog-modi-get-consts modi)
 			      (verilog-modi-get-gparams modi)
 			      (verilog-modi-get-sub-outputs modi)
-			      (verilog-modi-get-sub-inouts modi)
-			      ))))
+			      (verilog-modi-get-sub-inouts modi)))))
       (when sig-list
 	(forward-line 1)
 	(verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n")
@@ -9330,8 +9078,7 @@
 	    (insert "= " (verilog-sig-tieoff sig)
 		    ";\n")
 	    (setq sig-list (cdr sig-list))))
-	(verilog-insert-indent "// End of automatics\n")
-	))))
+	(verilog-insert-indent "// End of automatics\n")))))
 
 (defun verilog-auto-unused ()
   "Expand AUTOUNUSED statements, as part of \\[verilog-auto].
@@ -9395,8 +9142,7 @@
 		      (append (verilog-modi-get-inputs modi)
 			      (verilog-modi-get-inouts modi))
 		      (append (verilog-modi-get-sub-inputs modi)
-			      (verilog-modi-get-sub-inouts modi)
-			      ))))
+			      (verilog-modi-get-sub-inouts modi)))))
       (setq sig-list (verilog-signals-not-matching-regexp
 		      sig-list verilog-auto-unused-ignore-regexp))
       (when sig-list
@@ -9408,8 +9154,7 @@
 	    (indent-to indent-pt)
 	    (insert (verilog-sig-name sig) ",\n")
 	    (setq sig-list (cdr sig-list))))
-	(verilog-insert-indent "// End of automatics\n")
-	))))
+	(verilog-insert-indent "// End of automatics\n")))))
 
 (defun verilog-enum-ascii (signm elim-regexp)
   "Convert a enum name SIGNM to a ascii string for insertion.
@@ -9543,8 +9288,7 @@
       (verilog-insert-indent "endcase\n")
       (setq indent-pt (- indent-pt verilog-indent-level))
       (verilog-insert-indent "end\n"
-			     "// End of automatics\n")
-      )))
+			     "// End of automatics\n"))))
 
 (defun verilog-auto-templated-rel ()
   "Replace Templated relative line numbers with absolute line numbers.
@@ -9694,8 +9438,7 @@
 	   ;; Must be after all inputs outputs are generated
 	   (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg)
 	   ;; Fix line numbers (comments only)
-	   (verilog-auto-templated-rel)
-	   )
+	   (verilog-auto-templated-rel))
 	  ;;
 	  (run-hooks 'verilog-auto-hook)
 	  ;;
@@ -9709,14 +9452,13 @@
       ;; Unwind forms
       (progn
 	;; Restore font-lock
-	(when fontlocked (font-lock-mode t)))
-      )))
+	(when fontlocked (font-lock-mode t))))))
 
 
 ;;
 ;; Skeleton based code insertion
 ;;
-(defvar verilog-template-map 
+(defvar verilog-template-map
   (let ((map (make-sparse-keymap)))
     (define-key map "a" 'verilog-sk-always)
     (define-key map "b" 'verilog-sk-begin)
@@ -9985,16 +9727,14 @@
 (defun verilog-sk-define-signal ()
   "Insert a definition of signal under point at top of module."
   (interactive "*")
-  (let* (
-	 (sig-re "[a-zA-Z0-9_]*")
+  (let* ((sig-re "[a-zA-Z0-9_]*")
 	 (v1 (buffer-substring
 	       (save-excursion
 		 (skip-chars-backward sig-re)
 		 (point))
 	       (save-excursion
 		 (skip-chars-forward sig-re)
-		 (point))))
-	 )
+		 (point)))))
     (if (not (member v1 verilog-keywords))
 	(save-excursion
 	  (setq verilog-sk-signal v1)
@@ -10003,10 +9743,7 @@
 	  (verilog-forward-syntactic-ws)
 	  (verilog-sk-def-reg)
 	  (message "signal at point is %s" v1))
-      (message "object at point (%s) is a keyword" v1))
-    )
-  )
-
+      (message "object at point (%s) is a keyword" v1))))
 
 (define-skeleton verilog-sk-wire
   "Insert a wire definition."
@@ -10109,7 +9846,7 @@
   "^`include\\s-+\"\\([^\n\"]*\\)\""
   "Regexp that matches the include file.")
 
-(defvar verilog-mode-mouse-map 
+(defvar verilog-mode-mouse-map
   (let ((map (make-sparse-keymap))) ; as described in info pages, make a map
     (set-keymap-parent map verilog-mode-map)
     ;; mouse button bindings
@@ -10189,8 +9926,7 @@
 	  (progn
 	    (message
 	     "File '%s' isn't readable, use shift-mouse2 to paste in this field"
-	     (match-string 1))))
-      )))
+	     (match-string 1)))))))
 
 ;; ffap isn't useable for verilog mode. It uses library paths.
 ;; so define this function to do more or less the same as ffap
@@ -10208,8 +9944,7 @@
 	     (file-readable-p (car (verilog-library-filenames
 				    (match-string 1) (buffer-file-name)))))
 	    (find-file (car (verilog-library-filenames
-			     (match-string 1) (buffer-file-name))))))
-      ))
+			     (match-string 1) (buffer-file-name))))))))
 
 
 ;;
@@ -10230,6 +9965,7 @@
     (princ "\n")))
 
 (autoload 'reporter-submit-bug-report "reporter")
+(defvar reporter-prompt-for-summary-p)
 
 (defun verilog-submit-bug-report ()
   "Submit via mail a bug report on verilog-mode.el."
--- a/lisp/progmodes/vhdl-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/progmodes/vhdl-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -2047,7 +2047,7 @@
 (defun vhdl-keep-region-active ()
   "Do whatever is necessary to keep the region active in XEmacs.
 Ignore byte-compiler warnings you might see."
-  (and (boundp 'zmacs-region-stays)
+  (and (featurep 'xemacs)
        (setq zmacs-region-stays t)))
 
 ;; `wildcard-to-regexp' is included only in XEmacs 21
--- a/lisp/repeat.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/repeat.el	Wed Jan 30 07:57:28 2008 +0000
@@ -200,6 +200,14 @@
 (defvar repeat-previous-repeated-command nil
   "The previous repeated command.")
 
+;; The following variable counts repeated self-insertions.  The idea is
+;; that repeating a self-insertion command and subsequently undoing it
+;; should have almost the same effect as if the characters were inserted
+;; manually.  The basic difference is that we leave in one undo-boundary
+;; between the original insertion and its first repetition.
+(defvar repeat-undo-count nil
+  "Number of self-insertions since last `undo-boundary'.")
+
 ;;;###autoload
 (defun repeat (repeat-arg)
   "Repeat most recently executed command.
@@ -246,12 +254,6 @@
   ;; needs to be saved.
   (let ((repeat-repeat-char
          (if (eq repeat-on-final-keystroke t)
-	     ;; The following commented out since it's equivalent to
-	     ;; last-comment-char (martin 2007-08-29).
-;;;              ;; allow any final input event that was a character
-;;;              (when (eq last-command-char
-;;;                        last-command-event)
-;;;                last-command-char)
 	     last-command-char
            ;; allow only specified final keystrokes
            (car (memq last-command-char
@@ -293,11 +295,22 @@
 		  (i 0))
 	      ;; Run pre- and post-command hooks for self-insertion too.
 	      (run-hooks 'pre-command-hook)
+	      (cond
+	       ((not repeat-undo-count))
+	       ((< repeat-undo-count 20)
+		;; Don't make an undo-boundary here.
+		(setq repeat-undo-count (1+ repeat-undo-count)))
+	       (t
+		;; Make an undo-boundary after 20 repetitions only.
+		(undo-boundary)
+		(setq repeat-undo-count 1)))
 	      (while (< i count)
 		(repeat-self-insert insertion)
 		(setq i (1+ i)))
 	      (run-hooks 'post-command-hook)))
 	(let ((indirect (indirect-function last-repeatable-command)))
+	  ;; Make each repetition undo separately.
+	  (undo-boundary)
 	  (if (or (stringp indirect)
 		  (vectorp indirect))
 	      ;; Bind real-last-command so that executing the macro does
@@ -314,12 +327,20 @@
       ;; (only 32 repetitions are possible given the default value of 200 for
       ;; max-lisp-eval-depth), but if I now locally disable the repeat char I
       ;; can iterate indefinitely here around a single level of recursion.
-      (let (repeat-on-final-keystroke)
+      (let (repeat-on-final-keystroke
+	    ;; Bind `undo-inhibit-record-point' to t in order to avoid
+	    ;; recording point in `buffer-undo-list' here.  We have to
+	    ;; do this since the command loop does not set the last
+	    ;; position of point thus confusing the point recording
+	    ;; mechanism when inserting or deleting text.
+	    (undo-inhibit-record-point t))
 	(setq real-last-command 'repeat)
-        (while (eq (read-event) repeat-repeat-char)
-	  ;; Make each repetition undo separately.
-	  (undo-boundary)
-          (repeat repeat-arg))
+	(setq repeat-undo-count 1)
+	(unwind-protect
+	    (while (eq (read-event) repeat-repeat-char)
+	      (repeat repeat-arg))
+	  ;; Make sure `repeat-undo-count' is reset.
+	  (setq repeat-undo-count nil))
         (setq unread-command-events (list last-input-event))))))
 
 (defun repeat-self-insert (string)
--- a/lisp/replace.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/replace.el	Wed Jan 30 07:57:28 2008 +0000
@@ -789,6 +789,13 @@
   :type 'hook
   :group 'matching)
 
+(defcustom occur-mode-find-occurrence-hook nil
+  "Hook run by Occur after locating an occurrence.
+This will be called with the cursor position at the occurrence.  An application
+for this is to reveal context in an outline-mode when the occurrence is hidden."
+  :type 'hook
+  :group 'matching)
+
 (put 'occur-mode 'mode-class 'special)
 (defun occur-mode ()
   "Major mode for output from \\[occur].
@@ -837,14 +844,16 @@
         same-window-buffer-names
         same-window-regexps)
     (pop-to-buffer (marker-buffer pos))
-    (goto-char pos)))
+    (goto-char pos)
+    (run-hooks 'occur-mode-find-occurrence-hook)))
 
 (defun occur-mode-goto-occurrence-other-window ()
   "Go to the occurrence the current line describes, in another window."
   (interactive)
   (let ((pos (occur-mode-find-occurrence)))
     (switch-to-buffer-other-window (marker-buffer pos))
-    (goto-char pos)))
+    (goto-char pos)
+    (run-hooks 'occur-mode-find-occurrence-hook)))
 
 (defun occur-mode-display-occurrence ()
   "Display in another window the occurrence the current line describes."
@@ -858,7 +867,8 @@
     ;; This is the way to set point in the proper window.
     (save-selected-window
       (select-window window)
-      (goto-char pos))))
+      (goto-char pos)
+      (run-hooks 'occur-mode-find-occurrence-hook))))
 
 (defun occur-find-match (n search message)
   (if (not n) (setq n 1))
--- a/lisp/server.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/server.el	Wed Jan 30 07:57:28 2008 +0000
@@ -291,17 +291,29 @@
 
       (server-log "Deleted" proc))))
 
+(defvar server-log-time-function 'current-time-string
+  "Function to generate timestamps for `server-buffer'.")
+
+(defconst server-buffer " *server*"
+  "Buffer used internally by Emacs's server.
+One use is to log the I/O for debugging purposes (see `server-log'),
+the other is to provide a current buffer in which the process filter can
+safely let-bind buffer-local variables like `default-directory'.")
+
+(defvar server-log nil
+  "If non-nil, log the server's inputs and outputs in the `server-buffer'.")
+
 (defun server-log (string &optional client)
-  "If a *server* buffer exists, write STRING to it for logging purposes.
+  "If `server-log' is non-nil, log STRING to `server-buffer'.
 If CLIENT is non-nil, add a description of it to the logged message."
-  (when (get-buffer "*server*")
-    (with-current-buffer "*server*"
+  (when server-log
+    (with-current-buffer (get-buffer-create server-buffer)
       (goto-char (point-max))
-      (insert (current-time-string)
+      (insert (funcall server-log-time-function)
 	      (cond
-	       ((null client) " ")
-	       ((listp client) (format " %s: " (car client)))
-	       (t (format " %s: " client)))
+		((null client) " ")
+		((listp client) (format " %s: " (car client)))
+		(t (format " %s: " client)))
 	      string)
       (or (bolp) (newline)))))
 
@@ -494,7 +506,7 @@
 		       ;; Those are decoded by server-process-filter according
 		       ;; to file-name-coding-system.
 		       :coding 'raw-text
-		       ;; The rest of the args depends on the kind of socket used.
+		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
 			   (list :family nil
 				 :service t
@@ -764,7 +776,7 @@
   (server-log (concat "Received " string) proc)
   ;; First things first: let's check the authentication
   (unless (process-get proc :authenticated)
-    (if (and (string-match "-auth \\(.*?\\)\n" string)
+    (if (and (string-match "-auth \\([!-~]+\\)\n?" string)
 	     (equal (match-string 1 string) (process-get proc :auth-key)))
 	(progn
 	  (setq string (substring string (match-end 0)))
@@ -805,8 +817,7 @@
                 (tty-name nil)       ;nil, `window-system', or the tty name.
                 tty-type             ;string.
 		(files nil)
-		(lineno 1)
-		(columnno 0)
+                (filepos nil)
 		command-line-args-left
 		arg)
 	    ;; Remove this line from STRING.
@@ -876,9 +887,9 @@
                        (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?"
                                      (car command-line-args-left)))
 		  (setq arg (pop command-line-args-left))
-		  (setq lineno (string-to-number (match-string 1 arg))
-			columnno (if (null (match-end 2)) 0
-                                   (string-to-number (match-string 2 arg)))))
+		  (setq filepos
+                        (cons (string-to-number (match-string 1 arg))
+                              (string-to-number (or (match-string 2 arg) "")))))
 
 		 ;; -file FILENAME:  Load the given file.
 		 ((and (equal "-file" arg)
@@ -887,11 +898,10 @@
 		    (if coding-system
 			(setq file (decode-coding-string file coding-system)))
 		    (setq file (command-line-normalize-file-name file))
-		    (push (list file lineno columnno) files)
-		    (server-log (format "New file: %s (%d:%d)"
-                                        file lineno columnno) proc))
-		  (setq lineno 1
-			columnno 0))
+		    (push (cons file filepos) files)
+		    (server-log (format "New file: %s %s"
+                                        file (or filepos "")) proc))
+		  (setq filepos nil))
 
 		 ;; -eval EXPR:  Evaluate a Lisp expression.
 		 ((and (equal "-eval" arg)
@@ -901,8 +911,7 @@
 			(setq expr (decode-coding-string expr coding-system)))
                     (push (lambda () (server-eval-and-print expr proc))
                           commands)
-		    (setq lineno 1
-			  columnno 0)))
+		    (setq filepos nil)))
 
 		 ;; -env NAME=VALUE:  An environment variable.
 		 ((and (equal "-env" arg) command-line-args-left)
@@ -928,17 +937,25 @@
                      (server-create-window-system-frame display nowait proc))
                     (t (server-create-tty-frame tty-name tty-type proc))))
 
-            (process-put proc 'continuation
-                         (lexical-let ((proc proc)
-                                       (files files)
-                                       (nowait nowait)
-                                       (commands commands)
-                                       (dontkill dontkill)
-                                       (frame frame)
-                                       (tty-name tty-name))
-                           (lambda ()
-                             (server-execute proc files nowait commands
-                                             dontkill frame tty-name))))
+            (process-put
+             proc 'continuation
+             (lexical-let ((proc proc)
+                           (files files)
+                           (nowait nowait)
+                           (commands commands)
+                           (dontkill dontkill)
+                           (frame frame)
+                           (dir dir)
+                           (tty-name tty-name))
+               (lambda ()
+                 (with-current-buffer (get-buffer-create server-buffer)
+                   ;; Use the same cwd as the emacsclient, if possible, so
+                   ;; relative file names work correctly, even in `eval'.
+                   (let ((default-directory
+			  (if (and dir (file-directory-p dir))
+			      dir default-directory)))
+                     (server-execute proc files nowait commands
+                                     dontkill frame tty-name))))))
 
             (when (or frame files)
               (server-goto-toplevel proc))
@@ -991,18 +1008,19 @@
     (server-log (error-message-string err) proc)
     (delete-process proc)))
 
-(defun server-goto-line-column (file-line-col)
-  "Move point to the position indicated in FILE-LINE-COL.
-FILE-LINE-COL should be a three-element list as described in
-`server-visit-files'."
-  (goto-line (nth 1 file-line-col))
-  (let ((column-number (nth 2 file-line-col)))
-    (when (> column-number 0)
-      (move-to-column (1- column-number)))))
+(defun server-goto-line-column (line-col)
+  "Move point to the position indicated in LINE-COL.
+LINE-COL should be a pair (LINE . COL)."
+  (when line-col
+    (goto-line (car line-col))
+    (let ((column-number (cdr line-col)))
+      (when (> column-number 0)
+        (move-to-column (1- column-number))))))
 
 (defun server-visit-files (files proc &optional nowait)
   "Find FILES and return a list of buffers created.
-FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER).
+FILES is an alist whose elements are (FILENAME . FILEPOS)
+where FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).
 PROC is the client that requested this operation.
 NOWAIT non-nil means this client is not waiting for the results,
 so don't mark these buffers specially, just visit them normally."
@@ -1021,22 +1039,21 @@
 	       (filen (car file))
 	       (obuf (get-file-buffer filen)))
 	  (add-to-history 'file-name-history filen)
-	  (if (and obuf (set-buffer obuf))
-	      (progn
-		(cond ((file-exists-p filen)
-		       (when (not (verify-visited-file-modtime obuf))
-			 (revert-buffer t nil)))
-		      (t
-		       (when (y-or-n-p
-			      (concat "File no longer exists: " filen
-				      ", write buffer to file? "))
-			 (write-file filen))))
-		(unless server-buffer-clients
-		  (setq server-existing-buffer t))
-		(server-goto-line-column file))
-	    (set-buffer (find-file-noselect filen))
-	    (server-goto-line-column file)
-	    (run-hooks 'server-visit-hook)))
+	  (if (null obuf)
+              (set-buffer (find-file-noselect filen))
+            (set-buffer obuf)
+            (cond ((file-exists-p filen)
+                   (when (not (verify-visited-file-modtime obuf))
+                     (revert-buffer t nil)))
+                  (t
+                   (when (y-or-n-p
+                          (concat "File no longer exists: " filen
+                                  ", write buffer to file? "))
+                     (write-file filen))))
+            (unless server-buffer-clients
+              (setq server-existing-buffer t)))
+          (server-goto-line-column (cdr file))
+          (run-hooks 'server-visit-hook))
 	(unless nowait
 	  ;; When the buffer is killed, inform the clients.
 	  (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)
--- a/lisp/smerge-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/smerge-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -851,10 +851,12 @@
   (remove-overlays (match-beginning 0) (match-end 0) 'smerge 'refine)
   (smerge-ensure-match 1)
   (smerge-ensure-match 3)
-  (smerge-refine-subst (match-beginning 1) (match-end 1)
-                       (match-beginning 3) (match-end 3)
-                       '((smerge . refine)
-                         (face . smerge-refined-change))))
+  ;; Match 1 and 3 may be one and the same in case of trivial diff3 -A conflict.
+  (let ((n1 (if (eq (match-end 1) (match-end 3)) 2 1)))
+    (smerge-refine-subst (match-beginning n1) (match-end n1)
+                         (match-beginning 3)  (match-end 3)
+                         '((smerge . refine)
+                           (face . smerge-refined-change)))))
 
 (defun smerge-diff (n1 n2)
   (smerge-match-conflict)
@@ -992,6 +994,32 @@
 	       (message "Conflict resolution finished; you may save the buffer")))))
     (message "Please resolve conflicts now; exit ediff when done")))
 
+(defun smerge-makeup-conflict (pt1 pt2 pt3 &optional pt4)
+  "Insert diff3 markers to make a new conflict.
+Uses point and mark for 2 of the relevant positions and previous marks
+for the other ones.
+By default, makes up a 2-way conflict,
+with a \\[universal-argument] prefix, makes up a 3-way conflict."
+  (interactive
+   (list (point)
+         (mark)
+         (progn (pop-mark) (mark))
+         (when current-prefix-arg (pop-mark) (mark))))
+  ;; Start from the end so as to avoid problems with pos-changes.
+  (destructuring-bind (pt1 pt2 pt3 &optional pt4)
+      (sort (list* pt1 pt2 pt3 (if pt4 (list pt4))) '>=)
+    (goto-char pt1) (beginning-of-line)
+    (insert ">>>>>>> OTHER\n")
+    (goto-char pt2) (beginning-of-line)
+    (insert "=======\n")
+    (goto-char pt3) (beginning-of-line)
+    (when pt4
+      (insert "||||||| BASE\n")
+      (goto-char pt4) (beginning-of-line))
+    (insert "<<<<<<< MINE\n"))
+  (if smerge-mode nil (smerge-mode 1))
+  (smerge-refine))
+      
 
 (defconst smerge-parsep-re
   (concat smerge-begin-re "\\|" smerge-end-re "\\|"
@@ -1021,6 +1049,14 @@
   (unless smerge-mode
     (smerge-remove-props (point-min) (point-max))))
 
+;;;###autoload
+(defun smerge-start-session ()
+  "Turn on `smerge-mode' and move point to first conflict marker.
+If no conflict maker is found, turn off `smerge-mode'."
+  (smerge-mode 1)
+  (condition-case nil
+      (smerge-next)
+    (error (smerge-auto-leave))))
 
 (provide 'smerge-mode)
 
--- a/lisp/subr.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/subr.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1103,7 +1103,17 @@
 		(append hook-value (list function))
 	      (cons function hook-value))))
     ;; Set the actual variable
-    (if local (set hook hook-value) (set-default hook hook-value))))
+    (if local
+	(progn
+	  ;; If HOOK isn't a permanent local,
+	  ;; but FUNCTION wants to survive a change of modes,
+	  ;; mark HOOK as partially permanent.
+	  (and (symbolp function)
+	       (get function 'permanent-local-hook)
+	       (not (get hook 'permanent-local))
+	       (put hook 'permanent-local 'permanent-local-hook))
+	  (set hook hook-value))
+      (set-default hook hook-value))))
 
 (defun remove-hook (hook function &optional local)
   "Remove from the value of HOOK the function FUNCTION.
@@ -1860,6 +1870,10 @@
   (let ((handle (make-symbol "--change-group-handle--"))
 	(success (make-symbol "--change-group-success--")))
     `(let ((,handle (prepare-change-group))
+	   ;; Don't truncate any undo data in the middle of this.
+	   (undo-outer-limit nil)
+	   (undo-limit most-positive-fixnum)
+	   (undo-strong-limit most-positive-fixnum)
 	   (,success nil))
        (unwind-protect
 	   (progn
@@ -2113,26 +2127,29 @@
 (defun find-tag-default ()
   "Determine default tag to search for, based on text at point.
 If there is no plausible default, return nil."
-  (save-excursion
-    (while (looking-at "\\sw\\|\\s_")
-      (forward-char 1))
-    (if (or (re-search-backward "\\sw\\|\\s_"
-				(save-excursion (beginning-of-line) (point))
-				t)
-	    (re-search-forward "\\(\\sw\\|\\s_\\)+"
-			       (save-excursion (end-of-line) (point))
-			       t))
-	(progn
-	  (goto-char (match-end 0))
-	  (condition-case nil
-	      (buffer-substring-no-properties
-	       (point)
-	       (progn (forward-sexp -1)
-		      (while (looking-at "\\s'")
-			(forward-char 1))
-		      (point)))
-	    (error nil)))
-      nil)))
+  (let (from to bound)
+    (when (or (progn
+		;; Look at text around `point'.
+		(save-excursion
+		  (skip-syntax-backward "w_") (setq from (point)))
+		(save-excursion
+		  (skip-syntax-forward "w_") (setq to (point)))
+		(> to from))
+	      ;; Look between `line-beginning-position' and `point'.
+	      (save-excursion
+		(and (setq bound (line-beginning-position))
+		     (skip-syntax-backward "^w_" bound)
+		     (> (setq to (point)) bound)
+		     (skip-syntax-backward "w_")
+		     (setq from (point))))
+	      ;; Look between `point' and `line-end-position'.
+	      (save-excursion
+		(and (setq bound (line-end-position))
+		     (skip-syntax-forward "^w_" bound)
+		     (< (setq from (point)) bound)
+		     (skip-syntax-forward "w_")
+		     (setq to (point)))))
+      (buffer-substring-no-properties from to))))
 
 (defun play-sound (sound)
   "SOUND is a list of the form `(sound KEYWORD VALUE...)'.
--- a/lisp/t-mouse.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/t-mouse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -4,7 +4,8 @@
 ;; Maintainer: FSF
 ;; Keywords: mouse gpm linux
 
-;; Copyright (C) 1994, 1995, 1998, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1998, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -39,6 +40,9 @@
 
 ;;; Code:
 
+;; Prevent warning when compiling in an Emacs without gpm support.
+(declare-function gpm-mouse-start "term.c" ())
+
 ;;;###autoload
 (define-obsolete-function-alias 't-mouse-mode 'gpm-mouse-mode "23.1")
 ;;;###autoload
--- a/lisp/tar-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/tar-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -785,7 +785,8 @@
 	  (narrow-to-region (point-min) tar-header-offset)
 	  (goto-char pos)))
       (if view-p
-	  (view-buffer buffer (and just-created 'kill-buffer))
+	  (view-buffer
+	   buffer (and just-created 'kill-buffer-if-not-modified))
 	(if (eq other-window-p 'display)
 	    (display-buffer buffer)
 	  (if other-window-p
--- a/lisp/term/w32console.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/term/w32console.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,6 +1,6 @@
 ;;; w32console.el -- Setup w32 console keys and colors.
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
--- a/lisp/textmodes/bibtex.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/bibtex.el	Wed Jan 30 07:57:28 2008 +0000
@@ -119,6 +119,7 @@
 realign             Realign entries, so that field texts and perhaps equal
                       signs (depending on the value of
                       `bibtex-align-at-equal-sign') begin in the same column.
+                      Also fill fields.
 last-comma          Add or delete comma on end of last field in entry,
                       according to value of `bibtex-comma-after-last-field'.
 delimiters          Change delimiters according to variables
@@ -1085,6 +1086,7 @@
      "--"
      ["Convert Alien Buffer" bibtex-convert-alien t])
     ("Operating on Multiple Buffers"
+     ["(Re)Initialize BibTeX Buffers" bibtex-initialize t]
      ["Validate Entries" bibtex-validate-globally t])))
 
 (easy-menu-define
@@ -1782,7 +1784,7 @@
     ")"))
 
 (defun bibtex-flash-head (prompt)
-  "Flash at BibTeX entry head before point, if exists."
+  "Flash at BibTeX entry head before point, if it exists."
   (let ((case-fold-search t)
         (pnt (point)))
     (save-excursion
@@ -1790,7 +1792,8 @@
       (when (and (looking-at bibtex-any-entry-maybe-empty-head)
                  (< (point) pnt))
         (goto-char (match-beginning bibtex-type-in-head))
-        (if (pos-visible-in-window-p (point))
+        (if (and (< 0 blink-matching-delay)
+                 (pos-visible-in-window-p (point)))
             (sit-for blink-matching-delay)
           (message "%s%s" prompt (buffer-substring-no-properties
                                   (point) (match-end bibtex-key-in-head))))))))
@@ -1875,38 +1878,42 @@
 (defun bibtex-format-entry ()
   "Helper function for `bibtex-clean-entry'.
 Formats current entry according to variable `bibtex-entry-format'."
+  ;; initialize `bibtex-field-braces-opt' if necessary
+  (if (and bibtex-field-braces-alist (not bibtex-field-braces-opt))
+      (setq bibtex-field-braces-opt
+            (bibtex-field-re-init bibtex-field-braces-alist 'braces)))
+  ;; initialize `bibtex-field-strings-opt' if necessary
+  (if (and bibtex-field-strings-alist (not bibtex-field-strings-opt))
+      (setq bibtex-field-strings-opt
+            (bibtex-field-re-init bibtex-field-strings-alist 'strings)))
+
   (save-excursion
     (save-restriction
       (bibtex-narrow-to-entry)
       (let ((case-fold-search t)
             (format (if (eq bibtex-entry-format t)
-                        '(realign opts-or-alts required-fields
-                                  numerical-fields
-                                  last-comma page-dashes delimiters
-                                  unify-case inherit-booktitle)
+                        '(realign opts-or-alts required-fields numerical-fields
+                                  page-dashes whitespace inherit-booktitle
+                                  last-comma delimiters unify-case braces
+                                  strings)
                       bibtex-entry-format))
-            crossref-key bounds alternatives-there non-empty-alternative
-            entry-list req-field-list field-list)
-
-        ;; Initialize `bibtex-field-braces-opt' and `bibtex-field-strings-opt'
-        ;; if necessary.
-        (unless bibtex-field-braces-opt
-          (setq bibtex-field-braces-opt
-                (bibtex-field-re-init bibtex-field-braces-alist 'braces)))
-        (unless bibtex-field-strings-opt
-          (setq bibtex-field-strings-opt
-                (bibtex-field-re-init bibtex-field-strings-alist 'strings)))
+            bounds crossref-key req-field-list default-field-list field-list)
+
+        ;; There are more elegant high-level functions for several tasks
+        ;; done by `bibtex-format-entry'.  However, they contain some
+        ;; redundancy compared with what we need to do anyway.
+        ;; So for speed-up we avoid using them.
+        ;; (`bibtex-format-entry' is called many times by `bibtex-reformat'.)
 
         ;; identify entry type
         (goto-char (point-min))
         (or (re-search-forward bibtex-entry-type nil t)
             (error "Not inside a BibTeX entry"))
-        (let ((beg-type (1+ (match-beginning 0)))
-              (end-type (match-end 0)))
-          (setq entry-list (assoc-string (buffer-substring-no-properties
+        (let* ((beg-type (1+ (match-beginning 0)))
+               (end-type (match-end 0))
+               (entry-list (assoc-string (buffer-substring-no-properties
 					  beg-type end-type)
-					 bibtex-entry-field-alist
-					 t))
+					 bibtex-entry-field-alist t)))
 
           ;; unify case of entry name
           (when (memq 'unify-case format)
@@ -1918,35 +1925,24 @@
             (goto-char end-type)
             (skip-chars-forward " \t\n")
             (delete-char 1)
-            (insert (bibtex-entry-left-delimiter))))
-
-        ;; determine if entry has crossref field and if at least
-        ;; one alternative is non-empty
-        (goto-char (point-min))
-        (let* ((fields-alist (bibtex-parse-entry t))
-               (field (assoc-string "crossref" fields-alist t)))
-          (setq crossref-key (and field
-                                  (not (equal "" (cdr field)))
-                                  (cdr field))
-                req-field-list (if crossref-key
-                                   (nth 0 (nth 2 entry-list)) ; crossref part
-                                 (nth 0 (nth 1 entry-list)))) ; required part
-
-          (dolist (rfield req-field-list)
-            (when (nth 3 rfield) ; we should have an alternative
-              (setq alternatives-there t
-                    field (assoc-string (car rfield) fields-alist t))
-              (if (and field
-                       (not (equal "" (cdr field))))
-                  (cond ((not non-empty-alternative)
-                         (setq non-empty-alternative t))
-                        ((memq 'required-fields format)
-                         (error "More than one non-empty alternative")))))))
-
-        (if (and alternatives-there
-                 (not non-empty-alternative)
-                 (memq 'required-fields format))
-            (error "All alternatives are empty"))
+            (insert (bibtex-entry-left-delimiter)))
+
+          ;; Do we have a crossref key?
+          (goto-char (point-min))
+          (if (setq bounds (bibtex-search-forward-field "crossref"))
+              (let ((text (bibtex-text-in-field-bounds bounds t)))
+                (unless (equal "" text)
+                  (setq crossref-key text))))
+
+          ;; list of required fields appropriate for an entry with
+          ;; or without crossref key.
+          (setq req-field-list (if (and crossref-key (nth 2 entry-list))
+                                   (car (nth 2 entry-list))
+                                 (car (nth 1 entry-list)))
+                ;; default list of fields that may appear in this entry
+                default-field-list (append (nth 0 (nth 1 entry-list))
+                                           (nth 1 (nth 1 entry-list))
+                                           bibtex-user-optional-fields)))
 
         ;; process all fields
         (bibtex-beginning-first-field (point-min))
@@ -1965,25 +1961,18 @@
                  (empty-field (equal "" (bibtex-text-in-field-bounds bounds t)))
                  deleted)
 
-            ;; We have more elegant high-level functions for several
-            ;; tasks done by `bibtex-format-entry'.  However, they contain
-            ;; quite some redundancy compared with what we need to do
-            ;; anyway.  So for speed-up we avoid using them.
-
             (if (memq 'opts-or-alts format)
+                ;; delete empty optional and alternative fields
+                ;; (but keep empty required fields)
                 (cond ((and empty-field
                             (or opt-alt
                                 (let ((field (assoc-string
                                               field-name req-field-list t)))
                                   (or (not field)       ; OPT field
                                       (nth 3 field))))) ; ALT field
-                       ;; Either it is an empty ALT field.  Then we have checked
-                       ;; already that we have one non-empty alternative.  Or it
-                       ;; is an empty OPT field that we do not miss anyway.
-                       ;; So we can safely delete this field.
                        (delete-region beg-field end-field)
                        (setq deleted t))
-                      ;; otherwise: not empty, delete "OPT" or "ALT"
+                      ;; otherwise nonempty field: delete "OPT" or "ALT"
                       (opt-alt
                        (goto-char beg-name)
                        (delete-char 3))))
@@ -2087,16 +2076,7 @@
                       (goto-char (1+ beg-text))
                       (insert title))))
 
-	      ;; Use booktitle to set a missing title.
-	      (if (and empty-field
-		       (bibtex-string= field-name "title"))
-		  (let ((booktitle (bibtex-text-in-field "booktitle")))
-		    (when booktitle
-		      (setq empty-field nil)
-		      (goto-char (1+ beg-text))
-		      (insert booktitle))))
-
-              ;; if empty field, complain
+              ;; if empty field is a required field, complain
               (if (and empty-field
                        (memq 'required-fields format)
                        (assoc-string field-name req-field-list t))
@@ -2104,12 +2084,8 @@
 
               ;; unify case of field name
               (if (memq 'unify-case format)
-                  (let ((fname (car (assoc-string
-                                     field-name
-				     (append (nth 0 (nth 1 entry-list))
-					     (nth 1 (nth 1 entry-list))
-					     bibtex-user-optional-fields)
-				     t))))
+                  (let ((fname (car (assoc-string field-name
+                                                  default-field-list t))))
                     (if fname
                         (progn
                           (delete-region beg-name end-name)
@@ -2123,23 +2099,21 @@
 
         ;; check whether all required fields are present
         (if (memq 'required-fields format)
-            (let ((found 0) altlist)
+            (let ((found 0) alt-list)
               (dolist (fname req-field-list)
-                (if (nth 3 fname)
-                    (push (car fname) altlist))
-                (unless (or (member (car fname) field-list)
-                            (nth 3 fname))
-                  (error "Mandatory field `%s' is missing" (car fname))))
-              (when altlist
-                (dolist (fname altlist)
-                  (if (member fname field-list)
-                      (setq found (1+ found))))
-                (cond ((= found 0)
-                       (error "Alternative mandatory field `%s' is missing"
-                              altlist))
-                      ((> found 1)
-                       (error "Alternative fields `%s' are defined %s times"
-                              altlist found))))))
+                (cond ((nth 3 fname) ; t if field has alternative flag
+                       (push (car fname) alt-list)
+                       (if (member-ignore-case (car fname) field-list)
+                           (setq found (1+ found))))
+                      ((not (member-ignore-case (car fname) field-list))
+                       (error "Mandatory field `%s' is missing" (car fname)))))
+              (if alt-list
+                  (cond ((= found 0)
+                         (error "Alternative mandatory field `%s' is missing"
+                                alt-list))
+                        ((> found 1)
+                         (error "Alternative fields `%s' are defined %s times"
+                                alt-list found))))))
 
         ;; update comma after last field
         (if (memq 'last-comma format)
@@ -2158,7 +2132,7 @@
           (delete-char 1)
           (insert (bibtex-entry-right-delimiter)))
 
-        ;; fill entry
+        ;; realign and fill entry
         (if (memq 'realign format)
             (bibtex-fill-entry))))))
 
@@ -2426,7 +2400,7 @@
       (apply 'append
              (mapcar (lambda (buf)
                        (with-current-buffer buf bibtex-reference-keys))
-                     (bibtex-files-expand t)))
+                     (bibtex-initialize t)))
     bibtex-reference-keys))
 
 (defun bibtex-read-key (prompt &optional key global)
@@ -2606,14 +2580,22 @@
                   (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick)))))
         (setq buffers (cdr buffers))))))
 
-(defun bibtex-files-expand (&optional current force)
-  "Return an expanded list of BibTeX buffers based on `bibtex-files'.
+;;;###autoload
+(defun bibtex-initialize (&optional current force select)
+  "(Re)Initialize BibTeX buffers.
+Visit the BibTeX files defined by `bibtex-files' and return a list
+of corresponding buffers.
 Initialize in these buffers `bibtex-reference-keys' if not yet set.
 List of BibTeX buffers includes current buffer if CURRENT is non-nil.
 If FORCE is non-nil, (re)initialize `bibtex-reference-keys' even if
-already set."
+already set.  If SELECT is non-nil interactively select a BibTeX buffer.
+When called interactively, FORCE is t, CURRENT is t if current buffer uses
+`bibtex-mode', and SELECT is t if current buffer does not use `bibtex-mode',"
+  (interactive (list (eq major-mode 'bibtex-mode) t
+                     (not (eq major-mode 'bibtex-mode))))
   (let ((file-path (split-string (or bibtex-file-path default-directory) ":+"))
         file-list dir-list buffer-list)
+    ;; generate list of BibTeX files
     (dolist (file bibtex-files)
       (cond ((eq file 'bibtex-file-path)
              (setq dir-list (append dir-list file-path)))
@@ -2624,34 +2606,46 @@
                     (file-name-absolute-p file))
              (push file file-list))
             (t
-             (let (fullfilename found)
+             (let (expanded-file-name found)
                (dolist (dir file-path)
                  (when (file-readable-p
-                        (setq fullfilename (expand-file-name file dir)))
-                   (push fullfilename file-list)
+                        (setq expanded-file-name (expand-file-name file dir)))
+                   (push expanded-file-name file-list)
                    (setq found t)))
                (unless found
-                 (error "File %s not in paths defined via bibtex-file-path"
+                 (error "File `%s' not in paths defined via bibtex-file-path"
                         file))))))
     (dolist (file file-list)
       (unless (file-readable-p file)
-        (error "BibTeX file %s not found" file)))
+        (error "BibTeX file `%s' not found" file)))
     ;; expand dir-list
     (dolist (dir dir-list)
       (setq file-list
             (append file-list (directory-files dir t "\\.bib\\'" t))))
     (delete-dups file-list)
+    ;; visit files in FILE-LIST
     (dolist (file file-list)
-      (when (file-readable-p file)
-        (push (find-file-noselect file) buffer-list)
-        (with-current-buffer (car buffer-list)
-          (if (or force (not (listp bibtex-reference-keys)))
-            (bibtex-parse-keys)))))
+      (if (file-readable-p file)
+        (push (find-file-noselect file) buffer-list)))
+    ;; include current buffer iff we want it
     (cond ((and current (not (memq (current-buffer) buffer-list)))
-           (push (current-buffer) buffer-list)
-           (if force (bibtex-parse-keys)))
+           (push (current-buffer) buffer-list))
           ((and (not current) (memq (current-buffer) buffer-list))
            (setq buffer-list (delq (current-buffer) buffer-list))))
+    ;; parse keys
+    (dolist (buffer buffer-list)
+      (with-current-buffer buffer
+        (if (or force (nlistp bibtex-reference-keys))
+            (bibtex-parse-keys))))
+    ;; select BibTeX buffer
+    (if select
+        (if buffer-list
+            (switch-to-buffer
+             (completing-read "Switch to BibTeX buffer: "
+                              (mapcar 'buffer-name buffer-list)
+                              nil t
+                              (if current (buffer-name (current-buffer)))))
+          (message "No BibTeX buffers defined")))
     buffer-list))
 
 (defun bibtex-complete-internal (completions)
@@ -3130,7 +3124,6 @@
 based on the difference between the keys of the neighboring and the current
 entry (for example, the year parts of the keys)."
   (interactive)
-  (undo-boundary)	;So you can easily undo it, if it didn't work right.
   (bibtex-beginning-of-entry)
   (when (looking-at bibtex-entry-head)
     (let ((type (bibtex-type-in-head))
@@ -3413,13 +3406,18 @@
   (cond ((not index1) (not index2)) ; indices can be nil
         ((not index2) nil)
         ((eq bibtex-maintain-sorted-entries 'crossref)
-         (if (nth 1 index1)
-             (if (nth 1 index2)
+         ;; CROSSREF-KEY may be nil or it can point to an entry
+         ;; in another BibTeX file.  In both cases we ignore CROSSREF-KEY.
+         (if (and (nth 1 index1)
+                  (cdr (assoc-string (nth 1 index1) bibtex-reference-keys)))
+             (if (and (nth 1 index2)
+                      (cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
                  (or (string-lessp (nth 1 index1) (nth 1 index2))
                      (and (string-equal (nth 1 index1) (nth 1 index2))
                           (string-lessp (nth 0 index1) (nth 0 index2))))
                (not (string-lessp (nth 0 index2) (nth 1 index1))))
-           (if (nth 1 index2)
+           (if (and (nth 1 index2)
+                    (cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
                (string-lessp (nth 0 index1) (nth 1 index2))
              (string-lessp (nth 0 index1) (nth 0 index2)))))
         ((eq bibtex-maintain-sorted-entries 'entry-class)
@@ -3444,6 +3442,9 @@
   (interactive)
   (bibtex-beginning-of-first-entry)     ; Needed by `sort-subr'
   (bibtex-init-sort-entry-class-alist)  ; Needed by `bibtex-lessp'.
+  (if (and (eq bibtex-maintain-sorted-entries 'crossref)
+           (nlistp bibtex-reference-keys))
+      (bibtex-parse-keys))              ; Needed by `bibtex-lessp'.
   (sort-subr nil
              'bibtex-skip-to-valid-entry   ; NEXTREC function
              'bibtex-end-of-entry          ; ENDREC function
@@ -3539,7 +3540,7 @@
   (interactive (list (bibtex-read-key "Find key: " nil current-prefix-arg)
                      current-prefix-arg nil t))
   (if (and global bibtex-files)
-      (let ((buffer-list (bibtex-files-expand t))
+      (let ((buffer-list (bibtex-initialize t))
             buffer found)
         (while (and (not found)
                     (setq buffer (pop buffer-list)))
@@ -3581,6 +3582,9 @@
 see `bibtex-validate'.
 Return t if preparation was successful or nil if entry KEY already exists."
   (bibtex-init-sort-entry-class-alist)  ; Needed by `bibtex-lessp'.
+  (if (and (eq bibtex-maintain-sorted-entries 'crossref)
+           (nlistp bibtex-reference-keys))
+      (bibtex-parse-keys))              ; Needed by `bibtex-lessp'.
   (let ((key (nth 0 index))
         key-exist)
     (cond ((or (null key)
@@ -3671,6 +3675,9 @@
             (setq syntax-error t)
 
           ;; Check for duplicate keys and correct sort order
+          (bibtex-init-sort-entry-class-alist)  ; Needed by `bibtex-lessp'.
+          (bibtex-parse-keys) ; Possibly needed by `bibtex-lessp'.
+                              ; Always needed by subsequent global key check.
           (let (previous current key-list)
             (bibtex-progress-message "Checking for duplicate keys")
             (bibtex-map-entries
@@ -3692,9 +3699,12 @@
             (bibtex-progress-message 'done))
 
           ;; Check for duplicate keys in `bibtex-files'.
-          (bibtex-parse-keys)
+          ;; `bibtex-validate' only compares keys in current buffer with keys
+          ;; in `bibtex-files'. `bibtex-validate-globally' compares keys for
+          ;; each file in `bibtex-files' with keys of all other files in
+          ;; `bibtex-files'.
           ;; We don't want to be fooled by outdated `bibtex-reference-keys'.
-          (dolist (buffer (bibtex-files-expand nil t))
+          (dolist (buffer (bibtex-initialize nil t))
             (dolist (key (with-current-buffer buffer bibtex-reference-keys))
               (when (and (cdr key)
                          (cdr (assoc-string (car key) bibtex-reference-keys)))
@@ -3792,7 +3802,7 @@
 With optional prefix arg STRINGS, check for duplicate strings, too.
 Return t if test was successful, nil otherwise."
   (interactive "P")
-  (let ((buffer-list (bibtex-files-expand t))
+  (let ((buffer-list (bibtex-initialize t))
         buffer-key-list current-buf current-keys error-list)
     ;; Check for duplicate keys within BibTeX buffer
     (dolist (buffer buffer-list)
@@ -4133,14 +4143,15 @@
 	       (error "Not inside a BibTeX entry")))
         (entry-type (bibtex-type-in-head))
         (key (bibtex-key-in-head)))
-    ;; formatting
-    (cond ((bibtex-string= entry-type "preamble")
-           ;; (bibtex-format-preamble)
-           (error "No clean up of @Preamble entries"))
-          ((bibtex-string= entry-type "string")
-           (setq entry-type 'string))
-          ;; (bibtex-format-string)
-          (t (bibtex-format-entry)))
+    ;; formatting (undone if error occurs)
+    (atomic-change-group
+      (cond ((bibtex-string= entry-type "preamble")
+             ;; (bibtex-format-preamble)
+             (error "No clean up of @Preamble entries"))
+            ((bibtex-string= entry-type "string")
+             (setq entry-type 'string))
+             ;; (bibtex-format-string)
+            (t (bibtex-format-entry))))
     ;; set key
     (when (or new-key (not key))
       (setq key (bibtex-generate-autokey))
@@ -4184,7 +4195,7 @@
                           (bibtex-find-entry key nil end))))
         (if error
             (error "New inserted entry yields duplicate key"))
-        (dolist (buffer (bibtex-files-expand))
+        (dolist (buffer (bibtex-initialize))
           (with-current-buffer buffer
             (if (cdr (assoc-string key bibtex-reference-keys))
                 (error "Duplicate key in %s" (buffer-file-name)))))
--- a/lisp/textmodes/ispell.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/ispell.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1597,7 +1597,7 @@
 	     (or quietly
 		 (message "%s is correct"
 			  (funcall ispell-format-word-function word)))
-	     (and (fboundp 'extent-at)
+	     (and (featurep 'xemacs)
 		  (extent-at start)
 		  (and (fboundp 'delete-extent)
 		       (delete-extent (extent-at start)))))
@@ -1606,7 +1606,7 @@
 		 (message "%s is correct because of root %s"
 			  (funcall ispell-format-word-function word)
 			  (funcall ispell-format-word-function poss)))
-	     (and (fboundp 'extent-at)
+	     (and (featurep 'xemacs)
 		  (extent-at start)
 		  (and (fboundp 'delete-extent)
 		       (delete-extent (extent-at start)))))
--- a/lisp/textmodes/org-export-latex.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/org-export-latex.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,10 +1,10 @@
- ;;; org-export-latex.el --- LaTeX exporter for org-mode
+;;; org-export-latex.el --- LaTeX exporter for org-mode
 ;;
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (c) 2007, 2008 Free Software Foundation, Inc.
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 5.12
+;; Version: 5.19
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
@@ -18,31 +18,31 @@
 ;; Free Software Foundation; either version 3, or (at your option) any
 ;; later version.
 ;;
-;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-;; more details.
+;; GNU Emacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
 ;;
-;; You should have received a copy of the GNU General Public License along
-;; with GNU Emacs; see the file COPYING. If not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-;; 02110-1301, USA.
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301, USA.
 ;;
 ;;; Commentary:
 ;;
 ;; This library implements a LaTeX exporter for org-mode.
-;; 
+;;
 ;; Put this file into your load-path and the following into your ~/.emacs:
 ;;   (require 'org-export-latex)
-;; 
+;;
 ;; The interactive functions are similar to those of the HTML exporter:
-;; 
+;;
 ;; M-x `org-export-as-latex'
 ;; M-x `org-export-as-latex-batch'
 ;; M-x `org-export-as-latex-to-buffer'
 ;; M-x `org-export-region-as-latex'
 ;; M-x `org-replace-region-by-latex'
-;;
+;; 
 ;;; Code:
 
 (eval-when-compile
@@ -52,15 +52,19 @@
 (require 'org)
 
 ;;; Variables:
-(defvar org-latex-options-plist nil)
-(defvar org-latex-todo-keywords-1 nil)
-(defvar org-latex-all-targets-regexp nil)
-(defvar org-latex-add-level 0)
-(defvar org-latex-sectioning-depth 0)
+(defvar org-export-latex-class nil)
+(defvar org-export-latex-header nil)
+(defvar org-export-latex-append-header nil)
+(defvar org-export-latex-options-plist nil)
+(defvar org-export-latex-todo-keywords-1 nil)
+(defvar org-export-latex-all-targets-re nil)
+(defvar org-export-latex-add-level 0)
+(defvar org-export-latex-sectioning "")
+(defvar org-export-latex-sectioning-depth 0)
 (defvar org-export-latex-list-beginning-re
   "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +?")
 
-(defvar org-latex-special-string-regexps
+(defvar org-export-latex-special-string-regexps
   '(org-ts-regexp
     org-scheduled-string
     org-deadline-string
@@ -71,28 +75,82 @@
 (defvar re-quote)  ; dynamically scoped from org.el
 (defvar commentsp) ; dynamically scoped from org.el
 
-;;; Custom variables:
-(defcustom org-export-latex-sectioning-alist
-  '((1 "\\section{%s}" "\\section*{%s}")
-    (2 "\\subsection{%s}" "\\subsection*{%s}")
-    (3 "\\subsubsection{%s}" "\\subsubsection*{%s}")
-    (4 "\\paragraph{%s}" "\\paragraph*{%s}")
-    (5 "\\subparagraph{%s}" "\\subparagraph*{%s}"))
-  "Alist of LaTeX commands for inserting sections.
-Here is the structure of each cell:
+;;; User variables:
+
+(defcustom org-export-latex-default-class "article"
+  "The default LaTeX class."
+  :group 'org-export-latex
+  :type '(string :tag "LaTeX class"))
 
-  \(level unnumbered-section numbered-section\)
+(defcustom org-export-latex-classes
+  '(("article"
+     "\\documentclass[11pt,a4paper]{article}
+\\usepackage[utf8]{inputenc}
+\\usepackage[T1]{fontenc}
+\\usepackage{hyperref}"
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
+     ("\\paragraph{%s}" . "\\paragraph*{%s}")
+     ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
+    ("report"
+     "\\documentclass[11pt,a4paper]{report}
+\\usepackage[utf8]{inputenc}
+\\usepackage[T1]{fontenc}
+\\usepackage{hyperref}"
+     ("\\part{%s}" . "\\part*{%s}")
+     ("\\chapter{%s}" . "\\chapter*{%s}")
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
+    ("book"
+     "\\documentclass[11pt,a4paper]{book}
+\\usepackage[utf8]{inputenc}
+\\usepackage[T1]{fontenc}
+\\usepackage{hyperref}"
+     ("\\part{%s}" . "\\part*{%s}")
+     ("\\chapter{%s}" . "\\chapter*{%s}")
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
+  "Alist of LaTeX classes and associated header and structure.
+If #+LaTeX_CLASS is set in the buffer, use its value and the
+associated information.  Here is the structure of each cell:
 
-The %s formatter will be replaced by the title of the section."
+  \(class-name
+    header-string
+    (unnumbered-section numbered-section\)
+    ...\)
+
+A %s formatter is mandatory in each section string and will be
+replaced by the title of the section."
   :group 'org-export-latex
-  :type 'alist)
+  :type '(repeat
+	  (list (string :tag "LaTeX class")
+		(string :tag "LaTeX header")
+		(cons :tag "Level 1"
+		      (string :tag "Numbered")
+		      (string :tag "Unnumbered"))
+		(cons :tag "Level 2"
+		      (string :tag "Numbered")
+		      (string :tag "Unnumbered"))
+		(cons :tag "Level 3"
+		      (string :tag "Numbered")
+		      (string :tag "Unnumbered"))
+		(cons :tag "Level 4"
+		      (string :tag "Numbered")
+		      (string :tag "Unnumbered"))
+		(cons :tag "Level 5"
+		      (string :tag "Numbered")
+		      (string :tag "Unnumbered")))))
 
 (defcustom org-export-latex-emphasis-alist
   '(("*" "\\textbf{%s}" nil)
     ("/" "\\emph{%s}" nil)
     ("_" "\\underline{%s}" nil)
     ("+" "\\texttt{%s}" nil)
-    ("=" "\\texttt{%s}" nil))
+    ("=" "\\texttt{%s}" nil)
+    ("~" "\\texttt{%s}" t))
   "Alist of LaTeX expressions to convert emphasis fontifiers.
 Each element of the list is a list of three elements.
 The first element is the character used as a marker for fontification.
@@ -102,15 +160,6 @@
   :group 'org-export-latex
   :type 'alist)
 
-(defcustom org-export-latex-preamble
-  "\\documentclass[11pt,a4paper]{article}
-\\usepackage[utf8]{inputenc}
-\\usepackage[T1]{fontenc}
-\\usepackage{hyperref}"
-  "Preamble to be inserted at the very beginning of the LaTeX export."
-  :group 'org-export-latex
-  :type 'string)
-
 (defcustom org-export-latex-title-command "\\maketitle"
   "The command used to insert the title just after \\begin{document}.
 If this string contains the formatting specification \"%s\" then
@@ -119,7 +168,7 @@
   :group 'org-export-latex
   :type 'string)
 
-(defcustom org-export-latex-date-format 
+(defcustom org-export-latex-date-format
   "%d %B %Y"
   "Format string for \\date{...}."
   :group 'org-export-latex
@@ -130,14 +179,15 @@
   :group 'org-export-latex
   :type 'boolean)
 
-(defcustom org-export-latex-packages-alist nil
-  "Alist of packages to be inserted in the preamble.
-Each cell is of the forma \( option . package \).
+(defcustom org-export-latex-tables-column-borders nil
+  "When non-nil, group of columns are surrounded with borders,
+XSeven if these borders are the outside borders of the table."
+  :group 'org-export-latex
+  :type 'boolean)
 
-For example:
-
-\(setq org-export-latex-packages-alist
-      '((\"french\" \"babel\"))"
+(defcustom org-export-latex-packages-alist nil
+  "Alist of packages to be inserted in the header.
+Each cell is of the forma \( \"option\" . \"package\" \)."
   :group 'org-export-latex
   :type 'alist)
 
@@ -167,17 +217,42 @@
 (defcustom org-export-latex-image-default-option "width=10em"
   "Default option for images."
   :group 'org-export-latex
-  :type '(string))
+  :type 'string)
 
 (defcustom org-export-latex-coding-system nil
   "Coding system for the exported LaTex file."
   :group 'org-export-latex
   :type 'coding-system)
 
-;; FIXME Do we want this one?
-;; (defun org-export-as-latex-and-open (arg) ...)
+(defcustom org-list-radio-list-templates
+  '((latex-mode "% BEGIN RECEIVE ORGLST %n
+% END RECEIVE ORGLST %n
+\\begin{comment}
+#+ORGLST: SEND %n org-list-to-latex
+| | |
+\\end{comment}\n")
+    (texinfo-mode "@c BEGIN RECEIVE ORGLST %n
+@c END RECEIVE ORGLST %n
+@ignore
+#+ORGLST: SEND %n org-list-to-texinfo
+| | |
+@end ignore\n")
+    (html-mode "<!-- BEGIN RECEIVE ORGLST %n -->
+<!-- END RECEIVE ORGLST %n -->
+<!--
+#+ORGLST: SEND %n org-list-to-html
+| | |
+-->\n"))
+  "Templates for radio lists in different major modes.
+All occurrences of %n in a template will be replaced with the name of the
+list, obtained by prompting the user."
+  :group 'org-plain-lists
+  :type '(repeat
+	  (list (symbol :tag "Major mode")
+		(string :tag "Format"))))
 
 ;;; Autoload functions:
+
 ;;;###autoload
 (defun org-export-as-latex-batch ()
   "Call `org-export-as-latex', may be used in batch processing as
@@ -199,7 +274,7 @@
 (defun org-replace-region-by-latex (beg end)
   "Replace the region from BEG to END with its LaTeX export.
 It assumes the region has `org-mode' syntax, and then convert it to
-LaTeX. This can be used in any buffer. For example, you could
+LaTeX.  This can be used in any buffer.  For example, you could
 write an itemized list in `org-mode' syntax in an LaTeX buffer and
 then use this command to convert it."
   (interactive "r")
@@ -255,7 +330,21 @@
 ;;;###autoload
 (defun org-export-as-latex (arg &optional hidden ext-plist
 				to-buffer body-only)
-  "Export current buffer to a LaTeX file."
+  "Export current buffer to a LaTeX file.
+If there is an active region, export only the region.  The prefix
+ARG specifies how many levels of the outline should become
+headlines.  The default is 3.  Lower levels will be exported
+depending on `org-export-latex-low-levels'.  The default is to
+convert them as description lists.  When HIDDEN is non-nil, don't
+display the LaTeX buffer.  EXT-PLIST is a property list with
+external parameters overriding org-mode's default settings, but
+still inferior to file-local settings.  When TO-BUFFER is
+non-nil, create a buffer with that name and export to that
+buffer.  If TO-BUFFER is the symbol `string', don't leave any
+buffer behind but just return the resulting LaTeX as a string.
+When BODY-ONLY is set, don't produce the file header and footer,
+simply return the content of \begin{document}...\end{document},
+without even the \begin{document} and \end{document} commands."
   (interactive "P")
   ;; Make sure we have a file name when we need it.
   (when (and (not (or to-buffer body-only))
@@ -268,9 +357,23 @@
 
   (message "Exporting to LaTeX...")
   (org-update-radio-target-regexp)
-  (org-export-latex-set-initial-vars ext-plist)
+  (org-export-latex-set-initial-vars ext-plist arg)
   (let* ((wcf (current-window-configuration))
-	 (opt-plist org-latex-options-plist)
+	 (opt-plist org-export-latex-options-plist)
+	 (region-p (org-region-active-p))
+	 (subtree-p
+	  (when region-p
+	    (save-excursion
+	      (goto-char (region-beginning))
+	      (and (org-at-heading-p)
+		   (>= (org-end-of-subtree t t) (region-end))))))
+	 (title (or (and subtree-p (org-export-get-title-from-subtree))
+		    (plist-get opt-plist :title)
+		    (and (not
+			  (plist-get opt-plist :skip-before-1st-heading))
+			 (org-export-grab-title-from-buffer))
+		    (file-name-sans-extension
+		     (file-name-nondirectory buffer-file-name))))
 	 (filename (concat (file-name-as-directory
 			    (org-export-directory :LaTeX ext-plist))
 			   (file-name-sans-extension
@@ -286,10 +389,11 @@
 					       "*Org LaTeX Export*"))
 		      (t (get-buffer-create to-buffer)))
 		   (find-file-noselect filename)))
-	 (region-p (org-region-active-p))
 	 (odd org-odd-levels-only)
-	 (preamble (org-export-latex-make-preamble opt-plist))
-	 (skip (plist-get opt-plist :skip-before-1st-heading))
+	 (header (org-export-latex-make-header title opt-plist))
+	 (skip (if subtree-p nil
+		 ;; never skip first lines when exporting a subtree
+		 (plist-get opt-plist :skip-before-1st-heading)))
 	 (text (plist-get opt-plist :text))
 	 (first-lines (if skip "" (org-export-latex-first-lines)))
 	 (coding-system (and (boundp 'buffer-file-coding-system)
@@ -310,19 +414,21 @@
 		  :skip-before-1st-heading skip
 		  :LaTeX-fragments nil)))
 
-    (set-buffer buffer) 
+    (set-buffer buffer)
     (erase-buffer)
 
     (and (fboundp 'set-buffer-file-coding-system)
 	 (set-buffer-file-coding-system coding-system-for-write))
 
-    ;; insert the preamble and initial document commands
+    ;; insert the header and initial document commands
     (unless (or (eq to-buffer 'string) body-only)
-      (insert preamble))
+      (insert header))
 
     ;; insert text found in #+TEXT
     (when (and text (not (eq to-buffer 'string)))
-      (insert (org-export-latex-content text) "\n\n"))
+      (insert (org-export-latex-content
+	       text '(lists tables fixed-width keywords))
+	       "\n\n"))
 
     ;; insert lines before the first headline
     (unless (or skip (eq to-buffer 'string))
@@ -342,7 +448,7 @@
        (when (re-search-forward "^\\(\\*+\\) " nil t)
 	 (let* ((asters (length (match-string 1)))
 		(level (if odd (- asters 2) (- asters 1))))
-	   (setq org-latex-add-level
+	   (setq org-export-latex-add-level
 		 (if odd (1- (/ (1+ asters) 2)) (1- asters)))
 	   (org-export-latex-parse-global level odd)))))
 
@@ -358,16 +464,16 @@
 	  (current-buffer))
       (set-window-configuration wcf))))
 
+;;; Parsing functions:
 
-;;; Parsing functions:
 (defun org-export-latex-parse-global (level odd)
   "Parse the current buffer recursively, starting at LEVEL.
 If ODD is non-nil, assume the buffer only contains odd sections.
-Return A list reflecting the document structure."
+Return a list reflecting the document structure."
   (save-excursion
     (goto-char (point-min))
     (let* ((cnt 0) output
-	   (depth org-latex-sectioning-depth))
+	   (depth org-export-latex-sectioning-depth))
       (while (re-search-forward
 	      (concat "^\\(\\(?:\\*\\)\\{"
 		      (number-to-string (+ (if odd 2 1) level))
@@ -404,57 +510,11 @@
 			    `(occur . ,cnt)
 			    `(heading . ,heading)
 			    `(content . ,(org-export-latex-parse-content))
-			    `(subcontent . ,(org-export-latex-parse-subcontent 
+			    `(subcontent . ,(org-export-latex-parse-subcontent
 					     level odd)))))))
 	  (widen)))
       (list output))))
 
-(defun org-export-latex-parse-list (&optional delete)
-  "Parse the list at point.
-Return a list containing first level items as strings and
-sublevels as list of strings."
-  (let ((start (point))
-	;; Find the end of the list
-	(end (save-excursion 
-	       (catch 'exit
-		 (while (or (looking-at org-export-latex-list-beginning-re)
-			    (looking-at "^[ \t]+\\|^$"))
-		   (if (eq (point) (point-max))
-		       (throw 'exit (point-max)))
-		   (forward-line 1))) (point)))
-	output itemsep)
-    (while (re-search-forward org-export-latex-list-beginning-re end t)
-      (setq itemsep (if (save-match-data
-			  (string-match "^[0-9]" (match-string 2)))
-			"[0-9]+\\(?:\\.\\|)\\)" "[-+]"))
-      (let* ((indent1 (match-string 1))
-	     (nextitem (save-excursion 
-			 (save-match-data
-			   (or (and (re-search-forward 
-				     (concat "^" indent1 itemsep " *?") end t)
-				    (match-beginning 0)) end))))
-	     (item (buffer-substring
-		    (point)
-		    (or (and (re-search-forward 
-			      org-export-latex-list-beginning-re end t)
-			     (goto-char (match-beginning 0)))
-			(goto-char end))))
-	     (nextindent (match-string 1))
-	     (item (org-trim item))
-	     (item (if (string-match "^\\[.+\\]" item)
-		       (replace-match "\\\\texttt{\\&}"
-				      t nil item) item)))
-	(push item output)
-	(when (> (length nextindent)
-		 (length indent1))
-	  (narrow-to-region (point) nextitem)
-	  (push (org-export-latex-parse-list) output)
-	  (widen))))
-    (when delete (delete-region start end))
-    (setq output (nreverse output))
-    (push (if (string-match "^\\[0" itemsep)
-	      'ordered 'unordered) output)))
-
 (defun org-export-latex-parse-content ()
   "Extract the content of a section."
   (let ((beg (point))
@@ -487,7 +547,7 @@
   "Export the list SUBCONTENT to LaTeX.
 SUBCONTENT is an alist containing information about the headline
 and its content."
-  (let ((num (plist-get org-latex-options-plist :section-numbers)))
+  (let ((num (plist-get org-export-latex-options-plist :section-numbers)))
     (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
 
 (defun org-export-latex-subcontent (subcontent num)
@@ -495,20 +555,20 @@
   (let ((heading (org-export-latex-fontify-headline
 		  (cdr (assoc 'heading subcontent))))
 	(level (- (cdr (assoc 'level subcontent))
-		  org-latex-add-level))
+		  org-export-latex-add-level))
 	(occur (number-to-string (cdr (assoc 'occur subcontent))))
 	(content (cdr (assoc 'content subcontent)))
 	(subcontent (cadr (assoc 'subcontent subcontent))))
-    (cond 
+    (cond
      ;; Normal conversion
-     ((<= level org-latex-sectioning-depth)
-      (let ((sec (assoc level org-export-latex-sectioning-alist)))
-	(insert (format (if num (cadr sec) (caddr sec)) heading) "\n"))
+     ((<= level org-export-latex-sectioning-depth)
+      (let ((sec (nth (1- level) org-export-latex-sectioning)))
+	(insert (format (if num (car sec) (cdr sec)) heading) "\n"))
       (insert (org-export-latex-content content))
       (cond ((stringp subcontent) (insert subcontent))
 	    ((listp subcontent) (org-export-latex-sub subcontent))))
      ;; At a level under the hl option: we can drop this subsection
-     ((> level org-latex-sectioning-depth)
+     ((> level org-export-latex-sectioning-depth)
       (cond ((eq org-export-latex-low-levels 'description)
 	     (insert (format "\\begin{description}\n\n\\item[%s]\n\n" heading))
 	     (insert (org-export-latex-content content))
@@ -521,52 +581,47 @@
 	     (cond ((stringp subcontent) (insert subcontent))
 		   ((listp subcontent) (org-export-latex-sub subcontent)))))))))
 
-
 ;;; Exporting internals:
-(defun org-export-latex-protect-string (string)
-  "Prevent further conversion for STRING by adding the
-org-protect property."
-  (add-text-properties 
-   0 (length string) '(org-protected t) string) string)
-
-(defun org-export-latex-protect-char-in-string (char-list string)
-  "Add org-protected text-property to char from CHAR-LIST in STRING."
-  (with-temp-buffer
-    (save-match-data
-      (insert string)
-      (goto-char (point-min))
-      (while (re-search-forward (regexp-opt char-list) nil t)
-	(add-text-properties (match-beginning 0)
-			     (match-end 0) '(org-protected t)))
-      (buffer-string))))
-
-(defun org-export-latex-set-initial-vars (ext-plist)
+(defun org-export-latex-set-initial-vars (ext-plist level)
   "Store org local variables required for LaTeX export.
-EXT-PLIST is an optional additional plist."
-  (setq org-latex-todo-keywords-1 org-todo-keywords-1
-	org-latex-all-targets-regexp
+EXT-PLIST is an optional additional plist.
+LEVEL indicates the default depth for export."
+  (setq org-export-latex-todo-keywords-1 org-todo-keywords-1
+	org-export-latex-all-targets-re
 	(org-make-target-link-regexp (org-all-targets))
-	org-latex-options-plist
+	org-export-latex-options-plist
 	(org-combine-plists (org-default-export-plist) ext-plist
 			    (org-infile-export-plist))
-	org-latex-sectioning-depth
-	(let ((hl-levels (plist-get org-latex-options-plist :headline-levels))
-	      (sec-depth (length org-export-latex-sectioning-alist)))
-	      ;; Fall back on org-export-latex-sectioning-alist length if
-	      ;; headline-levels goes beyond it
-	  (if (> hl-levels sec-depth) sec-depth hl-levels))))
+	org-export-latex-class
+	(save-excursion
+	  (goto-char (point-min))
+	  (if (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t)
+		   (assoc (match-string 1) org-export-latex-classes))
+	      (match-string 1)
+	    org-export-latex-default-class))
+	org-export-latex-header
+	(cadr (assoc org-export-latex-class org-export-latex-classes))
+	org-export-latex-sectioning
+	(cddr (assoc org-export-latex-class org-export-latex-classes))
+	org-export-latex-sectioning-depth
+	(or level
+	    (let ((hl-levels
+		   (plist-get org-export-latex-options-plist :headline-levels))
+		  (sec-depth (length org-export-latex-sectioning)))
+	      (if (> hl-levels sec-depth) sec-depth hl-levels)))))
 
-(defun org-export-latex-make-preamble (opt-plist)
-  "Make the LaTeX preamble and return it as a string.
-Argument OPT-PLIST is the options plist for current buffer."
-  (let ((toc (plist-get opt-plist :table-of-contents)))
-    (concat 
+(defun org-export-latex-make-header (title opt-plist)
+  "Make the LaTeX header and return it as a string.
+TITLE is the current title from the buffer or region.
+OPT-PLIST is the options plist for current buffer."
+  (let ((toc (plist-get opt-plist :table-of-contents))
+	(author (plist-get opt-plist :author)))
+    (concat
      (if (plist-get opt-plist :time-stamp-file)
 	 (format-time-string "% Created %Y-%m-%d %a %H:%M\n"))
-     
-     ;; insert LaTeX custom preamble
-     org-export-latex-preamble "\n"
-     
+     ;; insert LaTeX custom header
+     org-export-latex-header
+     "\n"
      ;; insert information on LaTeX packages
      (when org-export-latex-packages-alist
        (mapconcat (lambda(p)
@@ -575,46 +630,34 @@
 		      (format "\\usepackage[%s]{%s}"
 			      (car p) (cadr p))))
 		  org-export-latex-packages-alist "\n"))
-     
+     ;; insert additional commands in the header
+     org-export-latex-append-header
      ;; insert the title
-     (format 
-      "\\title{%s}\n"
+     (format
+      "\n\n\\title{%s}\n"
       ;; convert the title
       (org-export-latex-content
-       (or (plist-get opt-plist :title)
-	   (and (not
-		 (plist-get opt-plist :skip-before-1st-heading))
-		(org-export-grab-title-from-buffer))
-	   (and buffer-file-name
-		(file-name-sans-extension
-		 (file-name-nondirectory buffer-file-name)))
-	   "UNTITLED")))
-     
+       title '(lists tables fixed-width keywords)))
      ;; insert author info
      (if (plist-get opt-plist :author-info)
-	 (format "\\author{%s}\n" 
-		 (or (plist-get opt-plist :author) user-full-name))
+	 (format "\\author{%s}\n"
+		 (or author user-full-name))
        (format "%%\\author{%s}\n"
-	       (or (plist-get opt-plist :author) user-full-name)))
-     
+	       (or author user-full-name)))
      ;; insert the date
      (format "\\date{%s}\n"
-	     (format-time-string 
+	     (format-time-string
 	      (or (plist-get opt-plist :date)
 		  org-export-latex-date-format)))
-     
      ;; beginning of the document
      "\n\\begin{document}\n\n"
-     
      ;; insert the title command
      (if (string-match "%s" org-export-latex-title-command)
-	 (format org-export-latex-title-command
-		 (plist-get opt-plist :title))
+	 (format org-export-latex-title-command title)
        org-export-latex-title-command)
      "\n\n"
-     
      ;; table of contents
-     (when (and org-export-with-toc 
+     (when (and org-export-with-toc
 		(plist-get opt-plist :section-numbers))
        (cond ((numberp toc)
 	      (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n"
@@ -628,8 +671,9 @@
 formatting string like %%%%s if we want to comment them out."
   (save-excursion
     (goto-char (point-min))
+    (if (org-at-heading-p) (beginning-of-line 2))
     (let* ((pt (point))
-	   (end (if (and (re-search-forward "^\\*" nil t)
+	   (end (if (and (re-search-forward "^\\* " nil t)
 			 (not (eq pt (match-beginning 0))))
 		    (goto-char (match-beginning 0))
 		  (goto-char (point-max)))))
@@ -643,10 +687,58 @@
 	:skip-before-1st-heading nil
 	:LaTeX-fragments nil)))))
 
+(defun org-export-latex-content (content &optional exclude-list)
+  "Convert CONTENT string to LaTeX.
+Don't perform conversions that are in EXCLUDE-LIST.  Recognized
+conversion types are: quotation-marks, emphasis, sub-superscript,
+links, keywords, lists, tables, fixed-width"
+  (with-temp-buffer
+   (insert content)
+   (unless (memq 'quotation-marks exclude-list)
+     (org-export-latex-quotation-marks))
+   (unless (memq 'emphasis exclude-list)
+     (when (plist-get org-export-latex-options-plist :emphasize)
+       (org-export-latex-fontify)))
+   (unless (memq 'sub-superscript exclude-list)
+     (org-export-latex-special-chars
+      (plist-get org-export-latex-options-plist :sub-superscript)))
+   (unless (memq 'links exclude-list)
+     (org-export-latex-links))
+   (unless (memq 'keywords exclude-list)
+     (org-export-latex-keywords
+      (plist-get org-export-latex-options-plist :timestamps)))
+   (unless (memq 'lists exclude-list)
+     (org-export-latex-lists))
+   (unless (memq 'tables exclude-list)
+     (org-export-latex-tables
+      (plist-get org-export-latex-options-plist :tables)))
+   (unless (memq 'fixed-width exclude-list)
+     (org-export-latex-fixed-width
+      (plist-get org-export-latex-options-plist :fixed-width)))
+   ;; return string
+   (buffer-substring (point-min) (point-max))))
+
+(defun org-export-latex-protect-string (s)
+  "Prevent further conversion for string S by adding the
+org-protect property."
+  (add-text-properties 0 (length s) '(org-protected t) s) s)
+
+(defun org-export-latex-protect-char-in-string (char-list string)
+  "Add org-protected text-property to char from CHAR-LIST in STRING."
+  (with-temp-buffer
+    (save-match-data
+      (insert string)
+      (goto-char (point-min))
+      (while (re-search-forward (regexp-opt char-list) nil t)
+	(add-text-properties (match-beginning 0)
+			     (match-end 0) '(org-protected t)))
+      (buffer-string))))
+
 (defun org-export-latex-keywords-maybe (remove-list)
   "Maybe remove keywords depending on rules in REMOVE-LIST."
   (goto-char (point-min))
-  (let ((re-todo (mapconcat 'identity org-latex-todo-keywords-1 "\\|")))
+  (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
+	(case-fold-search nil))
     ;; convert TODO keywords
     (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
       (if (plist-get remove-list :todo)
@@ -664,48 +756,25 @@
 	  (replace-match "")
 	(replace-match (format "\\texttt{%s}" (match-string 0)) t t)))))
 
-(defun org-export-latex-fontify-headline (headline)
-  "Fontify special words in a HEADLINE."
+(defun org-export-latex-fontify-headline (string)
+  "Fontify special words in string."
   (with-temp-buffer
     ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
     ;; the beginning of the buffer - inserting "\n" is safe here though.
-    (insert "\n" headline)
+    (insert "\n" string)
     (goto-char (point-min))
-    (when (plist-get org-latex-options-plist :emphasize)
+    (when (plist-get org-export-latex-options-plist :emphasize)
       (org-export-latex-fontify))
     (org-export-latex-special-chars
-     (plist-get org-latex-options-plist :sub-superscript))
+     (plist-get org-export-latex-options-plist :sub-superscript))
     (org-export-latex-keywords-maybe
      org-export-latex-remove-from-headlines)
     (org-export-latex-links)
     (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
 
-(defun org-export-latex-content (content)
-  "Convert CONTENT string to LaTeX."
-  (with-temp-buffer
-   (insert content)
-   (org-export-latex-quotation-marks)
-   (when (plist-get org-latex-options-plist :emphasize)
-     (org-export-latex-fontify))
-   (org-export-latex-special-chars
-    (plist-get org-latex-options-plist :sub-superscript))
-   (org-export-latex-links)
-   (org-export-latex-keywords
-    (plist-get org-latex-options-plist :timestamps))
-   (org-export-latex-lists)
-   (org-export-latex-tables
-    (plist-get org-latex-options-plist :tables))
-   (org-export-latex-fixed-width
-    (plist-get org-latex-options-plist :fixed-width))
-   ;; return string
-   (buffer-substring (point-min) (point-max))))
-
 (defun org-export-latex-quotation-marks ()
-  "Export question marks depending on language conventions.
-Local definition of the language overrides
-`org-export-latex-quotation-marks-convention' which overrides
-`org-export-default-language'."
-  (let* ((lang (plist-get org-latex-options-plist :language))
+  "Export question marks depending on language conventions."
+  (let* ((lang (plist-get org-export-latex-options-plist :language))
 	 (quote-rpl (if (equal lang "fr")
 			'(("\\(\\s-\\)\"" "«~")
 			  ("\\(\\S-\\)\"" "~»")
@@ -720,21 +789,6 @@
 		(org-if-unprotected
 		 (replace-match rpl t t))))) quote-rpl)))
 
-;; | chars/string in Org   | normal environment    | math environment      |
-;; |-----------------------+-----------------------+-----------------------|
-;; | & # % $               | \& \# \% \$           | \& \# \% \$           |
-;; | { } _ ^ \             | \{ \} \_ \^ \\        | {  }  _  ^ \          |
-;; |-----------------------+-----------------------+-----------------------|
-;; | a_b and a^b           | $a_b$ and $a^b$       | a_b and a^b           |
-;; | a_abc and a_{abc}     | $a_a$bc and $a_{abc}$ | a_abc and a_{abc}     |
-;; | \tau and \mu          | $\tau$ and $\mu$      | \tau and \mu          |
-;; |-----------------------+-----------------------+-----------------------|
-;; | \_ \^                 | \_  \^                | \_  \^                |
-;; | \(a=\mu\mbox{m}\)     | \(a=\mu\mbox{m}\)     | \(a=\mu\mbox{m}\)     |
-;; | \[\beta^2-a=0\]       | \[\beta^2-a=0\]       | \[\beta^2-a=0\]       |
-;; | $x=22\tau$            | $x=22\tau$            | $x=22\tau$            |
-;; | $$\alpha=\sqrt{a^3}$$ | $$\alpha=\sqrt{a^3}$$ | $$\alpha=\sqrt{a^3}$$ |
-
 (defun org-export-latex-special-chars (sub-superscript)
   "Export special characters to LaTeX.
 If SUB-SUPERSCRIPT is non-nil, convert \\ and ^.
@@ -744,7 +798,8 @@
 	  (goto-char (point-min))
 	  (while (re-search-forward c nil t)
 	    ;; Put the point where to check for org-protected
-	    (unless (get-text-property (match-beginning 2) 'org-protected)
+	    (unless (or (get-text-property (match-beginning 2) 'org-protected)
+			(org-at-table-p))
 	      (cond ((member (match-string 2) '("\\$" "$"))
 		     (if (equal (match-string 2) "\\$")
 			 (replace-match (concat (match-string 1) "$"
@@ -756,11 +811,15 @@
 			 (replace-match (match-string 2) t t)
 		       (replace-match (concat (match-string 1) "\\"
 					      (match-string 2)) t t)))
+		    ((equal (match-string 2) "...")
+		     (replace-match
+		      (concat (match-string 1)
+			      (org-export-latex-protect-string "\\ldots{}")) t t))
 		    ((equal (match-string 2) "~")
 		     (cond ((equal (match-string 1) "\\") nil)
 			   ((eq 'org-link (get-text-property 0 'face (match-string 2)))
 			    (replace-match (concat (match-string 1) "\\~") t t))
-			   (t (replace-match 
+			   (t (replace-match
 			       (org-export-latex-protect-string
 				(concat (match-string 1) "\\~{}")) t t))))
 		    ((member (match-string 2) '("{" "}"))
@@ -791,6 +850,7 @@
  	  "\\(.\\|^\\)\\({\\)"
 	  "\\(.\\|^\\)\\(}\\)"
 	  "\\(.\\|^\\)\\(~\\)"
+	  "\\(.\\|^\\)\\(\\.\\.\\.\\)"
 	  ;; (?\< . "\\textless{}")
 	  ;; (?\> . "\\textgreater{}")
 	  )))
@@ -812,7 +872,7 @@
 		    (cond ((eq 1 (length string-after))
 			   (concat string-before char string-after))
 			  ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
-			   (format "%s%s{%s}" string-before char 
+			   (format "%s%s{%s}" string-before char
 				   (match-string 1 string-after))))))
 	       ((and subsup
 		     (> (length string-after) 1)
@@ -842,7 +902,7 @@
 		  (string-match "^[ \t\n]" string-after)))
 	 ;; backslash might escape a character (like \#) or a user TeX
 	 ;; macro (like \setcounter)
-	 (org-export-latex-protect-string 
+	 (org-export-latex-protect-string
 	  (concat string-before "\\" string-after)))
 	((and (string-match "^[ \t\n]" string-after)
 	      (string-match "[ \t\n]\\'" string-before))
@@ -854,19 +914,18 @@
 
 (defun org-export-latex-keywords (timestamps)
   "Convert special keywords to LaTeX.
-Regexps are those from `org-latex-special-string-regexps'."
-  (let ((rg org-latex-special-string-regexps) r)
+Regexps are those from `org-export-latex-special-string-regexps'."
+  (let ((rg org-export-latex-special-string-regexps) r)
     (while (setq r (pop rg))
       (goto-char (point-min))
       (while (re-search-forward (eval r) nil t)
 	(if (not timestamps)
 	    (replace-match (format "\\\\texttt{%s}" (match-string 0)) t)
 	  (replace-match ""))))))
-  
+
 (defun org-export-latex-fixed-width (opt)
   "When OPT is non-nil convert fixed-width sections to LaTeX."
   (goto-char (point-min))
-  ;; FIXME the search shouldn't be performed on already converted text
   (while (re-search-forward "^[ \t]*:" nil t)
     (if opt
 	(progn (goto-char (match-beginning 0))
@@ -882,17 +941,351 @@
 				      (match-string 2)) t t)
 	       (forward-line))))))
 
+(defun org-export-latex-tables (insert)
+  "Convert tables to LaTeX and INSERT it."
+  (goto-char (point-min))
+  (while (re-search-forward "^\\([ \t]*\\)|" nil t)
+    ;; FIXME really need to save-excursion?
+    (save-excursion (org-table-align))
+    (let* ((beg (org-table-begin))
+	   (end (org-table-end))
+	   (raw-table (buffer-substring-no-properties beg end))
+	   fnum fields line lines olines gr colgropen line-fmt align)
+      (if org-export-latex-tables-verbatim
+	  (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
+			      "\\end{verbatim}\n")))
+	    (apply 'delete-region (list beg end))
+	    (insert tbl))
+	(progn
+	  (setq lines (split-string raw-table "\n" t))
+	  (apply 'delete-region (list beg end))
+ 	  (when org-export-table-remove-special-lines
+ 	    (setq lines (org-table-clean-before-export lines)))
+	  ;; make a formatting string to reflect aligment
+	  (setq olines lines)
+	  (while (and (not line-fmt) (setq line (pop olines)))
+	    (unless (string-match "^[ \t]*|-" line)
+	      (setq fields (org-split-string line "[ \t]*|[ \t]*"))
+	      (setq fnum (make-vector (length fields) 0))
+	      (setq line-fmt
+		    (mapconcat
+		     (lambda (x)
+		       (setq gr (pop org-table-colgroup-info))
+		       (format "%s%%s%s"
+			       (cond ((eq gr ':start)
+				      (prog1 (if colgropen "|" "")
+					(setq colgropen t)))
+				     ((eq gr ':startend)
+				      (prog1 (if colgropen "|" "|")
+					(setq colgropen nil)))
+				     (t ""))
+			       (if (memq gr '(:end :startend))
+				   (progn (setq colgropen nil) "|")
+				 "")))
+		     fnum ""))))
+	  ;; fix double || in line-fmt
+	  (setq line-fmt (replace-regexp-in-string "||" "|" line-fmt))
+	  ;; maybe remove the first and last "|"
+	  (when (and (not org-export-latex-tables-column-borders)
+		     (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
+	    (setq line-fmt (match-string 2 line-fmt)))
+	  ;; format alignment
+	  (setq align (apply 'format
+			     (cons line-fmt
+				   (mapcar (lambda (x) (if x "r" "l"))
+					   org-table-last-alignment))))
+	  ;; prepare the table to send to orgtbl-to-latex
+	  (setq lines
+		(mapcar
+		 (lambda(elem)
+		   (or (and (string-match "[ \t]*|-+" elem) 'hline)
+		       (split-string (org-trim elem) "|" t)))
+		 lines))
+    	  (when insert
+	    (insert (orgtbl-to-latex
+		     lines `(:tstart ,(concat "\\begin{tabular}{" align "}")))
+		    "\n\n")))))))
+
+(defun org-export-latex-fontify ()
+  "Convert fontification to LaTeX."
+  (goto-char (point-min))
+  (while (re-search-forward org-emph-re nil t)
+    ;; The match goes one char after the *string*
+    (let ((emph (assoc (match-string 3)
+		       org-export-latex-emphasis-alist))
+	  rpl)
+      (unless (get-text-property (1- (point)) 'org-protected)
+	(setq rpl (concat (match-string 1)
+			  (format (org-export-latex-protect-char-in-string
+				   '("\\" "{" "}") (cadr emph))
+				  (match-string 4))
+			  (match-string 5)))
+	(if (caddr emph)
+	    (setq rpl (org-export-latex-protect-string rpl)))
+	(replace-match rpl t t)))
+    (backward-char)))
+
+(defun org-export-latex-links ()
+  ;; Make sure to use the LaTeX hyperref and graphicx package
+  ;; or send some warnings.
+  "Convert links to LaTeX."
+  (goto-char (point-min))
+  (while (re-search-forward org-bracket-link-analytic-regexp nil t)
+    (org-if-unprotected
+     (goto-char (match-beginning 0))
+     (let* ((re-radio org-export-latex-all-targets-re)
+	    (remove (list (match-beginning 0) (match-end 0)))
+	    (type (match-string 2))
+	    (raw-path (match-string 3))
+	    (full-raw-path (concat (match-string 1) raw-path))
+	    (desc (match-string 5))
+	    imgp radiop
+	    ;; define the path of the link
+	    (path (cond
+		   ((member type '("http" "https" "ftp"))
+		    (concat type ":" raw-path))
+		   ((and re-radio (string-match re-radio raw-path))
+ 		    (setq radiop t))
+		   ((equal type "mailto")
+		    (concat type ":" raw-path))
+		   ((equal type "file")
+		    (if (and (or (org-file-image-p (expand-file-name raw-path))
+				 (string-match "\\.eps$" raw-path))
+			     (equal desc full-raw-path))
+			(setq imgp t)
+		      (progn (when (string-match "\\(.+\\)::.+" raw-path)
+			       (setq raw-path (match-string 1 raw-path)))
+			     (if (file-exists-p raw-path)
+				 (concat type "://" (expand-file-name raw-path))
+			       (concat type "://" (org-export-directory
+						   :LaTeX org-export-latex-options-plist)
+				       raw-path))))))))
+       ;; process with link inserting
+       (apply 'delete-region remove)
+       (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images))
+	      (insert (format "\\includegraphics[%s]{%s}"
+			      ;; image option should be set be a comment line
+			      org-export-latex-image-default-option
+			      (expand-file-name raw-path))))
+	     (radiop (insert (format "\\hyperref[%s]{%s}" raw-path desc)))
+	     (path (insert (format "\\href{%s}{%s}" path desc)))
+	     (t (insert "\\texttt{" desc "}")))))))
+
+(defvar org-latex-entities)   ; defined below
+
+(defun org-export-latex-cleaned-string ()
+  "Clean stuff in the LaTeX export."
+
+  ;; Preserve line breaks
+  (goto-char (point-min))
+  (while (re-search-forward "\\\\\\\\" nil t)
+    (add-text-properties (match-beginning 0) (match-end 0)
+			 '(org-protected t)))
+
+  ;; Convert LaTeX to \LaTeX{}
+  (goto-char (point-min))
+  (let ((case-fold-search nil) rpl)
+    (while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
+    (replace-match (org-export-latex-protect-string
+		    (concat (match-string 1) "\\LaTeX{}")) t t)))
+
+  ;; Convert horizontal rules
+  (goto-char (point-min))
+  (while (re-search-forward "^----+.$" nil t)
+    (replace-match (org-export-latex-protect-string "\\hrule") t t))
+
+  ;; Protect LaTeX commands like \commad[...]{...} or \command{...}
+  (goto-char (point-min))
+  (while (re-search-forward "\\\\[a-zA-Z]+\\(?:\\[.*\\]\\)?{.*}" nil t)
+    (add-text-properties (match-beginning 0) (match-end 0)
+			 '(org-protected t)))
+
+  ;; Protect LaTeX entities
+  (goto-char (point-min))
+  (while (re-search-forward (regexp-opt org-latex-entities) nil t)
+    (add-text-properties (match-beginning 0) (match-end 0)
+			 '(org-protected t)))
+
+  ;; Replace radio links
+  (goto-char (point-min))
+  (while (re-search-forward
+	  (concat "<<<?" org-export-latex-all-targets-re
+		  ">>>?\\((INVISIBLE)\\)?") nil t)
+    (replace-match
+     (org-export-latex-protect-string
+      (format "\\label{%s}%s"(match-string 1)
+	      (if (match-string 2) "" (match-string 1)))) t t))
+
+  ;; Delete @<...> constructs
+  (goto-char (point-min))
+  ;; Thanks to Daniel Clemente for this regexp
+  (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
+    (replace-match ""))
+
+  ;; When converting to LaTeX, replace footnotes
+  ;; FIXME: don't protect footnotes from conversion
+  (when (plist-get org-export-latex-options-plist :footnotes)
+    (goto-char (point-min))
+    (while (re-search-forward "\\[[0-9]+\\]" nil t)
+      (when (save-match-data
+	      (save-excursion (beginning-of-line)
+			      (looking-at "[^:|#]")))
+	(let ((foot-beg (match-beginning 0))
+	      (foot-end (match-end 0))
+	      (foot-prefix (match-string 0))
+	      footnote footnote-rpl)
+	  (save-excursion
+	    (when (search-forward foot-prefix nil t)
+	      (replace-match "")
+	      (let ((end (save-excursion
+			   (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
+			       (match-beginning 0) (point-max)))))
+		(setq footnote (concat (org-trim (buffer-substring (point) end)) 
+				       " ")) ; prevent last } being part of a link
+		(delete-region (point) end))
+	      (goto-char foot-beg)
+	    (delete-region foot-beg foot-end)
+	    (unless (null footnote)
+	      (setq footnote-rpl (format "\\footnote{%s}" footnote))
+	      (add-text-properties 0 10 '(org-protected t) footnote-rpl)
+	      (add-text-properties (1- (length footnote-rpl))
+				   (length footnote-rpl)
+				   '(org-protected t) footnote-rpl)
+	      (insert footnote-rpl)))))))
+
+    ;; Replace footnote section tag for LaTeX
+    (goto-char (point-min))
+    (while (re-search-forward
+	    (concat "^" footnote-section-tag-regexp) nil t)
+      (replace-match ""))))
+
+;;; List handling:
+
 (defun org-export-latex-lists ()
+  "Replace plain text lists in current buffer into LaTeX lists."
   "Convert lists to LaTeX."
   (goto-char (point-min))
   (while (re-search-forward org-export-latex-list-beginning-re nil t)
     (beginning-of-line)
-    (org-export-list-to-latex
-     (org-export-latex-parse-list t))))
+    (insert (org-list-to-latex (org-list-parse-list t)) "\n")))
+
+(defun org-list-parse-list (&optional delete)
+  "Parse the list at point.
+Return a list containing first level items as strings and
+sublevels as a list of strings."
+  (let ((start (org-list-item-begin))
+	(end (org-list-end))
+	output itemsep)
+    (while (re-search-forward org-export-latex-list-beginning-re end t)
+      (setq itemsep (if (save-match-data
+			  (string-match "^[0-9]" (match-string 2)))
+			"[0-9]+\\(?:\\.\\|)\\)" "[-+]"))
+      (let* ((indent1 (match-string 1))
+	     (nextitem (save-excursion
+			 (save-match-data
+			   (or (and (re-search-forward
+				     (concat "^" indent1 itemsep " *?") end t)
+				    (match-beginning 0)) end))))
+	     (item (buffer-substring
+		    (point)
+		    (or (and (re-search-forward
+			      org-export-latex-list-beginning-re end t)
+			     (goto-char (match-beginning 0)))
+			(goto-char end))))
+	     (nextindent (match-string 1))
+	     (item (org-trim item))
+	     (item (if (string-match "^\\[.+\\]" item)
+		       (replace-match "\\\\texttt{\\&}"
+				      t nil item) item)))
+	(push item output)
+	(when (> (length nextindent)
+		 (length indent1))
+	  (narrow-to-region (point) nextitem)
+	  (push (org-list-parse-list) output)
+	  (widen))))
+    (when delete (delete-region start end))
+    (setq output (nreverse output))
+    (push (if (string-match "^\\[0" itemsep)
+	      'ordered 'unordered) output)))
+
+(defun org-list-item-begin ()
+  "Find the beginning of the list item and return its position."
+  (save-excursion
+    (if (not (or (looking-at org-export-latex-list-beginning-re)
+		 (re-search-backward
+		  org-export-latex-list-beginning-re nil t)))
+	(progn (goto-char (point-min)) (point))
+      (match-beginning 0))))
+
+(defun org-list-end ()
+  "Find the end of the list and return its position."
+  (save-excursion
+    (catch 'exit
+      (while (or (looking-at org-export-latex-list-beginning-re)
+		 (looking-at "^[ \t]+\\|^$"))
+	(if (eq (point) (point-max))
+	    (throw 'exit (point-max)))
+	(forward-line 1))) (point)))
 
-(defun org-export-list-to-generic (list params)
-  "Convert a LIST parsed through `org-export-latex-parse-list' to other formats.
-  
+(defun org-list-insert-radio-list ()
+  "Insert a radio list template appropriate for this major mode."
+  (interactive)
+  (let* ((e (assq major-mode org-list-radio-list-templates))
+	 (txt (nth 1 e))
+	 name pos)
+    (unless e (error "No radio list setup defined for %s" major-mode))
+    (setq name (read-string "List name: "))
+    (while (string-match "%n" txt)
+      (setq txt (replace-match name t t txt)))
+    (or (bolp) (insert "\n"))
+    (setq pos (point))
+    (insert txt)
+    (goto-char pos)))
+
+(defun org-list-send-list (&optional maybe)
+  "Send a tranformed version of this list to the receiver position.
+With argument MAYBE, fail quietly if no transformation is defined for
+this list."
+  (interactive)
+  (catch 'exit
+    (unless (org-at-item-p) (error "Not at a list"))
+    (save-excursion
+      (goto-char (org-list-item-begin))
+      (beginning-of-line 0)
+      (unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
+	(if maybe
+	    (throw 'exit nil)
+	  (error "Don't know how to transform this list"))))
+    (let* ((name (match-string 1))
+	   beg
+	   (transform (intern (match-string 2)))
+	   (txt (buffer-substring-no-properties
+		 (org-list-item-begin)
+		 (org-list-end)))
+	   (list (org-list-parse-list)))
+      (unless (fboundp transform)
+	(error "No such transformation function %s" transform))
+      (setq txt (funcall transform list))
+      ;; Find the insertion place
+      (save-excursion
+	(goto-char (point-min))
+	(unless (re-search-forward
+		 (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t)
+	  (error "Don't know where to insert translated list"))
+	(goto-char (match-beginning 0))
+	(beginning-of-line 2)
+	(setq beg (point))
+	(unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
+	  (error "Cannot find end of insertion region"))
+	(beginning-of-line 1)
+	(delete-region beg (point))
+	(goto-char beg)
+	(insert txt "\n"))
+      (message "List converted and installed at receiver location"))))
+
+(defun org-list-to-generic (list params)
+  "Convert a LIST parsed through `org-list-parse-list' to other formats.
+
 Valid parameters are
 
 :ustart     String to start an unordered list
@@ -929,237 +1322,213 @@
 	(cond ((symbolp sublist) nil)
 	      ((stringp sublist)
 	       (setq rtn (concat rtn istart sublist iend isep)))
-	      (t 
+	      (t
 	       (setq rtn (concat rtn   ;; previous list
 				 lsep  ;; list separator
-				 (org-export-list-to-generic sublist p)
+				 (org-list-to-generic sublist p)
 				 lsep  ;; list separator
 				 )))))
       (format wrapper rtn))))
 
-(defun org-export-list-to-latex (list)
+(defun org-list-to-latex (list)
   "Convert LIST into a LaTeX list."
-  (insert 
-   (org-export-list-to-generic
-    list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
-	                :ustart "\\begin{itemize}" :uend "\\end{itemize}"
-                        :istart "\\item " :iend ""
-			:isep "\n" :lsep "\n"))
-   ;; Add a trailing \n after list conversion
-   "\n"))
+  (org-list-to-generic
+   list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
+                       :ustart "\\begin{itemize}" :uend "\\end{itemize}"
+                       :istart "\\item " :iend ""
+                       :isep "\n" :lsep "\n")))
 
-;; FIXME Use org-export-highlight-first-table-line ?
-(defun org-export-latex-tables (insert)
-  "Convert tables to LaTeX and INSERT it."
-  (goto-char (point-min))
-  (while (re-search-forward "^\\([ \t]*\\)|" nil t)
-    ;; FIXME really need to save-excursion?
-    (save-excursion (org-table-align))
-    (let* ((beg (org-table-begin))
-	   (end (org-table-end))
-	   (raw-table (buffer-substring-no-properties beg end))
-	   fnum fields line lines olines gr colgropen line-fmt align)
-      (if org-export-latex-tables-verbatim
-	  (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
-			      "\\end{verbatim}\n")))
-	    (apply 'delete-region (list beg end))
-	    (insert tbl))
-	(progn
-	  (setq lines (split-string raw-table "\n" t))
-	  (apply 'delete-region (list beg end))
- 	  (when org-export-table-remove-special-lines
- 	    (setq lines (org-table-clean-before-export lines)))
-	  ;; make a formatting string to reflect aligment
-	  (setq olines lines)
-	  (while (and (not line-fmt) (setq line (pop olines)))
-	    (unless (string-match "^[ \t]*|-" line)
-	      (setq fields (org-split-string line "[ \t]*|[ \t]*"))
-	      (setq fnum (make-vector (length fields) 0))
-	      (setq line-fmt 
-		    (mapconcat
-		     (lambda (x)
-		       (setq gr (pop org-table-colgroup-info))
-		       (format "%s%%s%s"
-			       (cond ((eq gr ':start)
-				      (prog1 (if colgropen "|" "")
-					(setq colgropen t)))
-				     ((eq gr ':startend)
-				      (prog1 (if colgropen "|" "|")
-					(setq colgropen nil)))
-				     (t ""))
-			       (if (memq gr '(:end :startend))
-				   (progn (setq colgropen nil) "|")
-				 "")))
-		     fnum ""))))
-	  ;; maybe remove the first and last "|"
-	  (when (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt)
-	    (setq line-fmt (match-string 2 line-fmt)))
-	  ;; format alignment
-	  (setq align (apply 'format 
-			     (cons line-fmt
-				   (mapcar (lambda (x) (if x "r" "l"))
-					   org-table-last-alignment))))
-	  ;; prepare the table to send to orgtbl-to-latex
-	  (setq lines
-		(mapcar
-		 (lambda(elem) 
-		   (or (and (string-match "[ \t]*|-+" elem) 'hline)
-		       (split-string (org-trim elem) "|" t)))
-		 lines))
-    	  (when insert
-	    (insert (orgtbl-to-latex
-		     lines `(:tstart ,(concat "\\begin{tabular}{" align "}")))
-		    "\n\n")))))))
+(defun org-list-to-html (list)
+  "Convert LIST into a HTML list."
+  (org-list-to-generic
+   list '(:splicep nil :ostart "<ol>" :oend "</ol>"
+                       :ustart "<ul>" :uend "</ul>"
+                       :istart "<li>" :iend "</li>"
+                       :isep "\n" :lsep "\n")))
 
-(defun org-export-latex-fontify ()
-  "Convert fontification to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward org-emph-re nil t)
-    ;; The match goes one char after the *string*
-    (let ((emph (assoc (match-string 3) 
-		       org-export-latex-emphasis-alist)) 
-	  rpl)
-      (unless (get-text-property (1- (point)) 'org-protected)
-	(setq rpl (concat (match-string 1)
-			  (format (org-export-latex-protect-char-in-string
-				   '("\\" "{" "}") (cadr emph))
-				  (match-string 4))
-			  (match-string 5)))
-	(if (caddr emph) 
-	    (setq rpl (org-export-latex-protect-string rpl)))
-	(replace-match rpl t t)))
-    (backward-char)))
+(defun org-list-to-texinfo (list)
+  "Convert LIST into a Texinfo list."
+  (org-list-to-generic
+   list '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
+                       :ustart "@enumerate" :uend "@end enumerate"
+                       :istart "@item\n" :iend ""
+                       :isep "\n" :lsep "\n")))
 
-(defun org-export-latex-links ()
-  ;; Make sure to use the LaTeX hyperref and graphicx package
-  ;; or send some warnings.
-  "Convert links to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward org-bracket-link-analytic-regexp nil t)
-    (org-if-unprotected
-     (goto-char (match-beginning 0))
-     (let* ((re-radio org-latex-all-targets-regexp)
-	    (remove (list (match-beginning 0) (match-end 0)))
-	    (type (match-string 2))
-	    (raw-path (match-string 3))
-	    (full-raw-path (concat (match-string 1) raw-path))
-	    (desc (match-string 5))
-	    imgp radiop
-	    ;; define the path of the link
-	    (path (cond
-		   ((member type '("http" "https" "ftp"))
-		    (concat type ":" raw-path))
-		   ((and re-radio (string-match re-radio raw-path))
- 		    (setq radiop t))
-		   ((equal type "mailto")
-		    (concat type ":" raw-path))
-		   ((equal type "file")
-		    (if (and (or (org-file-image-p (expand-file-name raw-path))
-				 (string-match "\\.eps$" raw-path))
-			     (equal desc full-raw-path))
-			(setq imgp t)
-		      (progn (when (string-match "\\(.+\\)::.+" raw-path)
-			       (setq raw-path (match-string 1 raw-path)))
-			     (if (file-exists-p raw-path)
-				 (concat type "://" (expand-file-name raw-path))
-			       (concat type "://" (org-export-directory
-						   :LaTeX org-latex-options-plist)
-				       raw-path))))))))
-       ;; process with link inserting
-       (apply 'delete-region remove)
-       (cond ((and imgp (plist-get org-latex-options-plist :inline-images))
-	      (insert (format "\\includegraphics[%s]{%s}"
-			      ;; image option should be set be a comment line
-			      org-export-latex-image-default-option
-			      (expand-file-name raw-path))))
-	     ;; FIXME: what about caption? image properties?
-	     (radiop (insert (format "\\hyperref[%s]{%s}" raw-path desc)))
-	     (path (insert (format "\\href{%s}{%s}" path desc)))
-	     (t (insert "\\texttt{" desc "}")))))))
-
-(defun org-export-latex-cleaned-string (&optional commentsp)
-  ;; FIXME remove commentsp call in org.el and here
-  "Clean stuff in the LaTeX export."
-
-  ;; Preserve line breaks
-  (goto-char (point-min))
-  (while (re-search-forward "\\\\\\\\" nil t)
-    (add-text-properties (match-beginning 0) (match-end 0)
-			 '(org-protected t)))
-
-  ;; Convert LaTeX to \LaTeX{}
-  (goto-char (point-min))
-  (let ((case-fold-search nil) rpl)
-    (while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
-    (replace-match (org-export-latex-protect-string 
-		    (concat (match-string 1) "\\LaTeX{}")) t t)))
-
-  ;; Convert horizontal rules
-  (goto-char (point-min))
-  (while (re-search-forward "^----+.$" nil t)
-    (replace-match (org-export-latex-protect-string "\\hrule") t t))
-
-  ;; Protect LaTeX \commands{...}
-  (goto-char (point-min))
-  (while (re-search-forward "\\\\[a-zA-Z]+\\(?:\\[.*\\]\\)?{.*}" nil t)
-    (add-text-properties (match-beginning 0) (match-end 0)
-			 '(org-protected t)))
-
-  ;; Replace radio links
-  (goto-char (point-min))
-  (while (re-search-forward
-	  (concat "<<<?" org-latex-all-targets-regexp 
-		  ">>>?\\((INVISIBLE)\\)?") nil t)
-    (replace-match
-     (org-export-latex-protect-string 
-      (format "\\label{%s}%s"(match-string 1)
-	      (if (match-string 2) "" (match-string 1)))) t t))
-
-  ;; Delete @<...> constructs
-  (goto-char (point-min))
-  ;; Thanks to Daniel Clemente for this regexp
-  (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
-    (replace-match ""))
-
-  ;; When converting to LaTeX, replace footnotes
-  ;; FIXME: don't protect footnotes from conversion
-  (when (plist-get org-latex-options-plist :footnotes)
-    (goto-char (point-min))
-    (while (re-search-forward "\\[[0-9]+\\]" nil t)
-      (when (save-match-data
-	      (save-excursion (beginning-of-line)
-			      (looking-at "[^:|#]")))
-	(let ((foot-beg (match-beginning 0))
-	      (foot-end (match-end 0))
-	      (foot-prefix (match-string 0))
-	      footnote footnote-rpl)
-	  (when (and (re-search-forward (regexp-quote foot-prefix) nil t))
-	    (replace-match "")
-	    (let ((end (save-excursion
-			 (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
-			     (match-beginning 0) (point-max)))))
-	      (setq footnote
-		    (concat 
-		     (org-trim (buffer-substring (point) end)) 
-		     ;; FIXME stupid workaround for cases where
-		     ;; `org-bracket-link-analytic-regexp' matches
-		     ;; }. as part of the link.
-		     " "))
-	      (delete-region (point) end)))
-	  (goto-char foot-beg)
-	  (delete-region foot-beg foot-end)
-	  (setq footnote-rpl (format "\\footnote{%s}" footnote))
-	  (add-text-properties 0 10 '(org-protected t) footnote-rpl)
-	  (add-text-properties (1- (length footnote-rpl))
-			       (length footnote-rpl)
-			       '(org-protected t) footnote-rpl)
-	  (insert footnote-rpl))))
-    
-    ;; Replace footnote section tag for LaTeX
-    (goto-char (point-min))
-    (while (re-search-forward 
-	    (concat "^" footnote-section-tag-regexp) nil t)
-      (replace-match ""))))
+(defconst org-latex-entities
+ '("\\!"
+   "\\'"
+   "\\+"
+   "\\,"
+   "\\-"
+   "\\:"
+   "\\;"
+   "\\<"
+   "\\="
+   "\\>"
+   "\\Huge"
+   "\\LARGE"
+   "\\Large"
+   "\\Styles"
+   "\\\\"
+   "\\`"
+   "\\addcontentsline"
+   "\\address"
+   "\\addtocontents"
+   "\\addtocounter"
+   "\\addtolength"
+   "\\addvspace"
+   "\\alph"
+   "\\appendix"
+   "\\arabic"
+   "\\author"
+   "\\begin{array}"
+   "\\begin{center}"
+   "\\begin{description}"
+   "\\begin{enumerate}"
+   "\\begin{eqnarray}"
+   "\\begin{equation}"
+   "\\begin{figure}"
+   "\\begin{flushleft}"
+   "\\begin{flushright}"
+   "\\begin{itemize}"
+   "\\begin{list}"
+   "\\begin{minipage}"
+   "\\begin{picture}"
+   "\\begin{quotation}"
+   "\\begin{quote}"
+   "\\begin{tabbing}"
+   "\\begin{table}"
+   "\\begin{tabular}"
+   "\\begin{thebibliography}"
+   "\\begin{theorem}"
+   "\\begin{titlepage}"
+   "\\begin{verbatim}"
+   "\\begin{verse}"
+   "\\bf"
+   "\\bf"
+   "\\bibitem"
+   "\\bigskip"
+   "\\cdots"
+   "\\centering"
+   "\\circle"
+   "\\cite"
+   "\\cleardoublepage"
+   "\\clearpage"
+   "\\cline"
+   "\\closing"
+   "\\dashbox"
+   "\\date"
+   "\\ddots"
+   "\\dotfill"
+   "\\em"
+   "\\fbox"
+   "\\flushbottom"
+   "\\fnsymbol"
+   "\\footnote"
+   "\\footnotemark"
+   "\\footnotesize"
+   "\\footnotetext"
+   "\\frac"
+   "\\frame"
+   "\\framebox"
+   "\\hfill"
+   "\\hline"
+   "\\hrulespace"
+   "\\hspace"
+   "\\huge"
+   "\\hyphenation"
+   "\\include"
+   "\\includeonly"
+   "\\indent"
+   "\\input"
+   "\\it"
+   "\\kill"
+   "\\label"
+   "\\large"
+   "\\ldots"
+   "\\line"
+   "\\linebreak"
+   "\\linethickness"
+   "\\listoffigures"
+   "\\listoftables"
+   "\\location"
+   "\\makebox"
+   "\\maketitle"
+   "\\mark"
+   "\\mbox"
+   "\\medskip"
+   "\\multicolumn"
+   "\\multiput"
+   "\\newcommand"
+   "\\newcounter"
+   "\\newenvironment"
+   "\\newfont"
+   "\\newlength"
+   "\\newline"
+   "\\newpage"
+   "\\newsavebox"
+   "\\newtheorem"
+   "\\nocite"
+   "\\nofiles"
+   "\\noindent"
+   "\\nolinebreak"
+   "\\nopagebreak"
+   "\\normalsize"
+   "\\onecolumn"
+   "\\opening"
+   "\\oval"
+   "\\overbrace"
+   "\\overline"
+   "\\pagebreak"
+   "\\pagenumbering"
+   "\\pageref"
+   "\\pagestyle"
+   "\\par"
+   "\\parbox"
+   "\\put"
+   "\\raggedbottom"
+   "\\raggedleft"
+   "\\raggedright"
+   "\\raisebox"
+   "\\ref"
+   "\\rm"
+   "\\roman"
+   "\\rule"
+   "\\savebox"
+   "\\sc"
+   "\\scriptsize"
+   "\\setcounter"
+   "\\setlength"
+   "\\settowidth"
+   "\\sf"
+   "\\shortstack"
+   "\\signature"
+   "\\sl"
+   "\\small"
+   "\\smallskip"
+   "\\sqrt"
+   "\\tableofcontents"
+   "\\telephone"
+   "\\thanks"
+   "\\thispagestyle"
+   "\\tiny"
+   "\\title"
+   "\\tt"
+   "\\twocolumn"
+   "\\typein"
+   "\\typeout"
+   "\\underbrace"
+   "\\underline"
+   "\\usebox"
+   "\\usecounter"
+   "\\value"
+   "\\vdots"
+   "\\vector"
+   "\\verb"
+   "\\vfill"
+   "\\vline"
+   "\\vspace")
+ "A list of LaTeX commands to be protected when performing conversion.")
 
 (provide 'org-export-latex)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/textmodes/org-mouse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -0,0 +1,1110 @@
+;;; org-mouse.el --- Better mouse support for org-mode
+
+;; Copyright (C) 2006, 2007, 2008 Free Software Foundation
+;;
+;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
+;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
+;; Version: 5.19
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Org-mouse provides mouse support for org-mode.
+;;
+;; http://orgmode.org
+;;
+;; Org-mouse implements the following features:
+;; * following links with the left mouse button (in Emacs 22)
+;; * subtree expansion/collapse (org-cycle) with the left mouse button
+;; * several context menus on the right mouse button:
+;;    + general text
+;;    + headlines
+;;    + timestamps
+;;    + priorities
+;;    + links
+;;    + tags
+;; * promoting/demoting/moving subtrees with mouse-3
+;;    + if the drag starts and ends in the same line then promote/demote
+;;    + otherwise move the subtree 
+;;
+;; Use
+;; ---
+;;
+;; To use this package, put the following line in your .emacs:
+;;
+;;    (require 'org-mouse)
+;;
+
+;; Fixme:
+;; + deal with folding / unfolding issues
+
+;; TODO (This list is only theoretical, if you'd like to have some
+;; feature implemented or a bug fix please send me an email, even if
+;; something similar appears in the list below.  This will help me get
+;; the priorities right.):
+;;
+;; + org-store-link, insert link
+;; + org tables
+;; + occur with the current word/tag (same menu item)
+;; + ctrl-c ctrl-c, for example, renumber the current list
+;; + internal links
+
+;; Please email the maintainer with new feature suggestions / bugs
+
+;; History:
+;;
+;; SInce version 5.10: Changes are listed in the general org-mode docs.
+;;
+;; Version 5.09
+;; + Version number synchronization with Org-mode.
+;;
+;; Version 0.25
+;; + made compatible with org-mode 4.70 (thanks to Carsten for the patch)
+;;
+;; Version 0.24
+;; + minor changes to the table menu
+;;
+;; Version 0.23
+;; + preliminary support for tables and calculation marks
+;; + context menu support for org-agenda-undo & org-sort-entries
+;;
+;; Version 0.22
+;; + handles undo support for the agenda buffer (requires org-mode >=4.58)
+;;
+;; Version 0.21
+;; + selected text activates its context menu
+;; + shift-middleclick or right-drag inserts the text from the clipboard in the form of a link
+;;
+;; Version 0.20
+;; + the new "TODO Status" submenu replaces the "Cycle TODO" menu item 
+;; + the TODO menu can now list occurrences of a specific TODO keyword
+;; + #+STARTUP line is now recognized
+;;
+;; Version 0.19
+;; + added support for dragging URLs to the org-buffer
+;;
+;; Version 0.18
+;; + added support for agenda blocks
+;;
+;; Version 0.17
+;; + toggle checkboxes with a single click
+;;
+;; Version 0.16
+;; + added support for checkboxes
+;;
+;; Version 0.15
+;; + org-mode now works with the Agenda buffer as well
+;;
+;; Version 0.14
+;; + added a menu option that converts plain list items to outline items
+;;
+;; Version 0.13 
+;; + "Insert Heading" now inserts a sibling heading if the point is
+;;   on "***" and a child heading otherwise
+;; 
+;; Version 0.12
+;; + compatible with Emacs 21
+;; + custom agenda commands added to the main menu
+;; + moving trees should now work between windows in the same frame
+;;
+;; Version 0.11
+;; + fixed org-mouse-at-link (thanks to Carsten)
+;; + removed [follow-link] bindings
+;;
+;; Version 0.10
+;; + added a menu option to remove highlights
+;; + compatible with org-mode 4.21 now
+;;
+;; Version 0.08: 
+;; + trees can be moved/promoted/demoted by dragging with the right
+;;   mouse button (mouse-3)
+;; + small changes in the above function
+;;
+;; Versions 0.01 -- 0.07: (I don't remember)
+
+(eval-when-compile (require 'cl))
+(require 'org)
+
+(defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
+  "Regular expression that matches a plain list.")
+(defvar org-mouse-direct t
+  "Internal variable indicating whether the current action is direct.
+
+If t, then the current action has been invoked directly through the buffer
+it is intended to operate on.  If nil, then the action has been invoked
+indirectly, for example, through the agenda buffer.")
+
+(defgroup org-mouse nil
+  "Mouse support for org-mode."
+  :tag "Org Mouse"
+  :group 'org)
+
+(defcustom org-mouse-punctuation ":"
+  "Punctuation used when inserting text by drag and drop."
+  :group 'org-mouse
+  :type 'string)
+
+
+(defun org-mouse-re-search-line (regexp)
+  "Search the current line for a given regular expression."
+  (beginning-of-line)
+  (re-search-forward regexp (point-at-eol) t))
+
+(defun org-mouse-end-headline ()
+  "Go to the end of current headline (ignoring tags)."
+  (interactive)
+  (end-of-line)
+  (skip-chars-backward "\t ")
+  (when (looking-back ":[A-Za-z]+:")
+    (skip-chars-backward ":A-Za-z")
+    (skip-chars-backward "\t ")))
+
+(defvar org-mouse-context-menu-function nil
+  "Function to create the context menu.
+The value of this variable is the function invoked by
+`org-mouse-context-menu' as the context menu.")
+(make-variable-buffer-local 'org-mouse-context-menu-function)
+
+(defun org-mouse-show-context-menu (event prefix)
+  "Invoke the context menu.
+
+If the value of `org-mouse-context-menu-function' is a function, then
+this function is called.  Otherwise, the current major mode menu is used."  
+  (interactive "@e \nP")
+  (if (and (= (event-click-count event) 1)
+	   (or (not mark-active) 
+	       (sit-for (/ double-click-time 1000.0))))
+      (progn
+ 	(select-window (posn-window (event-start event)))
+	(when (not (org-mouse-mark-active))
+	  (goto-char (posn-point (event-start event)))
+	  (when (not (eolp)) (save-excursion (run-hooks 'post-command-hook)))
+	  (let ((redisplay-dont-pause t))
+	    (sit-for 0)))
+	(if (functionp org-mouse-context-menu-function)
+	    (funcall org-mouse-context-menu-function event)
+	  (mouse-major-mode-menu event prefix)))
+    (setq this-command 'mouse-save-then-kill)
+    (mouse-save-then-kill event)))
+
+
+(defun org-mouse-line-position ()
+  "Returns `:beginning' or `:middle' or `:end', depending on the point position.
+
+If the point is at the end of the line, return `:end'.
+If the point is separated from the beginning of the line only by white
+space and *'s (`org-mouse-bolp'), return `:beginning'.  Otherwise,
+return `:middle'."
+  (cond
+   ((eolp) :end)
+   ((org-mouse-bolp) :beginning)
+   (t :middle)))
+
+(defun org-mouse-empty-line ()
+  "Return non-nil iff the line contains only white space."
+  (save-excursion (beginning-of-line) (looking-at "[ \t]*$")))
+
+(defun org-mouse-next-heading ()
+  "Go to the next heading.
+If there is none, ensure that the point is at the beginning of an empty line."
+  (unless (outline-next-heading)
+    (beginning-of-line)
+    (unless (org-mouse-empty-line)
+      (end-of-line)
+      (newline))))
+
+(defun org-mouse-insert-heading ()
+  "Insert a new heading, as `org-insert-heading'.
+
+If the point is at the :beginning (`org-mouse-line-position') of the line,
+insert the new heading before the current line.  Otherwise, insert it
+after the current heading."
+  (interactive)
+  (case (org-mouse-line-position)
+    (:beginning (beginning-of-line)
+	    (org-insert-heading))
+    (t (org-mouse-next-heading)
+       (org-insert-heading))))
+
+(defun org-mouse-timestamp-today (&optional shift units) 
+  "Change the timestamp into SHIFT UNITS in the future.  
+
+For the acceptable UNITS, see `org-timestamp-change'."
+  (interactive)
+  (flet ((org-read-date (&rest rest) (current-time)))
+     (org-time-stamp nil))
+  (when shift
+    (org-timestamp-change shift units)))
+
+(defun org-mouse-keyword-menu (keywords function &optional selected itemformat)
+  "A helper function.
+
+Returns a menu fragment consisting of KEYWORDS.  When a keyword
+is selected by the user, FUNCTION is called with the selected
+keyword as the only argument.
+
+If SELECTED is nil, then all items are normal menu items.  If
+SELECTED is a function, then each item is a checkbox, which is
+enabled for a given keyword iff (funcall SELECTED keyword) return
+non-nil.  If SELECTED is neither nil nor a function, then the
+items are radio buttons.  A radio button is enabled for the
+keyword `equal' to SELECTED. 
+
+ITEMFORMAT governs formatting of the elements of KEYWORDS.  If it
+is a function, it is invoked with the keyword as the only
+argument.  If it is a string, it is interpreted as the format
+string to (format ITEMFORMAT keyword).  If it is neither a string
+nor a function, elements of KEYWORDS are used directly. "
+  (mapcar 
+   `(lambda (keyword) 
+     (vector (cond
+	      ((functionp ,itemformat) (funcall ,itemformat keyword))
+	      ((stringp ,itemformat) (format ,itemformat keyword))
+	      (t keyword))
+	     (list 'funcall ,function keyword)
+	     :style (cond 
+		     ((null ,selected) t)
+		     ((functionp ,selected) 'toggle)
+		     (t 'radio))
+	     :selected (if (functionp ,selected) 
+			   (and (funcall ,selected keyword) t)
+			 (equal ,selected keyword))))
+    keywords))
+     
+(defun org-mouse-remove-match-and-spaces ()
+  "Remove the match, make just one space around the point."
+  (interactive)
+  (replace-match "")
+  (just-one-space))
+
+(defvar rest)
+(defun org-mouse-replace-match-and-surround (newtext &optional fixedcase 
+						     literal string subexp)
+  "The same as `replace-match', but surrounds the replacement with spaces."
+  (apply 'replace-match rest)
+  (save-excursion
+    (goto-char (match-beginning (or subexp 0))) 
+    (just-one-space)
+    (goto-char (match-end (or subexp 0))) 
+    (just-one-space)))
+  
+
+(defun org-mouse-keyword-replace-menu (keywords &optional group itemformat
+						nosurround)
+  "A helper function.
+
+Returns a menu fragment consisting of KEYWORDS.  When a keyword
+is selected, group GROUP of the current match is replaced by the
+keyword.  The method ensures that both ends of the replacement
+are separated from the rest of the text in the buffer by
+individual spaces (unless NOSURROND is non-nil).
+
+The final entry of the menu is always \"None\", which removes the
+match.
+
+ITEMFORMAT governs formatting of the elements of KEYWORDS.  If it
+is a function, it is invoked with the keyword as the only
+argument.  If it is a string, it is interpreted as the format
+string to (format ITEMFORMAT keyword).  If it is neither a string
+nor a function, elements of KEYWORDS are used directly. 
+"
+  (setq group (or group 0))
+  (let ((replace (org-mouse-match-closure 
+		  (if nosurround 'replace-match
+		    'org-mouse-replace-match-and-surround))))
+    (append
+     (org-mouse-keyword-menu 
+      keywords
+      `(lambda (keyword) (funcall ,replace keyword t t nil ,group))
+      (match-string group)
+      itemformat)
+     `(["None" org-mouse-remove-match-and-spaces 
+	:style radio
+	:selected ,(not (member (match-string group) keywords))]))))
+     
+(defun org-mouse-show-headlines ()
+  "Change the visibility of the current org buffer to only show headlines."
+  (interactive) 
+  (let ((this-command 'org-cycle) 
+	(last-command 'org-cycle)
+	(org-cycle-global-status nil))
+    (org-cycle '(4))
+    (org-cycle '(4))))
+
+(defun org-mouse-show-overview ()
+  "Change visibility of current org buffer to first-level headlines only."
+  (interactive) 
+  (let ((org-cycle-global-status nil))
+    (org-cycle '(4))))
+
+(defun org-mouse-set-priority (priority)
+  "Set the priority of the current headline to PRIORITY."
+  (flet ((read-char-exclusive () priority))
+    (org-priority)))
+
+(defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]"
+  "Regular expression matching the priority indicator.
+Differs from `org-priority-regexp' in that it doesn't contain the
+leading '.*?'.")
+
+(defun org-mouse-get-priority (&optional default)
+  "Return the priority of the current headline.
+DEFAULT is returned if no priority is given in the headline."
+  (save-excursion 
+    (if (org-mouse-re-search-line org-mouse-priority-regexp)
+	(match-string 1)
+      (when default (char-to-string org-default-priority)))))
+
+;; (defun org-mouse-at-link ()
+;;   (and (eq (get-text-property (point) 'face) 'org-link)
+;;        (save-excursion
+;;          (goto-char (previous-single-property-change (point) 'face))
+;;          (or (looking-at org-bracket-link-regexp)
+;;              (looking-at org-angle-link-re)
+;;              (looking-at org-plain-link-re)))))
+
+
+(defun org-mouse-delete-timestamp ()
+  "Deletes the current timestamp as well as the preceding keyword.
+SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
+  (when (or (org-at-date-range-p) (org-at-timestamp-p))
+    (replace-match "")			; delete the timestamp
+    (skip-chars-backward " :A-Z")
+    (when (looking-at " *[A-Z][A-Z]+:")
+      (replace-match ""))))
+
+(defun org-mouse-looking-at (regexp skipchars &optional movechars) 
+  (save-excursion
+    (let ((point (point)))
+      (if (looking-at regexp) t
+	(skip-chars-backward skipchars)
+	(forward-char (or movechars 0))
+	(when (looking-at regexp)
+	  (> (match-end 0) point))))))
+	      
+(defun org-mouse-priority-list ()
+   (loop for priority from ?A to org-lowest-priority 
+	 collect (char-to-string priority)))
+
+(defun org-mouse-tag-menu ()		;todo
+  (append
+   (let ((tags (org-split-string (org-get-tags) ":")))
+     (org-mouse-keyword-menu 
+      (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
+      `(lambda (tag) 
+	 (org-mouse-set-tags 
+	  (sort (if (member tag (quote ,tags)) 
+		    (delete tag (quote ,tags))
+		  (cons tag (quote ,tags)))
+		'string-lessp)))
+      `(lambda (tag) (member tag (quote ,tags)))
+      ))
+   '("--"
+     ["Align Tags Here" (org-set-tags nil t) t]
+     ["Align Tags in Buffer" (org-set-tags t t) t]
+     ["Set Tags ..." (org-set-tags) t])))
+   
+
+
+(defun org-mouse-set-tags (tags)
+  (save-excursion
+    ;; remove existing tags first
+    (beginning-of-line)
+    (when (org-mouse-re-search-line ":\\(\\([A-Za-z_]+:\\)+\\)")
+      (replace-match ""))
+
+    ;; set new tags if any
+    (when tags
+      (end-of-line)
+      (insert " :" (mapconcat 'identity tags ":") ":")
+      (org-set-tags nil t))))
+			  
+(defun org-mouse-insert-checkbox ()
+  (interactive)
+  (and (org-at-item-p)
+       (goto-char (match-end 0))
+       (unless (org-at-item-checkbox-p)
+	 (delete-horizontal-space)
+	 (insert " [ ] "))))
+
+(defun org-mouse-agenda-type (type)
+  (case type
+   ('tags "Tags: ")
+   ('todo "TODO: ")
+   ('tags-tree "Tags tree: ")
+   ('todo-tree "TODO tree: ")
+   ('occur-tree "Occur tree: ")
+   (t "Agenda command ???")))
+
+
+(defun org-mouse-list-options-menu (alloptions &optional function)
+  (let ((options (save-match-data 
+		   (split-string (match-string-no-properties 1)))))
+    (print options)
+    (loop for name in alloptions
+	  collect 
+	  (vector name 
+		  `(progn
+		     (replace-match 
+		      (mapconcat 'identity 
+				 (sort (if (member ',name ',options)
+					   (delete ',name ',options)
+					 (cons ',name ',options))
+				       'string-lessp)
+				 " ")
+		      nil nil nil 1)
+		     (when (functionp ',function) (funcall ',function)))
+		    :style 'toggle
+		    :selected (and (member name options) t)))))
+
+(defun org-mouse-clip-text (text maxlength)
+  (if (> (length text) maxlength)
+      (concat (substring text 0 (- maxlength 3)) "...")
+    text))
+
+(defun org-mouse-popup-global-menu ()
+  (popup-menu  
+   `("Main Menu"
+     ["Show Overview" org-mouse-show-overview t]
+     ["Show Headlines" org-mouse-show-headlines t]
+     ["Show All" show-all t]
+     ["Remove Highlights" org-remove-occur-highlights
+      :visible org-occur-highlights]
+     "--"
+     ["Check Deadlines" 
+      (if (functionp 'org-check-deadlines-and-todos)
+	  (org-check-deadlines-and-todos org-deadline-warning-days)
+	(org-check-deadlines org-deadline-warning-days)) t]
+     ["Check TODOs" org-show-todo-tree t]
+     ("Check Tags" 
+      ,@(org-mouse-keyword-menu 
+	 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
+	 '(lambda (tag) (org-tags-sparse-tree nil tag)))
+      "--"
+      ["Custom Tag ..." org-tags-sparse-tree t])
+     ["Check Phrase ..." org-occur]
+     "--"
+     ["Display Agenda" org-agenda-list t]
+     ["Display Timeline" org-timeline t]
+     ["Display TODO List" org-todo-list t]
+     ("Display Tags" 
+      ,@(org-mouse-keyword-menu 
+	 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
+	 '(lambda (tag) (org-tags-view nil tag)))
+      "--"
+      ["Custom Tag ..." org-tags-view t])
+     ["Display Calendar" org-goto-calendar t]
+     "--"
+     ,@(org-mouse-keyword-menu 
+	(mapcar 'car org-agenda-custom-commands)
+	'(lambda (key) 
+	   (eval `(flet ((read-char-exclusive () (string-to-char ,key))) 
+		      (org-agenda nil))))
+	nil 
+	'(lambda (key)
+	   (let ((entry (assoc key org-agenda-custom-commands)))
+	     (org-mouse-clip-text 
+	      (cond
+	       ((stringp (nth 1 entry)) (nth 1 entry))
+	       ((stringp (nth 2 entry)) 
+		(concat (org-mouse-agenda-type (nth 1 entry))
+			(nth 2 entry)))
+	       (t "Agenda Command '%s'"))
+	      30))))
+     "--"
+     ["Delete Blank Lines" delete-blank-lines 
+      :visible (org-mouse-empty-line)]
+     ["Insert Checkbox" org-mouse-insert-checkbox
+      :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
+     ["Insert Checkboxes" 
+      (org-mouse-for-each-item 'org-mouse-insert-checkbox)
+      :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
+     ["Plain List to Outline" org-mouse-transform-to-outline
+      :visible (org-at-item-p)])))
+
+			      
+(defun org-mouse-get-context (contextlist context)
+  (let ((contextdata (assq context contextlist)))
+    (when contextdata
+      (save-excursion 
+	(goto-char (second contextdata))
+	(re-search-forward ".*" (third contextdata))))))
+
+(defun org-mouse-for-each-item (function)
+  (save-excursion 
+    (ignore-errors 
+      (while t (org-previous-item)))
+    (ignore-errors 
+      (while t 
+	(funcall function)
+	(org-next-item)))))
+
+(defun org-mouse-bolp ()
+  "Returns true if there only spaces, tabs, and '*',  between the beginning of line and the point"
+  (save-excursion
+    (skip-chars-backward " \t*") (bolp)))
+  
+(defun org-mouse-insert-item (text)
+  (case (org-mouse-line-position)
+    (:beginning			; insert before 
+     (beginning-of-line) 
+     (looking-at "[ \t]*")
+     (open-line 1)
+     (indent-to (- (match-end 0) (match-beginning 0)))
+     (insert "+ "))
+	 
+    (:middle			; insert after
+     (end-of-line) 
+     (newline t) 
+     (indent-relative)
+     (insert "+ "))
+
+    (:end				; insert text here
+     (skip-chars-backward " \t") 
+     (kill-region (point) (point-at-eol))
+     (unless (looking-back org-mouse-punctuation) 
+       (insert (concat org-mouse-punctuation " ")))))
+    
+  (insert text)
+  (beginning-of-line))
+
+(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
+  (if (eq major-mode 'org-mode)
+      (org-mouse-insert-item text)
+    ad-do-it))
+
+(defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
+  (if (eq major-mode 'org-mode)
+      (org-mouse-insert-item uri)
+    ad-do-it))
+
+(defun org-mouse-match-closure (function)
+  (let ((match (match-data t)))
+    `(lambda (&rest rest) 
+      (save-match-data
+	(set-match-data ',match)
+	(apply ',function rest)))))
+
+(defun org-mouse-todo-keywords ()
+  (if (boundp 'org-todo-keywords-1) org-todo-keywords-1 org-todo-keywords))
+
+(defun org-mouse-match-todo-keyword ()
+  (save-excursion
+    (org-back-to-heading)
+    (if (looking-at outline-regexp) (goto-char (match-end 0)))
+    (or (looking-at (concat " +" org-todo-regexp " *"))
+	(looking-at " \\( *\\)"))))
+
+(defun org-mouse-yank-link (click)
+  (interactive "e")
+  ;; Give temporary modes such as isearch a chance to turn off.
+  (run-hooks 'mouse-leave-buffer-hook)
+  (mouse-set-point click)
+  (setq mouse-selection-click-count 0)
+  (delete-horizontal-space)
+  (insert-for-yank (concat " [[" (current-kill 0) "]] ")))
+
+(defun org-mouse-context-menu (&optional event)
+  (let ((stamp-prefixes (list org-deadline-string org-scheduled-string))
+	(contextlist (org-context)))
+    (flet ((get-context (context) (org-mouse-get-context contextlist context)))
+  (cond
+   ((org-mouse-mark-active)
+    (let ((region-string (buffer-substring (region-beginning) (region-end))))
+      (popup-menu
+       `(nil
+	 ["Sparse Tree" (org-occur ',region-string)]
+	 ["Find in Buffer" (occur ',region-string)]
+	 ["Grep in Current Dir" 
+	  (grep (format "grep -rnH -e '%s' *" ',region-string))]
+	 ["Grep in Parent Dir" 
+	  (grep (format "grep -rnH -e '%s' ../*" ',region-string))]
+	 "--"
+	 ["Convert to Link" 
+	  (progn (save-excursion (goto-char (region-beginning)) (insert "[["))
+		 (save-excursion (goto-char (region-end)) (insert "]]")))]
+	 ["Insert Link Here" (org-mouse-yank-link ',event)]))))
+
+   ((save-excursion (beginning-of-line) (looking-at "#\\+STARTUP: \\(.*\\)"))
+    (popup-menu 
+     `(nil 
+       ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
+				      'org-mode-restart))))
+   ((or (eolp) 
+	(and (looking-at "\\(  \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$")
+	     (looking-back "  \\|\t")))
+    (org-mouse-popup-global-menu))
+   ((get-context :checkbox)
+    (popup-menu 
+     '(nil 
+       ["Toggle" org-toggle-checkbox t]
+       ["Remove" org-mouse-remove-match-and-spaces t]
+       ""
+       ["All Clear" (org-mouse-for-each-item
+		     (lambda ()
+		       (when (save-excursion (org-at-item-checkbox-p))
+			 (replace-match "[ ]"))))]
+       ["All Set" (org-mouse-for-each-item
+		     (lambda ()
+		       (when (save-excursion (org-at-item-checkbox-p))
+			 (replace-match "[X]"))))]
+       ["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t]
+       ["All Remove" (org-mouse-for-each-item
+		     (lambda ()
+		       (when (save-excursion (org-at-item-checkbox-p))
+			 (org-mouse-remove-match-and-spaces))))]
+       )))
+   ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
+ 	 (member (match-string 0) (org-mouse-todo-keywords)))
+    (popup-menu 
+     `(nil
+       ,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords))
+       "--" 
+       ["Check TODOs" org-show-todo-tree t]
+       ["List all TODO keywords" org-todo-list t]
+       [,(format "List only %s" (match-string 0)) 
+	(org-todo-list (match-string 0)) t]
+       )))
+   ((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z")
+	 (member (match-string 0) stamp-prefixes))
+    (popup-menu 
+     `(nil 
+       ,@(org-mouse-keyword-replace-menu stamp-prefixes) 
+       "--"
+       ["Check Deadlines" org-check-deadlines t]
+       )))
+   ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority
+    (popup-menu `(nil ,@(org-mouse-keyword-replace-menu 
+			 (org-mouse-priority-list) 1 "Priority %s" t))))
+   ((get-context :link)
+    (popup-menu
+     '(nil
+       ["Open" org-open-at-point t]
+       ["Open in Emacs" (org-open-at-point t) t]
+       "--"
+       ["Copy link" (kill-new (match-string 0))]
+       ["Cut link" 
+	(progn 
+	  (kill-region (match-beginning 0) (match-end 0))
+	  (just-one-space))]
+       "--"
+       ["Grep for TODOs"
+	(grep (format "grep -nH -i 'todo\\|fixme' %s*" (match-string 2)))]
+;       ["Paste file link" ((insert "file:") (yank))]
+       )))
+   ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags
+    (popup-menu 
+     `(nil 
+       [,(format "Display '%s'" (match-string 1))
+	(org-tags-view nil ,(match-string 1))]
+       [,(format "Sparse Tree '%s'" (match-string 1))
+	(org-tags-sparse-tree nil ,(match-string 1))]
+       "--"
+       ,@(org-mouse-tag-menu))))
+   ((org-at-timestamp-p)
+    (popup-menu 
+     '(nil
+       ["Show Day" org-open-at-point t]
+       ["Change Timestamp" org-time-stamp t]
+       ["Delete Timestamp" (org-mouse-delete-timestamp) t]
+       ["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)]
+       "--"
+       ["Set for Today" org-mouse-timestamp-today]
+       ["Set for Tomorrow" (org-mouse-timestamp-today 1 'day)]
+       ["Set in 1 Week" (org-mouse-timestamp-today 7 'day)]
+       ["Set in 2 Weeks" (org-mouse-timestamp-today 14 'day)]
+       ["Set in a Month" (org-mouse-timestamp-today 1 'month)]
+       "--"
+       ["+ 1 Day" (org-timestamp-change 1 'day)]
+       ["+ 1 Week" (org-timestamp-change 7 'day)]
+       ["+ 1 Month" (org-timestamp-change 1 'month)]
+       "--"
+       ["- 1 Day" (org-timestamp-change -1 'day)]
+       ["- 1 Week" (org-timestamp-change -7 'day)]
+       ["- 1 Month" (org-timestamp-change -1 'month)])))
+   ((get-context :table-special)
+    (let ((mdata (match-data)))
+      (incf (car mdata) 2)
+      (store-match-data mdata))
+    (message "match: %S" (match-string 0))
+    (popup-menu `(nil ,@(org-mouse-keyword-replace-menu 
+			 '(" " "!" "^" "_" "$" "#" "*" "'") 0 
+			 (lambda (mark)
+			   (case (string-to-char mark)
+			     (?  "( ) Nothing Special")
+			     (?! "(!) Column Names")
+			     (?^ "(^) Field Names Above")
+			     (?_ "(^) Field Names Below")
+			     (?$ "($) Formula Parameters")
+			     (?# "(#) Recalculation: Auto")
+			     (?* "(*) Recalculation: Manual")
+			     (?' "(') Recalculation: None"))) t))))
+   ((assq :table contextlist)
+    (popup-menu
+     '(nil
+       ["Align Table" org-ctrl-c-ctrl-c]
+       ["Blank Field" org-table-blank-field]
+       ["Edit Field" org-table-edit-field]
+	"--"
+	("Column"
+	 ["Move Column Left" org-metaleft]
+	 ["Move Column Right" org-metaright]
+	 ["Delete Column" org-shiftmetaleft]
+	 ["Insert Column" org-shiftmetaright]
+	 "--"
+	 ["Enable Narrowing" (setq org-table-limit-column-width (not org-table-limit-column-width)) :selected org-table-limit-column-width :style toggle])
+	("Row"
+	 ["Move Row Up" org-metaup]
+	 ["Move Row Down" org-metadown]
+	 ["Delete Row" org-shiftmetaup]
+	 ["Insert Row" org-shiftmetadown]
+	 ["Sort lines in region" org-table-sort-lines (org-at-table-p)]
+	 "--"
+	 ["Insert Hline" org-table-insert-hline])
+	("Rectangle"
+	 ["Copy Rectangle" org-copy-special]
+	 ["Cut Rectangle" org-cut-special]
+	 ["Paste Rectangle" org-paste-special]
+	 ["Fill Rectangle" org-table-wrap-region])
+	"--"
+	["Set Column Formula" org-table-eval-formula]
+	["Set Field Formula" (org-table-eval-formula '(4))]
+	["Edit Formulas" org-table-edit-formulas]
+	"--"
+	["Recalculate Line" org-table-recalculate]
+	["Recalculate All" (org-table-recalculate '(4))]
+	["Iterate All" (org-table-recalculate '(16))]
+	"--"
+	["Toggle Recalculate Mark" org-table-rotate-recalc-marks]
+	["Sum Column/Rectangle" org-table-sum
+	 :active (or (org-at-table-p) (org-region-active-p))]
+	["Field Info" org-table-field-info]
+	["Debug Formulas"
+	 (setq org-table-formula-debug (not org-table-formula-debug))
+	 :style toggle :selected org-table-formula-debug]
+	)))
+   ((and (assq :headline contextlist) (not (eolp)))
+    (let ((priority (org-mouse-get-priority t)))
+      (popup-menu
+       `("Headline Menu"
+	 ("Tags and Priorities" 
+	  ,@(org-mouse-keyword-menu 
+	     (org-mouse-priority-list) 
+	     '(lambda (keyword) 
+		(org-mouse-set-priority (string-to-char keyword)))
+	     priority "Priority %s")
+	  "--"
+	  ,@(org-mouse-tag-menu))
+	 ("TODO Status"
+	  ,@(progn (org-mouse-match-todo-keyword)
+		   (org-mouse-keyword-replace-menu (org-mouse-todo-keywords)
+						   1)))
+	 ["Show Tags" 
+	  (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
+	  :visible (not org-mouse-direct)]
+	 ["Show Priority" 
+	  (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
+	  :visible (not org-mouse-direct)]
+	 ,@(if org-mouse-direct '("--") nil)
+	 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
+	 ["Set Deadline" 
+	  (progn (org-mouse-end-headline) (insert " ") (org-deadline)) 
+	  :active (not (save-excursion 
+			 (org-mouse-re-search-line org-deadline-regexp)))]
+	 ["Schedule Task" 
+	  (progn (org-mouse-end-headline) (insert " ") (org-schedule)) 
+	  :active (not (save-excursion 
+			 (org-mouse-re-search-line org-scheduled-regexp)))]
+	 ["Insert Timestamp" 
+	  (progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t]
+;	 ["Timestamp (inactive)" org-time-stamp-inactive t]
+	 "--"
+	 ["Archive Subtree" org-archive-subtree]
+	 ["Cut Subtree"  org-cut-special]
+	 ["Copy Subtree"  org-copy-special]
+	 ["Paste Subtree"  org-paste-special :visible org-mouse-direct]
+	 ("Sort Children" 
+	  ["Alphabetically" (org-sort-entries nil ?a)]
+	  ["Numerically" (org-sort-entries nil ?n)]
+	  ["By Time/Date" (org-sort-entries nil ?t)]
+	  "--"
+	  ["Reverse Alphabetically" (org-sort-entries nil ?A)]
+	  ["Reverse Numerically" (org-sort-entries nil ?N)]
+	  ["Reverse By Time/Date" (org-sort-entries nil ?T)])
+	 "--"
+	 ["Move Trees" org-mouse-move-tree :active nil]
+	 ))))
+   (t 
+    (org-mouse-popup-global-menu))))))
+
+;; (defun org-mouse-at-regexp (regexp)
+;;   (save-excursion
+;;     (let ((point (point))
+;; 	  (bol (progn (beginning-of-line) (point)))
+;; 	  (eol (progn (end-of-line) (point))))
+;;       (goto-char point)
+;;       (re-search-backward regexp bol 1)
+;;       (and (not (eolp))
+;; 	   (progn (forward-char)
+;; 		  (re-search-forward regexp eol t))
+;; 	   (<= (match-beginning 0) point)))))
+
+(defun org-mouse-mark-active ()
+  (and mark-active transient-mark-mode))
+
+(defun org-mouse-in-region-p (pos)
+  (and (org-mouse-mark-active) 
+       (>= pos (region-beginning)) 
+       (<  pos (region-end))))
+
+(defun org-mouse-down-mouse (event)
+  (interactive "e")
+  (setq this-command last-command)
+  (unless (and (= 1 (event-click-count event))
+	       (org-mouse-in-region-p (posn-point (event-start event))))
+    (mouse-drag-region event)))
+
+(add-hook 'org-mode-hook
+  '(lambda ()
+     (setq org-mouse-context-menu-function 'org-mouse-context-menu)
+
+;     (define-key org-mouse-map [follow-link] 'mouse-face)
+     (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil)
+     (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu)
+     (define-key org-mode-map [down-mouse-1] 'org-mouse-down-mouse)
+     (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree)
+     (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start)
+     (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link)
+     (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link)
+     (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
+     (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)
+
+     (font-lock-add-keywords nil 
+	`((,outline-regexp 
+	   0 `(face org-link mouse-face highlight keymap ,org-mouse-map)  
+	   'prepend)
+	  ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +" 
+	   (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend))
+	  ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)" 
+	   (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t)))
+ 	t)
+
+     (defadvice org-open-at-point (around org-mouse-open-at-point activate)
+       (let ((context (org-context)))
+	 (cond 
+	  ((assq :headline-stars context) (org-cycle))
+	  ((assq :checkbox context) (org-toggle-checkbox))
+	  ((assq :item-bullet context)
+	   (let ((org-cycle-include-plain-lists t)) (org-cycle)))
+	  (t ad-do-it))))))
+
+(defun org-mouse-move-tree-start (event)
+  (interactive "e")
+  (message "Same line: promote/demote, (***):move before, (text): make a child"))
+
+
+(defun org-mouse-make-marker (position)
+  (with-current-buffer (window-buffer (posn-window position))
+    (copy-marker (posn-point position))))
+
+(defun org-mouse-move-tree (event)
+  ;; todo: handle movements between different buffers
+  (interactive "e")
+  (save-excursion
+    (let* ((start (org-mouse-make-marker (event-start event)))
+	   (end (org-mouse-make-marker (event-end event)))
+	   (sbuf (marker-buffer start))
+	   (ebuf (marker-buffer end)))
+
+     (when (and sbuf ebuf)
+      (set-buffer sbuf)
+      (goto-char start)
+      (org-back-to-heading)
+      (if (and (eq sbuf ebuf)
+	       (equal 
+		(point)
+		(save-excursion (goto-char end) (org-back-to-heading) (point))))
+	;; if the same line then promote/demote
+	(if (>= end start) (org-demote-subtree) (org-promote-subtree))
+      ;; if different lines then move
+      (org-cut-subtree)
+      
+      (set-buffer ebuf)
+      (goto-char end)
+      (org-back-to-heading)
+      (when  (and (eq sbuf ebuf)
+		  (equal 
+		   (point)
+		   (save-excursion (goto-char start) 
+				   (org-back-to-heading) (point))))
+	(outline-end-of-subtree)
+	(end-of-line)
+	(if (eobp) (newline) (forward-char)))
+      
+      (when (looking-at outline-regexp)
+	(let ((level (- (match-end 0) (match-beginning 0))))
+	  (when (> end (match-end 0))
+	    (outline-end-of-subtree)
+	    (end-of-line)
+	    (if (eobp) (newline) (forward-char))
+	    (setq level (1+ level)))
+	  (org-paste-subtree level)
+	  (save-excursion
+	    (outline-end-of-subtree)
+	    (when (bolp) (delete-char -1))))))))))
+
+
+(defun org-mouse-transform-to-outline ()
+  (interactive)
+  (org-back-to-heading)
+  (let ((minlevel 1000)
+	(replace-text (concat (match-string 0) "* ")))
+    (beginning-of-line 2)
+    (save-excursion
+      (while (not (or (eobp) (looking-at outline-regexp)))
+	(when (looking-at org-mouse-plain-list-regexp)
+	  (setq minlevel (min minlevel (- (match-end 1) (match-beginning 1)))))
+	(forward-line)))
+    (while (not (or (eobp) (looking-at outline-regexp)))
+      (when (and (looking-at org-mouse-plain-list-regexp)
+		 (eq minlevel (- (match-end 1) (match-beginning 1))))
+	(replace-match replace-text))
+      (forward-line))))
+
+(defvar _cmd) ;dynamically scoped from `org-with-remote-undo'.
+
+(defun org-mouse-do-remotely (command)
+;  (org-agenda-check-no-diary)
+  (when (get-text-property (point) 'org-marker)
+    (let* ((anticol (- (point-at-eol) (point)))
+	   (marker (get-text-property (point) 'org-marker))
+	   (buffer (marker-buffer marker))
+	   (pos (marker-position marker))
+	   (hdmarker (get-text-property (point) 'org-hd-marker))
+	   (buffer-read-only nil)
+	   (newhead "--- removed ---")
+	   (org-mouse-direct nil)
+	   (org-mouse-main-buffer (current-buffer)))
+      (when (eq (with-current-buffer buffer major-mode) 'org-mode)
+	(let ((endmarker (save-excursion 
+			  (set-buffer buffer) 
+			  (outline-end-of-subtree) 
+			  (forward-char 1)
+			  (copy-marker (point)))))
+	  (org-with-remote-undo buffer
+	    (with-current-buffer buffer
+	      (widen)
+	      (goto-char pos)
+	      (org-show-hidden-entry)
+	      (save-excursion
+		(and (outline-next-heading)
+		     (org-flag-heading nil)))   ; show the next heading
+	      (org-back-to-heading)
+	      (setq marker (copy-marker (point)))
+	      (goto-char (max (point-at-bol) (- (point-at-eol) anticol)))
+	      (funcall command)
+	      (message "_cmd: %S" _cmd)
+	      (message "this-command: %S" this-command)
+	      (unless (eq (marker-position marker) (marker-position endmarker))
+		(setq newhead (org-get-heading))))
+	    
+	    (beginning-of-line 1)
+	    (save-excursion
+	      (org-agenda-change-all-lines newhead hdmarker 'fixface))))
+	t))))
+
+(defun org-mouse-agenda-context-menu (&optional event)
+  (or (org-mouse-do-remotely 'org-mouse-context-menu)
+      (popup-menu  
+       '("Agenda"
+	 ("Agenda Files")
+	 "--"
+	 ["Undo" (progn (message "last command: %S" last-command) (setq this-command 'org-agenda-undo) (org-agenda-undo))
+	  :visible (if (eq last-command 'org-agenda-undo) 
+		       org-agenda-pending-undo-list
+		     org-agenda-undo-list)]
+	 ["Rebuild Buffer" org-agenda-redo t]
+	 ["New Diary Entry" 
+	  org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline) t]
+	 "--"
+	 ["Goto Today" org-agenda-goto-today 
+	  (org-agenda-check-type nil 'agenda 'timeline) t]
+	 ["Display Calendar" org-agenda-goto-calendar 
+	  (org-agenda-check-type nil 'agenda 'timeline) t]
+	 ("Calendar Commands"
+	  ["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])
+	 "--"
+	 ["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 (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 (org-agenda-check-type nil 'agenda 'timeline)]
+	 ["Include Diary" org-agenda-toggle-diary
+	  :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 (org-agenda-check-type nil 'agenda)]
+	 ["Follow Mode" org-agenda-follow-mode
+	  :style toggle :selected org-agenda-follow-mode]
+	 "--"
+	 ["Quit" org-agenda-quit t]
+	 ["Exit and Release Buffers" org-agenda-exit t]
+	 ))))
+
+(defun org-mouse-get-gesture (event)
+  (let ((startxy (posn-x-y (event-start event)))
+	(endxy (posn-x-y (event-end event))))
+    (if (< (car startxy) (car endxy)) :right :left)))
+
+
+; (setq org-agenda-mode-hook nil)
+(add-hook 'org-agenda-mode-hook 
+   '(lambda ()
+     (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu)
+     (define-key org-agenda-keymap 
+       (if (featurep 'xemacs) [button3] [mouse-3]) 
+       'org-mouse-show-context-menu)
+     (define-key org-agenda-keymap [down-mouse-3] 'org-mouse-move-tree-start)
+     (define-key org-agenda-keymap [C-mouse-4] 'org-agenda-earlier)
+     (define-key org-agenda-keymap [C-mouse-5] 'org-agenda-later)
+     (define-key org-agenda-keymap [drag-mouse-3]
+       '(lambda (event) (interactive "e")
+	  (case (org-mouse-get-gesture event)
+	    (:left (org-agenda-earlier 1))
+	    (:right (org-agenda-later 1)))))))
+
+(provide 'org-mouse)
+
+;; arch-tag: ff1ae557-3529-41a3-95c6-baaebdcc280f
--- a/lisp/textmodes/org-publish.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/org-publish.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,28 +1,28 @@
 ;;; org-publish.el --- publish related org-mode files as a website
 
-;; Copyright (C) 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008  Free Software Foundation, Inc.
 
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Keywords: hypermedia, outlines
-;; Version: 1.80a
+;; Version: 1.80b
 
-;; This file is free software; you can redistribute it and/or modify
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ;; Boston, MA 02110-1301, USA.
 
-;; This file is part of GNU Emacs.
-
 ;;; Commentary:
 
 ;; Requires at least version 4.27 of org.el
@@ -572,11 +572,10 @@
 With prefix argument, force publishing all files in project."
   (interactive "P")
   (save-window-excursion
-    (let* ((project-name (org-publish-get-project-from-filename (buffer-file-name)))
-	   (org-publish-use-timestamps-flag (if force nil t)))
+    (let* ((project-name (org-publish-get-project-from-filename (buffer-file-name))))
       (if (not project-name)
 	  (error "File %s is not part of any known project." (buffer-file-name)))
-      (org-publish project-name))))
+      (org-publish project-name (if force nil t)))))
 
 
 ;;;###autoload
--- a/lisp/textmodes/org.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/org.el	Wed Jan 30 07:57:28 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 5.13i
+;; Version: 5.19a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -77,13 +77,14 @@
 (require 'outline) (require 'noutline)
 ;; Other stuff we need.
 (require 'time-date)
+(unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
 (require 'easymenu)
 
 ;;;; Customization variables
 
 ;;; Version
 
-(defconst org-version "5.13i"
+(defconst org-version "5.19a"
   "The version number of the file org.el.")
 (defun org-version ()
   (interactive)
@@ -97,8 +98,12 @@
     (get-text-property 0 'test (format "%s" x)))
   "Does format transport text properties?")
 
+(defmacro org-bound-and-true-p (var)
+  "Return the value of symbol VAR if it is bound, else nil."
+  `(and (boundp (quote ,var)) ,var))
+
 (defmacro org-unmodified (&rest body)
-  "Execute body without changing buffer-modified-p."
+  "Execute body without changing `buffer-modified-p'."
   `(set-buffer-modified-p
     (prog1 (buffer-modified-p) ,@body)))
 
@@ -251,7 +256,7 @@
   "Define a key, possibly translated, as returned by `org-key'."
   (define-key keymap (org-key key) def))
 
-(defcustom org-ellipsis 'org-ellipsis
+(defcustom org-ellipsis nil
   "The ellipsis to use in the Org-mode outline.
 When nil, just use the standard three dots.  When a string, use that instead,
 When a face, use the standart 3 dots, but with the specified face.
@@ -332,6 +337,25 @@
   :tag "Org Reveal Location"
   :group 'org-structure)
 
+(defconst org-context-choice
+  '(choice
+    (const :tag "Always" t)
+    (const :tag "Never" nil)
+    (repeat :greedy t :tag "Individual contexts"
+	    (cons
+	     (choice :tag "Context"
+		     (const agenda)
+		     (const org-goto)
+		     (const occur-tree)
+		     (const tags-tree)
+		     (const link-search)
+		     (const mark-goto)
+		     (const bookmark-jump)
+		     (const isearch)
+		     (const default))
+	     (boolean))))
+  "Contexts for the reveal options.")
+
 (defcustom org-show-hierarchy-above '((default . t))
   "Non-nil means, show full hierarchy when revealing a location.
 Org-mode often shows locations in an org-mode file which might have
@@ -350,22 +374,7 @@
   isearch        when exiting from an incremental search
   default        default for all contexts not set explicitly"
   :group 'org-reveal-location
-  :type '(choice
-	  (const :tag "Always" t)
-	  (const :tag "Never" nil)
-	  (repeat :greedy t :tag "Individual contexts"
-		  (cons
-		   (choice :tag "Context"
-		    (const agenda)
-		    (const org-goto)
-		    (const occur-tree)
-		    (const tags-tree)
-		    (const link-search)
-		    (const mark-goto)
-		    (const bookmark-jump)
-		    (const isearch)
-		    (const default))
-		   (boolean)))))
+  :type org-context-choice)
 
 (defcustom org-show-following-heading '((default . nil))
   "Non-nil means, show following heading when revealing a location.
@@ -378,22 +387,7 @@
 Instead of t, this can also be an alist specifying this option for different
 contexts.  See `org-show-hierarchy-above' for valid contexts."
   :group 'org-reveal-location
-  :type '(choice
-	  (const :tag "Always" t)
-	  (const :tag "Never" nil)
-	  (repeat :greedy t :tag "Individual contexts"
-		  (cons
-		   (choice :tag "Context"
-		    (const agenda)
-		    (const org-goto)
-		    (const occur-tree)
-		    (const tags-tree)
-		    (const link-search)
-		    (const mark-goto)
-		    (const bookmark-jump)
-		    (const isearch)
-		    (const default))
-		   (boolean)))))
+  :type org-context-choice)
 
 (defcustom org-show-siblings '((default . nil) (isearch t))
   "Non-nil means, show all sibling heading when revealing a location.
@@ -409,22 +403,19 @@
 Instead of t, this can also be an alist specifying this option for different
 contexts.  See `org-show-hierarchy-above' for valid contexts."
   :group 'org-reveal-location
-  :type '(choice
-	  (const :tag "Always" t)
-	  (const :tag "Never" nil)
-	  (repeat :greedy t :tag "Individual contexts"
-		  (cons
-		   (choice :tag "Context"
-		    (const agenda)
-		    (const org-goto)
-		    (const occur-tree)
-		    (const tags-tree)
-		    (const link-search)
-		    (const mark-goto)
-		    (const bookmark-jump)
-		    (const isearch)
-		    (const default))
-		   (boolean)))))
+  :type org-context-choice)
+
+(defcustom org-show-entry-below '((default . nil))
+  "Non-nil means, show the entry below a headline when revealing a location.
+Org-mode often shows locations in an org-mode file which might have
+been invisible before.  When this is set, the text below the headline that is
+exposed is also shown.
+
+By default this is off for all contexts.
+Instead of t, this can also be an alist specifying this option for different
+contexts.  See `org-show-hierarchy-above' for valid contexts."
+  :group 'org-reveal-location
+  :type org-context-choice)
 
 (defgroup org-cycle nil
   "Options concerning visibility cycling in Org-mode."
@@ -463,7 +454,7 @@
   "Where should `org-cycle' emulate TAB.
 nil         Never
 white       Only in completely white lines
-whitestart  Only at the beginning of lines, before the first non-white char.
+whitestart  Only at the beginning of lines, before the first non-white char
 t           Everywhere except in headlines
 exc-hl-bol  Everywhere except at the start of a headline
 If TAB is used in a place where it does not emulate TAB, the current subtree
@@ -568,7 +559,7 @@
 (defcustom org-insert-heading-hook nil
   "Hook being run after inserting a new heading."
   :group 'org-edit-structure
-  :type 'boolean)
+  :type 'hook)
 
 (defcustom org-enable-fixed-width-editor t
   "Non-nil means, lines starting with \":\" are treated as fixed-width.
@@ -658,7 +649,9 @@
 (defcustom org-archive-tag "ARCHIVE"
   "The tag that marks a subtree as archived.
 An archived subtree does not open during visibility cycling, and does
-not contribute to the agenda listings."
+not contribute to the agenda listings.
+After changing this, font-lock must be restarted in the relevant buffers to
+get the proper fontification."
   :group 'org-archive
   :group 'org-keywords
   :type 'string)
@@ -767,6 +760,17 @@
 	  (const :tag "Inherited tags" itags)
 	  (const :tag "Local tags" ltags)))
 
+(defgroup org-imenu-and-speedbar nil
+  "Options concerning imenu and speedbar in Org-mode."
+  :tag "Org Imenu and Speedbar"
+  :group 'org-structure)
+
+(defcustom org-imenu-depth 2
+  "The maximum level for Imenu access to Org-mode headlines.
+This also applied for speedbar access."
+  :group 'org-imenu-and-speedbar
+  :type 'number)
+
 (defgroup org-table nil
   "Options concerning tables in Org-mode."
   :tag "Org Table"
@@ -892,7 +896,7 @@
   :type 'number)
 
 (defgroup org-table-editing nil
-  "Bahavior of tables during editing in Org-mode."
+  "Behavior of tables during editing in Org-mode."
   :tag "Org Table Editing"
   :group 'org-table)
 
@@ -1031,15 +1035,18 @@
      [[linkkey:tag][description]]
 
 If REPLACE is a string, the tag will simply be appended to create the link.
-If the string contains \"%s\", the tag will be inserted there.  REPLACE may
-also be a function that will be called with the tag as the only argument to
-create the link.  See the manual for examples."
+If the string contains \"%s\", the tag will be inserted there.
+
+REPLACE may also be a function that will be called with the tag as the
+only argument to create the link, which should be returned as a string.
+
+See the manual for examples."
   :group 'org-link
   :type 'alist)
 
 (defcustom org-descriptive-links t
   "Non-nil means, hide link part and only show description of bracket links.
-Bracket links are like [[link][descritpion]]. This variable sets the initial
+Bracket links are like [[link][descritpion]].  This variable sets the initial
 state in new org-mode buffers.  The setting can then be toggled on a
 per-buffer basis from the Org->Hyperlinks menu."
   :group 'org-link
@@ -1049,10 +1056,10 @@
   "How the path name in file links should be stored.
 Valid values are:
 
-relative  relative to the current directory, i.e. the directory of the file
+relative  Relative to the current directory, i.e. the directory of the file
           into which the link is being inserted.
-absolute  absolute path, if possible with ~ for home directory.
-noabbrev  absolute path, no abbreviation of home directory.
+absolute  Absolute path, if possible with ~ for home directory.
+noabbrev  Absolute path, no abbreviation of home directory.
 adaptive  Use relative path for files in the current directory and sub-
           directories of it.  For other files, use an absolute path."
   :group 'org-link
@@ -1404,6 +1411,14 @@
   :group 'org-remember
   :type 'boolean)
 
+(defcustom org-remember-use-refile-when-interactive t
+  "Non-nil means, use refile to file a remember note.
+This is only used when the interactive mode for selecting a filing
+location is used (see the variable `org-remember-store-without-prompt').
+When nil, the `org-goto' interface is used."
+  :group 'org-remember
+  :type 'boolean)
+
 (defcustom org-remember-default-headline ""
   "The headline that should be the default location in the notes file.
 When filing remember notes, the cursor will start at that position.
@@ -1416,9 +1431,9 @@
   "Templates for the creation of remember buffers.
 When nil, just let remember make the buffer.
 When not nil, this is a list of 5-element lists.  In each entry, the first
-element is a the name of the template, It should be a single short word.
+element is the name of the template, which should be a single short word.
 The second element is a character, a unique key to select this template.
-The third element is the template.  The forth element is optional and can
+The third element is the template.  The fourth element is optional and can
 specify a destination file for remember items created with this template.
 The default file is given by `org-default-notes-file'.  An optional fifth
 element can specify the headline in that file that should be offered
@@ -1429,7 +1444,9 @@
 a first line starting with a star, to act as the org-mode headline.
 Furthermore, the following %-escapes will be replaced with content:
 
-  %^{prompt}  prompt the user for a string and replace this sequence with it.
+  %^{prompt}  Prompt the user for a string and replace this sequence with it.
+              A default value and a completion table ca be specified like this:
+              %^{prompt|default|completion2|completion3|...}
   %t          time stamp, date only
   %T          time stamp with date and time
   %u, %U      like the above, but inactive time stamps
@@ -1440,6 +1457,13 @@
   %i          initial content, the region when remember is called with C-u.
               If %i is indented, the entire inserted text will be indented
               as well.
+  %c          content of the clipboard, or current kill ring head
+  %^g         prompt for tags, with completion on tags in target file
+  %^G         prompt for tags, with completion all tags in all agenda files
+  %:keyword   specific information for certain link types, see below
+  %[pathname] insert the contents of the file given by `pathname'
+  %(sexp)     evaluate elisp `(sexp)' and replace with the result
+  %!          Store this note immediately after filling the template
 
   %?          After completing the template, position cursor here.
 
@@ -1483,7 +1507,9 @@
 
 (defcustom org-reverse-note-order nil
   "Non-nil means, store new notes at the beginning of a file or entry.
-When nil, new notes will be filed to the end of a file or entry."
+When nil, new notes will be filed to the end of a file or entry.
+This can also be a list with cons cells of regular expressions that
+are matched against file names, and values."
   :group 'org-remember
   :type '(choice
 	  (const :tag "Reverse always" t)
@@ -1491,6 +1517,51 @@
 	  (repeat :tag "By file name regexp"
 		  (cons regexp boolean))))
 
+(defcustom org-refile-targets nil
+  "Targets for refiling entries with \\[org-refile].
+This is list of cons cells.  Each cell contains:
+- a specification of the files to be considered, either a list of files,
+  or a symbol whose function or value fields will be used to retrieve
+  a file name or a list of file names.  Nil means, refile to a different
+  heading in the current buffer.
+- A specification of how to find candidate refile targets.  This may be
+  any of
+  - a cons cell (:tag . \"TAG\") to identify refile targets by a tag.
+    This tag has to be present in all target headlines, inheritance will
+    not be considered.
+  - a cons cell (:todo . \"KEYWORD\") to identify refile targets by
+    todo keyword.
+  - a cons cell (:regexp . \"REGEXP\") with a regular expression matching
+    headlines that are refiling targets.
+  - a cons cell (:level . N).  Any headline of level N is considered a target.
+  - a cons cell (:maxlevel . N). Any headline with level <= N is a target."
+;; FIXME: what if there are a var and func with same name???
+  :group 'org-remember
+  :type '(repeat
+	  (cons
+	   (choice :value org-agenda-files
+		   (const :tag "All agenda files" org-agenda-files)
+		   (const :tag "Current buffer" nil)
+		   (function) (variable) (file))
+	   (choice :tag "Identify target headline by"
+	    (cons :tag "Specific tag" (const :tag) (string))
+	    (cons :tag "TODO keyword" (const :todo) (string))
+	    (cons :tag "Regular expression" (const :regexp) (regexp))
+	    (cons :tag "Level number" (const :level) (integer))
+	    (cons :tag "Max Level number" (const :maxlevel) (integer))))))
+
+(defcustom org-refile-use-outline-path nil
+  "Non-nil means, provide refile targets as paths.
+So a level 3 headline will be available as level1/level2/level3.
+When the value is `file', also include the file name (without directory)
+into the path.  When `full-file-path', include the full file path."
+  :group 'org-remember
+  :type '(choice
+	  (const :tag "Not" nil)
+	  (const :tag "Yes" t)
+	  (const :tag "Start with file name" file)
+	  (const :tag "Start with full file path" full-file-path)))
+
 (defgroup org-todo nil
   "Options concerning TODO items in Org-mode."
   :tag "Org TODO"
@@ -1712,6 +1783,15 @@
   :group 'org-progress
   :type 'boolean)
 
+(defcustom org-clock-in-switch-to-state nil
+  "Set task to a special todo state while clocking it.
+The value should be the state to which the entry should be switched."
+  :group 'org-progress
+  :group 'org-todo
+  :type '(choice
+	  (const :tag "Don't force a state" nil)
+	  (string :tag "State")))
+
 (defgroup org-priorities nil
   "Priorities in Org-mode."
   :tag "Org Priorities"
@@ -1795,13 +1875,52 @@
 	(concat "[" (substring f 1 -1) "]")
       f)))
 
-(defcustom org-popup-calendar-for-date-prompt t
+(defcustom org-read-date-prefer-future t
+  "Non-nil means, assume future for incomplete date input from user.
+This affects the following situations:
+1. The user gives a day, but no month.
+   For example, if today is the 15th, and you enter \"3\", Org-mode will
+   read this as the third of *next* month.  However, if you enter \"17\",
+   it will be considered as *this* month.
+2. The user gives a month but not a year.
+   For example, if it is april and you enter \"feb 2\", this will be read
+   as feb 2, *next* year.  \"May 5\", however, will be this year.
+
+When this option is nil, the current month and year will always be used
+as defaults."
+  :group 'org-time
+  :type 'boolean)
+
+(defcustom org-read-date-display-live t
+  "Non-nil means, display current interpretation of date prompt live.
+This display will be in an overlay, in the minibuffer."
+  :group 'org-time
+  :type 'boolean)
+
+(defcustom org-read-date-popup-calendar t
   "Non-nil means, pop up a calendar when prompting for a date.
 In the calendar, the date can be selected with mouse-1.  However, the
 minibuffer will also be active, and you can simply enter the date as well.
 When nil, only the minibuffer will be available."
   :group 'org-time
   :type 'boolean)
+(if (fboundp 'defvaralias)
+    (defvaralias 'org-popup-calendar-for-date-prompt
+      'org-read-date-popup-calendar))
+
+(defcustom org-extend-today-until 0
+  "The hour when your day really ends.
+This has influence for the following applications:
+- When switching the agenda to \"today\".  It it is still earlier than
+  the time given here, the day recognized as TODAY is actually yesterday.
+- When a date is read from the user and it is still before the time given
+  here, the current date and time will be assumed to be yesterday, 23:59.
+
+FIXME:
+IMPORTANT:  This is still a very experimental feature, it may disappear
+again or it may be extended to mean more things."
+  :group 'org-time
+  :type 'number)
 
 (defcustom org-edit-timestamp-down-means-later nil
   "Non-nil means, S-down will increase the time in a time stamp.
@@ -1816,6 +1935,13 @@
   :group 'org-time
   :type 'boolean)
 
+(defcustom org-clock-heading-function nil
+  "When non-nil, should be a function to create `org-clock-heading'.
+This is the string shown in the mode line when a clock is running.
+The function is called with point at the beginning of the headline."
+  :group 'org-time ; FIXME: Should we have a separate group????
+  :type 'function)
+
 (defgroup org-tags nil
   "Options concerning tags in Org-mode."
   :tag "Org Tags"
@@ -1929,16 +2055,23 @@
 
 (defcustom org-use-property-inheritance nil
   "Non-nil means, properties apply also for sublevels.
-This can cause significant overhead when doing a search, so this is turned
-off by default.
+This setting is only relevant during property searches, not when querying
+an entry with `org-entry-get'.  To retrieve a property with inheritance,
+you need to call `org-entry-get' with the inheritance flag.
+Turning this on can cause significant overhead when doing a search, so
+this is turned off by default.
 When nil, only the properties directly given in the current entry count.
+The value may also be a list of properties that shouldhave inheritance.
 
 However, note that some special properties use inheritance under special
 circumstances (not in searches).  Examples are CATEGORY, ARCHIVE, COLUMNS,
 and the properties ending in \"_ALL\" when they are used as descriptor
 for valid values of a property."
   :group 'org-properties
-  :type 'boolean)
+  :type '(choice
+	  (const :tag "Not" nil)
+	  (const :tag "Always" nil)
+	  (repeat :tag "Specific properties" (string :tag "Property"))))
 
 (defcustom org-columns-default-format "%25ITEM %TODO %3PRIORITY %TAGS"
   "The default column format, if no other format has been defined.
@@ -1998,7 +2131,7 @@
 	  (repeat :tag "List of files and directories" file)
 	  (file :tag "Store list in a file\n" :value "~/.agenda_files")))
 
-(defcustom org-agenda-file-regexp "\\.org\\'"
+(defcustom org-agenda-file-regexp "\\`[^.].*\\.org\\'"
   "Regular expression to match files for `org-agenda-files'.
 If any element in the list in that variable contains a directory instead
 of a normal file, all files in that directory that are matched by this
@@ -2318,6 +2451,11 @@
   :group 'org-agenda-skip
   :type 'boolean)
 
+(defcustom org-agenda-skip-timestamp-if-done nil
+  "Non-nil means don't select item by timestamp or -range if it is DONE."
+  :group 'org-agenda-skip
+  :type 'boolean)
+
 (defcustom org-timeline-show-empty-dates 3
   "Non-nil means, `org-timeline' also shows dates without an entry.
 When nil, only the days which actually have entries are shown.
@@ -2400,7 +2538,9 @@
 current-window   Display in the current window
 other-window     Just display in another window.
 dedicated-frame  Create one new frame, and re-use it each time.
-new-frame        Make a new frame each time."
+new-frame        Make a new frame each time.  Note that in this case
+                 previously-made indirect buffers are kept, and you need to
+                 kill these buffers yourself."
   :group 'org-structure
   :group 'org-agenda-windows
   :type '(choice
@@ -2542,18 +2682,19 @@
   :tag "Org Agenda Sorting"
   :group 'org-agenda)
 
-(let ((sorting-choice
-       '(choice
-	 (const time-up) (const time-down)
-	 (const category-keep) (const category-up) (const category-down)
-	 (const tag-down) (const tag-up)
-	 (const priority-up) (const priority-down))))
-
-  (defcustom org-agenda-sorting-strategy
-    '((agenda time-up category-keep priority-down)
-      (todo category-keep priority-down)
-      (tags category-keep priority-down))
-    "Sorting structure for the agenda items of a single day.
+(defconst org-sorting-choice
+  '(choice
+    (const time-up) (const time-down)
+    (const category-keep) (const category-up) (const category-down)
+    (const tag-down) (const tag-up)
+    (const priority-up) (const priority-down))
+  "Sorting choices.")
+
+(defcustom org-agenda-sorting-strategy
+  '((agenda time-up category-keep priority-down)
+    (todo category-keep priority-down)
+    (tags category-keep priority-down))
+  "Sorting structure for the agenda items of a single day.
 This is a list of symbols which will be used in sequence to determine
 if an entry should be listed before another entry.  The following
 symbols are recognized:
@@ -2580,17 +2721,21 @@
 priority.
 
 Leaving out `category-keep' would mean that items will be sorted across
-categories by priority."
+categories by priority.
+
+Instead of a single list, this can also be a set of list for specific
+contents, with a context symbol in the car of the list, any of
+`agenda', `todo', `tags' for the corresponding agenda views."
   :group 'org-agenda-sorting
   :type `(choice
-	  (repeat :tag "General" ,sorting-choice)
+	  (repeat :tag "General" ,org-sorting-choice)
 	  (list :tag "Individually"
 		(cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
-		      (repeat ,sorting-choice))
+		      (repeat ,org-sorting-choice))
 		(cons (const :tag "Strategy for TODO lists" todo)
-		      (repeat ,sorting-choice))
+		      (repeat ,org-sorting-choice))
 		(cons (const :tag "Strategy for Tags matches" tags)
-		      (repeat ,sorting-choice))))))
+		      (repeat ,org-sorting-choice)))))
 
 (defcustom org-sort-agenda-notime-is-late t
   "Non-nil means, items without time are considered late.
@@ -2673,9 +2818,16 @@
   "The compiled version of the most recently used prefix format.
 See the variable `org-agenda-prefix-format'.")
 
+(defcustom org-agenda-todo-keyword-format "%-1s"
+  "Format for the TODO keyword in agenda lines.
+Set this to something like \"%-12s\" if you want all TODO keywords
+to occupy a fixed space in the agenda display."
+  :group 'org-agenda-line-format
+  :type 'string)
+
 (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
   "Text preceeding scheduled items in the agenda view.
-THis is a list with two strings.  The first applies when the item is
+This is a list with two strings.  The first applies when the item is
 scheduled on the current day.  The second applies when it has been scheduled
 previously, it may contain a %d to capture how many days ago the item was
 scheduled."
@@ -2811,23 +2963,23 @@
   :tag "Org Export General"
   :group 'org-export)
 
-(defcustom org-export-publishing-directory "."
-  "Path to the location where exported files should be located.
-This path may be relative to the directory where the Org-mode file lives.
-The default is to put them into the same directory as the Org-mode file.
-The variable may also be an alist with export types `:html', `:ascii',
-`:ical', `:LaTeX', or `:xoxo' and the corresponding directories.
-If a directory path is relative, it is interpreted relative to the
-directory where the exported Org-mode files lives."
-  :group 'org-export-general
-  :type '(choice
-	  (directory)
-	  (repeat
-	   (cons
-	    (choice :tag "Type"
-		    (const :html) (const :LaTeX)
-		    (const :ascii) (const :ical) (const :xoxo))
-	    (directory)))))
+;; FIXME
+(defvar org-export-publishing-directory nil)
+
+(defcustom org-export-with-special-strings t
+  "Non-nil means, interpret \"\-\", \"--\" and \"---\" for export.
+When this option is turned on, these strings will be exported as:
+
+  Org   HTML       LaTeX
+ -----+----------+--------
+  \\-    &shy;      \\-
+  --    &ndash;    --
+  ---   &mdash;    ---
+  ...   &hellip;   \ldots
+
+This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
+  :group 'org-export-translation
+  :type 'boolean)
 
 (defcustom org-export-language-setup
   '(("en"  "Author"          "Date"  "Table of Contents")
@@ -3032,6 +3184,20 @@
 	  (const :tag "Only with braces" {})
 	  (const :tag "Never interpret" nil)))
 
+(defcustom org-export-with-special-strings t
+  "Non-nil means, interpret \"\-\", \"--\" and \"---\" for export.
+When this option is turned on, these strings will be exported as:
+
+\\-  : &shy;
+--  : &ndash;
+--- :  &mdash;
+
+Not all export backends support this, but HTML does.
+
+This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
+  :group 'org-export-translation
+  :type 'boolean)
+
 (defcustom org-export-with-TeX-macros t
   "Non-nil means, interpret simple TeX-like macros when exporting.
 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
@@ -3138,7 +3304,7 @@
 
 (defcustom org-export-ascii-bullets '(?* ?+ ?-)
   "Bullet characters for headlines converted to lists in ASCII export.
-The first character is is used for the first lest level generated in this
+The first character is used for the first lest level generated in this
 way, and so on.  If there are more levels than characters given here,
 the list will be repeated.
 Note that plain lists will keep the same bullets as the have in the
@@ -3377,8 +3543,20 @@
   :group 'org-font-lock
   :type 'boolean)
 
+(defcustom org-highlight-latex-fragments-and-specials nil
+  "Non-nil means, fontify what is treated specially by the exporters."
+  :group 'org-font-lock
+  :type 'boolean)
+
+(defcustom org-hide-emphasis-markers nil
+  "Non-nil mean font-lock should hide the emphasis marker characters."
+  :group 'org-font-lock
+  :type 'boolean)
+
 (defvar org-emph-re nil
   "Regular expression for matching emphasis.")
+(defvar org-verbatim-re nil
+  "Regular expression for matching verbatim text.")
 (defvar org-emphasis-regexp-components) ; defined just below
 (defvar org-emphasis-alist) ; defined just below
 (defun org-set-emph-re (var val)
@@ -3393,33 +3571,53 @@
 	   (border (nth 2 e))
 	   (body (nth 3 e))
 	   (nl (nth 4 e))
-	   (stacked (nth 5 e))
+	   (stacked (and nil (nth 5 e))) ; stacked is no longer allowed, forced to nil
 	   (body1 (concat body "*?"))
-	   (markers (mapconcat 'car org-emphasis-alist "")))
+	   (markers (mapconcat 'car org-emphasis-alist ""))
+	   (vmarkers (mapconcat
+		      (lambda (x) (if (eq (nth 4 x) 'verbatim) (car x) ""))
+		      org-emphasis-alist "")))
       ;; make sure special characters appear at the right position in the class
       (if (string-match "\\^" markers)
 	  (setq markers (concat (replace-match "" t t markers) "^")))
       (if (string-match "-" markers)
 	  (setq markers (concat (replace-match "" t t markers) "-")))
+      (if (string-match "\\^" vmarkers)
+	  (setq vmarkers (concat (replace-match "" t t vmarkers) "^")))
+      (if (string-match "-" vmarkers)
+	  (setq vmarkers (concat (replace-match "" t t vmarkers) "-")))
       (if (> nl 0)
           (setq body1 (concat body1 "\\(?:\n" body "*?\\)\\{0,"
                               (int-to-string nl) "\\}")))
       ;; Make the regexp
       (setq org-emph-re
-	    (concat "\\([" pre (if stacked markers) "]\\|^\\)"
+	    (concat "\\([" pre (if (and nil stacked) markers) "]\\|^\\)"
 		    "\\("
 		    "\\([" markers "]\\)"
 		    "\\("
+		    "[^" border "]\\|"
 		    "[^" border (if (and nil stacked) markers) "]"
 		    body1
 		    "[^" border (if (and nil stacked) markers) "]"
 		    "\\)"
 		    "\\3\\)"
-		    "\\([" post (if stacked markers) "]\\|$\\)")))))
+		    "\\([" post (if (and nil stacked) markers) "]\\|$\\)"))
+      (setq org-verbatim-re
+	    (concat "\\([" pre "]\\|^\\)"
+		    "\\("
+		    "\\([" vmarkers "]\\)"
+		    "\\("
+		    "[^" border "]\\|"
+		    "[^" border "]"
+		    body1
+		    "[^" border "]"
+		    "\\)"
+		    "\\3\\)"
+		    "\\([" post  "]\\|$\\)")))))
 
 (defcustom org-emphasis-regexp-components
-  '(" \t('\"" "- \t.,:?;'\")" " \t\r\n,\"'" "." 1 nil)
-  "Components used to build the reqular expression for emphasis.
+  '(" \t('\"" "- \t.,:?;'\")" " \t\r\n,\"'" "." 1)
+  "Components used to build the regular expression for emphasis.
 This is a list with 6 entries.  Terminology:  In an emphasis string
 like \" *strong word* \", we call the initial space PREMATCH, the final
 space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
@@ -3432,10 +3630,7 @@
 body-regexp  A regexp like \".\" to match a body character.  Don't use
              non-shy groups here, and don't allow newline here.
 newline      The maximum number of newlines allowed in an emphasis exp.
-stacked      Non-nil means, allow stacked styles.  This works only in HTML
-             export.  When this is set, all marker characters (as given in
-             `org-emphasis-alist') will be allowed as pre/post, aiding
-             inside-out matching.
+
 Use customize to modify this, or restart Emacs after changing it."
   :group 'org-font-lock
   :set 'org-set-emph-re
@@ -3445,16 +3640,17 @@
 	  (sexp    :tag "Forbidden chars in border ")
 	  (sexp    :tag "Regexp for body           ")
 	  (integer :tag "number of newlines allowed")
-	  (boolean :tag "Stacking allowed          ")))
+	  (option (boolean :tag "Stacking (DISABLED)       "))))
 
 (defcustom org-emphasis-alist
   '(("*" bold "<b>" "</b>")
     ("/" italic "<i>" "</i>")
     ("_" underline "<u>" "</u>")
-    ("=" org-code "<code>" "</code>")
+    ("=" org-code "<code>" "</code>" verbatim)
+    ("~" org-verbatim "" "" verbatim)
     ("+" (:strike-through t) "<del>" "</del>")
     )
-"Special syntax for emphasized text.
+  "Special syntax for emphasized text.
 Text starting and ending with a special character will be emphasized, for
 example *bold*, _underlined_ and /italic/.  This variable sets the marker
 characters, the face to be used by font-lock for highlighting in Org-mode
@@ -3469,7 +3665,8 @@
 	    (face :tag "Font-lock-face")
 	    (plist :tag "Face property list"))
 	   (string :tag "HTML start tag")
-	   (string :tag "HTML end tag"))))
+	   (string :tag "HTML end tag")
+	   (option (const verbatim)))))
 
 ;;; The faces
 
@@ -3508,6 +3705,7 @@
 	 (t (or (assoc (car e) r) (push e r)))))
       (nreverse r)))
    (t specs)))
+(put 'org-compatible-face 'lisp-indent-function 1)
 
 (defface org-hide
   '((((background light)) (:foreground "white"))
@@ -3518,108 +3716,98 @@
   :group 'org-faces)
 
 (defface org-level-1 ;; font-lock-function-name-face
-  (org-compatible-face
-   'outline-1
-   '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-     (t (:bold t))))
+  (org-compatible-face 'outline-1
+    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
+      (t (:bold t))))
   "Face used for level 1 headlines."
   :group 'org-faces)
 
 (defface org-level-2 ;; font-lock-variable-name-face
-  (org-compatible-face
-   'outline-2
-   '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
-     (((class color) (min-colors 16) (background dark))  (:foreground "LightGoldenrod"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "yellow"))
-     (((class color) (min-colors 8)  (background dark))  (:foreground "yellow" :bold t))
-     (t (:bold t))))
+  (org-compatible-face 'outline-2
+    '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
+      (((class color) (min-colors 16) (background dark))  (:foreground "LightGoldenrod"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "yellow"))
+      (((class color) (min-colors 8)  (background dark))  (:foreground "yellow" :bold t))
+      (t (:bold t))))
   "Face used for level 2 headlines."
   :group 'org-faces)
 
 (defface org-level-3 ;; font-lock-keyword-face
-  (org-compatible-face
-   'outline-3
-   '((((class color) (min-colors 88) (background light)) (:foreground "Purple"))
-     (((class color) (min-colors 88) (background dark))  (:foreground "Cyan1"))
-     (((class color) (min-colors 16) (background light)) (:foreground "Purple"))
-     (((class color) (min-colors 16) (background dark))  (:foreground "Cyan"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "purple" :bold t))
-     (((class color) (min-colors 8)  (background dark))  (:foreground "cyan" :bold t))
-     (t (:bold t))))
+  (org-compatible-face 'outline-3
+    '((((class color) (min-colors 88) (background light)) (:foreground "Purple"))
+      (((class color) (min-colors 88) (background dark))  (:foreground "Cyan1"))
+      (((class color) (min-colors 16) (background light)) (:foreground "Purple"))
+      (((class color) (min-colors 16) (background dark))  (:foreground "Cyan"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "purple" :bold t))
+      (((class color) (min-colors 8)  (background dark))  (:foreground "cyan" :bold t))
+      (t (:bold t))))
   "Face used for level 3 headlines."
   :group 'org-faces)
 
 (defface org-level-4   ;; font-lock-comment-face
-  (org-compatible-face
-   'outline-4
-   '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-     (((class color) (min-colors 88) (background dark))  (:foreground "chocolate1"))
-     (((class color) (min-colors 16) (background light)) (:foreground "red"))
-     (((class color) (min-colors 16) (background dark))  (:foreground "red1"))
-     (((class color) (min-colors 8) (background light))  (:foreground "red" :bold t))
-     (((class color) (min-colors 8) (background dark))   (:foreground "red" :bold t))
-     (t (:bold t))))
+  (org-compatible-face 'outline-4
+    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
+      (((class color) (min-colors 88) (background dark))  (:foreground "chocolate1"))
+      (((class color) (min-colors 16) (background light)) (:foreground "red"))
+      (((class color) (min-colors 16) (background dark))  (:foreground "red1"))
+      (((class color) (min-colors 8) (background light))  (:foreground "red" :bold t))
+      (((class color) (min-colors 8) (background dark))   (:foreground "red" :bold t))
+      (t (:bold t))))
   "Face used for level 4 headlines."
   :group 'org-faces)
 
 (defface org-level-5 ;; font-lock-type-face
-  (org-compatible-face
-   'outline-5
-   '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
-     (((class color) (min-colors 8)) (:foreground "green"))))
+  (org-compatible-face 'outline-5
+    '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
+      (((class color) (min-colors 8)) (:foreground "green"))))
   "Face used for level 5 headlines."
   :group 'org-faces)
 
 (defface org-level-6 ;; font-lock-constant-face
-  (org-compatible-face
-   'outline-6
-   '((((class color) (min-colors 16) (background light)) (:foreground "CadetBlue"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
-     (((class color) (min-colors 8)) (:foreground "magenta"))))
+  (org-compatible-face 'outline-6
+    '((((class color) (min-colors 16) (background light)) (:foreground "CadetBlue"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
+      (((class color) (min-colors 8)) (:foreground "magenta"))))
   "Face used for level 6 headlines."
   :group 'org-faces)
 
 (defface org-level-7 ;; font-lock-builtin-face
-  (org-compatible-face
-   'outline-7
-   '((((class color) (min-colors 16) (background light)) (:foreground "Orchid"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue"))
-     (((class color) (min-colors 8)) (:foreground "blue"))))
+  (org-compatible-face 'outline-7
+    '((((class color) (min-colors 16) (background light)) (:foreground "Orchid"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue"))
+      (((class color) (min-colors 8)) (:foreground "blue"))))
   "Face used for level 7 headlines."
   :group 'org-faces)
 
 (defface org-level-8 ;; font-lock-string-face
-  (org-compatible-face
-   'outline-8
-   '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
-     (((class color) (min-colors 8)) (:foreground "green"))))
+  (org-compatible-face 'outline-8
+    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
+      (((class color) (min-colors 8)) (:foreground "green"))))
   "Face used for level 8 headlines."
   :group 'org-faces)
 
 (defface org-special-keyword ;; font-lock-string-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
-     (t (:italic t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
+      (t (:italic t))))
   "Face used for special keywords."
   :group 'org-faces)
 
 (defface org-drawer ;; font-lock-function-name-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-     (t (:bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
+      (t (:bold t))))
   "Face used for drawers."
   :group 'org-faces)
 
@@ -3628,15 +3816,14 @@
   :group 'org-faces)
 
 (defface org-column
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light))
-      (:background "grey90"))
-     (((class color) (min-colors 16) (background dark))
-      (:background "grey30"))
-     (((class color) (min-colors 8))
-      (:background "cyan" :foreground "black"))
-     (t (:inverse-video t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light))
+       (:background "grey90"))
+      (((class color) (min-colors 16) (background dark))
+       (:background "grey30"))
+      (((class color) (min-colors 8))
+       (:background "cyan" :foreground "black"))
+      (t (:inverse-video t))))
   "Face for column display of entry properties."
   :group 'org-faces)
 
@@ -3647,29 +3834,27 @@
 		      :family (face-attribute 'default :family)))
 
 (defface org-warning
-  (org-compatible-face
-   'font-lock-warning-face
-   '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
-     (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
-     (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
-     (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
-     (t (:bold t))))
+  (org-compatible-face 'font-lock-warning-face
+    '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
+      (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
+      (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
+      (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
+      (t (:bold t))))
   "Face for deadlines and TODO keywords."
   :group 'org-faces)
 
 (defface org-archived    ; similar to shadow
-  (org-compatible-face
-   'shadow
-   '((((class color grayscale) (min-colors 88) (background light))
-      (:foreground "grey50"))
-     (((class color grayscale) (min-colors 88) (background dark))
-      (:foreground "grey70"))
-     (((class color) (min-colors 8) (background light))
-      (:foreground "green"))
-     (((class color) (min-colors 8) (background dark))
-      (:foreground "yellow"))))
-   "Face for headline with the ARCHIVE tag."
-   :group 'org-faces)
+  (org-compatible-face 'shadow
+    '((((class color grayscale) (min-colors 88) (background light))
+       (:foreground "grey50"))
+      (((class color grayscale) (min-colors 88) (background dark))
+       (:foreground "grey70"))
+      (((class color) (min-colors 8) (background light))
+       (:foreground "green"))
+      (((class color) (min-colors 8) (background dark))
+       (:foreground "yellow"))))
+  "Face for headline with the ARCHIVE tag."
+  :group 'org-faces)
 
 (defface org-link
   '((((class color) (background light)) (:foreground "Purple" :underline t))
@@ -3679,8 +3864,8 @@
   :group 'org-faces)
 
 (defface org-ellipsis
-  '((((class color) (background light)) (:foreground "DarkGoldenrod" :strike-through t))
-    (((class color) (background dark)) (:foreground "LightGoldenrod" :strike-through t))
+  '((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t))
+    (((class color) (background dark)) (:foreground "LightGoldenrod" :underline t))
     (t (:strike-through t)))
   "Face for the ellipsis in folded text."
   :group 'org-faces)
@@ -3712,32 +3897,29 @@
   :group 'org-faces)
 
 (defface org-todo ; font-lock-warning-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
-     (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
-     (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
-     (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
-     (t (:inverse-video t :bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
+      (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
+      (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
+      (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
+      (t (:inverse-video t :bold t))))
   "Face for TODO keywords."
   :group 'org-faces)
 
 (defface org-done ;; font-lock-type-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen" :bold t))
-     (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen" :bold t))
-     (((class color) (min-colors 8)) (:foreground "green"))
-     (t (:bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen" :bold t))
+      (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen" :bold t))
+      (((class color) (min-colors 8)) (:foreground "green"))
+      (t (:bold t))))
   "Face used for todo keywords that indicate DONE items."
   :group 'org-faces)
 
 (defface org-headline-done ;; font-lock-string-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
-     (((class color) (min-colors 8)  (background light)) (:bold nil))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
+      (((class color) (min-colors 8)  (background light)) (:bold nil))))
   "Face used to indicate that a headline is DONE.
 This face is only used if `org-fontify-done-headline' is set.  If applies
 to the part of the headline after the DONE keyword."
@@ -3756,84 +3938,91 @@
 	   (sexp :tag "face"))))
 
 (defface org-table ;; font-lock-function-name-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "blue"))
-     (((class color) (min-colors 8)  (background dark)))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "blue"))
+      (((class color) (min-colors 8)  (background dark)))))
   "Face used for tables."
   :group 'org-faces)
 
 (defface org-formula
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-     (((class color) (min-colors 8)  (background dark)) (:foreground "red"))
-     (t (:bold t :italic t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
+      (((class color) (min-colors 8)  (background dark)) (:foreground "red"))
+      (t (:bold t :italic t))))
   "Face for formulas."
   :group 'org-faces)
 
 (defface org-code
-  (org-compatible-face
-   nil
-   '((((class color grayscale) (min-colors 88) (background light))
-      (:foreground "grey50"))
-     (((class color grayscale) (min-colors 88) (background dark))
-      (:foreground "grey70"))
-     (((class color) (min-colors 8) (background light))
-      (:foreground "green"))
-     (((class color) (min-colors 8) (background dark))
-      (:foreground "yellow"))))
-   "Face for fixed-with text like code snippets."
-   :group 'org-faces
-   :version "22.1")
+  (org-compatible-face nil
+    '((((class color grayscale) (min-colors 88) (background light))
+       (:foreground "grey50"))
+      (((class color grayscale) (min-colors 88) (background dark))
+       (:foreground "grey70"))
+      (((class color) (min-colors 8) (background light))
+       (:foreground "green"))
+      (((class color) (min-colors 8) (background dark))
+       (:foreground "yellow"))))
+  "Face for fixed-with text like code snippets."
+  :group 'org-faces
+  :version "22.1")
+
+(defface org-verbatim
+  (org-compatible-face nil
+    '((((class color grayscale) (min-colors 88) (background light))
+       (:foreground "grey50" :underline t))
+      (((class color grayscale) (min-colors 88) (background dark))
+       (:foreground "grey70" :underline t))
+      (((class color) (min-colors 8) (background light))
+       (:foreground "green" :underline t))
+      (((class color) (min-colors 8) (background dark))
+       (:foreground "yellow" :underline t))))
+  "Face for fixed-with text like code snippets."
+  :group 'org-faces
+  :version "22.1")
 
 (defface org-agenda-structure ;; font-lock-function-name-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-     (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-     (t (:bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
+      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
+      (t (:bold t))))
   "Face used in agenda for captions and dates."
   :group 'org-faces)
 
 (defface org-scheduled-today
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
-     (((class color) (min-colors 8)) (:foreground "green"))
-     (t (:bold t :italic t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
+      (((class color) (min-colors 8)) (:foreground "green"))
+      (t (:bold t :italic t))))
   "Face for items scheduled for a certain day."
   :group 'org-faces)
 
 (defface org-scheduled-previously
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-     (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
-     (t (:bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
+      (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
+      (t (:bold t))))
   "Face for items scheduled previously, and not yet done."
   :group 'org-faces)
 
 (defface org-upcoming-deadline
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-     (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-     (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-     (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
-     (t (:bold t))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
+      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
+      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
+      (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
+      (t (:bold t))))
   "Face for items scheduled previously, and not yet done."
   :group 'org-faces)
 
@@ -3842,8 +4031,8 @@
     (0.5 . org-upcoming-deadline)
     (0.0 . default))
   "Faces for showing deadlines in the agenda.
-This is a list of cons cells.  The cdr of each cess is a face to be used,
-and it can also just be a like like '(:foreground \"yellow\").
+This is a list of cons cells.  The cdr of each cell is a face to be used,
+and it can also just be like '(:foreground \"yellow\").
 Each car is a fraction of the head-warning time that must have passed for
 this the face in the cdr to be used for display.  The numbers must be
 given in descending order.  The head-warning time is normally taken
@@ -3862,12 +4051,23 @@
 	   (number :tag "Fraction of head-warning time passed")
 	   (sexp :tag "Face"))))
 
+;; FIXME: this is not a good face yet.
+(defface org-agenda-restriction-lock
+  (org-compatible-face nil
+    '((((class color) (min-colors 88) (background light)) (:background "yellow1"))
+      (((class color) (min-colors 88) (background dark))  (:background "skyblue4"))
+      (((class color) (min-colors 16) (background light)) (:background "yellow1"))
+      (((class color) (min-colors 16) (background dark))  (:background "skyblue4"))
+      (((class color) (min-colors 8)) (:background "cyan" :foreground "black"))
+      (t (:inverse-video t))))
+  "Face for showing the agenda restriction lock."
+  :group 'org-faces)
+
 (defface org-time-grid ;; font-lock-variable-name-face
-  (org-compatible-face
-   nil
-   '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
-     (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
-     (((class color) (min-colors 8)) (:foreground "yellow" :weight light))))
+  (org-compatible-face nil
+    '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
+      (((class color) (min-colors 8)) (:foreground "yellow" :weight light))))
   "Face used for time grids."
   :group 'org-faces)
 
@@ -3883,7 +4083,24 @@
   :type 'number
   :group 'org-faces)
 
-;;; Function declarations.
+;;; Functions and variables from ther packages
+;;  Declared here to avoid compiler warnings
+
+(eval-and-compile
+  (unless (fboundp 'declare-function)
+    (defmacro declare-function (fn file &optional arglist fileonly))))
+
+;; XEmacs only
+(defvar outline-mode-menu-heading)
+(defvar outline-mode-menu-show)
+(defvar outline-mode-menu-hide)
+(defvar zmacs-regions) ; XEmacs regions
+
+;; Emacs only
+(defvar mark-active)
+
+;; Various packages
+;; FIXME: get the argument lists for the UNKNOWN stuff
 (declare-function add-to-diary-list "diary-lib"
                   (date string specifier &optional marker globcolor literal))
 (declare-function table--at-cell-p "table" (position &optional object at-column))
@@ -3899,6 +4116,8 @@
 (declare-function bibtex-generate-autokey "bibtex" ())
 (declare-function bibtex-parse-entry "bibtex" (&optional content))
 (declare-function bibtex-url "bibtex" (&optional pos no-browse))
+(defvar calc-embedded-close-formula)
+(defvar calc-embedded-open-formula)
 (declare-function calendar-astro-date-string    "cal-julian" (&optional date))
 (declare-function calendar-bahai-date-string    "cal-bahai"  (&optional date))
 (declare-function calendar-check-holidays       "holidays"   (date))
@@ -3915,10 +4134,23 @@
 (declare-function calendar-julian-date-string   "cal-julian" (&optional date))
 (declare-function calendar-mayan-date-string    "cal-mayan"  (&optional date))
 (declare-function calendar-persian-date-string  "cal-persia" (&optional date))
+(defvar calendar-mode-map)
+(defvar original-date) ; dynamically scoped in calendar.el does scope this
 (declare-function cdlatex-tab "ext:cdlatex" ())
 (declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
+(declare-function elmo-folder-exists-p "ext:elmo" (folder) t)
+(declare-function elmo-message-entity-field "ext:elmo-msgdb" (entity field &optional type))
+(declare-function elmo-message-field "ext:elmo" (folder number field &optional type) t)
+;; backward compatibility to old version of elmo
+(declare-function elmo-msgdb-overview-get-entity "ext:elmo" (&rest unknown) t)
+(defvar font-lock-unfontify-region-function)
 (declare-function gnus-article-show-summary "gnus-art" ())
 (declare-function gnus-summary-last-subject "gnus-sum" ())
+(defvar gnus-other-frame-object)
+(defvar gnus-group-name)
+(defvar gnus-article-current)
+(defvar Info-current-file)
+(defvar Info-current-node)
 (declare-function mh-display-msg "mh-show" (msg-num folder-name))
 (declare-function mh-find-path "mh-utils" ())
 (declare-function mh-get-header-field "mh-utils" (field))
@@ -3934,16 +4166,25 @@
 (declare-function mh-show-msg "mh-show" (msg))
 (declare-function mh-show-show "mh-show" t t)
 (declare-function mh-visit-folder "mh-folder" (folder &optional range index-data))
-(declare-function org-export-latex-cleaned-string "org-export-latex" (&optional commentsp))
+(defvar mh-progs)
+(defvar mh-current-folder)
+(defvar mh-show-folder-buffer)
+(defvar mh-index-folder)
+(defvar mh-searcher)
+(declare-function org-export-latex-cleaned-string "org-export-latex" ())
 (declare-function parse-time-string "parse-time" (string))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
+(defvar remember-save-after-remembering)
+(defvar remember-data-file)
+(defvar remember-register)
+(defvar remember-buffer)
+(defvar remember-handler-functions)
+(defvar remember-annotation-functions)
 (declare-function rmail-narrow-to-non-pruned-header "rmail" ())
 (declare-function rmail-show-message "rmail" (&optional n no-summary))
 (declare-function rmail-what-message "rmail" ())
-(declare-function elmo-folder-exists-p "ext:elmo" (folder) t)
-(declare-function elmo-message-entity-field "ext:elmo-msgdb" (entity field &optional type))
-(declare-function elmo-message-field "ext:elmo" (folder number field &optional type) t)
+(defvar texmathp-why)
 (declare-function vm-beginning-of-message "ext:vm-page" ())
 (declare-function vm-follow-summary-cursor "ext:vm-motion" ())
 (declare-function vm-get-header-contents "ext:vm-summary" (message header-name-regexp &optional clump-sep))
@@ -3953,6 +4194,12 @@
 (declare-function vm-su-message-id "ext:vm-summary" (m))
 (declare-function vm-su-subject "ext:vm-summary" (m))
 (declare-function vm-summarize "ext:vm-summary" (&optional display raise))
+(defvar vm-message-pointer)
+(defvar vm-folder-directory)
+(defvar w3m-current-url)
+(defvar w3m-current-title)
+;; backward compatibility to old version of wl
+(declare-function wl-summary-buffer-msgdb "ext:wl-folder" (&rest unknown) t)
 (declare-function wl-folder-get-elmo-folder "ext:wl-folder" (entity &optional no-cache))
 (declare-function wl-summary-goto-folder-subr "ext:wl-summary" (&optional name scan-type other-window sticky interactive scoring force-exit))
 (declare-function wl-summary-jump-to-msg-by-message-id "ext:wl-summary" (&optional id))
@@ -3960,6 +4207,12 @@
 (declare-function wl-summary-line-subject "ext:wl-summary" ())
 (declare-function wl-summary-message-number "ext:wl-summary" ())
 (declare-function wl-summary-redisplay "ext:wl-summary" (&optional arg))
+(defvar wl-summary-buffer-elmo-folder)
+(defvar wl-summary-buffer-folder-name)
+(declare-function speedbar-line-directory "speedbar" (&optional depth))
+
+(defvar org-latex-regexps)
+(defvar constants-unit-system)
 
 ;;; Variables for pre-computed regular expressions, all buffer local
 
@@ -4134,7 +4387,7 @@
 	     ((equal key "CATEGORY")
 	      (if (string-match "[ \t]+$" value)
 		  (setq value (replace-match "" t t value)))
-	      (setq cat (intern value)))
+	      (setq cat value))
 	     ((member key '("SEQ_TODO" "TODO"))
 	      (push (cons 'sequence (org-split-string value splitre)) kwds))
 	     ((equal key "TYP_TODO")
@@ -4176,7 +4429,9 @@
 	      (remove-text-properties 0 (length arch)
 				      '(face t fontified t) arch)))
 	    )))
-      (and cat (org-set-local 'org-category cat))
+      (when cat
+	(org-set-local 'org-category (intern cat))
+	(push (cons "CATEGORY" cat) props))
       (when prio
 	(if (< (length prio) 3) (setq prio '("A" "C" "B")))
 	(setq prio (mapcar 'string-to-char prio))
@@ -4332,7 +4587,7 @@
 		  "\\|" org-closed-string "\\|" org-clock-string
 		  "\\)\\>\\)")
 	  )
-
+    (org-compute-latex-and-specials-regexp)
     (org-set-font-lock-defaults)))
 
 (defun org-remove-keyword-keys (list)
@@ -4342,6 +4597,31 @@
 	      x))
 	  list))
 
+;; FIXME: this could be done much better, using second characters etc.
+(defun org-assign-fast-keys (alist)
+  "Assign fast keys to a keyword-key alist.
+Respect keys that are already there."
+  (let (new e k c c1 c2 (char ?a))
+    (while (setq e (pop alist))
+      (cond
+       ((equal e '(:startgroup)) (push e new))
+       ((equal e '(:endgroup)) (push e new))
+       (t
+	(setq k (car e) c2 nil)
+	(if (cdr e)
+	    (setq c (cdr e))
+	  ;; automatically assign a character.
+	  (setq c1 (string-to-char
+		    (downcase (substring
+			       k (if (= (string-to-char k) ?@) 1 0)))))
+	  (if (or (rassoc c1 new) (rassoc c1 alist))
+	      (while (or (rassoc char new) (rassoc char alist))
+		(setq char (1+ char)))
+	    (setq c2 c1))
+	  (setq c (or c2 char)))
+	(push (cons k c) new))))
+    (nreverse new)))
+
 ;;; Some variables ujsed in various places
 
 (defvar org-window-configuration nil
@@ -4350,49 +4630,6 @@
   "Function to be called when `C-c C-c' is used.
 This is for getting out of special buffers like remember.")
 
-;;; Foreign variables, to inform the compiler
-
-;; XEmacs only
-(defvar outline-mode-menu-heading)
-(defvar outline-mode-menu-show)
-(defvar outline-mode-menu-hide)
-(defvar zmacs-regions) ; XEmacs regions
-;; Emacs only
-(defvar mark-active)
-
-;; Packages that org-mode interacts with
-(defvar calc-embedded-close-formula)
-(defvar calc-embedded-open-formula)
-(defvar font-lock-unfontify-region-function)
-(defvar org-goto-start-pos)
-(defvar vm-message-pointer)
-(defvar vm-folder-directory)
-(defvar wl-summary-buffer-elmo-folder)
-(defvar wl-summary-buffer-folder-name)
-(defvar gnus-other-frame-object)
-(defvar gnus-group-name)
-(defvar gnus-article-current)
-(defvar w3m-current-url)
-(defvar w3m-current-title)
-(defvar mh-progs)
-(defvar mh-current-folder)
-(defvar mh-show-folder-buffer)
-(defvar mh-index-folder)
-(defvar mh-searcher)
-(defvar calendar-mode-map)
-(defvar Info-current-file)
-(defvar Info-current-node)
-(defvar texmathp-why)
-(defvar remember-save-after-remembering)
-(defvar remember-data-file)
-(defvar remember-register)
-(defvar remember-buffer)
-(defvar annotation) ; from remember.el, dynamically scoped in `remember-mode'
-(defvar initial)    ; from remember.el, dynamically scoped in `remember-mode'
-(defvar org-latex-regexps)
-(defvar constants-unit-system)
-
-(defvar original-date) ; dynamically scoped in calendar.el does scope this
 
 ;; FIXME: Occasionally check by commenting these, to make sure
 ;;        no other functions uses these, forgetting to let-bind them.
@@ -4402,7 +4639,6 @@
 (defvar date)
 (defvar description)
 
-
 ;; Defined somewhere in this file, but used before definition.
 (defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized
 (defvar org-agenda-buffer-name)
@@ -4495,8 +4731,10 @@
   (if org-ignore-region
       nil
     (if (featurep 'xemacs)
-	(region-active-p)
-      (use-region-p))))
+	(and zmacs-regions (region-active-p))
+      (if (fboundp 'use-region-p)
+	  (use-region-p)
+	(and transient-mark-mode mark-active))))) ; Emacs 22 and before
 
 ;; Invisibility compatibility
 
@@ -4624,6 +4862,10 @@
 ;  (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping
   (org-set-local 'comment-padding " ")
 
+  ;; Imenu
+  (org-set-local 'imenu-create-index-function
+		 'org-imenu-get-tree)
+
   ;; Make isearch reveal context
   (if (or (featurep 'xemacs)
 	  (not (boundp 'outline-isearch-open-invisible-function)))
@@ -4704,7 +4946,7 @@
 
 (defconst org-non-link-chars "]\t\n\r<>")
 (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news" "bbdb" "vm"
-			   "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp"))
+			   "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp" "message"))
 (defvar org-link-re-with-space nil
    "Matches a link with spaces, optional angular brackets around it.")
 (defvar org-link-re-with-space2 nil
@@ -4749,7 +4991,7 @@
 	 "\\)>")
 	org-plain-link-re
 	(concat
-	 "\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
+	 "\\<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
 	 "\\([^]\t\n\r<>,;() ]+\\)")
 	org-bracket-link-regexp
 	"\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
@@ -4810,7 +5052,12 @@
 							   org-emphasis-alist)))
 	    (add-text-properties (match-beginning 2) (match-end 2)
 				 '(font-lock-multiline t))
-	    (backward-char 1))))
+	    (when org-hide-emphasis-markers
+	      (add-text-properties (match-end 4) (match-beginning 5)
+				   '(invisible org-link))
+	      (add-text-properties (match-beginning 3) (match-end 3)
+				   '(invisible org-link)))))
+      (backward-char 1))
     rtn))
 
 (defun org-emphasize (&optional char)
@@ -4925,10 +5172,10 @@
 	     (ip (org-maybe-intangible
 		  (list 'invisible 'org-link 'rear-nonsticky org-nonsticky-props
 			'keymap org-mouse-map 'mouse-face 'highlight
-			'help-echo help)))
+			'font-lock-multiline t 'help-echo help)))
 	     (vp (list 'rear-nonsticky org-nonsticky-props
 		       'keymap org-mouse-map 'mouse-face 'highlight
-		       'help-echo help)))
+		       ' font-lock-multiline t 'help-echo help)))
 	;; We need to remove the invisible property here.  Table narrowing
 	;; may have made some of this invisible.
 	(remove-text-properties (match-beginning 0) (match-end 0)
@@ -4998,6 +5245,97 @@
       (goto-char e)
       t)))
 
+(defvar org-latex-and-specials-regexp nil
+  "Regular expression for highlighting export special stuff.")
+(defvar org-match-substring-regexp)
+(defvar org-match-substring-with-braces-regexp)
+(defvar org-export-html-special-string-regexps)
+
+(defun org-compute-latex-and-specials-regexp ()
+  "Compute regular expression for stuff treated specially by exporters."
+  (if (not org-highlight-latex-fragments-and-specials)
+      (org-set-local 'org-latex-and-specials-regexp nil)
+    (let*
+	((matchers (plist-get org-format-latex-options :matchers))
+	 (latexs (delq nil (mapcar (lambda (x) (if (member (car x) matchers) x))
+				   org-latex-regexps)))
+	 (options (org-combine-plists (org-default-export-plist)
+				      (org-infile-export-plist)))
+	 (org-export-with-sub-superscripts (plist-get options :sub-superscript))
+	 (org-export-with-LaTeX-fragments (plist-get options :LaTeX-fragments))
+	 (org-export-with-TeX-macros (plist-get options :TeX-macros))
+	 (org-export-html-expand (plist-get options :expand-quoted-html))
+	 (org-export-with-special-strings (plist-get options :special-strings))
+	 (re-sub
+	  (cond
+	   ((equal org-export-with-sub-superscripts '{})
+	    (list org-match-substring-with-braces-regexp))
+	   (org-export-with-sub-superscripts
+	    (list org-match-substring-regexp))
+	   (t nil)))
+	 (re-latex
+	  (if org-export-with-LaTeX-fragments
+	      (mapcar (lambda (x) (nth 1 x)) latexs)))
+	 (re-macros
+	  (if org-export-with-TeX-macros
+	      (list (concat "\\\\"
+			    (regexp-opt
+			     (append (mapcar 'car org-html-entities)
+				     (if (boundp 'org-latex-entities)
+					 org-latex-entities nil))
+			     'words))) ; FIXME
+	    ))
+    ;;			(list "\\\\\\(?:[a-zA-Z]+\\)")))
+	 (re-special (if org-export-with-special-strings
+			 (mapcar (lambda (x) (car x))
+				 org-export-html-special-string-regexps)))
+	 (re-rest
+	  (delq nil
+		(list
+		 (if org-export-html-expand "@<[^>\n]+>")
+		 ))))
+      (org-set-local
+       'org-latex-and-specials-regexp
+       (mapconcat 'identity (append re-latex re-sub re-macros re-special
+				    re-rest) "\\|")))))
+
+(defface org-latex-and-export-specials
+  (let ((font (cond ((assq :inherit custom-face-attributes)
+		     '(:inherit underline))
+		    (t '(:underline t)))))
+    `((((class grayscale) (background light))
+       (:foreground "DimGray" ,@font))
+      (((class grayscale) (background dark))
+       (:foreground "LightGray" ,@font))
+      (((class color) (background light))
+       (:foreground "SaddleBrown"))
+      (((class color) (background dark))
+       (:foreground "burlywood"))
+      (t (,@font))))
+  "Face used to highlight math latex and other special exporter stuff."
+  :group 'org-faces)
+
+(defun org-do-latex-and-special-faces (limit)
+  "Run through the buffer and add overlays to links."
+  (when org-latex-and-specials-regexp
+    (let (rtn d)
+      (while (and (not rtn) (re-search-forward org-latex-and-specials-regexp
+					       limit t))
+	(if (not (memq (car-safe (get-text-property (1+ (match-beginning 0))
+						    'face))
+		       '(org-code org-verbatim underline)))
+	    (progn
+	      (setq rtn t
+		    d (cond ((member (char-after (1+ (match-beginning 0)))
+				     '(?_ ?^)) 1)
+			    (t 0)))
+	      (font-lock-prepend-text-property
+	       (+ d (match-beginning 0)) (match-end 0)
+	       'face 'org-latex-and-export-specials)
+	      (add-text-properties (+ d (match-beginning 0)) (match-end 0)
+				   '(font-lock-multiline t)))))
+      rtn)))
+
 (defun org-restart-font-lock ()
   "Restart font-lock-mode, to force refontification."
   (when (and (boundp 'font-lock-mode) font-lock-mode)
@@ -5064,7 +5402,7 @@
 	   '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
 	     (1 'org-table t))
 	   ;; Table internals
-	   '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t))
+	   '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
 	   '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
 	   '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
 	   ;; Drawers
@@ -5113,14 +5451,17 @@
 	   (if org-provide-checkbox-statistics
 	       '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
 		 (0 (org-get-checkbox-statistics-face) t)))
+	   (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
+		 '(1 'org-archived prepend))
+	   ;; Specials
+	   '(org-do-latex-and-special-faces)
+	   ;; Code
+	   '(org-activate-code (1 'org-code t))
 	   ;; COMMENT
 	   (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string
 			 "\\|" org-quote-string "\\)\\>")
 		 '(1 'org-special-keyword t))
 	   '("^#.*" (0 'font-lock-comment-face t))
-	   '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend))
-	   ;; Code
-	   '(org-activate-code (1 'org-code t))
 	   )))
     (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
     ;; Now set the full font-lock-keywords
@@ -5345,12 +5686,12 @@
 			(>= (match-end 0) pos))))
 	  t
 	(eq org-cycle-emulate-tab t))
-      (if (and (looking-at "[ \n\r\t]")
-	       (string-match "^[ \t]*$" (buffer-substring
-					 (point-at-bol) (point))))
-	  (progn
-	    (beginning-of-line 1)
-	    (and (looking-at "[ \t]+") (replace-match ""))))
+;      (if (and (looking-at "[ \n\r\t]")
+;	       (string-match "^[ \t]*$" (buffer-substring
+;					 (point-at-bol) (point))))
+;	  (progn
+;	    (beginning-of-line 1)
+;	    (and (looking-at "[ \t]+") (replace-match ""))))
       (call-interactively (global-key-binding "\t")))
 
      (t (save-excursion
@@ -5418,6 +5759,17 @@
      ((eq state 'children) (or (org-subtree-end-visible-p) (recenter 1)))
      ((eq state 'subtree)  (or (org-subtree-end-visible-p) (recenter 1))))))
 
+(defun org-compact-display-after-subtree-move ()
+  (let (beg end)
+    (save-excursion
+      (if (org-up-heading-safe)
+	  (progn
+	    (hide-subtree)
+	    (show-entry)
+	    (show-children)
+	    (org-cycle-show-empty-lines 'children)
+	    (org-cycle-hide-drawers 'children))
+	(org-overview)))))
 
 (defun org-cycle-show-empty-lines (state)
   "Show empty lines above all visible headlines.
@@ -5508,6 +5860,8 @@
 \[Up]/[Down]=next/prev headline   TAB=cycle visibility   [/] org-occur"
 )
 
+(defvar org-goto-start-pos) ; dynamically scoped parameter
+
 (defun org-goto ()
   "Look up a different location in the current file, keeping current visibility.
 
@@ -5631,8 +5985,10 @@
   "Create indirect buffer and narrow it to current subtree.
 With numerical prefix ARG, go up to this level and then take that tree.
 If ARG is negative, go up that many levels.
-Normally this command removes the indirect buffer previously made
-with this command.  However, when called with a C-u prefix, the last buffer
+If `org-indirect-buffer-display' is not `new-frame', the command removes the
+indirect buffer previously made with this command, to avoid proliferation of
+indirect buffers.  However, when you call the command with a `C-u' prefix, or
+when `org-indirect-buffer-display' is `new-frame', the last buffer
 is kept so that you can work with several indirect buffers at the same time.
 If `org-indirect-buffer-display' is `dedicated-frame', the C-u prefix also
 requests that a new frame be made for the new buffer, so that the dedicated
@@ -5652,8 +6008,9 @@
       (setq beg (point)
 	    heading (org-get-heading))
       (org-end-of-subtree t) (setq end (point)))
-    (if (and (not arg)
-	     (buffer-live-p org-last-indirect-buffer))
+    (if (and (buffer-live-p org-last-indirect-buffer)
+	     (not (eq org-indirect-buffer-display 'new-frame))
+	     (not arg))
 	(kill-buffer org-last-indirect-buffer))
     (setq ibuf (org-get-indirect-buffer cbuf)
 	  org-last-indirect-buffer ibuf)
@@ -5917,7 +6274,8 @@
 	  col)
       (unless (save-excursion (end-of-line 1)
 			      (re-search-forward prohibit end t))
-	(while (re-search-forward "^[ \t]+" end t)
+	(while (and (< (point) end)
+		    (re-search-forward "^[ \t]+" end t))
 	  (goto-char (match-end 0))
 	  (setq col (current-column))
 	  (if (< diff 0) (replace-match ""))
@@ -5980,38 +6338,65 @@
 		   'outline-get-last-sibling))
 	(ins-point (make-marker))
 	(cnt (abs arg))
-	beg end txt folded)
+	beg beg0 end txt folded ne-beg ne-end ne-ins ins-end)
     ;; Select the tree
     (org-back-to-heading)
-    (setq beg (point))
+    (setq beg0 (point))
+    (save-excursion
+      (setq ne-beg (org-back-over-empty-lines))
+      (setq beg (point)))
     (save-match-data
       (save-excursion (outline-end-of-heading)
 		      (setq folded (org-invisible-p)))
       (outline-end-of-subtree))
     (outline-next-heading)
+    (setq ne-end (org-back-over-empty-lines))
     (setq end (point))
+    (goto-char beg0)
+    (when (and (> arg 0) (org-first-sibling-p) (< ne-end ne-beg))
+      ;; include less whitespace
+      (save-excursion
+	(goto-char beg)
+	(forward-line (- ne-beg ne-end))
+	(setq beg (point))))
     ;; Find insertion point, with error handling
-    (goto-char beg)
     (while (> cnt 0)
       (or (and (funcall movfunc) (looking-at outline-regexp))
-	  (progn (goto-char beg)
+	  (progn (goto-char beg0)
 		 (error "Cannot move past superior level or buffer limit")))
       (setq cnt (1- cnt)))
     (if (> arg 0)
 	;; Moving forward - still need to move over subtree
-	(progn (outline-end-of-subtree)
-	       (outline-next-heading)
-	       (if (not (or (looking-at (concat "^" outline-regexp))
-			    (bolp)))
-		   (newline))))
+	(progn (org-end-of-subtree t t)
+	       (save-excursion
+		 (org-back-over-empty-lines)
+		 (or (bolp) (newline)))))
+    (setq ne-ins (org-back-over-empty-lines))
     (move-marker ins-point (point))
     (setq txt (buffer-substring beg end))
     (delete-region beg end)
+    (outline-flag-region (1- beg) beg nil)
+    (outline-flag-region (1- (point)) (point) nil)
     (insert txt)
     (or (bolp) (insert "\n"))
+    (setq ins-end (point))
     (goto-char ins-point)
-    (if folded (hide-subtree))
-    (move-marker ins-point nil)))
+    (org-skip-whitespace)
+    (when (and (< arg 0)
+	       (org-first-sibling-p)
+	       (> ne-ins ne-beg))
+      ;; Move whitespace back to beginning
+      (save-excursion
+	(goto-char ins-end)
+	(let ((kill-whole-line t))
+	  (kill-line (- ne-ins ne-beg)) (point)))
+      (insert (make-string (- ne-ins ne-beg) ?\n)))
+    (move-marker ins-point nil)
+    (org-compact-display-after-subtree-move)
+    (unless folded
+      (org-show-entry)
+      (show-children)
+      (org-cycle-hide-drawers 'children))))
 
 (defvar org-subtree-clip ""
   "Clipboard for cut and paste of subtrees.
@@ -6035,11 +6420,13 @@
 This is a short-hand for marking the subtree and then copying it.
 If CUT is non-nil, actually cut the subtree."
   (interactive "p")
-  (let (beg end folded)
+  (let (beg end folded (beg0 (point)))
     (if (interactive-p)
 	(org-back-to-heading nil) ; take what looks like a subtree
       (org-back-to-heading t)) ; take what is really there
+    (org-back-over-empty-lines)
     (setq beg (point))
+    (skip-chars-forward " \t\r\n")
     (save-match-data
       (save-excursion (outline-end-of-heading)
 		      (setq folded (org-invisible-p)))
@@ -6047,8 +6434,9 @@
 	  (outline-forward-same-level (1- n))
 	(error nil))
       (org-end-of-subtree t t))
+    (org-back-over-empty-lines)
     (setq end (point))
-    (goto-char beg)
+    (goto-char beg0)
     (when (> end beg)
       (setq org-subtree-clip-folded folded)
       (if cut (kill-region beg end) (copy-region-as-kill beg end))
@@ -6124,11 +6512,14 @@
 	(delete-region (point-at-bol) (point)))
     ;; Paste
     (beginning-of-line 1)
+    (org-back-over-empty-lines)   ;; FIXME: correct fix????
     (setq beg (point))
-    (insert txt)
-    (unless (string-match "\n[ \t]*\\'" txt) (insert "\n"))
+    (insert-before-markers txt)   ;; FIXME: correct fix????
+    (unless (string-match "\n\\'" txt) (insert "\n"))
     (setq end (point))
     (goto-char beg)
+    (skip-chars-forward " \t\n\r")
+    (setq beg (point))
     ;; Shift if necessary
     (unless (= shift 0)
       (save-restriction
@@ -6154,10 +6545,12 @@
 If optional TXT is given, check this string instead of the current kill."
   (let* ((kill (or txt (and kill-ring (current-kill 0)) ""))
 	 (start-level (and kill
-			   (string-match (concat "\\`" org-outline-regexp) kill)
-			   (- (match-end 0) (match-beginning 0) 1)))
+			   (string-match (concat "\\`\\([ \t\n\r]*?\n\\)?\\("
+						 org-outline-regexp "\\)")
+					 kill)
+			   (- (match-end 2) (match-beginning 2) 1)))
 	 (re (concat "^" org-outline-regexp))
-	 (start 1))
+	 (start (1+ (match-beginning 2))))
     (if (not start-level)
 	(progn
 	  nil)  ;; does not even start with a heading
@@ -6228,7 +6621,11 @@
           (condition-case nil (progn (org-back-to-heading) t) (error nil)))
       ;; we will sort the children of the current headline
       (org-back-to-heading)
-      (setq start (point) end (org-end-of-subtree) what "children")
+      (setq start (point)
+	    end (progn (org-end-of-subtree t t)
+		       (org-back-over-empty-lines)
+		       (point))
+	    what "children")
       (goto-char start)
       (show-subtree)
       (outline-next-heading))
@@ -6309,12 +6706,12 @@
 		 (cond
 		  ((= dcst ?n)
 		   (string-to-number (buffer-substring (match-end 0)
-						       (line-end-position))))
+						       (point-at-eol))))
 		  ((= dcst ?a)
-		   (buffer-substring (match-end 0) (line-end-position)))
+		   (buffer-substring (match-end 0) (point-at-eol)))
 		  ((= dcst ?t)
 		   (if (re-search-forward org-ts-regexp
-					  (line-end-position) t)
+					  (point-at-eol) t)
 		       (org-time-string-to-time (match-string 0))
 		     now))
 		  ((= dcst ?f)
@@ -6330,11 +6727,11 @@
 	      ((= dcst ?n)
 	       (if (looking-at outline-regexp)
 		   (string-to-number (buffer-substring (match-end 0)
-						       (line-end-position)))
+						       (point-at-eol)))
 		 nil))
 	      ((= dcst ?a)
-	       (funcall case-func (buffer-substring (line-beginning-position)
-						    (line-end-position))))
+	       (funcall case-func (buffer-substring (point-at-bol)
+						    (point-at-eol))))
 	      ((= dcst ?t)
 	       (if (re-search-forward org-ts-regexp
 				      (save-excursion
@@ -6343,7 +6740,7 @@
 		   (org-time-string-to-time (match-string 0))
 		 now))
 	      ((= dcst ?p)
-	       (if (re-search-forward org-priority-regexp (line-end-position) t)
+	       (if (re-search-forward org-priority-regexp (point-at-eol) t)
 		   (string-to-char (match-string 2))
 		 org-default-priority))
 	      ((= dcst ?r)
@@ -6383,7 +6780,8 @@
       (setq extractfun 'string-to-number
 	    comparefun (if (= dcst sorting-type) '< '>)))
      ((= dcst ?a)
-      (setq extractfun (if with-case 'identity 'downcase)
+      (setq extractfun (if with-case (lambda(x) (org-sort-remove-invisible x))
+			 (lambda(x) (downcase (org-sort-remove-invisible x))))
 	    comparefun (if (= dcst sorting-type)
 			   'string<
 			 (lambda (a b) (and (not (string< a b))
@@ -6483,12 +6881,13 @@
        ((org-on-heading-p)
 	(setq beg (point) end (save-excursion (outline-next-heading) (point))))
        ((org-at-item-checkbox-p)
-	(save-excursion
+	(let ((pos (point)))
 	  (replace-match
 	   (cond (arg "[-]")
 		 ((member (match-string 0) '("[ ]" "[-]")) "[X]")
 		 (t "[ ]"))
-	   t t))
+	   t t)
+	  (goto-char pos))
 	(throw 'exit t))
        (t (error "Not at a checkbox or heading, and no active region")))
       (save-excursion
@@ -6707,27 +7106,49 @@
       (error (goto-char pos)
 	     (error "On first item")))))
 
+(defun org-first-list-item-p ()
+  "Is this heading the item in a plain list?"
+  (unless (org-at-item-p)
+    (error "Not at a plain list item"))
+  (org-beginning-of-item)
+  (= (point) (save-excursion (org-beginning-of-item-list))))
+
 (defun org-move-item-down ()
   "Move the plain list item at point down, i.e. swap with following item.
 Subitems (items with larger indentation) are considered part of the item,
 so this really moves item trees."
   (interactive)
-  (let (beg end ind ind1 (pos (point)) txt)
+  (let (beg beg0 end end0 ind ind1 (pos (point)) txt ne-end ne-beg)
     (org-beginning-of-item)
-    (setq beg (point))
+    (setq beg0 (point))
+    (save-excursion
+      (setq ne-beg (org-back-over-empty-lines))
+      (setq beg (point)))
+    (goto-char beg0)
     (setq ind (org-get-indentation))
     (org-end-of-item)
+    (setq end0 (point))
+    (setq ind1 (org-get-indentation))
+    (setq ne-end (org-back-over-empty-lines))
     (setq end (point))
-    (setq ind1 (org-get-indentation))
+    (goto-char beg0)
+    (when (and (org-first-list-item-p) (< ne-end ne-beg))
+      ;; include less whitespace
+      (save-excursion
+	(goto-char beg)
+	(forward-line (- ne-beg ne-end))
+	(setq beg (point))))
+    (goto-char end0)
     (if (and (org-at-item-p) (= ind ind1))
 	(progn
 	  (org-end-of-item)
+	  (org-back-over-empty-lines)
 	  (setq txt (buffer-substring beg end))
 	  (save-excursion
 	    (delete-region beg end))
 	  (setq pos (point))
 	  (insert txt)
-	  (goto-char pos)
+	  (goto-char pos) (org-skip-whitespace)
 	  (org-maybe-renumber-ordered-list))
       (goto-char pos)
       (error "Cannot move this item further down"))))
@@ -6737,13 +7158,19 @@
 Subitems (items with larger indentation) are considered part of the item,
 so this really moves item trees."
   (interactive "p")
-  (let (beg end ind ind1 (pos (point)) txt)
+  (let (beg beg0 end end0 ind ind1 (pos (point)) txt
+	    ne-beg ne-end ne-ins ins-end)
     (org-beginning-of-item)
-    (setq beg (point))
+    (setq beg0 (point))
     (setq ind (org-get-indentation))
+    (save-excursion
+      (setq ne-beg (org-back-over-empty-lines))
+      (setq beg (point)))
+    (goto-char beg0)
     (org-end-of-item)
+    (setq ne-end (org-back-over-empty-lines))
     (setq end (point))
-    (goto-char beg)
+    (goto-char beg0)
     (catch 'exit
       (while t
 	(beginning-of-line 0)
@@ -6762,12 +7189,23 @@
     (setq ind1 (org-get-indentation))
     (if (and (org-at-item-p) (= ind ind1))
 	(progn
+	  (setq ne-ins (org-back-over-empty-lines))
 	  (setq txt (buffer-substring beg end))
 	  (save-excursion
 	    (delete-region beg end))
 	  (setq pos (point))
 	  (insert txt)
-	  (goto-char pos)
+	  (setq ins-end (point))
+	  (goto-char pos) (org-skip-whitespace)
+
+	  (when (and (org-first-list-item-p) (> ne-ins ne-beg))
+	    ;; Move whitespace back to beginning
+	    (save-excursion
+	      (goto-char ins-end)
+	      (let ((kill-whole-line t))
+		(kill-line (- ne-ins ne-beg)) (point)))
+	    (insert (make-string (- ne-ins ne-beg) ?\n)))
+
 	  (org-maybe-renumber-ordered-list))
       (goto-char pos)
       (error "Cannot move this item further up"))))
@@ -7090,7 +7528,7 @@
   "Unconditionally turn on `orgstruct-mode', and force org-mode indentations.
 In addition to setting orgstruct-mode, this also exports all indentation and
 autofilling variables from org-mode into the buffer.  Note that turning
-off orgstruct-mode will *not* remove these additonal settings."
+off orgstruct-mode will *not* remove these additional settings."
   (orgstruct-mode 1)
   (let (var val)
     (mapc
@@ -7105,7 +7543,7 @@
 (defun orgstruct-error ()
   "Error when there is no default binding for a structure key."
   (interactive)
-  (error "This key is has no function outside structure elements"))
+  (error "This key has no function outside structure elements"))
 
 (defun orgstruct-setup ()
   "Setup orgstruct keymaps."
@@ -7252,7 +7690,8 @@
 	  (this-buffer (current-buffer))
 	  (org-archive-location org-archive-location)
 	  (re "^#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$")
-          ;; start of variables that will be used for savind context
+          ;; start of variables that will be used for saving context
+	  ;; The compiler complains about them - keep them anyway!
 	  (file (abbreviate-file-name (buffer-file-name)))
 	  (time (format-time-string
 		 (substring (cdr org-time-stamp-formats) 1 -1)
@@ -7469,7 +7908,8 @@
   (save-excursion
     (beginning-of-line 1)
     (when (looking-at "^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:")
-      (let ((b (match-end 0)))
+      (let ((b (match-end 0))
+	    (outline-regexp org-outline-regexp))
 	(if (re-search-forward
 	     "^[ \t]*:END:"
 	     (save-excursion (outline-next-heading) (point)) t)
@@ -7488,7 +7928,7 @@
 	(goto-char beg)
 	(if (looking-at (concat ".*:" org-archive-tag ":"))
 	    (message "%s" (substitute-command-keys
-		      "Subtree is archived and stays closed.  Use \\[org-force-cycle-archived] to cycle it anyway.")))))))
+			   "Subtree is archived and stays closed.  Use \\[org-force-cycle-archived] to cycle it anyway.")))))))
 
 (defun org-force-cycle-archived ()
   "Cycle subtree even if it is archived."
@@ -7830,19 +8270,23 @@
 		 (make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|"))
 	 (hfmt1 (concat
 		 (make-string sp2 ?-) "%s" (make-string sp1 ?-) "+"))
-	 emptystrings links dates narrow fmax f1 len c e)
+	 emptystrings links dates emph narrow fmax f1 len c e)
     (untabify beg end)
     (remove-text-properties beg end '(org-cwidth t org-dwidth t display t))
     ;; Check if we have links or dates
     (goto-char beg)
     (setq links (re-search-forward org-bracket-link-regexp end t))
     (goto-char beg)
+    (setq emph (and org-hide-emphasis-markers
+		    (re-search-forward org-emph-re end t)))
+    (goto-char beg)
     (setq dates (and org-display-custom-times
 		     (re-search-forward org-ts-regexp-both end t)))
     ;; Make sure the link properties are right
     (when links (goto-char beg) (while (org-activate-bracket-links end)))
     ;; Make sure the date properties are right
     (when dates (goto-char beg) (while (org-activate-dates end)))
+    (when emph (goto-char beg) (while (org-do-emphasis-faces end)))
 
     ;; Check if we are narrowing any columns
     (goto-char beg)
@@ -7923,13 +8367,14 @@
 
     ;; With invisible characters, `format' does not get the field width right
     ;; So we need to make these fields wide by hand.
-    (when links
+    (when (or links emph)
       (loop for i from 0 upto (1- maxfields) do
 	    (setq len (nth i lengths))
 	    (loop for j from 0 upto (1- (length fields)) do
 		  (setq c (nthcdr i (car (nthcdr j fields))))
 		  (if (and (stringp (car c))
-			   (string-match org-bracket-link-regexp (car c))
+			   (text-property-any 0 (length (car c)) 'invisible 'org-link (car c))
+;			   (string-match org-bracket-link-regexp (car c))
 			   (< (org-string-width (car c)) len))
 		      (setcar c (concat (car c) (make-string (- len (org-string-width (car c))) ?\ )))))))
 
@@ -8653,7 +9098,11 @@
     (skip-chars-backward "^|")
     (setq ecol (1- (current-column)))
     (org-table-goto-column column)
-    (setq lns (mapcar (lambda(x) (cons (org-trim (substring x bcol ecol)) x))
+    (setq lns (mapcar (lambda(x) (cons
+				  (org-sort-remove-invisible
+				   (nth (1- column)
+					(org-split-string x "[ \t]*|[ \t]*")))
+				  x))
 		      (org-split-string (buffer-substring beg end) "\n")))
     (setq lns (org-do-sort lns "Table" with-case sorting-type))
     (delete-region beg end)
@@ -8664,6 +9113,15 @@
     (org-table-goto-column thiscol)
     (message "%d lines sorted, based on column %d" (length lns) column)))
 
+;; FIXME: maybe we will not need this?  Table sorting is broken....
+(defun org-sort-remove-invisible (s)
+  (remove-text-properties 0 (length s) org-rm-props s)
+  (while (string-match org-bracket-link-regexp s)
+    (setq s (replace-match (if (match-end 2)
+			       (match-string 3 s)
+			     (match-string 1 s)) t t s)))
+  s)
+
 (defun org-table-cut-region (beg end)
   "Copy region in table to the clipboard and blank all relevant fields."
   (interactive "r")
@@ -9366,8 +9824,7 @@
 	  (goto-line l1)))
     (if (not (= epos (point-at-eol))) (org-table-align))
     (goto-line l)
-    (and (interactive-p)
-	 (message "%s" (or (cdr (assoc new org-recalc-marks)) "")))))
+    (and (interactive-p) (message "%s" (cdr (assoc new org-recalc-marks))))))
 
 (defun org-table-maybe-recalculate-line ()
   "Recompute the current line if marked for it, and if we haven't just done it."
@@ -10679,7 +11136,7 @@
 (defun orgtbl-error ()
   "Error when there is no default binding for a table key."
   (interactive)
-  (error "This key is has no function outside tables"))
+  (error "This key has no function outside tables"))
 
 (defun orgtbl-setup ()
   "Setup orgtbl keymaps."
@@ -11202,9 +11659,9 @@
                    %s for the original field value.  For example, to wrap
                    everything in @kbd{}, you could use :fmt \"@kbd{%s}\".
                    This may also be a property list with column numbers and
-                   formats. for example :fmt (2 \"@kbd{%s}\" 4 \"@code{%s}\").
-
-:cf \"f1 f2..\"    The column fractions for the table.  Bye default these
+                   formats. For example :fmt (2 \"@kbd{%s}\" 4 \"@code{%s}\").
+
+:cf \"f1 f2..\"    The column fractions for the table.  By default these
                    are computed automatically from the width of the columns
                    under org-mode.
 
@@ -11265,7 +11722,7 @@
 this link (for example by looking at the major mode).
 If not, it must exit and return nil.
 If yes, it should return a non-nil value after a calling
-`org-store-link-properties' with a list of properties and values.
+`org-store-link-props' with a list of properties and values.
 Special properties are:
 
 :type         The link prefix. like \"http\".  This must be given.
@@ -11285,8 +11742,9 @@
 an argument.
 FOLLOW should do whatever is necessary to follow the link, for example
 to find a file or display a mail message.
+
 PUBLISH takes the path and retuns the string that should be used when
-this document is published."
+this document is published. FIMXE: This is actually not yet implemented."
   (add-to-list 'org-link-types type t)
   (org-make-link-regexps)
   (add-to-list 'org-link-protocols
@@ -11374,10 +11832,10 @@
 	      (if (fboundp 'elmo-message-entity)
 		  (elmo-message-entity
 		   wl-summary-buffer-elmo-folder msgnum)
-		  (elmo-msgdb-overview-get-entity
-		   msgnum (wl-summary-buffer-msgdb))))
+		(elmo-msgdb-overview-get-entity
+		 msgnum (wl-summary-buffer-msgdb))))
 	     (from (wl-summary-line-from))
-	     (to (elmo-message-entity-field wl-message-entity 'to))
+	     (to (car (elmo-message-entity-field wl-message-entity 'to)))
 	     (subject (let (wl-thr-indent-string wl-parent-message-entity)
 			(wl-summary-line-subject))))
 	(org-store-link-props :type "wl" :from from :to to
@@ -11613,8 +12071,10 @@
     (error "Empty link"))
   (when (stringp description)
     ;; Remove brackets from the description, they are fatal.
-    (while (string-match "\\[\\|\\]" description)
-      (setq description (replace-match "" t t description))))
+    (while (string-match "\\[" description)
+      (setq description (replace-match "{" t t description)))
+    (while (string-match "\\]" description)
+      (setq description (replace-match "}" t t description))))
   (when (equal (org-link-escape link) description)
     ;; No description needed, it is identical
     (setq description nil))
@@ -11626,29 +12086,29 @@
 	  "]"))
 
 (defconst org-link-escape-chars
-  '((" " . "%20")
-    ("[" . "%5B")
-    ("]" . "%5d")
-    ("\340" . "%E0")  ; `a
-    ("\342" . "%E2")  ; ^a
-    ("\347" . "%E7")  ; ,c
-    ("\350" . "%E8")  ; `e
-    ("\351" . "%E9")  ; 'e
-    ("\352" . "%EA")  ; ^e
-    ("\356" . "%EE")  ; ^i
-    ("\364" . "%F4")  ; ^o
-    ("\371" . "%F9")  ; `u
-    ("\373" . "%FB")  ; ^u
-    (";" . "%3B")
-    ("?" . "%3F")
-    ("=" . "%3D")
-    ("+" . "%2B")
+  '((?\    . "%20")
+    (?\[   . "%5B")
+    (?\]   . "%5D")
+    (?\340 . "%E0")  ; `a
+    (?\342 . "%E2")  ; ^a
+    (?\347 . "%E7")  ; ,c
+    (?\350 . "%E8")  ; `e
+    (?\351 . "%E9")  ; 'e
+    (?\352 . "%EA")  ; ^e
+    (?\356 . "%EE")  ; ^i
+    (?\364 . "%F4")  ; ^o
+    (?\371 . "%F9")  ; `u
+    (?\373 . "%FB")  ; ^u
+    (?\;   . "%3B")
+    (??    . "%3F")
+    (?=    . "%3D")
+    (?+    . "%2B")
     )
   "Association list of escapes for some characters problematic in links.
 This is the list that is used for internal purposes.")
 
 (defconst org-link-escape-chars-browser
-  '((" " . "%20"))
+  '((?\  . "%20")) ; 32 for the SPC char
   "Association list of escapes for some characters problematic in links.
 This is the list that is used before handing over to the browser.")
 
@@ -11656,12 +12116,14 @@
   "Escape charaters in TEXT that are problematic for links."
   (setq table (or table org-link-escape-chars))
   (when text
-    (let ((re (mapconcat (lambda (x) (regexp-quote (car x)))
+    (let ((re (mapconcat (lambda (x) (regexp-quote
+				      (char-to-string (car x))))
 			 table "\\|")))
       (while (string-match re text)
 	(setq text
 	      (replace-match
-	       (cdr (assoc (match-string 0 text) table))
+	       (cdr (assoc (string-to-char (match-string 0 text))
+			   table))
 	       t t text)))
       text)))
 
@@ -11674,7 +12136,7 @@
       (while (string-match re text)
 	(setq text
 	      (replace-match
-	       (car (rassoc (match-string 0 text) table))
+	       (char-to-string (car (rassoc (match-string 0 text) table)))
 	       t t text)))
       text)))
 
@@ -11957,189 +12419,192 @@
 Normally, files will be opened by an appropriate application.  If the
 optional argument IN-EMACS is non-nil, Emacs will visit the file."
   (interactive "P")
-  (move-marker org-open-link-marker (point))
-  (setq org-window-config-before-follow-link (current-window-configuration))
-  (org-remove-occur-highlights nil nil t)
-  (if (org-at-timestamp-p t)
-      (org-follow-timestamp-link)
-    (let (type path link line search (pos (point)))
-      (catch 'match
-	(save-excursion
-	  (skip-chars-forward "^]\n\r")
-	  (when (org-in-regexp org-bracket-link-regexp)
-	    (setq link (org-link-unescape (org-match-string-no-properties 1)))
-	    (while (string-match " *\n *" link)
-	      (setq link (replace-match " " t t link)))
-	    (setq link (org-link-expand-abbrev link))
-	    (if (string-match org-link-re-with-space2 link)
-		(setq type (match-string 1 link) path (match-string 2 link))
-	      (setq type "thisfile" path link))
-	    (throw 'match t)))
-
-	(when (get-text-property (point) 'org-linked-text)
-	  (setq type "thisfile"
-		pos (if (get-text-property (1+ (point)) 'org-linked-text)
-			(1+ (point)) (point))
-		path (buffer-substring
-		      (previous-single-property-change pos 'org-linked-text)
-		      (next-single-property-change pos 'org-linked-text)))
-	  (throw 'match t))
-
-	(save-excursion
-	  (when (or (org-in-regexp org-angle-link-re)
-		    (org-in-regexp org-plain-link-re))
-	    (setq type (match-string 1) path (match-string 2))
-	    (throw 'match t)))
-	(when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
-	  (setq type "tree-match"
-		path (match-string 1))
-	  (throw 'match t))
-	(save-excursion
-	  (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
-	    (setq type "tags"
+  (catch 'abort
+    (move-marker org-open-link-marker (point))
+    (setq org-window-config-before-follow-link (current-window-configuration))
+    (org-remove-occur-highlights nil nil t)
+    (if (org-at-timestamp-p t)
+	(org-follow-timestamp-link)
+      (let (type path link line search (pos (point)))
+	(catch 'match
+	  (save-excursion
+	    (skip-chars-forward "^]\n\r")
+	    (when (org-in-regexp org-bracket-link-regexp)
+	      (setq link (org-link-unescape (org-match-string-no-properties 1)))
+	      (while (string-match " *\n *" link)
+		(setq link (replace-match " " t t link)))
+	      (setq link (org-link-expand-abbrev link))
+	      (if (string-match org-link-re-with-space2 link)
+		  (setq type (match-string 1 link) path (match-string 2 link))
+		(setq type "thisfile" path link))
+	      (throw 'match t)))
+
+	  (when (get-text-property (point) 'org-linked-text)
+	    (setq type "thisfile"
+		  pos (if (get-text-property (1+ (point)) 'org-linked-text)
+			  (1+ (point)) (point))
+		  path (buffer-substring
+			(previous-single-property-change pos 'org-linked-text)
+			(next-single-property-change pos 'org-linked-text)))
+	    (throw 'match t))
+
+	  (save-excursion
+	    (when (or (org-in-regexp org-angle-link-re)
+		      (org-in-regexp org-plain-link-re))
+	      (setq type (match-string 1) path (match-string 2))
+	      (throw 'match t)))
+	  (when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
+	    (setq type "tree-match"
 		  path (match-string 1))
-	    (while (string-match ":" path)
-	      (setq path (replace-match "+" t t path)))
-	    (throw 'match t))))
-      (unless path
-	(error "No link found"))
-      ;; Remove any trailing spaces in path
-      (if (string-match " +\\'" path)
-	  (setq path (replace-match "" t t path)))
-
-      (cond
-
-       ((assoc type org-link-protocols)
-	(funcall (nth 1 (assoc type org-link-protocols)) path))
-
-       ((equal type "mailto")
-	(let ((cmd (car org-link-mailto-program))
-	      (args (cdr org-link-mailto-program)) args1
-	      (address path) (subject "") a)
-	  (if (string-match "\\(.*\\)::\\(.*\\)" path)
-	      (setq address (match-string 1 path)
-		    subject (org-link-escape (match-string 2 path))))
-	  (while args
-	    (cond
-	     ((not (stringp (car args))) (push (pop args) args1))
-	     (t (setq a (pop args))
-		(if (string-match "%a" a)
-		    (setq a (replace-match address t t a)))
-		(if (string-match "%s" a)
-		    (setq a (replace-match subject t t a)))
-		(push a args1))))
-	  (apply cmd (nreverse args1))))
-
-       ((member type '("http" "https" "ftp" "news"))
-	(browse-url (concat type ":" (org-link-escape
-				      path org-link-escape-chars-browser))))
-
-       ((string= type "tags")
-	(org-tags-view in-emacs path))
-       ((string= type "thisfile")
-	(if in-emacs
-	    (switch-to-buffer-other-window
-	     (org-get-buffer-for-internal-link (current-buffer)))
-	  (org-mark-ring-push))
-	(let ((cmd `(org-link-search
-		     ,path
-		     ,(cond ((equal in-emacs '(4)) 'occur)
-			    ((equal in-emacs '(16)) 'org-occur)
-			    (t nil))
-		     ,pos)))
-	  (condition-case nil (eval cmd)
-	    (error (progn (widen) (eval cmd))))))
-
-       ((string= type "tree-match")
-	(org-occur (concat "\\[" (regexp-quote path) "\\]")))
-
-       ((string= type "file")
-	(if (string-match "::\\([0-9]+\\)\\'" path)
-	    (setq line (string-to-number (match-string 1 path))
-		  path (substring path 0 (match-beginning 0)))
-	  (if (string-match "::\\(.+\\)\\'" path)
-	      (setq search (match-string 1 path)
-		    path (substring path 0 (match-beginning 0)))))
-	(org-open-file path in-emacs line search))
-
-       ((string= type "news")
-	(org-follow-gnus-link path))
-
-       ((string= type "bbdb")
-	(org-follow-bbdb-link path))
-
-       ((string= type "info")
-	(org-follow-info-link path))
-
-       ((string= type "gnus")
-	(let (group article)
-	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-	      (error "Error in Gnus link"))
-	  (setq group (match-string 1 path)
-		article (match-string 3 path))
-	  (org-follow-gnus-link group article)))
-
-       ((string= type "vm")
-	(let (folder article)
-	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-	      (error "Error in VM link"))
-	  (setq folder (match-string 1 path)
-		article (match-string 3 path))
-	  ;; in-emacs is the prefix arg, will be interpreted as read-only
-	  (org-follow-vm-link folder article in-emacs)))
-
-       ((string= type "wl")
-	(let (folder article)
-	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-	      (error "Error in Wanderlust link"))
-	  (setq folder (match-string 1 path)
-		article (match-string 3 path))
-	  (org-follow-wl-link folder article)))
-
-       ((string= type "mhe")
-	(let (folder article)
-	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-	      (error "Error in MHE link"))
-	  (setq folder (match-string 1 path)
-		article (match-string 3 path))
-	  (org-follow-mhe-link folder article)))
-
-       ((string= type "rmail")
-	(let (folder article)
-	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-	      (error "Error in RMAIL link"))
-	  (setq folder (match-string 1 path)
-		article (match-string 3 path))
-	  (org-follow-rmail-link folder article)))
-
-       ((string= type "shell")
-	(let ((cmd path))
-	  ;; The following is only for backward compatibility
-	  (while (string-match "@{" cmd) (setq cmd (replace-match "<" t t cmd)))
-	  (while (string-match "@}" cmd) (setq cmd (replace-match ">" t t cmd)))
-	  (if (or (not org-confirm-shell-link-function)
-		  (funcall org-confirm-shell-link-function
-			   (format "Execute \"%s\" in shell? "
-				   (org-add-props cmd nil
-				     'face 'org-warning))))
-	      (progn
-		(message "Executing %s" cmd)
-		(shell-command cmd))
-	    (error "Abort"))))
-
-       ((string= type "elisp")
-	(let ((cmd path))
-	  (if (or (not org-confirm-elisp-link-function)
-		  (funcall org-confirm-elisp-link-function
-			   (format "Execute \"%s\" as elisp? "
-				   (org-add-props cmd nil
-						  'face 'org-warning))))
-              (message "%s => %s" cmd (eval (read cmd)))
-	    (error "Abort"))))
-
-       (t
-	(browse-url-at-point)))))
-  (move-marker org-open-link-marker nil))
+	    (throw 'match t))
+	  (save-excursion
+	    (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
+	      (setq type "tags"
+		    path (match-string 1))
+	      (while (string-match ":" path)
+		(setq path (replace-match "+" t t path)))
+	      (throw 'match t))))
+	(unless path
+	  (error "No link found"))
+	;; Remove any trailing spaces in path
+	(if (string-match " +\\'" path)
+	    (setq path (replace-match "" t t path)))
+
+	(cond
+
+	 ((assoc type org-link-protocols)
+	  (funcall (nth 1 (assoc type org-link-protocols)) path))
+
+	 ((equal type "mailto")
+	  (let ((cmd (car org-link-mailto-program))
+		(args (cdr org-link-mailto-program)) args1
+		(address path) (subject "") a)
+	    (if (string-match "\\(.*\\)::\\(.*\\)" path)
+		(setq address (match-string 1 path)
+		      subject (org-link-escape (match-string 2 path))))
+	    (while args
+	      (cond
+	       ((not (stringp (car args))) (push (pop args) args1))
+	       (t (setq a (pop args))
+		  (if (string-match "%a" a)
+		      (setq a (replace-match address t t a)))
+		  (if (string-match "%s" a)
+		      (setq a (replace-match subject t t a)))
+		  (push a args1))))
+	    (apply cmd (nreverse args1))))
+
+	 ((member type '("http" "https" "ftp" "news"))
+	  (browse-url (concat type ":" (org-link-escape
+					path org-link-escape-chars-browser))))
+
+	 ((member type '("message"))
+	  (browse-url (concat type ":" path)))
+
+	 ((string= type "tags")
+	  (org-tags-view in-emacs path))
+	 ((string= type "thisfile")
+	  (if in-emacs
+	      (switch-to-buffer-other-window
+	       (org-get-buffer-for-internal-link (current-buffer)))
+	    (org-mark-ring-push))
+	  (let ((cmd `(org-link-search
+		       ,path
+		       ,(cond ((equal in-emacs '(4)) 'occur)
+			      ((equal in-emacs '(16)) 'org-occur)
+			      (t nil))
+		       ,pos)))
+	    (condition-case nil (eval cmd)
+	      (error (progn (widen) (eval cmd))))))
+
+	 ((string= type "tree-match")
+	  (org-occur (concat "\\[" (regexp-quote path) "\\]")))
+
+	 ((string= type "file")
+	  (if (string-match "::\\([0-9]+\\)\\'" path)
+	      (setq line (string-to-number (match-string 1 path))
+		    path (substring path 0 (match-beginning 0)))
+	    (if (string-match "::\\(.+\\)\\'" path)
+		(setq search (match-string 1 path)
+		      path (substring path 0 (match-beginning 0)))))
+	  (if (string-match "[*?{]" (file-name-nondirectory path))
+	      (dired path)
+	    (org-open-file path in-emacs line search)))
+
+	 ((string= type "news")
+	  (org-follow-gnus-link path))
+
+	 ((string= type "bbdb")
+	  (org-follow-bbdb-link path))
+
+	 ((string= type "info")
+	  (org-follow-info-link path))
+
+	 ((string= type "gnus")
+	  (let (group article)
+	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+		(error "Error in Gnus link"))
+	    (setq group (match-string 1 path)
+		  article (match-string 3 path))
+	    (org-follow-gnus-link group article)))
+
+	 ((string= type "vm")
+	  (let (folder article)
+	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+		(error "Error in VM link"))
+	    (setq folder (match-string 1 path)
+		  article (match-string 3 path))
+	    ;; in-emacs is the prefix arg, will be interpreted as read-only
+	    (org-follow-vm-link folder article in-emacs)))
+
+	 ((string= type "wl")
+	  (let (folder article)
+	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+		(error "Error in Wanderlust link"))
+	    (setq folder (match-string 1 path)
+		  article (match-string 3 path))
+	    (org-follow-wl-link folder article)))
+
+	 ((string= type "mhe")
+	  (let (folder article)
+	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+		(error "Error in MHE link"))
+	    (setq folder (match-string 1 path)
+		  article (match-string 3 path))
+	    (org-follow-mhe-link folder article)))
+
+	 ((string= type "rmail")
+	  (let (folder article)
+	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+		(error "Error in RMAIL link"))
+	    (setq folder (match-string 1 path)
+		  article (match-string 3 path))
+	    (org-follow-rmail-link folder article)))
+
+	 ((string= type "shell")
+	  (let ((cmd path))
+	    (if (or (not org-confirm-shell-link-function)
+		    (funcall org-confirm-shell-link-function
+			     (format "Execute \"%s\" in shell? "
+				     (org-add-props cmd nil
+						    'face 'org-warning))))
+		(progn
+		  (message "Executing %s" cmd)
+		  (shell-command cmd))
+	      (error "Abort"))))
+
+	 ((string= type "elisp")
+	  (let ((cmd path))
+	    (if (or (not org-confirm-elisp-link-function)
+		    (funcall org-confirm-elisp-link-function
+			     (format "Execute \"%s\" as elisp? "
+				     (org-add-props cmd nil
+						    'face 'org-warning))))
+		(message "%s => %s" cmd (eval (read cmd)))
+	      (error "Abort"))))
+
+	 (t
+	  (browse-url-at-point)))))
+    (move-marker org-open-link-marker nil)))
 
 ;;; File search
 
@@ -12575,8 +13040,8 @@
       (mh-show-buffer-message-number))))
 
 (defun org-mhe-get-header (header)
-  "Return a header of the message in folder mode. This will create a
-show buffer for the corresponding message. If you have a more clever
+  "Return a header of the message in folder mode.  This will create a
+show buffer for the corresponding message.  If you have a more clever
 idea..."
   (let* ((folder (org-mhe-get-message-folder))
          (num (org-mhe-get-message-num))
@@ -12727,9 +13192,10 @@
     (cond
      ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
       ;; Remove quotes around the file name - we'll use shell-quote-argument.
-      (if (string-match "['\"]%s['\"]" cmd)
-	  (setq cmd (replace-match "%s" t t cmd)))
-      (setq cmd (format cmd (shell-quote-argument file)))
+      (while (string-match "['\"]%s['\"]" cmd)
+	(setq cmd (replace-match "%s" t t cmd)))
+      (while (string-match "%s" cmd)
+	(setq cmd (replace-match (shell-quote-argument file) t t cmd)))
       (save-window-excursion
 	(start-process-shell-command cmd nil cmd)))
      ((or (stringp cmd)
@@ -12772,7 +13238,18 @@
         (t nil)))
 
 
-;;;; Hooks for remember.el
+;;;; Hooks for remember.el, and refiling
+
+(defvar annotation) ; from remember.el, dynamically scoped in `remember-mode'
+(defvar initial)    ; from remember.el, dynamically scoped in `remember-mode'
+
+;;;###autoload
+(defun org-remember-insinuate ()
+  "Setup remember.el for use wiht Org-mode."
+  (require 'remember)
+  (setq remember-annotation-functions '(org-remember-annotation))
+  (setq remember-handler-functions '(org-remember-handler))
+  (add-hook 'remember-mode-hook 'org-remember-apply-template))
 
 ;;;###autoload
 (defun org-remember-annotation ()
@@ -12792,44 +13269,54 @@
 (defvar org-remember-previous-location nil)
 (defvar org-force-remember-template-char) ;; dynamically scoped
 
+(defun org-select-remember-template (&optional use-char)
+  (when org-remember-templates
+    (let* ((templates (mapcar (lambda (x)
+				(if (stringp (car x))
+				    (append (list (nth 1 x) (car x)) (cddr x))
+				  (append (list (car x) "") (cdr x))))
+			      org-remember-templates))
+	   (char (or use-char
+		     (cond
+		      ((= (length templates) 1)
+		       (caar templates))
+		      ((and (boundp 'org-force-remember-template-char)
+			    org-force-remember-template-char)
+		       (if (stringp org-force-remember-template-char)
+			   (string-to-char org-force-remember-template-char)
+			 org-force-remember-template-char))
+		      (t
+		       (message "Select template: %s"
+				(mapconcat
+				 (lambda (x)
+				   (cond
+				    ((not (string-match "\\S-" (nth 1 x)))
+				     (format "[%c]" (car x)))
+				    ((equal (downcase (car x))
+					    (downcase (aref (nth 1 x) 0)))
+				     (format "[%c]%s" (car x)
+					     (substring (nth 1 x) 1)))
+				    (t (format "[%c]%s" (car x) (nth 1 x)))))
+				 templates " "))
+		       (let ((inhibit-quit t) (char0 (read-char-exclusive)))
+			 (when (equal char0 ?\C-g)
+			   (jump-to-register remember-register)
+			   (kill-buffer remember-buffer))
+			 char0))))))
+      (cddr (assoc char templates)))))
+
+(defvar x-last-selected-text)
+(defvar x-last-selected-text-primary)
+
 ;;;###autoload
 (defun org-remember-apply-template (&optional use-char skip-interactive)
   "Initialize *remember* buffer with template, invoke `org-mode'.
 This function should be placed into `remember-mode-hook' and in fact requires
-to be run from that hook to fucntion properly."
+to be run from that hook to function properly."
+  (unless (fboundp 'remember-finalize)
+    (defalias 'remember-finalize 'remember-buffer))
   (if org-remember-templates
-      (let* ((templates (mapcar (lambda (x)
-				  (if (stringp (car x))
-				      (append (list (nth 1 x) (car x)) (cddr x))
-				    (append (list (car x) "") (cdr x))))
-				org-remember-templates))
-	     (char (or use-char
-		       (cond
-			((= (length templates) 1)
-			 (caar templates))
-			((and (boundp 'org-force-remember-template-char)
-			      org-force-remember-template-char)
-			 (if (stringp org-force-remember-template-char)
-			     (string-to-char org-force-remember-template-char)
-			   org-force-remember-template-char))
-			(t
-			 (message "Select template: %s"
-				  (mapconcat
-				   (lambda (x)
-				     (cond
-				      ((not (string-match "\\S-" (nth 1 x)))
-				       (format "[%c]" (car x)))
-				      ((equal (downcase (car x))
-					      (downcase (aref (nth 1 x) 0)))
-				       (format "[%c]%s" (car x) (substring (nth 1 x) 1)))
-				      (t (format "[%c]%s" (car x) (nth 1 x)))))
-				   templates " "))
-			 (let ((inhibit-quit t) (char0 (read-char-exclusive)))
-			   (when (equal char0 ?\C-g)
-			     (jump-to-register remember-register)
-			     (kill-buffer remember-buffer))
-			   char0)))))
-	     (entry (cddr (assoc char templates)))
+      (let* ((entry (org-select-remember-template use-char))
 	     (tpl (car entry))
 	     (plist-p (if org-store-link-plist t nil))
 	     (file (if (and (nth 1 entry) (stringp (nth 1 entry))
@@ -12837,6 +13324,12 @@
 		       (nth 1 entry)
 		     org-default-notes-file))
 	     (headline (nth 2 entry))
+	     (v-c (or (and (eq window-system 'x)
+			   (fboundp 'x-cut-buffer-or-selection-value)
+			   (x-cut-buffer-or-selection-value))
+		      (org-bound-and-true-p x-last-selected-text)
+		      (org-bound-and-true-p x-last-selected-text-primary)
+		      (and (> (length kill-ring) 0) (current-kill 0))))
 	     (v-t (format-time-string (car org-time-stamp-formats) (org-current-time)))
 	     (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time)))
 	     (v-u (concat "[" (substring v-t 1 -1) "]"))
@@ -12852,11 +13345,12 @@
 		    v-a))
 	     (v-n user-full-name)
 	     (org-startup-folded nil)
-	     org-time-was-given org-end-time-was-given x prompt char time)
+	     org-time-was-given org-end-time-was-given x
+	     prompt completions char time pos default histvar)
 	(setq org-store-link-plist
 	      (append (list :annotation v-a :initial v-i)
 		      org-store-link-plist))
-	(unless tpl (setq tpl "")	(message "No template") (ding))
+	(unless tpl (setq tpl "") (message "No template") (ding) (sit-for 1))
 	(erase-buffer)
 	(insert (substitute-command-keys
 		 (format
@@ -12873,7 +13367,7 @@
 		  (or (cdr org-remember-previous-location) "???"))))
 	(insert tpl) (goto-char (point-min))
 	;; Simple %-escapes
-	(while (re-search-forward "%\\([tTuUaiA]\\)" nil t)
+	(while (re-search-forward "%\\([tTuUaiAc]\\)" nil t)
 	  (when (and initial (equal (match-string 0) "%i"))
 	    (save-match-data
 	      (let* ((lead (buffer-substring
@@ -12884,16 +13378,43 @@
 	  (replace-match
 	   (or (eval (intern (concat "v-" (match-string 1)))) "")
 	   t t))
+
+	;; %[] Insert contents of a file.
+	(goto-char (point-min))
+	(while (re-search-forward "%\\[\\(.+\\)\\]" nil t)
+	  (let ((start (match-beginning 0))
+		(end (match-end 0))
+		(filename (expand-file-name (match-string 1))))
+	    (goto-char start)
+	    (delete-region start end)
+	    (condition-case error
+		(insert-file-contents filename)
+	      (error (insert (format "%%![Couldn't insert %s: %s]"
+				     filename error))))))
+	;; %() embedded elisp
+	(goto-char (point-min))
+	(while (re-search-forward "%\\((.+)\\)" nil t)
+	  (goto-char (match-beginning 0))
+	  (let ((template-start (point)))
+	    (forward-char 1)
+	    (let ((result
+		   (condition-case error
+		       (eval (read (current-buffer)))
+		     (error (format "%%![Error: %s]" error)))))
+	      (delete-region template-start (point))
+	      (insert result))))
+
 	;; From the property list
 	(when plist-p
 	  (goto-char (point-min))
 	  (while (re-search-forward "%\\(:[-a-zA-Z]+\\)" nil t)
-	    (and (setq x (plist-get org-store-link-plist
-				    (intern (match-string 1))))
+	    (and (setq x (or (plist-get org-store-link-plist
+					(intern (match-string 1))) ""))
 		 (replace-match x t t))))
+
 	;; Turn on org-mode in the remember buffer, set local variables
 	(org-mode)
-	(org-set-local 'org-finish-function 'remember-buffer)
+	(org-set-local 'org-finish-function 'remember-finalize)
 	(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
 	    (org-set-local 'org-default-notes-file file))
 	(if (and headline (stringp headline) (string-match "\\S-" headline))
@@ -12905,6 +13426,15 @@
 		prompt (if (match-end 2) (match-string 2)))
 	  (goto-char (match-beginning 0))
 	  (replace-match "")
+	  (setq completions nil default nil)
+	  (when prompt
+	    (setq completions (org-split-string prompt "|")
+		  prompt (pop completions)
+		  default (car completions)
+		  histvar (intern (concat
+				   "org-remember-template-prompt-history::"
+				   (or prompt "")))
+		  completions (mapcar 'list completions)))
 	  (cond
 	   ((member char '("G" "g"))
 	    (let* ((org-last-tags-completion-table
@@ -12930,33 +13460,92 @@
 				   (member char '("u" "U"))
 				   nil nil (list org-end-time-was-given)))
 	   (t
-	    (insert (read-string
-		     (if prompt (concat prompt ": ") "Enter string"))))))
+	    (insert (org-completing-read
+		     (concat (if prompt prompt "Enter string")
+			     (if default (concat " [" default "]"))
+			     ": ")
+		     completions nil nil nil histvar default)))))
 	(goto-char (point-min))
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")
 	  (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
     (org-mode)
-    (org-set-local 'org-finish-function 'remember-buffer)))
+    (org-set-local 'org-finish-function 'remember-finalize))
+  (when (save-excursion
+	  (goto-char (point-min))
+	  (re-search-forward "%!" nil t))
+    (replace-match "")
+    (add-hook 'post-command-hook 'org-remember-finish-immediately 'append)))
+
+(defun org-remember-finish-immediately ()
+  "File remember note immediately.
+This should be run in `post-command-hook' and will remove itself
+from that hook."
+  (remove-hook 'post-command-hook 'org-remember-finish-immediately)
+  (when org-finish-function
+    (funcall org-finish-function)))
+
 
 ;;;###autoload
-(defun org-remember (&optional org-force-remember-template-char)
+(defun org-remember (&optional goto org-force-remember-template-char)
   "Call `remember'.  If this is already a remember buffer, re-apply template.
 If there is an active region, make sure remember uses it as initial content
-of the remember buffer."
-  (interactive)
-  (if (eq org-finish-function 'remember-buffer)
-      (progn
-	(when (< (length org-remember-templates) 2)
-	  (error "No other template available"))
-	(erase-buffer)
-	(let ((annotation (plist-get org-store-link-plist :annotation))
-	      (initial (plist-get org-store-link-plist :initial)))
-	  (org-remember-apply-template))
-	(message "Press C-c C-c to remember data"))
-    (if (org-region-active-p)
-	(remember (buffer-substring (point) (mark)))
-      (call-interactively 'remember))))
+of the remember buffer.
+
+When called interactively with a `C-u' prefix argument GOTO, don't remember
+anything, just go to the file/headline where the selected template usually
+stores its notes.  With a double prefix arg `C-u C-u', go to the last
+note stored by remember.
+
+Lisp programs can set ORG-FORCE-REMEMBER-TEMPLATE-CHAR to a character
+associated with a template in `org-remember-templates'."
+  (interactive "P")
+  (cond
+   ((equal goto '(4)) (org-go-to-remember-target))
+   ((equal goto '(16)) (org-remember-goto-last-stored))
+   (t
+    (if (memq org-finish-function '(remember-buffer remember-finalize))
+	(progn
+	  (when (< (length org-remember-templates) 2)
+	    (error "No other template available"))
+	  (erase-buffer)
+	  (let ((annotation (plist-get org-store-link-plist :annotation))
+		(initial (plist-get org-store-link-plist :initial)))
+	    (org-remember-apply-template))
+	  (message "Press C-c C-c to remember data"))
+      (if (org-region-active-p)
+	  (remember (buffer-substring (point) (mark)))
+	(call-interactively 'remember))))))
+
+(defun org-remember-goto-last-stored ()
+  "Go to the location where the last remember note was stored."
+  (interactive)
+  (bookmark-jump "org-remember-last-stored")
+  (message "This is the last note stored by remember"))
+
+(defun org-go-to-remember-target (&optional template-key)
+  "Go to the target location of a remember template.
+The user is queried for the template."
+  (interactive)
+  (let* ((entry (org-select-remember-template template-key))
+	 (file (nth 1 entry))
+	 (heading (nth 2 entry))
+	 visiting)
+    (unless (and file (stringp file) (string-match "\\S-" file))
+      (setq file org-default-notes-file))
+    (unless (and heading (stringp heading) (string-match "\\S-" heading))
+      (setq heading org-remember-default-headline))
+    (setq visiting (org-find-base-buffer-visiting file))
+    (if (not visiting) (find-file-noselect file))
+    (switch-to-buffer (or visiting (get-file-buffer file)))
+    (widen)
+    (goto-char (point-min))
+    (if (re-search-forward
+	 (concat "^\\*+[ \t]+" (regexp-quote heading)
+		 (org-re "\\([ \t]+:[[:alnum:]@_:]*\\)?[ \t]*$"))
+	 nil t)
+	(goto-char (match-beginning 0))
+      (error "Target headline not found: %s" heading))))
 
 (defvar org-note-abort nil) ; dynamically scoped
 
@@ -13000,23 +13589,34 @@
   (while (looking-at "^[ \t]*\n\\|^##.*\n")
     (replace-match ""))
   (goto-char (point-max))
-  (unless (equal (char-before) ?\n) (insert "\n"))
+  (beginning-of-line 1)
+  (while (looking-at "[ \t]*$\\|##.*")
+    (delete-region (1- (point)) (point-max))
+    (beginning-of-line 1))
   (catch 'quit
     (if org-note-abort (throw 'quit nil))
     (let* ((txt (buffer-substring (point-min) (point-max)))
 	   (fastp (org-xor (equal current-prefix-arg '(4))
 			   org-remember-store-without-prompt))
-	   (file (if fastp org-default-notes-file (org-get-org-file)))
+	   (file (cond
+		  (fastp org-default-notes-file)
+		  ((and org-remember-use-refile-when-interactive
+			org-refile-targets)
+		   org-default-notes-file)
+		  (t (org-get-org-file))))
 	   (heading org-remember-default-headline)
-	   (visiting (org-find-base-buffer-visiting file))
+	   (visiting (and file (org-find-base-buffer-visiting file)))
 	   (org-startup-folded nil)
 	   (org-startup-align-all-tables nil)
 	   (org-goto-start-pos 1)
 	   spos exitcmd level indent reversed)
       (if (and (equal current-prefix-arg '(16)) org-remember-previous-location)
 	  (setq file (car org-remember-previous-location)
-		heading (cdr org-remember-previous-location)))
+		heading (cdr org-remember-previous-location)
+		fastp t))
       (setq current-prefix-arg nil)
+      (if (string-match "[ \t\n]+\\'" txt)
+	  (setq txt (replace-match "" t t txt)))
       ;; Modify text so that it becomes a nice subtree which can be inserted
       ;; into an org tree.
       (let* ((lines (split-string txt "\n"))
@@ -13031,9 +13631,25 @@
 			      " (" (remember-buffer-desc) ")")
 		indent "  "))
 	(if (and org-adapt-indentation indent)
-	    (setq lines (mapcar (lambda (x) (concat indent x)) lines)))
+	    (setq lines (mapcar
+			 (lambda (x)
+			   (if (string-match "\\S-" x)
+			       (concat indent x) x))
+			 lines)))
 	(setq txt (concat first "\n"
 			  (mapconcat 'identity lines "\n"))))
+      (if (string-match "\n[ \t]*\n[ \t\n]*\\'" txt)
+	  (setq txt (replace-match "\n\n" t t txt))
+	(if (string-match "[ \t\n]*\\'" txt)
+	    (setq txt (replace-match "\n" t t txt))))
+      ;; Put the modified text back into the remember buffer, for refile.
+      (erase-buffer)
+      (insert txt)
+      (goto-char (point-min))
+      (when (and org-remember-use-refile-when-interactive
+		 (not fastp))
+	(org-refile nil (or visiting (find-file-noselect file)))
+	(throw 'quit t))
       ;; Find the file
       (if (not visiting) (find-file-noselect file))
       (with-current-buffer (or visiting (get-file-buffer file))
@@ -13082,19 +13698,22 @@
 				 (org-get-heading 'notags)))
 		     (if reversed
 			 (outline-next-heading)
-		       (org-end-of-subtree)
+		       (org-end-of-subtree t)
 		       (if (not (bolp))
 			   (if (looking-at "[ \t]*\n")
 			       (beginning-of-line 2)
 			     (end-of-line 1)
 			     (insert "\n"))))
+		     (bookmark-set "org-remember-last-stored")
 		     (org-paste-subtree (org-get-legal-level level 1) txt))
 		    ((eq exitcmd 'left)
 		     ;; before current
+		     (bookmark-set "org-remember-last-stored")
 		     (org-paste-subtree level txt))
 		    ((eq exitcmd 'right)
 		     ;; after current
 		     (org-end-of-subtree t)
+		     (bookmark-set "org-remember-last-stored")
 		     (org-paste-subtree level txt))
 		    (t (error "This should not happen"))))
 
@@ -13104,6 +13723,7 @@
 		     (widen)
 		     (goto-char (point-max))
 		     (if (not (bolp)) (newline))
+		     (bookmark-set "org-remember-last-stored")
 		     (org-paste-subtree (org-get-legal-level 1 1) txt)))
 
 		  ((and (bobp) reversed)
@@ -13113,16 +13733,19 @@
 		     (goto-char (point-min))
 		     (re-search-forward "^\\*+ " nil t)
 		     (beginning-of-line 1)
+		     (bookmark-set "org-remember-last-stored")
 		     (org-paste-subtree 1 txt)))
 		  (t
 		   ;; Put it right there, with automatic level determined by
 		   ;; org-paste-subtree or from prefix arg
+		   (bookmark-set "org-remember-last-stored")
 		   (org-paste-subtree
 		    (if (numberp current-prefix-arg) current-prefix-arg)
 		    txt)))
 	    (when remember-save-after-remembering
 	      (save-buffer)
 	      (if (not visiting) (kill-buffer (current-buffer)))))))))
+
   t)    ;; return t to indicate that we took care of this note.
 
 (defun org-get-org-file ()
@@ -13146,6 +13769,160 @@
 		(throw 'exit (cdr entry))))
 	  nil)))))
 
+;;; Refiling
+
+(defvar org-refile-target-table nil
+  "The list of refile targets, created by `org-refile'.")
+
+(defvar org-agenda-new-buffers nil
+  "Buffers created to visit agenda files.")
+
+(defun org-get-refile-targets (&optional default-buffer)
+  "Produce a table with refile targets."
+  (let ((entries (or org-refile-targets '((nil . (:level . 1)))))
+	org-agenda-new-buffers targets txt re files f desc descre)
+    (with-current-buffer (or default-buffer (current-buffer))
+      (while (setq entry (pop entries))
+	(setq files (car entry) desc (cdr entry))
+	(cond
+	 ((null files) (setq files (list (current-buffer))))
+	 ((eq files 'org-agenda-files)
+	  (setq files (org-agenda-files 'unrestricted)))
+	 ((and (symbolp files) (fboundp files))
+	  (setq files (funcall files)))
+	 ((and (symbolp files) (boundp files))
+	  (setq files (symbol-value files))))
+	(if (stringp files) (setq files (list files)))
+	(cond
+	 ((eq (car desc) :tag)
+	  (setq descre (concat "^\\*+[ \t]+.*?:" (regexp-quote (cdr desc)) ":")))
+	 ((eq (car desc) :todo)
+	  (setq descre (concat "^\\*+[ \t]+" (regexp-quote (cdr desc)) "[ \t]")))
+	 ((eq (car desc) :regexp)
+	  (setq descre (cdr desc)))
+	 ((eq (car desc) :level)
+	  (setq descre (concat "^\\*\\{" (number-to-string
+					  (if org-odd-levels-only
+					      (1- (* 2 (cdr desc)))
+					    (cdr desc)))
+			       "\\}[ \t]")))
+	 ((eq (car desc) :maxlevel)
+	  (setq descre (concat "^\\*\\{1," (number-to-string
+					    (if org-odd-levels-only
+						(1- (* 2 (cdr desc)))
+					      (cdr desc)))
+			       "\\}[ \t]")))
+	 (t (error "Bad refiling target description %s" desc)))
+	(while (setq f (pop files))
+	  (save-excursion
+	    (set-buffer (if (bufferp f) f (org-get-agenda-file-buffer f)))
+	    (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f))))
+	    (save-excursion
+	      (save-restriction
+		(widen)
+		(goto-char (point-min))
+		(while (re-search-forward descre nil t)
+		  (goto-char (point-at-bol))
+		  (when (looking-at org-complex-heading-regexp)
+		    (setq txt (match-string 4)
+			  re (concat "^" (regexp-quote
+					  (buffer-substring (match-beginning 1)
+							    (match-end 4)))))
+		    (if (match-end 5) (setq re (concat re "[ \t]+"
+						       (regexp-quote
+							(match-string 5)))))
+		    (setq re (concat re "[ \t]*$"))
+		    (when org-refile-use-outline-path
+		      (setq txt (mapconcat 'identity
+					   (append
+					    (if (eq org-refile-use-outline-path 'file)
+						(list (file-name-nondirectory
+						       (buffer-file-name (buffer-base-buffer))))
+					      (if (eq org-refile-use-outline-path 'full-file-path)
+						  (list (buffer-file-name (buffer-base-buffer)))))
+					    (org-get-outline-path)
+					    (list txt))
+					   "/")))
+		    (push (list txt f re (point)) targets))
+		  (goto-char (point-at-eol))))))))
+      (org-release-buffers org-agenda-new-buffers)
+      (nreverse targets))))
+
+(defun org-get-outline-path ()
+  (let (rtn)
+    (save-excursion
+      (while (org-up-heading-safe)
+	(when (looking-at org-complex-heading-regexp)
+	  (push (org-match-string-no-properties 4) rtn)))
+      rtn)))
+
+(defvar org-refile-history nil
+  "History for refiling operations.")
+
+(defun org-refile (&optional reversed-or-update default-buffer)
+  "Move the entry at point to another heading.
+The list of target headings is compiled using the information in
+`org-refile-targets', which see.  This list is created upon first use, and
+you can update it by calling this command with a double prefix (`C-u C-u').
+FIXME: Can we find a better way of updating?
+
+At the target location, the entry is filed as a subitem of the target heading.
+Depending on `org-reverse-note-order', the new subitem will either be the
+first of the last subitem.  A single C-u prefix will toggle the value of this
+variable for the duration of the command."
+  (interactive "P")
+  (if (equal reversed-or-update '(16))
+      (progn
+	(setq org-refile-target-table (org-get-refile-targets default-buffer))
+	(message "Refile targets updated (%d targets)"
+		 (length org-refile-target-table)))
+    (when (or (not org-refile-target-table)
+	      (assq nil org-refile-targets))
+      (setq org-refile-target-table (org-get-refile-targets default-buffer)))
+    (unless org-refile-target-table
+      (error "No refile targets"))
+    (let* ((cbuf (current-buffer))
+	   (filename (buffer-file-name (buffer-base-buffer cbuf)))
+	   (fname (and filename (file-truename filename)))
+	   (tbl (mapcar
+		 (lambda (x)
+		   (if (not (equal fname (file-truename (nth 1 x))))
+		       (cons (concat (car x) " (" (file-name-nondirectory
+						   (nth 1 x)) ")")
+			     (cdr x))
+		     x))
+		 org-refile-target-table))
+	   (completion-ignore-case t)
+	   pos it nbuf file re level reversed)
+      (when (setq it (completing-read "Refile to: " tbl
+				      nil t nil 'org-refile-history))
+	(setq it (assoc it tbl)
+	      file (nth 1 it)
+	      re (nth 2 it))
+	(org-copy-special)
+	(save-excursion
+	  (set-buffer (setq nbuf (or (find-buffer-visiting file)
+				     (find-file-noselect file))))
+	  (setq reversed (org-notes-order-reversed-p))
+	  (if (equal reversed-or-update '(16)) (setq reversed (not reversed)))
+	  (save-excursion
+	    (save-restriction
+	      (widen)
+	      (goto-char (point-min))
+	      (unless (re-search-forward re nil t)
+		(error "Cannot find target location - try again with `C-u' prefix."))
+	      (goto-char (match-beginning 0))
+	      (looking-at outline-regexp)
+	      (setq level (org-get-legal-level (funcall outline-level) 1))
+	      (goto-char (or (save-excursion
+			       (if reversed
+				   (outline-next-heading)
+				 (outline-get-next-sibling)))
+			     (point-max)))
+	      (org-paste-subtree level))))
+	(org-cut-special)
+	(message "Entry refiled to \"%s\"" (car it))))))
+
 ;;;; Dynamic blocks
 
 (defun org-find-dblock (name)
@@ -13264,7 +14041,8 @@
 
 (defconst org-additional-option-like-keywords
   '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX"
-    "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "DATE:"))
+    "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "DATE:" "TBLFM"
+    "BEGIN_EXAMPLE" "END_EXAMPLE"))
 
 (defun org-complete (&optional arg)
   "Perform completion on word at point.
@@ -13385,13 +14163,14 @@
   (interactive)
   (save-excursion
     (org-back-to-heading)
-    (if (looking-at (concat outline-regexp
-			    "\\( *\\<" org-comment-string "\\>[ \t]*\\)"))
-	(replace-match "" t t nil 1)
-      (if (looking-at outline-regexp)
-	  (progn
-	    (goto-char (match-end 0))
-	    (insert org-comment-string " "))))))
+    (let (case-fold-search)
+      (if (looking-at (concat outline-regexp
+			      "\\( *\\<" org-comment-string "\\>[ \t]*\\)"))
+	  (replace-match "" t t nil 1)
+	(if (looking-at outline-regexp)
+	    (progn
+	      (goto-char (match-end 0))
+	      (insert org-comment-string " ")))))))
 
 (defvar org-last-todo-state-is-todo nil
   "This is non-nil when the last TODO state change led to a TODO state.
@@ -13491,7 +14270,7 @@
       (or (looking-at (concat " +" org-todo-regexp " *"))
 	  (looking-at " *"))
       (let* ((match-data (match-data))
-	     (startpos (line-beginning-position))
+	     (startpos (point-at-bol))
 	     (logging (save-match-data (org-entry-get nil "LOGGING" t)))
 	     (org-log-done (org-parse-local-options logging 'org-log-done))
 	     (org-log-repeat (org-parse-local-options logging 'org-log-repeat))
@@ -13666,8 +14445,6 @@
     (save-window-excursion
       (if expert
 	  (set-buffer (get-buffer-create " *Org todo*"))
-;	(delete-other-windows)
-;	(split-window-vertically)
 	(org-switch-to-buffer-other-window (get-buffer-create " *Org todo*")))
       (erase-buffer)
       (org-set-local 'org-done-keywords done-keywords)
@@ -13968,7 +14745,7 @@
 	  (end-of-line 1)
 	  (if (not (bolp)) (let ((inhibit-read-only t)) (insert "\n")))
 	  (indent-relative nil)
-	  (insert "  - " (pop lines))
+	  (insert "- " (pop lines))
 	  (org-indent-line-function)
 	  (beginning-of-line 1)
 	  (looking-at "[ \t]*")
@@ -13994,12 +14771,17 @@
 T      Show entries selected by a tags match.
 p      Enter a property name and its value (both with completion on existing
        names/values) and show entries with that property.
-r      Show entries matching a regular expression"
+r      Show entries matching a regular expression
+d      Show deadlines due within `org-deadline-warning-days'."
   (interactive "P")
   (let (ans kwd value)
-    (message "Sparse tree: [r]egexp   [t]odo-kwd   [T]ag   [p]roperty")
+    (message "Sparse tree: [/]regexp [t]odo-kwd [T]ag [p]roperty [d]eadlines [b]efore-date")
     (setq ans (read-char-exclusive))
     (cond
+     ((equal ans ?d)
+      (call-interactively 'org-check-deadlines))
+     ((equal ans ?b)
+      (call-interactively 'org-check-before-date))
      ((equal ans ?t)
       (org-show-todo-tree '(4)))
      ((equal ans ?T)
@@ -14012,7 +14794,7 @@
       (unless (string-match "\\`{.*}\\'" value)
 	(setq value (concat "\"" value "\"")))
       (org-tags-sparse-tree arg (concat kwd "=" value)))
-     ((member ans '(?r ?R))
+     ((member ans '(?r ?R ?/))
       (call-interactively 'org-occur))
      (t (error "No such sparse tree command \"%c\"" ans)))))
 
@@ -14063,12 +14845,13 @@
   (let ((heading-p   (org-on-heading-p t))
 	(hierarchy-p (org-get-alist-option org-show-hierarchy-above key))
 	(following-p (org-get-alist-option org-show-following-heading key))
+	(entry-p     (org-get-alist-option org-show-entry-below key))
 	(siblings-p  (org-get-alist-option org-show-siblings key)))
     (catch 'exit
       ;; Show heading or entry text
-      (if heading-p
+      (if (and heading-p (not entry-p))
 	  (org-flag-heading nil)    ; only show the heading
-	(and (or (org-invisible-p) (org-invisible-p2))
+	(and (or entry-p (org-invisible-p) (org-invisible-p2))
 	     (org-show-hidden-entry)))    ; show entire entry
       (when following-p
 	;; Show next sibling, or heading below text
@@ -14303,11 +15086,13 @@
 If optional argument TODO_ONLY is non-nil, only select lines that are
 also TODO lines."
   (interactive "P")
+  (org-prepare-agenda-buffers (list (current-buffer)))
   (org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match)) todo-only))
 
 (defvar org-cached-props nil)
 (defun org-cached-entry-get (pom property)
-  (if org-use-property-inheritance
+  (if (or (eq t org-use-property-inheritance)
+	  (member property org-use-property-inheritance))
       ;; Caching is not possible, check it directly
       (org-entry-get pom property 'inherit)
     ;; Get all properties, so that we can do complicated checks easily
@@ -14345,7 +15130,7 @@
 	(re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)=\\({[^}]+}\\|\"[^\"]+\"\\)\\|[[:alnum:]_@]+\\)"))
 	minus tag mm
 	tagsmatch todomatch tagsmatcher todomatcher kwd matcher
-	orterms term orlist re-p level-p prop-p pn pv)
+	orterms term orlist re-p level-p prop-p pn pv cat-p gv)
     (if (string-match "/+" match)
 	;; match contains also a todo-matching request
 	(progn
@@ -14379,11 +15164,15 @@
 		    (prop-p
 		     (setq pn (match-string 4 term)
 			   pv (match-string 5 term)
+			   cat-p (equal pn "CATEGORY")
 			   re-p (equal (string-to-char pv) ?{)
 			   pv (substring pv 1 -1))
+		     (if (equal pn "CATEGORY")
+			 (setq gv '(get-text-property (point) 'org-category))
+		       (setq gv `(org-cached-entry-get nil ,pn)))
 		     (if re-p
-			 `(string-match ,pv (or (org-cached-entry-get nil ,pn) ""))
-		       `(equal ,pv (org-cached-entry-get nil ,pn))))
+			 `(string-match ,pv (or ,gv ""))
+		       `(equal ,pv ,gv)))
 		    (t `(member ,(downcase tag) tags-list)))
 		mm (if minus (list 'not mm) mm)
 		term (substring term (match-end 0)))
@@ -14839,7 +15628,8 @@
 ;;; Setting and retrieving properties
 
 (defconst org-special-properties
-  '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "PRIORITY")
+  '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "PRIORITY"
+    "TIMESTAMP" "TIMESTAMP_IA")
   "The special properties valid in Org-mode.
 
 These are properties that are not defined in the property drawer,
@@ -14935,11 +15725,12 @@
   (org-with-point-at pom
     (let ((clockstr (substring org-clock-string 0 -1))
 	  (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY"))
-	  beg end range props sum-props key value)
+	  beg end range props sum-props key value string clocksum)
       (save-excursion
 	(when (condition-case nil (org-back-to-heading t) (error nil))
 	  (setq beg (point))
 	  (setq sum-props (get-text-property (point) 'org-summaries))
+	  (setq clocksum (get-text-property (point) :org-clock-minutes))
 	  (outline-next-heading)
 	  (setq end (point))
 	  (when (memq which '(all special))
@@ -14955,17 +15746,23 @@
 	    (when (setq value (org-get-tags-at))
 	      (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":") ":"))
 		    props))
-	    (while (re-search-forward org-keyword-time-regexp end t)
-	      (setq key (substring (org-match-string-no-properties 1) 0 -1))
-	      (unless (member key excluded) (push key excluded))
-	      (push (cons key
-			  (if (equal key clockstr)
-			      (org-no-properties
-			       (org-trim
-				(buffer-substring
-				 (match-beginning 2) (point-at-eol))))
-			    (org-match-string-no-properties 2)))
-		    props)))
+	    (while (re-search-forward org-maybe-keyword-time-regexp end t)
+	      (setq key (if (match-end 1) (substring (org-match-string-no-properties 1) 0 -1))
+		    string (if (equal key clockstr)
+			       (org-no-properties
+				(org-trim
+				 (buffer-substring
+				  (match-beginning 3) (goto-char (point-at-eol)))))
+			     (substring (org-match-string-no-properties 3) 1 -1)))
+	      (unless key
+		(if (= (char-after (match-beginning 3)) ?\[)
+		    (setq key "TIMESTAMP_IA")
+		  (setq key "TIMESTAMP")))
+	      (when (or (equal key clockstr) (not (assoc key props)))
+		(push (cons key string) props)))
+
+	    )
+
 	  (when (memq which '(all standard))
 	    ;; Get the standard properties, like :PORP: ...
 	    (setq range (org-get-property-block beg end))
@@ -14978,6 +15775,11 @@
 		      value (org-trim (or (org-match-string-no-properties 2) "")))
 		(unless (member key excluded)
 		  (push (cons key (or value "")) props)))))
+	  (if clocksum
+	      (push (cons "CLOCKSUM"
+			  (org-column-number-to-string (/ (float clocksum) 60.)
+						       'add_times))
+		    props))
 	  (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit)
@@ -15175,6 +15977,7 @@
     (and (equal (char-after) ?\n) (forward-char 1))
     (org-skip-over-state-notes)
     (skip-chars-backward " \t\n\r")
+    (if (eq (char-before) ?*) (forward-char 1))
     (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:"))
     (beginning-of-line 0)
     (indent-to-column indent)
@@ -15610,6 +16413,8 @@
 			    org-columns-overlays)))
 	 nval eval allowed)
     (cond
+     ((equal key "CLOCKSUM")
+      (error "This special column cannot be edited"))
      ((equal key "ITEM")
       (setq eval '(org-with-point-at pom
 		    (org-edit-headline))))
@@ -15680,7 +16485,7 @@
 	 (key1 (concat key "_ALL"))
 	 (allowed (org-entry-get (point) key1 t))
 	 nval)
-    ;; FIXME: Cover editing TODO, TAGS etc inbiffer settings.????
+    ;; FIXME: Cover editing TODO, TAGS etc in-buffer settings.????
     (setq nval (read-string "Allowed: " allowed))
     (org-entry-put
      (cond ((marker-position org-entry-property-inherited-from)
@@ -15697,7 +16502,7 @@
     (save-excursion
       (beginning-of-line 1)
       ;; `next-line' is needed here, because it skips invisible line.
-     (condition-case nil (org-no-warnings (next-line 1)) (error nil))
+      (condition-case nil (org-no-warnings (next-line 1)) (error nil))
       (setq hidep (org-on-heading-p 1)))
     (eval form)
     (and hidep (hide-entry))))
@@ -15797,7 +16602,7 @@
   (org-verify-version 'columns)
   (org-columns-remove-overlays)
   (move-marker org-columns-begin-marker (point))
-  (let (beg end fmt cache maxwidths)
+  (let (beg end fmt cache maxwidths clocksump)
     (setq fmt (org-columns-get-format-and-top-level))
     (save-excursion
       (goto-char org-columns-top-level-marker)
@@ -15806,8 +16611,14 @@
 	(org-columns-compute-all))
       (setq end (or (condition-case nil (org-end-of-subtree t t) (error nil))
 		    (point-max)))
+      ;; Get and cache the properties
       (goto-char beg)
-      ;; Get and cache the properties
+      (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled)
+	(setq clocksump t)
+	(save-excursion
+	  (save-restriction
+	    (narrow-to-region beg end)
+	    (org-clock-sum))))
       (while (re-search-forward (concat "^" outline-regexp) end t)
 	(push (cons (org-current-line) (org-entry-properties)) cache))
       (when cache
@@ -15819,7 +16630,7 @@
 		(org-columns-display-here (cdr x)))
 	      cache)))))
 
-(defun org-columns-new (&optional prop title width op fmt)
+(defun org-columns-new (&optional prop title width op fmt &rest rest)
   "Insert a new column, to the leeft o the current column."
   (interactive)
   (let ((editp (and prop (assoc prop org-columns-current-fmt-compiled)))
@@ -15833,7 +16644,7 @@
 	(setq width (string-to-number width))
       (setq width nil))
     (setq fmt (completing-read "Summary [none]: "
-			       '(("none") ("add_numbers") ("add_times") ("checkbox"))
+			       '(("none") ("add_numbers") ("currency") ("add_times") ("checkbox"))
 			       nil t))
     (if (string-match "\\S-" fmt)
 	(setq fmt (intern fmt))
@@ -16036,6 +16847,7 @@
 	 (level 0)
 	 (ass (assoc property org-columns-current-fmt-compiled))
 	 (format (nth 4 ass))
+	 (printf (nth 5 ass))
 	 (beg org-columns-top-level-marker)
 	 last-level val valflag flag end sumpos sum-alist sum str str1 useval)
     (save-excursion
@@ -16055,7 +16867,7 @@
 	  ;; put the sum of lower levels here as a property
 	  (setq sum (aref lsum last-level)   ; current sum
 		flag (aref lflag last-level) ; any valid entries from children?
-		str (org-column-number-to-string sum format)
+		str (org-column-number-to-string sum format printf)
 		str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
 		useval (if flag str1 (if valflag val ""))
 		sum-alist (get-text-property sumpos 'org-summaries))
@@ -16069,7 +16881,6 @@
 	    (org-entry-put nil property (if flag str val)))
 	  ;; add current to current  level accumulator
 	  (when (or flag valflag)
-	    ;; FIXME: is this ok?????????
 	    (aset lsum level (+ (aref lsum level)
 				(if flag sum (org-column-string-to-number
 					      (if flag str val) format))))
@@ -16112,7 +16923,7 @@
 	(setq sum (+ (string-to-number (pop l)) (/ sum 60))))
       sum)))
 
-(defun org-column-number-to-string (n fmt)
+(defun org-column-number-to-string (n fmt &optional printf)
   "Convert a computed column number to a string value, according to FMT."
   (cond
    ((eq fmt 'add_times)
@@ -16122,6 +16933,9 @@
     (cond ((= n (floor n)) "[X]")
 	  ((> n 1.) "[-]")
 	  (t "[ ]")))
+   (printf (format printf n))
+   ((eq fmt 'currency)
+    (format "%.2f" n))
    (t (number-to-string n))))
 
 (defun org-column-string-to-number (s fmt)
@@ -16138,17 +16952,20 @@
 
 (defun org-columns-uncompile-format (cfmt)
   "Turn the compiled columns format back into a string representation."
-  (let ((rtn "") e s prop title op width fmt)
+  (let ((rtn "") e s prop title op width fmt printf)
     (while (setq e (pop cfmt))
       (setq prop (car e)
 	    title (nth 1 e)
 	    width (nth 2 e)
 	    op (nth 3 e)
-	    fmt (nth 4 e))
+	    fmt (nth 4 e)
+	    printf (nth 5 e))
       (cond
        ((eq fmt 'add_times) (setq op ":"))
        ((eq fmt 'checkbox) (setq op "X"))
-       ((eq fmt 'add_numbers) (setq op "+")))
+       ((eq fmt 'add_numbers) (setq op "+"))
+       ((eq fmt 'currency) (setq op "$")))
+      (if (and op printf) (setq op (concat op ";" printf)))
       (if (equal title prop) (setq title nil))
       (setq s (concat "%" (if width (number-to-string width))
 		      prop
@@ -16165,8 +16982,9 @@
 title        the title field for the columns
 width        the column width in characters, can be nil for automatic
 operator     the operator if any
-format       the output format for computed results, derived from operator"
-  (let ((start 0) width prop title op f)
+format       the output format for computed results, derived from operator
+printf       a printf format for computed values"
+  (let ((start 0) width prop title op f printf)
     (setq org-columns-current-fmt-compiled nil)
     (while (string-match
 	    (org-re "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*")
@@ -16176,13 +16994,18 @@
 	    prop (match-string 2 fmt)
 	    title (or (match-string 3 fmt) prop)
 	    op (match-string 4 fmt)
-	    f nil)
+	    f nil
+	    printf nil)
       (if width (setq width (string-to-number width)))
+      (when (and op (string-match ";" op))
+	(setq printf (substring op (match-end 0))
+	      op (substring op 0 (match-beginning 0))))
       (cond
        ((equal op "+") (setq f 'add_numbers))
+       ((equal op "$") (setq f 'currency))
        ((equal op ":") (setq f 'add_times))
        ((equal op "X") (setq f 'checkbox)))
-      (push (list prop title width op f) org-columns-current-fmt-compiled))
+      (push (list prop title width op f printf) org-columns-current-fmt-compiled))
     (setq org-columns-current-fmt-compiled
 	  (nreverse org-columns-current-fmt-compiled))))
 
@@ -16311,28 +17134,30 @@
 will represent the current date/time.  If there is already a timestamp
 at the cursor, it will be modified."
   (interactive "P")
-  (let ((default-time
-	  ;; Default time is either today, or, when entering a range,
-	  ;; the range start.
-	  (if (or (org-at-timestamp-p t)
-		  (save-excursion
-		    (re-search-backward
-		     (concat org-ts-regexp "--?-?\\=") ; 1-3 minuses
-		     (- (point) 20) t)))
-	      (apply 'encode-time (org-parse-time-string (match-string 1)))
-	    (current-time)))
-	org-time-was-given org-end-time-was-given time)
+  (let* ((ts nil)
+	 (default-time
+	   ;; Default time is either today, or, when entering a range,
+	   ;; the range start.
+	   (if (or (and (org-at-timestamp-p t) (setq ts (match-string 0)))
+		   (save-excursion
+		     (re-search-backward
+		      (concat org-ts-regexp "--?-?\\=") ; 1-3 minuses
+		      (- (point) 20) t)))
+	       (apply 'encode-time (org-parse-time-string (match-string 1)))
+	     (current-time)))
+	 (default-input (and ts (org-get-compact-tod ts)))
+	 org-time-was-given org-end-time-was-given time)
     (cond
      ((and (org-at-timestamp-p)
 	   (eq last-command 'org-time-stamp)
 	   (eq this-command 'org-time-stamp))
       (insert "--")
       (setq time (let ((this-command this-command))
-		  (org-read-date arg 'totime nil nil default-time)))
+		  (org-read-date arg 'totime nil nil default-time default-input)))
       (org-insert-time-stamp time (or org-time-was-given arg)))
      ((org-at-timestamp-p)
       (setq time (let ((this-command this-command))
-		   (org-read-date arg 'totime nil nil default-time)))
+		   (org-read-date arg 'totime nil nil default-time default-input)))
       (when (org-at-timestamp-p) ; just to get the match data
 	(replace-match "")
 	(setq org-last-changed-timestamp
@@ -16342,10 +17167,28 @@
       (message "Timestamp updated"))
      (t
       (setq time (let ((this-command this-command))
-		   (org-read-date arg 'totime nil nil default-time)))
+		   (org-read-date arg 'totime nil nil default-time default-input)))
       (org-insert-time-stamp time (or org-time-was-given arg)
 			     nil nil nil (list org-end-time-was-given))))))
 
+;; FIXME: can we use this for something else????
+;; like computing time differences?????
+(defun org-get-compact-tod (s)
+  (when (string-match "\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\(-\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\)?" s)
+    (let* ((t1 (match-string 1 s))
+	   (h1 (string-to-number (match-string 2 s)))
+	   (m1 (string-to-number (match-string 3 s)))
+	   (t2 (and (match-end 4) (match-string 5 s)))
+	   (h2 (and t2 (string-to-number (match-string 6 s))))
+	   (m2 (and t2 (string-to-number (match-string 7 s))))
+	   dh dm)
+      (if (not t2)
+	  t1
+	(setq dh (- h2 h1) dm (- m2 m1))
+	(if (< dm 0) (setq dm (+ dm 60) dh (1- dh)))
+	(concat t1 "+" (number-to-string dh)
+		(if (/= 0 dm) (concat ":" (number-to-string dm))))))))
+
 (defun org-time-stamp-inactive (&optional arg)
   "Insert an inactive time stamp.
 An inactive time stamp is enclosed in square brackets instead of angle
@@ -16366,9 +17209,13 @@
 (defvar org-ans2) ; dynamically scoped parameter
 
 (defvar org-plain-time-of-day-regexp) ; defined below
+
+(defvar org-read-date-overlay nil)
+(defvar org-dcst nil) ; dynamically scoped
+
 (defun org-read-date (&optional with-time to-time from-string prompt
-				default-time)
-  "Read a date and make things smooth for the user.
+				default-time default-input)
+  "Read a date, possibly a time, and make things smooth for the user.
 The prompt will suggest to enter an ISO date, but you can also enter anything
 which will at least partially be understood by `parse-time-string'.
 Unrecognized parts of the date will default to the current day, month, year,
@@ -16402,7 +17249,7 @@
 date with the mouse (button 1).  The calendar shows a period of three
 months.  To scroll it to other months, use the keys `>' and `<'.
 If you don't like the calendar, turn it off with
-       \(setq org-popup-calendar-for-date-prompt nil)
+       \(setq org-read-date-popup-calendar nil)
 
 With optional argument TO-TIME, the date will immediately be converted
 to an internal time.
@@ -16411,29 +17258,35 @@
 enter a time, and this function will inform the calling routine about
 this change.  The calling routine may then choose to change the format
 used to insert the time stamp into the buffer to include the time.
-With optional argument FROM-STRING, read fomr this string instead from
+With optional argument FROM-STRING, read from this string instead from
 the user.  PROMPT can overwrite the default prompt.  DEFAULT-TIME is
 the time/date that is used for everything that is not specified by the
 user."
   (require 'parse-time)
   (let* ((org-time-stamp-rounding-minutes
 	  (if (equal with-time '(16)) 0 org-time-stamp-rounding-minutes))
+	 (org-dcst org-display-custom-times)
 	 (ct (org-current-time))
 	 (def (or default-time ct))
-	 ; (defdecode (decode-time def))
+	 (defdecode (decode-time def))
+	 (dummy (progn
+		  (when (< (nth 2 defdecode) org-extend-today-until)
+		    (setcar (nthcdr 2 defdecode) -1)
+		    (setcar (nthcdr 1 defdecode) 59)
+		    (setq def (apply 'encode-time defdecode)
+			  defdecode (decode-time def)))))
 	 (calendar-move-hook nil)
 	 (view-diary-entries-initially nil)
 	 (view-calendar-holidays-initially nil)
 	 (timestr (format-time-string
 		   (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
 	 (prompt (concat (if prompt (concat prompt " ") "")
-			 (format "Date and/or time (default [%s]): " timestr)))
-	 ans (org-ans0 "") org-ans1 org-ans2 delta deltan deltaw deltadef
-	 second minute hour day month year tl wday wday1 pm h2 m2)
+			 (format "Date+time [%s]: " timestr)))
+	 ans (org-ans0 "") org-ans1 org-ans2 final)
 
     (cond
      (from-string (setq ans from-string))
-     (org-popup-calendar-for-date-prompt
+     (org-read-date-popup-calendar
       (save-excursion
 	(save-window-excursion
 	  (calendar)
@@ -16455,6 +17308,12 @@
 	    (org-defkey minibuffer-local-map [(meta shift right)]
 	      (lambda () (interactive)
 		(org-eval-in-calendar '(calendar-forward-month 1))))
+	    (org-defkey minibuffer-local-map [(meta shift up)]
+	      (lambda () (interactive)
+		(org-eval-in-calendar '(calendar-backward-year 1))))
+	    (org-defkey minibuffer-local-map [(meta shift down)]
+	      (lambda () (interactive)
+		(org-eval-in-calendar '(calendar-forward-year 1))))
 	    (org-defkey minibuffer-local-map [(shift up)]
 	      (lambda () (interactive)
 		(org-eval-in-calendar '(calendar-backward-week 1))))
@@ -16476,15 +17335,75 @@
 	    (unwind-protect
 		(progn
 		  (use-local-map map)
-		  (setq org-ans0 (read-string prompt "" nil nil))
+		  (add-hook 'post-command-hook 'org-read-date-display)
+		  (setq org-ans0 (read-string prompt default-input nil nil))
 		  ;; org-ans0: from prompt
 		  ;; org-ans1: from mouse click
 		  ;; org-ans2: from calendar motion
 		  (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
-	      (use-local-map old-map))))))
+	      (remove-hook 'post-command-hook 'org-read-date-display)
+	      (use-local-map old-map)
+	      (when org-read-date-overlay
+		(org-delete-overlay org-read-date-overlay)
+		(setq org-read-date-overlay nil)))))))
+
      (t ; Naked prompt only
-      (setq ans (read-string prompt "" nil timestr))))
-    (org-detach-overlay org-date-ovl)
+      (unwind-protect
+	  (setq ans (read-string prompt default-input nil timestr))
+	(when org-read-date-overlay
+	  (org-delete-overlay org-read-date-overlay)
+	  (setq org-read-date-overlay nil)))))
+
+    (setq final (org-read-date-analyze ans def defdecode))
+
+    (if to-time
+	(apply 'encode-time final)
+      (if (and (boundp 'org-time-was-given) org-time-was-given)
+	  (format "%04d-%02d-%02d %02d:%02d"
+		  (nth 5 final) (nth 4 final) (nth 3 final)
+		  (nth 2 final) (nth 1 final))
+	(format "%04d-%02d-%02d" (nth 5 final) (nth 4 final) (nth 3 final))))))
+(defvar def)
+(defvar defdecode)
+(defvar with-time)
+(defun org-read-date-display ()
+  "Display the currrent date prompt interpretation in the minibuffer."
+  (when org-read-date-display-live
+    (when org-read-date-overlay
+      (org-delete-overlay org-read-date-overlay))
+    (let ((p (point)))
+      (end-of-line 1)
+      (while (not (equal (buffer-substring
+			  (max (point-min) (- (point) 4)) (point))
+			 "    "))
+	(insert " "))
+      (goto-char p))
+    (let* ((ans (concat (buffer-substring (point-at-bol) (point-max))
+			" " (or org-ans1 org-ans2)))
+	   (org-end-time-was-given nil)
+	   (f (org-read-date-analyze ans def defdecode))
+	   (fmts (if org-dcst
+		     org-time-stamp-custom-formats
+		   org-time-stamp-formats))
+	   (fmt (if (or with-time
+			(and (boundp 'org-time-was-given) org-time-was-given))
+		    (cdr fmts)
+		  (car fmts)))
+	   (txt (concat "=> " (format-time-string fmt (apply 'encode-time f)))))
+      (when (and org-end-time-was-given
+		 (string-match org-plain-time-of-day-regexp txt))
+	(setq txt (concat (substring txt 0 (match-end 0)) "-"
+			  org-end-time-was-given
+			  (substring txt (match-end 0)))))
+      (setq org-read-date-overlay
+	    (make-overlay (1- (point-at-eol)) (point-at-eol)))
+      (org-overlay-display org-read-date-overlay txt 'secondary-selection))))
+
+(defun org-read-date-analyze (ans def defdecode)
+  "Analyze the combined answer of the date prompt."
+  ;; FIXME: cleanup and comment
+  (let (delta deltan deltaw deltadef year month day
+	      hour minute second wday pm h2 m2 tl wday1)
 
     (when (setq delta (org-read-date-get-relative ans (current-time) def))
       (setq ans (replace-match "" t t ans)
@@ -16527,22 +17446,32 @@
 	    h2 (+ hour (string-to-number (match-string 3 ans)))
 	    minute (string-to-number (match-string 2 ans))
 	    m2 (+ minute (if (match-end 5) (string-to-number (match-string 5 ans))0)))
+      (if (>= m2 60) (setq h2 (1+ h2) m2 (- m2 60)))
       (setq ans (replace-match (format "%02d:%02d-%02d:%02d" hour minute h2 m2) t t ans)))
 
     ;; Check if there is a time range
-    (when (and (boundp 'org-end-time-was-given)
-	       (string-match org-plain-time-of-day-regexp ans)
-	       (match-end 8))
-      (setq org-end-time-was-given (match-string 8 ans))
-      (setq ans (concat (substring ans 0 (match-beginning 7))
-			(substring ans (match-end 7)))))
+    (when (boundp 'org-end-time-was-given)
+      (setq org-time-was-given nil)
+      (when (and (string-match org-plain-time-of-day-regexp ans)
+		 (match-end 8))
+	(setq org-end-time-was-given (match-string 8 ans))
+	(setq ans (concat (substring ans 0 (match-beginning 7))
+			  (substring ans (match-end 7))))))
 
     (setq tl (parse-time-string ans)
-	  day (or (nth 3 tl) (string-to-number (format-time-string "%d" def)))
-	  month (or (nth 4 tl) (string-to-number (format-time-string "%m" def)))
-	  year (or (nth 5 tl) (string-to-number (format-time-string "%Y" def)))
-	  hour (or (nth 2 tl) (string-to-number (format-time-string "%H" def)))
-	  minute (or (nth 1 tl) (string-to-number (format-time-string "%M" def)))
+	  day (or (nth 3 tl) (nth 3 defdecode))
+	  month (or (nth 4 tl)
+		    (if (and org-read-date-prefer-future
+			     (nth 3 tl) (< (nth 3 tl) (nth 3 defdecode)))
+			(1+ (nth 4 defdecode))
+		      (nth 4 defdecode)))
+	  year (or (nth 5 tl)
+		   (if (and org-read-date-prefer-future
+			    (nth 4 tl) (< (nth 4 tl) (nth 4 defdecode)))
+		       (1+ (nth 5 defdecode))
+		     (nth 5 defdecode)))
+	  hour (or (nth 2 tl) (nth 2 defdecode))
+	  minute (or (nth 1 tl) (nth 1 defdecode))
 	  second (or (nth 0 tl) 0)
 	  wday (nth 6 tl))
     (when deltan
@@ -16563,25 +17492,8 @@
 	     (nth 2 tl))
 	(setq org-time-was-given t))
     (if (< year 100) (setq year (+ 2000 year)))
-    (if to-time
-	(encode-time second minute hour day month year)
-      (if (or (nth 1 tl) (nth 2 tl))
-	  (format "%04d-%02d-%02d %02d:%02d" year month day hour minute)
-	(format "%04d-%02d-%02d" year month day)))))
-
-;(defun org-parse-for-shift (n1 n2 given-dec default-dec)
-;  (cond
-;   ((not (nth n1 given-dec))
-;    (nth n1 default-dec))
-;   ((or (> (nth n1 given-dec) (nth n1 (default-dec)))
-;	(not org-read-date-prefer-future))
-;    (nth n1 given-dec))
-;   (t (1+
-;       (if (nth 3 given-dec)
-;	   (nth 3 given-dec)
-;    (if (> (nth
-;  (setq given
-;  (if (and
+    (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable
+    (list second minute hour day month year)))
 
 (defvar parse-time-weekdays)
 
@@ -16589,8 +17501,8 @@
   "Check string S for special relative date string.
 TODAY and DEFAULT are internal times, for today and for a default.
 Return shift list (N what def-flag)
-WHAT       is \"d\", \"w\", \"m\", or \"y\" for day. week, month, year.
-N          is the number if WHATs to shift
+WHAT       is \"d\", \"w\", \"m\", or \"y\" for day, week, month, year.
+N          is the number of WHATs to shift.
 DEF-FLAG   is t when a double ++ or -- indicates shift relative to
            the DEFAULT date rather than TODAY."
   (when (string-match
@@ -16628,17 +17540,18 @@
 	     (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
 	(setq org-ans2 (format-time-string "%Y-%m-%d" time))))
     (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
-    (select-window sw)
-    ;; Update the prompt to show new default date
-    (save-excursion
-      (goto-char (point-min))
-      (when (and org-ans2
-		 (re-search-forward "\\[[-0-9]+\\]" nil t)
-		 (get-text-property (match-end 0) 'field))
-	(let ((inhibit-read-only t))
-	  (replace-match (concat "[" org-ans2 "]") t t)
-	  (add-text-properties (point-min) (1+ (match-end 0))
-			       (text-properties-at (1+ (point-min)))))))))
+    (select-window sw)))
+
+;    ;; Update the prompt to show new default date
+;    (save-excursion
+;      (goto-char (point-min))
+;      (when (and org-ans2
+;		 (re-search-forward "\\[[-0-9]+\\]" nil t)
+;		 (get-text-property (match-end 0) 'field))
+;	(let ((inhibit-read-only t))
+;	  (replace-match (concat "[" org-ans2 "]") t t)
+;	  (add-text-properties (point-min) (1+ (match-end 0))
+;			       (text-properties-at (1+ (point-min)))))))))
 
 (defun org-calendar-select ()
   "Return to `org-read-date' with the date currently selected.
@@ -16817,6 +17730,20 @@
 	     (org-occur regexp nil callback)
 	     org-warn-days)))
 
+(defun org-check-before-date (date)
+  "Check if there are deadlines or scheduled entries before DATE."
+  (interactive (list (org-read-date)))
+  (let ((case-fold-search nil)
+	(regexp (concat "\\<\\(" org-deadline-string
+			"\\|" org-scheduled-string
+			"\\) *<\\([^>]+\\)>"))
+	(callback
+	 (lambda () (time-less-p
+		     (org-time-string-to-time (match-string 2))
+		     (org-time-string-to-time date)))))
+    (message "%d entries before %s"
+	     (org-occur regexp nil callback) date)))
+
 (defun org-evaluate-time-range (&optional to-buffer)
   "Evaluate a time range by computing the difference between start and end.
 Normally the result is just printed in the echo area, but with prefix arg
@@ -16865,10 +17792,12 @@
 	h 0 m 0))
      (if (not to-buffer)
 	 (message "%s" (org-make-tdiff-string y d h m))
-       (when (org-at-table-p)
-	 (goto-char match-end)
-	 (setq align t)
-	 (and (looking-at " *|") (goto-char (match-end 0))))
+       (if (org-at-table-p)
+	   (progn
+	     (goto-char match-end)
+	     (setq align t)
+	     (and (looking-at " *|") (goto-char (match-end 0))))
+	 (goto-char match-end))
        (if (looking-at
 	    "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
 	   (replace-match ""))
@@ -16917,7 +17846,10 @@
 
 (defun org-calendar-holiday ()
   "List of holidays, for Diary display in Org-mode."
-  (let ((hl (calendar-check-holidays date)))
+  (require 'holidays)
+  (let ((hl (funcall
+	     (if (fboundp 'calendar-check-holidays)
+		 'calendar-check-holidays 'check-calendar-holidays) date)))
     (if hl (mapconcat 'identity hl "; "))))
 
 (defun org-diary-sexp-entry (sexp entry date)
@@ -16941,7 +17873,7 @@
           (t nil))))
 
 (defun org-diary-to-ical-string (frombuf)
-  "Get iCalendar entreis from diary entries in buffer FROMBUF.
+  "Get iCalendar entries from diary entries in buffer FROMBUF.
 This uses the icalendar.el library."
   (let* ((tmpdir (if (featurep 'xemacs)
 		     (temp-directory)
@@ -17292,6 +18224,7 @@
   (if (equal filter '(4))
       (setq filter (read-from-minibuffer "Regexp filter: ")))
   (let* ((cnt 0) ; count added events
+	 (org-agenda-new-buffers nil)
 	 (today (org-date-to-gregorian
 		 (time-to-days (current-time))))
 	 (files (org-agenda-files)) entries file)
@@ -17316,7 +18249,7 @@
 				(cadr (assoc 'category filter)) cat)
 			       (string-match
 				(cadr (assoc 'headline filter)) evt))))))
-	 ;; FIXME Shall we remove text-properties for the appt text?
+	 ;; FIXME: Shall we remove text-properties for the appt text?
 	 ;; (setq evt (set-text-properties 0 (length evt) nil evt))
 	 (when (and ok tod)
 	   (setq tod (number-to-string tod)
@@ -17326,6 +18259,7 @@
 			       (match-string 2 tod))))
 	   (appt-add tod evt)
 	   (setq cnt (1+ cnt))))) entries)
+    (org-release-buffers org-agenda-new-buffers)
     (message "Added %d event%s for today" cnt (if (> cnt 1) "s" ""))))
 
 ;;; The clock for measuring work time.
@@ -17360,9 +18294,17 @@
   (let (ts)
     (save-excursion
       (org-back-to-heading t)
-      (if (looking-at org-todo-line-regexp)
-	  (setq org-clock-heading (match-string 3))
-	(setq org-clock-heading "???"))
+      (when (and org-clock-in-switch-to-state
+		 (not (looking-at (concat outline-regexp "[ \t]*"
+					  org-clock-in-switch-to-state
+					  "\\>"))))
+	(org-todo org-clock-in-switch-to-state))
+      (if (and org-clock-heading-function
+	       (functionp org-clock-heading-function))
+	  (setq org-clock-heading (funcall org-clock-heading-function))
+	(if (looking-at org-complex-heading-regexp)
+	    (setq org-clock-heading (match-string 4))
+	  (setq org-clock-heading "???")))
       (setq org-clock-heading (propertize org-clock-heading 'face nil))
       (org-clock-find-position)
 
@@ -17480,6 +18422,9 @@
     (set-buffer (marker-buffer org-clock-marker))
     (goto-char org-clock-marker)
     (delete-region (1- (point-at-bol)) (point-at-eol)))
+  (setq global-mode-string
+	(delq 'org-mode-line-string global-mode-string))
+  (force-mode-line-update)
   (message "Clock canceled"))
 
 (defun org-clock-goto (&optional delete-windows)
@@ -18016,8 +18961,10 @@
 (org-defkey org-agenda-mode-map "f" 'org-agenda-follow-mode)
 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
-(org-defkey org-agenda-mode-map "g" 'org-agenda-toggle-time-grid)
+(org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
+(org-defkey org-agenda-mode-map "g" 'org-agenda-redo)
+(org-defkey org-agenda-mode-map "e" 'org-agenda-execute)
 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-write-agenda)
@@ -18234,6 +19181,7 @@
 (defvar org-agenda-restrict-begin (make-marker))
 (defvar org-agenda-restrict-end (make-marker))
 (defvar org-agenda-last-dispatch-buffer nil)
+(defvar org-agenda-overriding-restriction nil)
 
 ;;;###autoload
 (defun org-agenda (arg &optional keys restriction)
@@ -18263,6 +19211,7 @@
   (interactive "P")
   (catch 'exit
     (let* ((prefix-descriptions nil)
+	   (org-agenda-custom-commands-orig org-agenda-custom-commands)
 	   (org-agenda-custom-commands
 	    ;; normalize different versions
 	    (delq nil
@@ -18278,11 +19227,12 @@
 	   (buf (current-buffer))
 	   (bfn (buffer-file-name (buffer-base-buffer)))
 	   entry key type match lprops ans)
-      ;; Turn off restriction
-      (put 'org-agenda-files 'org-restrict nil)
-      (setq org-agenda-restrict nil)
-      (move-marker org-agenda-restrict-begin nil)
-      (move-marker org-agenda-restrict-end nil)
+      ;; Turn off restriction unless there is an overriding one
+      (unless org-agenda-overriding-restriction
+	(put 'org-agenda-files 'org-restrict nil)
+	(setq org-agenda-restrict nil)
+	(move-marker org-agenda-restrict-begin nil)
+	(move-marker org-agenda-restrict-end nil))
       ;; Delete old local properties
       (put 'org-agenda-redo-command 'org-lprops nil)
       ;; Remember where this call originated
@@ -18292,7 +19242,7 @@
 	      keys (car ans)
 	      restriction (cdr ans)))
       ;; Estabish the restriction, if any
-      (when restriction
+      (when (and (not org-agenda-overriding-restriction) restriction)
 	(put 'org-agenda-files 'org-restrict (list bfn))
 	(cond
 	 ((eq restriction 'region)
@@ -18346,7 +19296,9 @@
 		(org-let lprops '(funcall type match)))
 	       (t (error "Invalid custom agenda command type %s" type))))
 	  (org-run-agenda-series (nth 1 entry) (cddr entry))))
-       ((equal keys "C") (customize-variable 'org-agenda-custom-commands))
+       ((equal keys "C")
+	(setq org-agenda-custom-commands org-agenda-custom-commands-orig)
+	(customize-variable 'org-agenda-custom-commands))
        ((equal keys "a") (call-interactively 'org-agenda-list))
        ((equal keys "t") (call-interactively 'org-todo-list))
        ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
@@ -18364,6 +19316,16 @@
        ((equal keys "!") (customize-variable 'org-stuck-projects))
        (t (error "Invalid agenda key"))))))
 
+(defun org-agenda-normalize-custom-commands (cmds)
+  (delq nil
+	(mapcar
+	 (lambda (x)
+	   (cond ((stringp (cdr x)) nil)
+		 ((stringp (nth 1 x)) x)
+		 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
+		 (t (cons (car x) (cons "" (cdr x))))))
+	 cmds)))
+
 (defun org-agenda-get-restriction-and-command (prefix-descriptions)
   "The user interface for selecting an agenda command."
   (catch 'exit
@@ -18380,13 +19342,14 @@
 	(erase-buffer)
 	(insert (eval-when-compile
 		  (let ((header
-"Press key for an agenda command:        <   Buffer,subtree/region restriction
---------------------------------        C   Configure custom agenda commands
+"
+Press key for an agenda command:        <   Buffer,subtree/region restriction
+--------------------------------        >   Remove restriction
 a   Agenda for current week or day      e   Export agenda views
 t   List of all TODO entries            T   Entries with special TODO kwd
 m   Match a TAGS query                  M   Like m, but only TODO entries
 L   Timeline for current buffer         #   List stuck projects (!=configure)
-/   Multi-occur
+/   Multi-occur                         C   Configure custom agenda commands
 ")
 			(start 0))
 		    (while (string-match
@@ -18402,10 +19365,10 @@
 	  (when (eq rmheader t)
 	    (goto-line 1)
 	    (re-search-forward ":" nil t)
-	    (delete-region (match-end 0) (line-end-position))
+	    (delete-region (match-end 0) (point-at-eol))
 	    (forward-char 1)
 	    (looking-at "-+")
-	    (delete-region (match-end 0) (line-end-position))
+	    (delete-region (match-end 0) (point-at-eol))
 	    (move-marker header-end (match-end 0)))
 	  (goto-char header-end)
 	  (delete-region (point) (point-max))
@@ -18458,10 +19421,12 @@
 	      (setq second-time t)
 	      (fit-window-to-buffer)))
 	  (message "Press key for agenda command%s:"
-		   (if restrict-ok
-		       (if restriction
-			   (format " (restricted to %s)" restriction)
-			 " (unrestricted)")
+		   (if (or restrict-ok org-agenda-overriding-restriction)
+		       (if org-agenda-overriding-restriction
+			   " (restriction lock active)"
+			 (if restriction
+			     (format " (restricted to %s)" restriction)
+			   " (unrestricted)"))
 		     ""))
 	  (setq c (read-char-exclusive))
 	  (message "")
@@ -18484,10 +19449,13 @@
 	    (message "Restriction is only possible in Org-mode buffers")
 	    (ding) (sit-for 1))
 	   ((eq c ?1)
+	    (org-agenda-remove-restriction-lock 'noupdate)
 	    (setq restriction 'buffer))
 	   ((eq c ?0)
+	    (org-agenda-remove-restriction-lock 'noupdate)
 	    (setq restriction (if region-p 'region 'subtree)))
 	   ((eq c ?<)
+	    (org-agenda-remove-restriction-lock 'noupdate)
 	    (setq restriction
 		  (cond
 		   ((eq restriction 'buffer)
@@ -18495,8 +19463,15 @@
 		   ((memq restriction '(subtree region))
 		    nil)
 		   (t 'buffer))))
-	   ((and (equal selstring "") (memq c '(?a ?t ?m ?L ?C ?e ?T ?M ?# ?/)))
+	   ((eq c ?>)
+	    (org-agenda-remove-restriction-lock 'noupdate)
+	    (setq restriction nil))
+	   ((and (equal selstring "") (memq c '(?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/)))
 	    (throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
+           ((and (> (length selstring) 0) (eq c ?\d))
+            (delete-window)
+            (org-agenda-get-restriction-and-command prefix-descriptions))
+
 	   ((equal c ?q) (error "Abort"))
 	   (t (error "Invalid key %c" c))))))))
 
@@ -18543,7 +19518,7 @@
   "Run an agenda command in batch mode and send the result to STDOUT.
 If CMD-KEY is a string of length 1, it is used as a key in
 `org-agenda-custom-commands' and triggers this command.  If it is a
-longer string is is used as a tags/todo match string.
+longer string it is used as a tags/todo match string.
 Paramters are alternating variable names and values that will be bound
 before running the agenda command."
   (let (pars)
@@ -18568,7 +19543,7 @@
   "Run an agenda command in batch mode and send the result to STDOUT.
 If CMD-KEY is a string of length 1, it is used as a key in
 `org-agenda-custom-commands' and triggers this command.  If it is a
-longer string is is used as a tags/todo match string.
+longer string it is used as a tags/todo match string.
 Paramters are alternating variable names and values that will be bound
 before running the agenda command.
 
@@ -18625,7 +19600,7 @@
 
 (defun org-fix-agenda-info (props)
   "Make sure all properties on an agenda item have a canonical form,
-so the the export commands caneasily use it."
+so the export commands can easily use it."
   (let (tmp re)
     (when (setq tmp (plist-get props 'tags))
       (setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
@@ -18675,7 +19650,7 @@
 ;;;###autoload
 (defmacro org-batch-store-agenda-views (&rest parameters)
   "Run all custom agenda commands that have a file argument."
-  (let ((cmds org-agenda-custom-commands)
+  (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
 	(pop-up-frames nil)
 	(dir default-directory)
 	pars cmd thiscmdkey files opts)
@@ -18686,8 +19661,8 @@
       (while cmds
 	(setq cmd (pop cmds)
 	      thiscmdkey (car cmd)
-	      opts (nth 3 cmd)
-	      files (nth 4 cmd))
+	      opts (nth 4 cmd)
+	      files (nth 5 cmd))
 	(if (stringp files) (setq files (list files)))
 	(when files
 	  (eval (list 'let (append org-agenda-exporter-settings opts pars)
@@ -18777,7 +19752,8 @@
     (setq files (apply 'append
 		       (mapcar (lambda (f)
 				 (if (file-directory-p f)
-				     (directory-files f t "\\.org\\'")
+				     (directory-files f t
+						      org-agenda-file-regexp)
 				   (list f)))
 			       files)))
     (if org-agenda-skip-unavailable-files
@@ -18808,7 +19784,7 @@
 			(message "New agenda file list installed"))
 		      nil 'local)
 	(message "%s" (substitute-command-keys
-		  "Edit list and finish with \\[save-buffer]")))
+		       "Edit list and finish with \\[save-buffer]")))
     (customize-variable 'org-agenda-files)))
 
 (defun org-store-new-agenda-file-list (list)
@@ -18893,7 +19869,7 @@
 	  (org-store-new-agenda-file-list files)
 	  (org-install-agenda-files-menu)
 	  (message "Removed file: %s" afile))
-      (message "File was not in list: %s" afile))))
+      (message "File was not in list: %s (not removed)" afile))))
 
 (defun org-file-menu-entry (file)
   (vector file (list 'find-file file) t))
@@ -18982,10 +19958,9 @@
   (interactive)
   (mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-priority)
 			(org-delete-overlay o)))
-	(overlays-in (point-min) (point-max)))
-  (save-excursion
-    (let ((ovs (org-overlays-in (point-min) (point-max)))
-	  (inhibit-read-only t)
+	(org-overlays-in (point-min) (point-max)))
+  (save-excursion
+    (let ((inhibit-read-only t)
 	  b e p ov h l)
       (goto-char (point-min))
       (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
@@ -18994,7 +19969,7 @@
 	      l (or (get-char-property (point) 'org-lowest-priority)
 		    org-lowest-priority)
 	      p (string-to-char (match-string 1))
-	      b (match-beginning 0) e (line-end-position)
+	      b (match-beginning 0) e (point-at-eol)
 	      ov (org-make-overlay b e))
 	(org-overlay-put
 	 ov 'face
@@ -19016,8 +19991,10 @@
     (save-excursion
       (save-restriction
 	(while (setq file (pop files))
-	  (org-check-agenda-file file)
-	  (set-buffer (org-get-agenda-file-buffer file))
+	  (if (bufferp file)
+	      (set-buffer file)
+	    (org-check-agenda-file file)
+	    (set-buffer (org-get-agenda-file-buffer file)))
 	  (widen)
 	  (setq bmp (buffer-modified-p))
 	  (org-refresh-category-properties)
@@ -19096,9 +20073,6 @@
       (while org-agenda-markers
 	(move-marker (pop org-agenda-markers) nil))))
 
-(defvar org-agenda-new-buffers nil
-  "Buffers created to visit agenda files.")
-
 (defun org-get-agenda-file-buffer (file)
   "Get a buffer visiting FILE.  If the buffer needs to be created, add
 it to the list of buffers which might be released later."
@@ -19303,7 +20277,9 @@
 	      org-agenda-start-on-weekday nil))
 	 (thefiles (org-agenda-files))
 	 (files thefiles)
-	 (today (time-to-days (current-time)))
+	 (today (time-to-days
+		 (time-subtract (current-time)
+				(list 0 (* 3600 org-extend-today-until) 0))))
 	 (sd (or start-day today))
 	 (start (if (or (null org-agenda-start-on-weekday)
 			(< org-agenda-ndays 7))
@@ -19576,11 +20552,12 @@
 
 (defun org-agenda-skip-entry-if (&rest conditions)
   "Skip entry if any of CONDITIONS is true.
-See `org-agenda-skip-if for details."
+See `org-agenda-skip-if' for details."
   (org-agenda-skip-if nil conditions))
+
 (defun org-agenda-skip-subtree-if (&rest conditions)
   "Skip entry if any of CONDITIONS is true.
-See `org-agenda-skip-if for details."
+See `org-agenda-skip-if' for details."
   (org-agenda-skip-if t conditions))
 
 (defun org-agenda-skip-if (subtree conditions)
@@ -19598,13 +20575,13 @@
 regexp        Check if regexp matches
 notregexp     Check if regexp does not match.
 
-The regexp is taken from the conditions list, it must com right after the
-`regexp' of `notregexp' element.
+The regexp is taken from the conditions list, it must come right after
+the `regexp' or `notregexp' element.
 
 If any of these conditions is met, this function returns the end point of
 the entity, causing the search to continue from there.  This is a function
 that can be put into `org-agenda-skip-function' for the duration of a command."
-  (let (beg end m r)
+  (let (beg end m)
     (org-back-to-heading t)
     (setq beg (point)
 	  end (if subtree
@@ -19622,13 +20599,14 @@
       (and (memq 'notdeadline conditions)
 	   (not (re-search-forward org-deadline-time-regexp end t)))
       (and (setq m (memq 'regexp conditions))
-	   (stringp (setq r (nth 1 m)))
+	   (stringp (nth 1 m))
 	   (re-search-forward (nth 1 m) end t))
       (and (setq m (memq 'notregexp conditions))
-	   (stringp (setq r (nth 1 m)))
+	   (stringp (nth 1 m))
 	   (not (re-search-forward (nth 1 m) end t))))
      end)))
 
+;;;###autoload
 (defun org-agenda-list-stuck-projects (&rest ignore)
   "Create agenda view for projects that are stuck.
 Stuck projects are project that have no next actions.  For the definitions
@@ -19895,14 +20873,6 @@
 		  (setq results (append results rtn))))))))
 	results))))
 
-;; FIXME: this works only if the cursor is *not* at the
-;; beginning of the entry
-;(defun org-entry-is-done-p ()
-;  "Is the current entry marked DONE?"
-;  (save-excursion
-;    (and (re-search-backward "[\r\n]\\*+ " nil t)
-;	 (looking-at org-nl-done-regexp))))
-
 (defun org-entry-is-todo-p ()
   (member (org-get-todo-state) org-not-done-keywords))
 
@@ -20024,7 +20994,7 @@
 	   "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
 	   "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
 	 marker hdmarker deadlinep scheduledp donep tmp priority category
-	 ee txt timestr tags b0 b3 e3)
+	 ee txt timestr tags b0 b3 e3 head)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (setq b0 (match-beginning 0)
@@ -20058,8 +21028,10 @@
 		(setq hdmarker (org-agenda-new-marker)
 		      tags (org-get-tags-at))
 		(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
+		(setq head (match-string 1))
+		(and org-agenda-skip-timestamp-if-done donep (throw :skip t))
 		(setq txt (org-format-agenda-item
-			   nil (match-string 1) category tags timestr nil
+			   nil head category tags timestr nil
 			   remove-re)))
 	    (setq txt org-agenda-no-heading-message))
 	  (setq priority (org-get-priority txt))
@@ -20331,7 +21303,8 @@
 			      (abbreviate-file-name buffer-file-name))))
 	 (regexp org-tr-regexp)
 	 (d0 (calendar-absolute-from-gregorian date))
-	 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags pos)
+	 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags pos
+	 donep head)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -20354,10 +21327,14 @@
 		    (setq hdmarker (org-agenda-new-marker (point)))
 		    (setq tags (org-get-tags-at))
 		    (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
+		    (setq head (match-string 1))
+		    (and org-agenda-skip-timestamp-if-done
+			 (org-entry-is-done-p)
+			 (throw :skip t))
 		    (setq txt (org-format-agenda-item
 			       (format (if (= d1 d2) "" "(%d/%d): ")
 				       (1+ (- d0 d1)) (1+ (- d2 d1)))
-			       (match-string 1) category tags
+			       head category tags
 			       (if (= d0 d1) timestr))))
 		(setq txt org-agenda-no-heading-message))
 	      (org-add-props txt props
@@ -20518,7 +21495,7 @@
 	'extra extra
 	'dotime dotime))))
 
-(defvar org-agenda-sorting-strategy) ;; FIXME: can be removed?
+(defvar org-agenda-sorting-strategy) ;; because the def is in a let form
 (defvar org-agenda-sorting-strategy-selected nil)
 
 (defun org-agenda-add-time-grid-maybe (list ndays todayp)
@@ -20636,16 +21613,32 @@
 	  (beginning-of-line 1)
 	  (setq re (get-text-property (point) 'org-todo-regexp))
 	  (goto-char (+ (point) (or (get-text-property (point) 'prefix-length) 0)))
-	  (and (looking-at (concat "[ \t]*\\.*" re))
-	       (add-text-properties (match-beginning 0) (match-end 0)
-				    (list 'face (org-get-todo-face 0)))))
+	  (when (looking-at (concat "[ \t]*\\.*" re " +"))
+	    (add-text-properties (match-beginning 0) (match-end 0)
+				 (list 'face (org-get-todo-face 0)))
+	    (let ((s (buffer-substring (match-beginning 1) (match-end 1))))
+	      (delete-region (match-beginning 1) (1- (match-end 0)))
+	      (goto-char (match-beginning 1))
+	      (insert (format org-agenda-todo-keyword-format s)))))
       (setq re (concat (get-text-property 0 'org-todo-regexp x))
 	    pl (get-text-property 0 'prefix-length x))
-      (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl)
-	   (add-text-properties
-	    (or (match-end 1) (match-end 0)) (match-end 0)
-	    (list 'face (org-get-todo-face (match-string 2 x)))
-	    x))
+;      (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl)
+;	   (add-text-properties
+;	    (or (match-end 1) (match-end 0)) (match-end 0)
+;	    (list 'face (org-get-todo-face (match-string 2 x)))
+;	    x))
+      (when (and re
+		 (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)")
+				      x (or pl 0)) pl))
+	(add-text-properties
+	 (or (match-end 1) (match-end 0)) (match-end 0)
+	 (list 'face (org-get-todo-face (match-string 2 x)))
+	 x)
+	(setq x (concat (substring x 0 (match-end 1))
+			(format org-agenda-todo-keyword-format
+				(match-string 2 x))
+			" "
+			(substring x (match-end 3)))))
       x)))
 
 (defsubst org-cmp-priority (a b)
@@ -20700,6 +21693,85 @@
 	  (eval (cons 'or org-agenda-sorting-strategy-selected))
 	  '((-1 . t) (1 . nil) (nil . nil))))))
 
+;;; Agenda restriction lock
+
+(defvar org-agenda-restriction-lock-overlay (org-make-overlay 1 1)
+  "Overlay to mark the headline to which arenda commands are restricted.")
+(org-overlay-put org-agenda-restriction-lock-overlay
+		 'face 'org-agenda-restriction-lock)
+(org-overlay-put org-agenda-restriction-lock-overlay
+		 'help-echo "Agendas are currently limited to this subtree.")
+(org-detach-overlay org-agenda-restriction-lock-overlay)
+(defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1)
+  "Overlay marking the agenda restriction line in speedbar.")
+(org-overlay-put org-speedbar-restriction-lock-overlay
+		 'face 'org-agenda-restriction-lock)
+(org-overlay-put org-speedbar-restriction-lock-overlay
+		 'help-echo "Agendas are currently limited to this item.")
+(org-detach-overlay org-speedbar-restriction-lock-overlay)
+
+(defun org-agenda-set-restriction-lock (&optional type)
+  "Set restriction lock for agenda, to current subtree or file.
+Restriction will be the file if TYPE is `file', or if type is the
+universal prefix '(4), or if the cursor is before the first headline
+in the file.  Otherwise, restriction will be to the current subtree."
+  (interactive "P")
+  (and (equal type '(4)) (setq type 'file))
+  (setq type (cond
+	      (type type)
+	      ((org-at-heading-p) 'subtree)
+	      ((condition-case nil (org-back-to-heading t) (error nil))
+	       'subtree)
+	      (t 'file)))
+  (if (eq type 'subtree)
+      (progn
+	(setq org-agenda-restrict t)
+	(setq org-agenda-overriding-restriction 'subtree)
+	(put 'org-agenda-files 'org-restrict
+	     (list (buffer-file-name (buffer-base-buffer))))
+	(org-back-to-heading t)
+	(org-move-overlay org-agenda-restriction-lock-overlay (point) (point-at-eol))
+	(move-marker org-agenda-restrict-begin (point))
+	(move-marker org-agenda-restrict-end
+		     (save-excursion (org-end-of-subtree t)))
+	(message "Locking agenda restriction to subtree"))
+    (put 'org-agenda-files 'org-restrict
+	 (list (buffer-file-name (buffer-base-buffer))))
+    (setq org-agenda-restrict nil)
+    (setq org-agenda-overriding-restriction 'file)
+    (move-marker org-agenda-restrict-begin nil)
+    (move-marker org-agenda-restrict-end nil)
+    (message "Locking agenda restriction to file"))
+  (setq current-prefix-arg nil)
+  (org-agenda-maybe-redo))
+
+(defun org-agenda-remove-restriction-lock (&optional noupdate)
+  "Remove the agenda restriction lock."
+  (interactive "P")
+  (org-detach-overlay org-agenda-restriction-lock-overlay)
+  (org-detach-overlay org-speedbar-restriction-lock-overlay)
+  (setq org-agenda-overriding-restriction nil)
+  (setq org-agenda-restrict nil)
+  (put 'org-agenda-files 'org-restrict nil)
+  (move-marker org-agenda-restrict-begin nil)
+  (move-marker org-agenda-restrict-end nil)
+  (setq current-prefix-arg nil)
+  (message "Agenda restriction lock removed")
+  (or noupdate (org-agenda-maybe-redo)))
+
+(defun org-agenda-maybe-redo ()
+  "If there is any window showing the agenda view, update it."
+  (let ((w (get-buffer-window org-agenda-buffer-name t))
+	(w0 (selected-window)))
+    (when w
+      (select-window w)
+      (org-agenda-redo)
+      (select-window w0)
+      (if org-agenda-overriding-restriction
+	  (message "Agenda view shifted to new %s restriction"
+		   org-agenda-overriding-restriction)
+	(message "Agenda restriction lock removed")))))
+
 ;;; Agenda commands
 
 (defun org-agenda-check-type (error &rest types)
@@ -20734,6 +21806,13 @@
   (setq org-agenda-new-buffers nil)
   (org-agenda-quit))
 
+(defun org-agenda-execute (arg)
+  "Execute another agenda command, keeping same window.\\<global-map>
+So this is just a shortcut for `\\[org-agenda]', available in the agenda."
+  (interactive "P")
+  (let ((org-agenda-window-setup 'current-window))
+    (org-agenda arg)))
+
 (defun org-save-all-org-buffers ()
   "Save all Org-mode buffers without user confirmation."
   (interactive)
@@ -20770,7 +21849,9 @@
     (cond
      (tdpos (goto-char tdpos))
      ((eq org-agenda-type 'agenda)
-      (let* ((sd (time-to-days (current-time)))
+      (let* ((sd (time-to-days
+		  (time-subtract (current-time)
+				 (list 0 (* 3600 org-extend-today-until) 0))))
 	     (comp (org-agenda-compute-time-span sd org-agenda-span))
 	     (org-agenda-overriding-arguments org-agenda-last-arguments))
 	(setf (nth 1 org-agenda-overriding-arguments) (car comp))
@@ -22034,6 +23115,7 @@
     (:archived-trees       . org-export-with-archived-trees)
     (:emphasize            . org-export-with-emphasize)
     (:sub-superscript      . org-export-with-sub-superscripts)
+    (:special-strings      . org-export-with-special-strings)
     (:footnotes            . org-export-with-footnotes)
     (:drawers              . org-export-with-drawers)
     (:tags                 . org-export-with-tags)
@@ -22047,10 +23129,11 @@
     (:tables               . org-export-with-tables)
     (:table-auto-headline  . org-export-highlight-first-table-line)
     (:style                . org-export-html-style)
-    (:agenda-style         . org-agenda-export-html-style) ;; FIXME: Does this work????
+    (:agenda-style         . org-agenda-export-html-style)
     (:convert-org-links    . org-export-html-link-org-files-as-html)
     (:inline-images        . org-export-html-inline-images)
     (:html-extension       . org-export-html-extension)
+    (:html-table-tag       . org-export-html-table-tag)
     (:expand-quoted-html   . org-export-html-expand)
     (:timestamp            . org-export-html-with-timestamp)
     (:publishing-directory . org-export-publishing-directory)
@@ -22071,50 +23154,53 @@
 (defun org-infile-export-plist ()
   "Return the property list with file-local settings for export."
   (save-excursion
-    (goto-char 0)
-    (let ((re (org-make-options-regexp
-	       '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
-	  p key val text options)
-      (while (re-search-forward re nil t)
-	(setq key (org-match-string-no-properties 1)
-	      val (org-match-string-no-properties 2))
-	(cond
-	 ((string-equal key "TITLE") (setq p (plist-put p :title val)))
-	 ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
-	 ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
-	 ((string-equal key "DATE") (setq p (plist-put p :date val)))
-	 ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
-	 ((string-equal key "TEXT")
-	  (setq text (if text (concat text "\n" val) val)))
-	 ((string-equal key "OPTIONS") (setq options val))))
-      (setq p (plist-put p :text text))
-      (when options
-	(let ((op '(("H"     . :headline-levels)
-		    ("num"   . :section-numbers)
-		    ("toc"   . :table-of-contents)
-		    ("\\n"   . :preserve-breaks)
-		    ("@"     . :expand-quoted-html)
-		    (":"     . :fixed-width)
-		    ("|"     . :tables)
-		    ("^"     . :sub-superscript)
-		    ("f"     . :footnotes)
-		    ("d"     . :drawers)
-		    ("tags"  . :tags)
-		    ("*"     . :emphasize)
-		    ("TeX"   . :TeX-macros)
-		    ("LaTeX" . :LaTeX-fragments)
-		    ("skip"  . :skip-before-1st-heading)
-		    ("author" . :author-info)
-		    ("timestamp" . :time-stamp-file)))
-	      o)
-	  (while (setq o (pop op))
-	    (if (string-match (concat (regexp-quote (car o))
-				      ":\\([^ \t\n\r;,.]*\\)")
-			      options)
-		(setq p (plist-put p (cdr o)
-				   (car (read-from-string
-					 (match-string 1 options)))))))))
-      p)))
+    (save-restriction
+      (widen)
+      (goto-char 0)
+      (let ((re (org-make-options-regexp
+		 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
+	    p key val text options)
+	(while (re-search-forward re nil t)
+	  (setq key (org-match-string-no-properties 1)
+		val (org-match-string-no-properties 2))
+	  (cond
+	   ((string-equal key "TITLE") (setq p (plist-put p :title val)))
+	   ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
+	   ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
+	   ((string-equal key "DATE") (setq p (plist-put p :date val)))
+	   ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
+	   ((string-equal key "TEXT")
+	    (setq text (if text (concat text "\n" val) val)))
+	   ((string-equal key "OPTIONS") (setq options val))))
+	(setq p (plist-put p :text text))
+	(when options
+	  (let ((op '(("H"     . :headline-levels)
+		      ("num"   . :section-numbers)
+		      ("toc"   . :table-of-contents)
+		      ("\\n"   . :preserve-breaks)
+		      ("@"     . :expand-quoted-html)
+		      (":"     . :fixed-width)
+		      ("|"     . :tables)
+		      ("^"     . :sub-superscript)
+		      ("-"     . :special-strings)
+		      ("f"     . :footnotes)
+		      ("d"     . :drawers)
+		      ("tags"  . :tags)
+		      ("*"     . :emphasize)
+		      ("TeX"   . :TeX-macros)
+		      ("LaTeX" . :LaTeX-fragments)
+		      ("skip"  . :skip-before-1st-heading)
+		      ("author" . :author-info)
+		      ("timestamp" . :time-stamp-file)))
+		o)
+	    (while (setq o (pop op))
+	      (if (string-match (concat (regexp-quote (car o))
+					":\\([^ \t\n\r;,.]*\\)")
+				options)
+		  (setq p (plist-put p (cdr o)
+				     (car (read-from-string
+					   (match-string 1 options)))))))))
+	p))))
 
 (defun org-export-directory (type plist)
   (let* ((val (plist-get plist :publishing-directory))
@@ -22397,8 +23483,8 @@
     ("prop") ("proptp"."&prop;")
     ("infin") ("infty"."&infin;")
     ("ang") ("angle"."&ang;")
-    ("and") ("vee"."&and;")
-    ("or") ("wedge"."&or;")
+    ("and") ("wedge"."&and;")
+    ("or") ("vee"."&or;")
     ("cap")
     ("cup")
     ("int")
@@ -22523,6 +23609,8 @@
 	 (commentsp (plist-get parameters :comments))
 	 (archived-trees (plist-get parameters :archived-trees))
 	 (inhibit-read-only t)
+	 (drawers org-drawers)
+	 (exp-drawers (plist-get parameters :drawers))
 	 (outline-regexp "\\*+ ")
 	 a b xx
 	 rtn p)
@@ -22561,14 +23649,14 @@
 	    (if (> b a) (delete-region a b)))))
 
       ;; Get rid of drawers
-      (unless (eq t org-export-with-drawers)
+      (unless (eq t exp-drawers)
 	(goto-char (point-min))
 	(let ((re (concat "^[ \t]*:\\("
-			  (mapconcat 'identity
-				     (if (listp org-export-with-drawers)
-					 org-export-with-drawers
-				       org-drawers)
-				     "\\|")
+			  (mapconcat
+			   'identity
+			   (org-delete-all exp-drawers
+					   (copy-sequence drawers))
+			   "\\|")
 			  "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
 	  (while (re-search-forward re nil t)
 	    (replace-match ""))))
@@ -22580,12 +23668,18 @@
 	(replace-match "\\1(INVISIBLE)"))
 
       ;; Protect backend specific stuff, throw away the others.
-      (goto-char (point-min))
       (let ((formatters
 	     `((,htmlp "HTML" "BEGIN_HTML" "END_HTML")
 	       (,asciip "ASCII" "BEGIN_ASCII" "END_ASCII")
 	       (,latexp "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
 	    fmt)
+	(goto-char (point-min))
+	(while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
+	  (goto-char (match-end 0))
+	  (while (not (looking-at "#\\+END_EXAMPLE"))
+	    (insert ": ")
+	    (beginning-of-line 2)))
+	(goto-char (point-min))
 	(while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
 	  (add-text-properties (match-beginning 0) (match-end 0)
 			       '(org-protected t)))
@@ -22617,6 +23711,13 @@
 	(add-text-properties (point) (org-end-of-subtree t)
 			     '(org-protected t)))
 
+      ;; Protect verbatim elements
+      (goto-char (point-min))
+      (while (re-search-forward org-verbatim-re nil t)
+	(add-text-properties (match-beginning 4) (match-end 4)
+			     '(org-protected t))
+	(goto-char (1+ (match-end 4))))
+
       ;; Remove subtrees that are commented
       (goto-char (point-min))
       (while (re-search-forward re-commented nil t)
@@ -22640,6 +23741,9 @@
 	(require 'org-export-latex nil)
 	(org-export-latex-cleaned-string))
 
+      (when asciip
+	(org-export-ascii-clean-string))
+
       ;; Specific HTML stuff
       (when htmlp
 	;; Convert LaTeX fragments to images
@@ -22887,6 +23991,8 @@
 		  :for-ascii t
 		  :skip-before-1st-heading
 		  (plist-get opt-plist :skip-before-1st-heading)
+		  :drawers (plist-get opt-plist :drawers)
+		  :verbatim-multiline t
 		  :archived-trees
 		  (plist-get opt-plist :archived-trees)
 		  :add-text (plist-get opt-plist :text))
@@ -23083,6 +24189,16 @@
 	(goto-char beg)))
     (goto-char (point-min))))
 
+(defun org-export-ascii-clean-string ()
+  "Do extra work for ASCII export"
+  (goto-char (point-min))
+  (while (re-search-forward org-verbatim-re nil t)
+    (goto-char (match-end 2))
+    (backward-delete-char 1) (insert "'")
+    (goto-char (match-beginning 2))
+    (delete-char 1) (insert "`")
+    (goto-char (match-end 2))))
+
 (defun org-search-todo-below (line lines level)
   "Search the subtree below LINE for any TODO entries."
   (let ((rest (cdr (memq line lines)))
@@ -23232,7 +24348,7 @@
 #+EMAIL:     %s
 #+LANGUAGE:  %s
 #+TEXT:      Some descriptive text to be emitted.  Several lines OK.
-#+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s
+#+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s
 #+CATEGORY:  %s
 #+SEQ_TODO:  %s
 #+TYP_TODO:  %s
@@ -23252,6 +24368,7 @@
    org-export-with-fixed-width
    org-export-with-tables
    org-export-with-sub-superscripts
+   org-export-with-special-strings
    org-export-with-footnotes
    org-export-with-emphasize
    org-export-with-TeX-macros
@@ -23308,6 +24425,7 @@
 	 (beg (if regionp (region-beginning) (point)))
 	 (end (if regionp (region-end)))
 	 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
+	 (case-fold-search nil)
 	 (re "[ \t]*\\(:\\)")
 	 off)
     (if regionp
@@ -23415,6 +24533,7 @@
 	(switch-to-buffer-other-window rtn)
       rtn)))
 
+(defvar html-table-tag nil) ; dynamically scoped into this.
 (defun org-export-as-html (arg &optional hidden ext-plist
 			       to-buffer body-only)
   "Export the outline as a pretty HTML file.
@@ -23469,14 +24588,16 @@
          (umax nil)
          (umax-toc nil)
          (filename (if to-buffer nil
-		     (concat (file-name-as-directory
-			      (org-export-directory :html opt-plist))
-			     (file-name-sans-extension
-			      (or (and subtree-p
-				       (org-entry-get (region-beginning)
-						      "EXPORT_FILE_NAME" t))
-				  (file-name-nondirectory buffer-file-name)))
-			     "." org-export-html-extension)))
+		     (expand-file-name
+		      (concat
+		       (file-name-sans-extension
+			(or (and subtree-p
+				 (org-entry-get (region-beginning)
+						"EXPORT_FILE_NAME" t))
+			    (file-name-nondirectory buffer-file-name)))
+		       "." org-export-html-extension)
+		      (file-name-as-directory
+		       (org-export-directory :html opt-plist)))))
 	 (current-dir (if buffer-file-name
 			  (file-name-directory buffer-file-name)
 			default-directory))
@@ -23497,6 +24618,7 @@
 			       (file-name-sans-extension
 				(file-name-nondirectory buffer-file-name)))
 			  "UNTITLED"))
+	 (html-table-tag (plist-get opt-plist :html-table-tag))
 	 (quote-re0   (concat "^[ \t]*" org-quote-string "\\>"))
 	 (quote-re    (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
 	 (inquote     nil)
@@ -23533,6 +24655,7 @@
 	    :for-html t
 	    :skip-before-1st-heading
 	    (plist-get opt-plist :skip-before-1st-heading)
+	    :drawers (plist-get opt-plist :drawers)
 	    :archived-trees
 	    (plist-get opt-plist :archived-trees)
 	    :add-text
@@ -23569,7 +24692,7 @@
 
     ;; Switch to the output buffer
     (set-buffer buffer)
-    (erase-buffer)
+    (let ((inhibit-read-only t)) (erase-buffer))
     (fundamental-mode)
 
     (and (fboundp 'set-buffer-file-coding-system)
@@ -23732,7 +24855,8 @@
 		(replace-match "\\2\n"))
 	      (insert line "\n")
 	      (while (and lines
-			  (get-text-property 0 'org-protected (car lines)))
+			  (or (= (length (car lines)) 0)
+			      (get-text-property 0 'org-protected (car lines))))
 		(insert (pop lines) "\n"))
 	      (and par (insert "<p>\n")))
 	    (throw 'nextline nil))
@@ -23768,7 +24892,8 @@
 	  ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
 	  ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
 	  ;; Also handle sub_superscripts and checkboxes
-	  (setq line (org-html-expand line))
+	  (or (string-match org-table-hline-regexp line)
+	      (setq line (org-html-expand line)))
 
 	  ;; Format the links
 	  (setq start 0)
@@ -23868,14 +24993,17 @@
 
 	  ;; Does this contain a reference to a footnote?
 	  (when org-export-with-footnotes
-	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line)
-	      (let ((n (match-string 2 line)))
-		(setq line
-		      (replace-match
-		       (format
-			"%s<sup><a class=\"footref\" name=\"fnr.%s\" href=\"#fn.%s\">%s</a></sup>"
-			(match-string 1 line) n n n)
-		       t t line)))))
+	    (setq start 0)
+	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
+	      (if (get-text-property (match-beginning 2) 'org-protected line)
+		  (setq start (match-end 2))
+		(let ((n (match-string 2 line)))
+		  (setq line
+			(replace-match
+			 (format
+			  "%s<sup><a class=\"footref\" name=\"fnr.%s\" href=\"#fn.%s\">%s</a></sup>"
+			  (match-string 1 line) n n n)
+			 t t line))))))
 
 	  (cond
 	   ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
@@ -24005,7 +25133,7 @@
 	  (pop local-list-num))
 	(setq local-list-indent nil
 	      in-local-list nil))
-      (org-html-level-start 0 nil umax
+      (org-html-level-start 1 nil umax
 			    (and org-export-with-toc (<= level umax))
 			    head-count)
 
@@ -24016,8 +25144,13 @@
 	    (insert "<p class=\"author\"> "
 		    (nth 1 lang-words) ": " author "\n")
 	    (when email
-	      (insert "<a href=\"mailto:" email "\">&lt;"
-		      email "&gt;</a>\n"))
+	      (if (listp (split-string email ",+ *"))
+		  (mapc (lambda(e)
+			  (insert "<a href=\"mailto:" e "\">&lt;"
+				  e "&gt;</a>\n"))
+			(split-string email ",+ *"))
+		(insert "<a href=\"mailto:" email "\">&lt;"
+			email "&gt;</a>\n")))
 	    (insert "</p>\n"))
 	  (when (and date org-export-time-stamp-file)
 	    (insert "<p class=\"date\"> "
@@ -24201,11 +25334,11 @@
     (unless splice (push "</table>\n" html))
     (setq html (nreverse html))
     (unless splice
-      ;; Put in COL tags with the alignment (unfortuntely often ignored...)
+      ;; Put in col tags with the alignment (unfortuntely often ignored...)
       (push (mapconcat
 	     (lambda (x)
 	       (setq gr (pop org-table-colgroup-info))
-	       (format "%s<COL align=\"%s\"></COL>%s"
+	       (format "%s<col align=\"%s\"></col>%s"
 		       (if (memq gr '(:start :startend))
 			   (prog1
 			       (if colgropen "</colgroup>\n<colgroup>" "<colgroup>")
@@ -24219,7 +25352,7 @@
 	     fnum "")
 	    html)
       (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html)))))
-      (push org-export-html-table-tag html))
+      (push html-table-tag html))
     (concat (mapconcat 'identity html "\n") "\n")))
 
 (defun org-table-clean-before-export (lines)
@@ -24267,8 +25400,7 @@
 	      ((or (string-match "^\\([ \t]*\\)|-+\\+" x)
 		   (string-match "^\\([ \t]*\\)|[^|]*|" x))
 	       ;; remove the first column
-	       (replace-match "\\1|" t nil x))
-	      (t (error "This should not happen"))))
+	       (replace-match "\\1|" t nil x))))
 	   lines))))
 
 (defun org-format-table-table-html (lines)
@@ -24279,7 +25411,7 @@
   (let (line field-buffer
 	     (head org-export-highlight-first-table-line)
 	     fields html empty)
-    (setq html (concat org-export-html-table-tag "\n"))
+    (setq html (concat html-table-tag "\n"))
     (while (setq line (pop lines))
       (setq empty "&nbsp;")
       (catch 'next-line
@@ -24407,21 +25539,26 @@
   "Apply all active conversions to translate special ASCII to HTML."
   (setq s (org-html-protect s))
   (if org-export-html-expand
-      (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
-	(setq s (replace-match "<\\1>" t nil s))))
+      (let ((start 0))
+	(while (string-match "@&lt;\\([^&]*\\)&gt;" s)
+	  (setq s (replace-match "<\\1>" t nil s)))))
   (if org-export-with-emphasize
       (setq s (org-export-html-convert-emphasize s)))
+  (if org-export-with-special-strings
+      (setq s (org-export-html-convert-special-strings s)))
   (if org-export-with-sub-superscripts
       (setq s (org-export-html-convert-sub-super s)))
   (if org-export-with-TeX-macros
       (let ((start 0) wd ass)
 	(while (setq start (string-match "\\\\\\([a-zA-Z]+\\)" s start))
-	  (setq wd (match-string 1 s))
-	  (if (setq ass (assoc wd org-html-entities))
-	      (setq s (replace-match (or (cdr ass)
-					 (concat "&" (car ass) ";"))
-				     t t s))
-	    (setq start (+ start (length wd)))))))
+	  (if (get-text-property (match-beginning 0) 'org-protected s)
+	      (setq start (match-end 0))
+	    (setq wd (match-string 1 s))
+	    (if (setq ass (assoc wd org-html-entities))
+		(setq s (replace-match (or (cdr ass)
+					   (concat "&" (car ass) ";"))
+				       t t s))
+	      (setq start (+ start (length wd))))))))
   s)
 
 (defun org-create-multibrace-regexp (left right n)
@@ -24452,16 +25589,41 @@
    "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
   "The regular expression matching a sub- or superscript.")
 
-;(let ((s "a\\_b"))
-;  (and (string-match org-match-substring-regexp s)
-;       (conca	     t (match-string 1 s) ":::" (match-string 2 s))))
+(defvar org-match-substring-with-braces-regexp
+  (concat
+   "\\([^\\]\\)\\([_^]\\)\\("
+   "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
+   "\\)")
+  "The regular expression matching a sub- or superscript, forcing braces.")
+
+(defconst org-export-html-special-string-regexps
+  '(("\\\\-" . "&shy;")
+    ("---\\([^-]\\)" . "&mdash;\\1")
+    ("--\\([^-]\\)" . "&ndash;\\1")
+    ("\\.\\.\\." . "&hellip;"))
+  "Regular expressions for special string conversion.")
+
+(defun org-export-html-convert-special-strings (string)
+  "Convert special characters in STRING to HTML."
+  (let ((all org-export-html-special-string-regexps)
+	e a re rpl start)
+    (while (setq a (pop all))
+      (setq re (car a) rpl (cdr a) start 0)
+      (while (string-match re string start)
+	(if (get-text-property (match-beginning 0) 'org-protected string)
+	    (setq start (match-end 0))
+	  (setq string (replace-match rpl t nil string)))))
+    string))
 
 (defun org-export-html-convert-sub-super (string)
   "Convert sub- and superscripts in STRING to HTML."
   (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
     (while (string-match org-match-substring-regexp string s)
-      (if (and requireb (match-end 8))
-	  (setq s (match-end 2))
+      (cond
+       ((and requireb (match-end 8)) (setq s (match-end 2)))
+       ((get-text-property  (match-beginning 2) 'org-protected string)
+	(setq s (match-end 2)))
+       (t
 	(setq s (match-end 1)
 	      key (if (string= (match-string 2 string) "_") "sub" "sup")
 	      c (or (match-string 8 string)
@@ -24470,22 +25632,29 @@
 	      string (replace-match
 		      (concat (match-string 1 string)
 			      "<" key ">" c "</" key ">")
-		      t t string))))
+		      t t string)))))
     (while (string-match "\\\\\\([_^]\\)" string)
       (setq string (replace-match (match-string 1 string) t t string)))
     string))
 
 (defun org-export-html-convert-emphasize (string)
   "Apply emphasis."
-  (let ((s 0))
+  (let ((s 0) rpl)
     (while (string-match org-emph-re string s)
       (if (not (equal
 		(substring string (match-beginning 3) (1+ (match-beginning 3)))
 		(substring string (match-beginning 4) (1+ (match-beginning 4)))))
-	  (setq string (replace-match
-			(concat "\\1" (nth 2 (assoc (match-string 3 string) org-emphasis-alist))
-				"\\4" (nth 3 (assoc (match-string 3 string) org-emphasis-alist))
-				"\\5") t nil string))
+	  (setq s (match-beginning 0)
+		rpl
+		(concat
+		 (match-string 1 string)
+		 (nth 2 (assoc (match-string 3 string) org-emphasis-alist))
+		 (match-string 4 string)
+		 (nth 3 (assoc (match-string 3 string)
+			       org-emphasis-alist))
+		 (match-string 5 string))
+		string (replace-match rpl t t string)
+		s (+ s (- (length rpl) 2)))
 	(setq s (1+ s))))
     string))
 
@@ -24511,7 +25680,7 @@
 When TITLE is nil, just close all open levels."
   (org-close-par-maybe)
   (let ((l org-level-max))
-    (while (>= l (1+ level))
+    (while (>= l level)
       (if (aref org-levels-open (1- l))
 	  (progn
 	    (org-html-level-close l umax)
@@ -24657,10 +25826,14 @@
 		ts (match-string 0)
 		inc t
 		hd (org-get-heading)
-		summary (org-entry-get nil "SUMMARY")
-		desc (or (org-entry-get nil "DESCRIPTION")
-			 (org-get-cleaned-entry org-icalendar-include-body))
-		location (org-entry-get nil "LOCATION")
+		summary (org-icalendar-cleanup-string
+			 (org-entry-get nil "SUMMARY"))
+		desc (org-icalendar-cleanup-string
+		      (or (org-entry-get nil "DESCRIPTION")
+			  (and org-icalendar-include-body (org-get-entry)))
+		      t org-icalendar-include-body)
+		location (org-icalendar-cleanup-string
+			  (org-entry-get nil "LOCATION"))
 		category (org-get-category))
 	  (if (looking-at re2)
 	      (progn
@@ -24748,10 +25921,14 @@
 		       (not (member org-archive-tag (org-get-tags-at)))
 		       )
 	      (setq hd (match-string 3)
-		    summary (org-entry-get nil "SUMMARY")
-		    desc (or (org-entry-get nil "DESCRIPTION")
-			     (org-get-cleaned-entry org-icalendar-include-body))
-		    location (org-entry-get nil "LOCATION"))
+		    summary (org-icalendar-cleanup-string
+			     (org-entry-get nil "SUMMARY"))
+		    desc (org-icalendar-cleanup-string
+			  (or (org-entry-get nil "DESCRIPTION")
+			      (and org-icalendar-include-body (org-get-entry)))
+			  t org-icalendar-include-body)
+		    location (org-icalendar-cleanup-string
+			      (org-entry-get nil "LOCATION")))
 	      (if (string-match org-bracket-link-regexp hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
 					    (match-string 1 hd))
@@ -24780,24 +25957,38 @@
 				 (concat "\nDESCRIPTION: " desc) "")
 			     category pri status)))))))))
 
-(defun org-get-cleaned-entry (what)
-  "Clean-up description string."
-  (when what
-    (save-excursion
-      (org-back-to-heading t)
-      (let ((s (buffer-substring (point-at-bol 2) (org-end-of-subtree t)))
-	    (re (concat org-drawer-regexp "[^\000]*?:END:.*\n?"))
+(defun org-icalendar-cleanup-string (s &optional is-body maxlength)
+  "Take out stuff and quote what needs to be quoted.
+When IS-BODY is non-nil, assume that this is the body of an item, clean up
+whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
+characters."
+  (if (not s)
+      nil
+    (when is-body
+      (let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
 	    (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
 	(while (string-match re s) (setq s (replace-match "" t t s)))
-	(while (string-match re2 s) (setq s (replace-match "" t t s)))
-	(if (string-match "[ \t\r\n]+\\'" s) (setq s (replace-match "" t t s)))
-	(while (string-match "[ \t]*\n[ \t]*" s)
-	  (setq s (replace-match "\\n" t t s)))
-	(setq s (org-trim s))
-	(if (and (numberp what)
-		 (> (length s) what))
-	    (substring s 0 what)
-	  s)))))
+	(while (string-match re2 s) (setq s (replace-match "" t t s)))))
+    (let ((start 0))
+      (while (string-match "\\([,;\\]\\)" s start)
+	(setq start (+ (match-beginning 0) 2)
+	      s (replace-match "\\\\\\1" nil nil s))))
+    (when is-body
+      (while (string-match "[ \t]*\n[ \t]*" s)
+	(setq s (replace-match "\\n" t t s))))
+    (setq s (org-trim s))
+    (if is-body
+	(if maxlength
+	    (if (and (numberp maxlength)
+		     (> (length s) maxlength))
+		(setq s (substring s 0 maxlength)))))
+    s))
+
+(defun org-get-entry ()
+  "Clean-up description string."
+  (save-excursion
+    (org-back-to-heading t)
+    (buffer-substring (point-at-bol 2) (org-end-of-subtree t))))
 
 (defun org-start-icalendar-file (name)
   "Start an iCalendar file by inserting the header."
@@ -24853,8 +26044,8 @@
 
   ;; Output everything as XOXO
   (with-current-buffer (get-buffer buffer)
-    (goto-char (point-min))  ;; CD:  beginning-of-buffer is not allowed.
-    (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+    (let* ((pos (point))
+	   (opt-plist (org-combine-plists (org-default-export-plist)
 					(org-infile-export-plist)))
 	   (filename (concat (file-name-as-directory
 			      (org-export-directory :xoxo opt-plist))
@@ -24864,6 +26055,7 @@
 	   (out (find-file-noselect filename))
 	   (last-level 1)
 	   (hanging-li nil))
+      (goto-char (point-min))  ;; CD:  beginning-of-buffer is not allowed.
       ;; Check the output buffer is empty.
       (with-current-buffer out (erase-buffer))
       ;; Kick off the output
@@ -24916,6 +26108,7 @@
             (org-export-as-xoxo-insert-into out "</li>\n"))
         (org-export-as-xoxo-insert-into out "</ol>\n"))
 
+      (goto-char pos)
       ;; Finish the buffer off and clean it up.
       (switch-to-buffer-other-window out)
       (indent-region (point-min) (point-max) nil)
@@ -25009,7 +26202,7 @@
 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline)
 (org-defkey org-mode-map "\C-c;"    'org-toggle-comment)
 (org-defkey org-mode-map "\C-c\C-v" 'org-show-todo-tree)
-(org-defkey org-mode-map "\C-c\C-w" 'org-check-deadlines)
+(org-defkey org-mode-map "\C-c\C-w" 'org-refile)
 (org-defkey org-mode-map "\C-c/"    'org-sparse-tree)   ; Minor-mode reserved
 (org-defkey org-mode-map "\C-c\\"   'org-tags-sparse-tree) ; Minor-mode res.
 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret)
@@ -25032,12 +26225,15 @@
 (org-defkey org-mode-map [(control ?\')]     'org-cycle-agenda-files)
 (org-defkey org-mode-map "\C-c["    'org-agenda-file-to-front)
 (org-defkey org-mode-map "\C-c]"    'org-remove-file)
+(org-defkey org-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock)
+(org-defkey org-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
 (org-defkey org-mode-map "\C-c-"    'org-ctrl-c-minus)
 (org-defkey org-mode-map "\C-c^"    'org-sort)
 (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
 (org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
 (org-defkey org-mode-map "\C-c#"    'org-update-checkbox-count)
 (org-defkey org-mode-map "\C-m"     'org-return)
+(org-defkey org-mode-map "\C-j"     'org-return-indent)
 (org-defkey org-mode-map "\C-c?"    'org-table-field-info)
 (org-defkey org-mode-map "\C-c "    'org-table-blank-field)
 (org-defkey org-mode-map "\C-c+"    'org-table-sum)
@@ -25175,12 +26371,9 @@
 (put 'org-delete-char 'flyspell-delayed t)
 (put 'org-delete-backward-char 'flyspell-delayed t)
 
-(eval-after-load "pabbrev"
-  '(progn
-     (add-to-list 'pabbrev-expand-after-command-list
-		  'orgtbl-self-insert-command t)
-     (add-to-list 'pabbrev-expand-after-command-list
-		  'org-self-insert-command t)))
+;; Make pabbrev-mode expand after org-mode commands
+(put 'org-self-insert-command 'pabbrev-expand-after-command t)
+(put 'orgybl-self-insert-command 'pabbrev-expand-after-command t)
 
 ;; How to do this: Measure non-white length of current string
 ;; If equal to column width, we should realign.
@@ -25442,7 +26635,9 @@
   links in this buffer.
 
 - If the cursor is on a numbered item in a plain list, renumber the
-  ordered list."
+  ordered list.
+
+- If the cursor is on a checkbox, toggle it."
   (interactive "P")
   (let  ((org-enable-table-editor t))
     (cond
@@ -25500,25 +26695,31 @@
   (message "Org-mode restarted to refresh keyword and special line setup"))
 
 (defun org-kill-note-or-show-branches ()
-  "If this is a Note buffer, abort storing the note. Else call `show-branches'."
+  "If this is a Note buffer, abort storing the note.  Else call `show-branches'."
   (interactive)
   (if (not org-finish-function)
       (call-interactively 'show-branches)
     (let ((org-note-abort t))
       (funcall org-finish-function))))
 
-(defun org-return ()
+(defun org-return (&optional indent)
   "Goto next table row or insert a newline.
 Calls `org-table-next-row' or `newline', depending on context.
 See the individual commands for more information."
   (interactive)
   (cond
-   ((bobp) (newline))
+   ((bobp) (if indent (newline-and-indent) (newline)))
    ((org-at-table-p)
     (org-table-justify-field-maybe)
     (call-interactively 'org-table-next-row))
-   (t (newline))))
-
+   (t (if indent (newline-and-indent) (newline)))))
+
+(defun org-return-indent ()
+  (interactive)
+  "Goto next table row or insert a newline and indent.
+Calls `org-table-next-row' or `newline-and-indent', depending on
+context.  See the individual commands for more information."
+  (org-return t))
 
 (defun org-ctrl-c-minus ()
   "Insert separator line in table or modify bullet type in list.
@@ -25723,6 +26924,7 @@
       :style toggle :selected org-log-done])
     "--"
     ["Agenda Command..." org-agenda t]
+    ["Set Restriction Lock" org-agenda-set-restriction-lock t]
     ("File List for Agenda")
     ("Special views current file"
      ["TODO Tree"  org-show-todo-tree t]
@@ -25981,6 +27183,18 @@
     (setq list (delete (pop elts) list)))
   list)
 
+(defun org-back-over-empty-lines ()
+  "Move backwards over witespace, to the beginning of the first empty line.
+Returns the number o empty lines passed."
+  (let ((pos (point)))
+    (skip-chars-backward " \t\n\r")
+    (beginning-of-line 2)
+    (goto-char (min (point) pos))
+    (count-lines (point) pos)))
+
+(defun org-skip-whitespace ()
+  (skip-chars-forward " \t\n\r"))
+
 (defun org-point-in-group (point group &optional context)
   "Check if POINT is in match-group GROUP.
 If CONTEXT is non-nil, return a list with CONTEXT and the boundaries of the
@@ -26129,10 +27343,13 @@
 	    (setq column tcol)
 	  (goto-char pos)
 	  (beginning-of-line 1)
-	  (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
-	  (setq bullet (match-string 1)
-		btype (if (string-match "[0-9]" bullet) "n" bullet))
-	  (setq column (if (equal btype bullet-type) bcol tcol))))
+	  (if (looking-at "\\S-")
+	      (progn
+		(looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
+		(setq bullet (match-string 1)
+		      btype (if (string-match "[0-9]" bullet) "n" bullet))
+		(setq column (if (equal btype bullet-type) bcol tcol)))
+	    (setq column (org-get-indentation)))))
        (t (setq column (org-get-indentation))))))
     (goto-char pos)
     (if (<= (current-column) (current-indentation))
@@ -26141,7 +27358,7 @@
     (setq column (current-column))
     (beginning-of-line 1)
     (if (looking-at
-	 "\\([ \t]+\\)\\(:[0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
+	 "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
 	(replace-match (concat "\\1" (format org-property-format
 					     (match-string 2) (match-string 3)))
 		       t nil))
@@ -26183,10 +27400,13 @@
   "Re-align a table, pass through to fill-paragraph if no table."
   (let ((table-p (org-at-table-p))
 	(table.el-p (org-at-table.el-p)))
-    (cond ((equal (char-after (point-at-bol)) ?*) t) ; skip headlines
-	  (table.el-p t)                             ; skip table.el tables
-	  (table-p (org-table-align) t)              ; align org-mode tables
-	  (t nil))))                                 ; call paragraph-fill
+    (cond ((and (equal (char-after (point-at-bol)) ?*)
+		(save-excursion (goto-char (point-at-bol))
+				(looking-at outline-regexp)))
+	   t)					     ; skip headlines
+	  (table.el-p t)			     ; skip table.el tables
+	  (table-p (org-table-align) t)		     ; align org-mode tables
+	  (t nil))))				     ; call paragraph-fill
 
 ;; For reference, this is the default value of adaptive-fill-regexp
 ;;  "[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"
@@ -26318,6 +27538,20 @@
 	(if (< level start-level) (throw 'exit level)))
       nil)))
 
+(defun org-first-sibling-p ()
+  "Is this heading the first child of its parents?"
+  (interactive)
+  (let ((re (concat "^" outline-regexp))
+	level l)
+    (unless (org-at-heading-p t)
+      (error "Not at a heading"))
+    (setq level (funcall outline-level))
+    (save-excursion
+      (if (not (re-search-backward re nil t))
+	  t
+	(setq l (funcall outline-level))
+	(< l level)))))
+
 (defun org-goto-sibling (&optional previous)
   "Goto the next sibling, even if it is invisible.
 When PREVIOUS is set, go to the previous sibling instead.  Returns t
@@ -26446,7 +27680,104 @@
   (org-show-context 'isearch))
 
 
-;;;; Address problems with some other packages
+;;;; Integration with and fixes for other packages
+
+;;; Imenu support
+
+(defvar org-imenu-markers nil
+  "All markers currently used by Imenu.")
+(make-variable-buffer-local 'org-imenu-markers)
+
+(defun org-imenu-new-marker (&optional pos)
+  "Return a new marker for use by Imenu, and remember the marker."
+  (let ((m (make-marker)))
+    (move-marker m (or pos (point)))
+    (push m org-imenu-markers)
+    m))
+
+(defun org-imenu-get-tree ()
+  "Produce the index for Imenu."
+  (mapc (lambda (x) (move-marker x nil)) org-imenu-markers)
+  (setq org-imenu-markers nil)
+  (let* ((n org-imenu-depth)
+	 (re (concat "^" outline-regexp))
+	 (subs (make-vector (1+ n) nil))
+	 (last-level 0)
+	 m tree level head)
+    (save-excursion
+      (save-restriction
+	(widen)
+	(goto-char (point-max))
+	(while (re-search-backward re nil t)
+	  (setq level (org-reduced-level (funcall outline-level)))
+	  (when (<= level n)
+	    (looking-at org-complex-heading-regexp)
+	    (setq head (org-match-string-no-properties 4)
+		  m (org-imenu-new-marker))
+	    (org-add-props head nil 'org-imenu-marker m 'org-imenu t)
+	    (if (>= level last-level)
+		(push (cons head m) (aref subs level))
+	      (push (cons head (aref subs (1+ level))) (aref subs level))
+	      (loop for i from (1+ level) to n do (aset subs i nil)))
+	    (setq last-level level)))))
+    (aref subs 1)))
+
+(eval-after-load "imenu"
+  '(progn
+     (add-hook 'imenu-after-jump-hook
+	       (lambda () (org-show-context 'org-goto)))))
+
+;; Speedbar support
+
+(defun org-speedbar-set-agenda-restriction ()
+  "Restrict future agenda commands to the location at point in speedbar.
+To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
+  (interactive)
+  (let (p m tp np dir txt w)
+    (cond
+     ((setq p (text-property-any (point-at-bol) (point-at-eol)
+				 'org-imenu t))
+      (setq m (get-text-property p 'org-imenu-marker))
+      (save-excursion
+	(save-restriction
+	  (set-buffer (marker-buffer m))
+	  (goto-char m)
+	  (org-agenda-set-restriction-lock 'subtree))))
+     ((setq p (text-property-any (point-at-bol) (point-at-eol)
+				 'speedbar-function 'speedbar-find-file))
+      (setq tp (previous-single-property-change
+		(1+ p) 'speedbar-function)
+	    np (next-single-property-change
+		tp 'speedbar-function)
+	    dir (speedbar-line-directory)
+	    txt (buffer-substring-no-properties (or tp (point-min))
+						(or np (point-max))))
+      (save-excursion
+	(save-restriction
+	  (set-buffer (find-file-noselect
+		       (let ((default-directory dir))
+			 (expand-file-name txt))))
+	  (unless (org-mode-p)
+	    (error "Cannot restrict to non-Org-mode file"))
+	  (org-agenda-set-restriction-lock 'file))))
+     (t (error "Don't know how to restrict Org-mode's agenda")))
+    (org-move-overlay org-speedbar-restriction-lock-overlay
+		      (point-at-bol) (point-at-eol))
+    (setq current-prefix-arg nil)
+    (org-agenda-maybe-redo)))
+
+(eval-after-load "speedbar"
+  '(progn
+     (speedbar-add-supported-extension ".org")
+     (define-key speedbar-file-key-map "<" 'org-speedbar-set-agenda-restriction)
+     (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction)
+     (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
+     (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
+     (add-hook 'speedbar-visiting-tag-hook
+	       (lambda () (org-show-context 'org-goto)))))
+
+
+;;; Fixes and Hacks
 
 ;; Make flyspell not check words in links, to not mess up our keymap
 (defun org-mode-flyspell-verify ()
@@ -26471,6 +27802,13 @@
 			   (org-invisible-p)))
        (org-show-context 'bookmark-jump)))
 
+;; Fix a bug in htmlize where there are text properties (face nil)
+(eval-after-load "htmlize"
+  '(progn
+     (defadvice htmlize-faces-in-buffer (after org-no-nil-faces activate)
+       "Make sure there are no nil faces"
+       (setq ad-return-value (delq nil ad-return-value)))))
+
 ;; Make session.el ignore our circular variable
 (eval-after-load "session"
   '(add-to-list 'session-globals-exclude 'org-mark-ring))
@@ -26479,7 +27817,7 @@
 
 (defun org-closed-in-range ()
   "Sparse tree of items closed in a certain time range.
-Still experimental, may disappear in the furture."
+Still experimental, may disappear in the future."
   (interactive)
   ;; Get the time interval from the user.
   (let* ((time1 (time-to-seconds
@@ -26498,64 +27836,6 @@
     ;; make tree, check each match with the callback
     (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
 
-(defun org-fill-paragraph-experimental (&optional justify)
-  "Re-align a table, pass through to fill-paragraph if no table."
-  (let ((table-p (org-at-table-p))
-	(table.el-p (org-at-table.el-p)))
-    (cond ((equal (char-after (point-at-bol)) ?*) t) ; skip headlines
-	  (table.el-p t)                             ; skip table.el tables
-	  (table-p (org-table-align) t)              ; align org-mode tables
-	  ((save-excursion
-	     (let ((pos (1+ (point-at-eol))))
-	       (backward-paragraph 1)
-	       (re-search-forward "\\\\\\\\[ \t]*$" pos t)))
-	   (save-excursion
-	     (save-restriction
-	       (narrow-to-region (1+ (match-end 0)) (point-max))
-	       (fill-paragraph nil)
-	       t)))
-	  (t nil))))                                 ; call paragraph-fill
-
-;; FIXME: this needs a much better algorithm
-(defun org-assign-fast-keys (alist)
-  "Assign fast keys to a keyword-key alist.
-Respect keys that are already there."
-  (let (new e k c c1 c2 (char ?a))
-    (while (setq e (pop alist))
-      (cond
-       ((equal e '(:startgroup)) (push e new))
-       ((equal e '(:endgroup)) (push e new))
-       (t
-	(setq k (car e) c2 nil)
-	(if (cdr e)
-	    (setq c (cdr e))
-	  ;; automatically assign a character.
-	  (setq c1 (string-to-char
-		    (downcase (substring
-			       k (if (= (string-to-char k) ?@) 1 0)))))
-	  (if (or (rassoc c1 new) (rassoc c1 alist))
-	      (while (or (rassoc char new) (rassoc char alist))
-		(setq char (1+ char)))
-	    (setq c2 c1))
-	  (setq c (or c2 char)))
-	(push (cons k c) new))))
-    (nreverse new)))
-
-;(defcustom org-read-date-prefer-future nil
-;  "Non-nil means, when reading an incomplete date from the user, assume future.
-;This affects the following situations:
-;1. The user give a day, but no month.
-;   In this case, if the day number if after today, the current month will
-;   be used, otherwise the next month.
-;2. The user gives a month but not a year.
-;   In this case, the the given month is after the current month, the current
-;   year will be used.  Otherwise the next year will be used.;
-;
-;When nil, always the current month and year will be used."
-;  :group 'org-time ;????
-;  :type 'boolean)
-
-
 ;;;; Finish up
 
 (provide 'org)
@@ -26565,4 +27845,3 @@
 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
 ;;; org.el ends here
 
-
--- a/lisp/textmodes/reftex-index.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/reftex-index.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1243,8 +1243,9 @@
           (beginning-of-line 2))
       (while (looking-at "^[ \t]*$")
           (beginning-of-line 2))          
-      (cond ((fboundp 'zmacs-activate-region) (zmacs-activate-region))
-            ((boundp 'make-active) (setq mark-active t)))
+      (if (featurep 'xemacs) 
+	  (zmacs-activate-region)
+	(setq mark-active t))
       (if (yes-or-no-p "Delete and rebuild header? ")
           (delete-region (point-min) (point))))
 
@@ -1495,8 +1496,9 @@
       (unwind-protect
           (progn
             ;; Hide the region highlighting
-            (cond ((fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region))
-                  ((fboundp 'deactivate-mark) (deactivate-mark)))
+            (if (featurep 'xemacs)
+		(zmacs-deactivate-region)
+	      (deactivate-mark))
             (delete-other-windows)
             (reftex-index-visit-phrases-buffer)
             (reftex-index-all-phrases))
--- a/lisp/textmodes/reftex-toc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/reftex-toc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -326,7 +326,7 @@
 (defun reftex-toc-next (&optional arg)
   "Move to next selectable item."
   (interactive "p")
-  (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
+  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
   (goto-char (or (next-single-property-change (point) :data) 
@@ -334,21 +334,21 @@
 (defun reftex-toc-previous (&optional arg)
   "Move to previous selectable item."
   (interactive "p")
-  (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
+  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd nil)
   (goto-char (or (previous-single-property-change (point) :data)
                  (point))))
 (defun reftex-toc-next-heading (&optional arg)
   "Move to next table of contentes line."
   (interactive "p")
-  (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
+  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (end-of-line)
   (re-search-forward "^ " nil t arg)
   (beginning-of-line))
 (defun reftex-toc-previous-heading (&optional arg)
   "Move to previous table of contentes line."
   (interactive "p")
-  (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
+  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (re-search-backward "^ " nil t arg))
 (defun reftex-toc-toggle-follow ()
   "Toggle follow (other window follows with context)."
@@ -637,7 +637,7 @@
   (if mark-line
       (progn
         (set-mark mpos)
-        (if (fboundp 'zmacs-activate-region)
+        (if (featurep 'xemacs)
             (zmacs-activate-region)
           (setq mark-active t
                 deactivate-mark nil)))))
--- a/lisp/textmodes/remember.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/remember.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,7 +1,7 @@
 ;;; remember --- a mode for quickly jotting down things to remember
 
-;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-;;   2007 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
+;;   2008  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Created: 29 Mar 1999
--- a/lisp/textmodes/sgml-mode.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/textmodes/sgml-mode.el	Wed Jan 30 07:57:28 2008 +0000
@@ -157,7 +157,7 @@
   "Syntax table used in SGML mode.  See also `sgml-specials'.")
 
 (defconst sgml-tag-syntax-table
-  (let ((table (sgml-make-syntax-table '(?- ?\" ?\'))))
+  (let ((table (sgml-make-syntax-table sgml-specials)))
     (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/))
       (modify-syntax-entry char "." table))
     table)
--- a/lisp/url/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/url/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,16 @@
+2008-01-29  John Wiegley  <johnw@newartisans.com>
+
+	* url-auth.el (url-digest-auth): If the 'opaque' argument is not
+	being used, don't add it to the response text.  Also, changed an
+	if so that the interaction between the PROMPT and OVERWRITE
+	arguments can no longer result in the user being queried twice for
+	the same login and password information.
+
+2008-01-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* url-handlers.el (unhandled-file-name-directory): Add handler.
+	(url-handler-unhandled-file-name-directory): New fun.
+
 2008-01-07  Michael Albinus  <michael.albinus@gmx.de>
 
 	* url-handlers.el (url-file-handler): Autoload.
--- a/lisp/url/url-auth.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/url/url-auth.el	Wed Jan 30 07:57:28 2008 +0000
@@ -188,31 +188,40 @@
 			 (string= data (substring file 0 (length data)))))
 		    (setq retval (cdr (car byserv))))
 		(setq byserv (cdr byserv))))
-	  (if (or (and (not retval) prompt) overwrite)
-	      (progn
-		(setq user (read-string (url-auth-user-prompt url realm)
-					(user-real-login-name))
-		      pass (read-passwd "Password: ")
-		      retval (setq retval
-				   (cons user
-					 (url-digest-auth-create-key
-					  user pass realm
-					  (or url-request-method "GET")
-					  url)))
-		      byserv (assoc server url-digest-auth-storage))
+	  (if overwrite
+	      (if (and (not retval) prompt)
+		  (setq user (read-string (url-auth-user-prompt url realm)
+					  (user-real-login-name))
+			pass (read-passwd "Password: ")
+			retval (setq retval
+				     (cons user
+					   (url-digest-auth-create-key
+					    user pass realm
+					    (or url-request-method "GET")
+					    url)))
+			byserv (assoc server url-digest-auth-storage))
 		(setcdr byserv
 			(cons (cons file retval) (cdr byserv))))))
 	 (t (setq retval nil)))
 	(if retval
-	    (let ((nonce (or (cdr-safe (assoc "nonce" args)) "nonegiven"))
-		  (opaque (or (cdr-safe (assoc "opaque" args)) "nonegiven")))
-	      (format
-	       (concat "Digest username=\"%s\", realm=\"%s\","
-		       "nonce=\"%s\", uri=\"%s\","
-		       "response=\"%s\", opaque=\"%s\"")
-	       (nth 0 retval) realm nonce (url-filename href)
-	       (md5 (concat (nth 1 retval) ":" nonce ":"
-			    (nth 2 retval))) opaque))))))
+	    (if (cdr-safe (assoc "opaque" args))
+		(let ((nonce (or (cdr-safe (assoc "nonce" args)) "nonegiven"))
+		      (opaque (cdr-safe (assoc "opaque" args))))
+		  (format
+		   (concat "Digest username=\"%s\", realm=\"%s\","
+			   "nonce=\"%s\", uri=\"%s\","
+			   "response=\"%s\", opaque=\"%s\"")
+		   (nth 0 retval) realm nonce (url-filename href)
+		   (md5 (concat (nth 1 retval) ":" nonce ":"
+				(nth 2 retval))) opaque))
+	      (let ((nonce (or (cdr-safe (assoc "nonce" args)) "nonegiven")))
+		(format
+		 (concat "Digest username=\"%s\", realm=\"%s\","
+			 "nonce=\"%s\", uri=\"%s\","
+			 "response=\"%s\"")
+		 (nth 0 retval) realm nonce (url-filename href)
+		 (md5 (concat (nth 1 retval) ":" nonce ":"
+			      (nth 2 retval))))))))))
 
 (defvar url-registered-auth-schemes nil
   "A list of the registered authorization schemes and various and sundry
--- a/lisp/url/url-handlers.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/url/url-handlers.el	Wed Jan 30 07:57:28 2008 +0000
@@ -150,6 +150,7 @@
 (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t))
 (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name)
 (put 'directory-file-name 'url-file-handlers 'url-handler-directory-file-name)
+(put 'unhandled-file-name-directory 'url-file-handlers 'url-handler-unhandled-file-name-directory)
 ;; (put 'file-name-as-directory 'url-file-handlers 'url-handler-file-name-as-directory)
 
 ;; These are operations that we do not support yet (DAV!!!)
@@ -181,6 +182,13 @@
   (if (string-match "//\\'" dir) dir
     (url-run-real-handler 'directory-file-name (list dir))))
 
+(defun url-handler-unhandled-file-name-directory (filename)
+  ;; Copied from tramp.el.  This is used as the cwd for subprocesses:
+  ;; without it running call-process or start-process in a URL directory
+  ;; signals an error.
+  ;; FIXME: we can do better if `filename' is a "file://" URL.
+  (expand-file-name "~/"))
+
 ;; The actual implementation
 ;;;###autoload
 (defun url-copy-file (url newname &optional ok-if-already-exists keep-time)
--- a/lisp/url/url-parse.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/url/url-parse.el	Wed Jan 30 07:57:28 2008 +0000
@@ -77,9 +77,9 @@
 
 ;;;###autoload
 (defun url-generic-parse-url (url)
-  "Return a vector of the parts of URL.
-Format is:
-\[TYPE USER PASSWORD HOST PORT FILE TARGET ATTRIBUTES FULL\]"
+  "Return an URL-struct of the parts of URL.
+The CL-style struct contains the following fields:
+TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS."
   ;; See RFC 3986.
   (cond
    ((null url)
--- a/lisp/vc-arch.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/vc-arch.el	Wed Jan 30 07:57:28 2008 +0000
@@ -347,9 +347,11 @@
   (save-excursion
     (let ((rej (concat buffer-file-name ".rej")))
       (when (and buffer-file-name (vc-arch-diff3-rej-p rej))
-	(if (not (re-search-forward "^<<<<<<< " nil t))
-	    ;; The .rej file is obsolete.
-	    (condition-case nil (delete-file rej) (error nil)))))))
+	(unless (re-search-forward "^<<<<<<< " nil t)
+	  ;; The .rej file is obsolete.
+	  (condition-case nil (delete-file rej) (error nil))
+	  ;; Remove the hook so that it is not called multiple times.
+	  (remove-hook 'after-save-hook 'vc-arch-delete-rej-if-obsolete t))))))
 
 (defun vc-arch-find-file-hook ()
   (let ((rej (concat buffer-file-name ".rej")))
--- a/lisp/vc-cvs.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/vc-cvs.el	Wed Jan 30 07:57:28 2008 +0000
@@ -453,7 +453,7 @@
   (message "Merging changes into %s..." file)
   ;; (vc-file-setprop file 'vc-working-revision nil)
   (vc-file-setprop file 'vc-checkout-time 0)
-  (vc-cvs-command nil 0 file "update")
+  (vc-cvs-command nil nil file "update")
   ;; Analyze the merge result reported by CVS, and set
   ;; file properties accordingly.
   (with-current-buffer (get-buffer "*vc*")
--- a/lisp/vc-hg.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/vc-hg.el	Wed Jan 30 07:57:28 2008 +0000
@@ -149,7 +149,7 @@
   (when (vc-hg-root file)           ; short cut
     (let ((state (vc-hg-state file)))  ; expensive
       (vc-file-setprop file 'vc-state state)
-      (not (memq state '(ignored unregistered))))))
+      (and state (not (memq state '(ignored unregistered)))))))
 
 (defun vc-hg-state (file)
   "Hg-specific version of `vc-state'."
@@ -316,8 +316,7 @@
 	    (if oldvers
 		(if newvers
 		    (list "-r" oldvers "-r" newvers)
-		  (list "-r" oldvers))
-	      (list ""))))))
+		  (list "-r" oldvers)))))))
 
 (defun vc-hg-revision-table (files)
   (let ((default-directory (file-name-directory (car files))))
@@ -480,35 +479,41 @@
 
 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming")
 
-
 ;; XXX Experimental function for the vc-dired replacement.
-(defun vc-hg-dir-status (dir)
-  "Return a list of conses (file . state) for DIR."
-  (with-temp-buffer
-    (vc-hg-command (current-buffer) nil dir "status" "-A")
-    (goto-char (point-min))
-    (let ((status-char nil)
-	  (file nil)
-	  (translation '((?= . up-to-date)
-			 (?C . up-to-date)
-			 (?A . added)
-			 (?R . removed)
-			 (?M . edited)
-			 (?I . ignored)
-			 (?! . deleted)
-			 (?? . unregistered)))
-	  (translated nil)
+(defun vc-hg-after-dir-status (update-function buff)
+  (let ((status-char nil)
+	(file nil)
+	(translation '((?= . up-to-date)
+		       (?C . up-to-date)
+		       (?A . added)
+		       (?R . removed)
+		       (?M . edited)
+		       (?I . ignored)
+		       (?! . deleted)
+		       (?? . unregistered)))
+	(translated nil)
 	  (result nil))
+      (goto-char (point-min))
       (while (not (eobp))
 	(setq status-char (char-after))
 	(setq file 
 	      (buffer-substring-no-properties (+ (point) 2) 
-					       (line-end-position)))
+					      (line-end-position)))
 	(setq translated (assoc status-char translation))
 	(when (and translated (not (eq (cdr translated) 'up-to-date)))
 	  (push (cons file (cdr translated)) result))
 	(forward-line))
-      result)))
+      (funcall update-function result buff)))
+
+;; XXX Experimental function for the vc-dired replacement.
+(defun vc-hg-dir-status (dir update-function status-buffer)
+  "Return a list of conses (file . state) for DIR."
+  (with-current-buffer
+      (get-buffer-create
+       (expand-file-name " *VC-hg* tmp status" dir))
+    (vc-hg-command (current-buffer) 'async dir "status")
+    (vc-exec-after 
+     `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer))))
 
 ;; XXX this adds another top level menu, instead figure out how to
 ;; replace the Log-View menu.
--- a/lisp/vc-svn.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/vc-svn.el	Wed Jan 30 07:57:28 2008 +0000
@@ -132,7 +132,8 @@
                ;; an `error' by vc-do-command.
                (error nil))))
         (when (eq 0 status)
-          (vc-svn-parse-status file))))))
+	  (let ((parsed (vc-svn-parse-status file)))
+	    (and parsed (not (memq parsed '(ignored unregistered))))))))))
 
 (defun vc-svn-state (file &optional localp)
   "SVN-specific version of `vc-state'."
@@ -157,6 +158,35 @@
       (vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
       (vc-svn-parse-status))))
 
+(defun vc-svn-after-dir-status (callback buffer)
+  (let ((state-map '((?A . added)
+                    (?C . edited)
+                    (?D . removed)
+                    (?I . ignored)
+                    (?M . edited)
+                    (?R . removed)
+                    (?? . unregistered)
+                    ;; This is what vc-svn-parse-status does.
+                    (?~ . edited)))
+       result)
+    (goto-char (point-min))
+    (while (re-search-forward "^\\(.\\)..... \\(.*\\)$" nil t)
+      (let ((state (cdr (assq (aref (match-string 1) 0) state-map)))
+           (filename (match-string 2)))
+       (when state
+         (setq result (cons (cons filename state) result)))))
+    (funcall callback result buffer)))
+
+(defun vc-svn-dir-status (dir callback buffer)
+  "Run 'svn status' for DIR and update BUFFER via CALLBACK.
+CALLBACK is called as (CALLBACK RESULT BUFFER), where
+RESULT is a list of conses (FILE . STATE) for directory DIR."
+  (with-current-buffer (get-buffer-create
+                       (generate-new-buffer-name " *vc svn status*"))
+    (vc-svn-command (current-buffer) 'async nil "status")
+    (vc-exec-after
+     `(vc-svn-after-dir-status (quote ,callback) ,buffer))))
+
 (defun vc-svn-working-revision (file)
   "SVN-specific version of `vc-working-revision'."
   ;; There is no need to consult RCS headers under SVN, because we
@@ -537,8 +567,10 @@
   "Call \"svn resolved\" if the conflict markers have been removed."
   (save-excursion
     (goto-char (point-min))
-    (if (not (re-search-forward "^<<<<<<< " nil t))
-        (vc-svn-command nil 0 buffer-file-name "resolved"))))
+    (unless (re-search-forward "^<<<<<<< " nil t)
+      (vc-svn-command nil 0 buffer-file-name "resolved")
+      ;; Remove the hook so that it is not called multiple times.
+      (remove-hook 'after-save-hook 'vc-svn-resolve-when-done t))))
 
 ;; Inspired by vc-arch-find-file-hook.
 (defun vc-svn-find-file-hook ()
@@ -550,7 +582,7 @@
           (re-search-forward "^<<<<<<< " nil t))
         ;; There are conflict markers.
         (progn
-          (smerge-mode 1)
+          (smerge-start-session)
           (add-hook 'after-save-hook 'vc-svn-resolve-when-done nil t))
       ;; There are no conflict markers.  This is problematic: maybe it means
       ;; the conflict has been resolved and we should immediately call "svn
--- a/lisp/vc.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/vc.el	Wed Jan 30 07:57:28 2008 +0000
@@ -1,14 +1,13 @@
 ;;; vc.el --- drive a version-control system from within Emacs
 
 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
 ;; Author:     FSF (see below for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
 ;; Keywords: tools
 
-;; $Id$
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -522,6 +521,55 @@
 ;;   to your backend and which does not map to any of the VC generic
 ;;   concepts.
 
+;;; Todo:
+
+;; - Make vc-checkin avoid reverting the buffer if has not changed
+;;   after the checkin.  Comparing (md5 BUFFER) to (md5 FILE) should
+;;   be enough.
+;;
+;; - vc-update/vc-merge should deal with VC systems that don't
+;;   update/merge on a file basis, but on a whole repository basis.
+;;
+;; - the backend sometimes knows when a file it opens has been marked
+;;   by the VCS as having a "conflict". Find a way to pass this info -
+;;   to VC so that it can turn on smerge-mode when opening such a
+;;   file.
+;;
+;; - the *VC-log* buffer needs font-locking.
+;;
+;; - make it easier to write logs, maybe C-x 4 a should add to the log
+;;   buffer if there's one instead of the ChangeLog.
+;;
+;; - make vc-state for all backends return 'unregistered instead of
+;;   nil for unregistered files, then update vc-next-action.
+;;
+;; - add a generic mechanism for remembering the current branch names,
+;;   display the branch name in the mode-line. Replace
+;;   vc-cvs-sticky-tag with that.
+;;
+;; - vc-register should register a fileset at a time. The backends
+;;   already support this, only the front-end needs to be change to
+;;   handle multiple files at a time.
+;;
+;; - add a mechanism to for ignoring files.
+;;
+;; - deal with push/pull operations.
+;;
+;; - decide if vc-status should replace vc-dired.
+;;
+;; - vc-status needs a menu, mouse bindings and some color bling.
+;;
+;; - vc-status needs to show missing files. It probably needs to have
+;;   another state for those files. The user might want to restore
+;;   them, or remove them from the VCS. C-x v v might also need
+;;   adjustments.
+;;
+;; - "snapshots" should be renamed to "branches", and thoroughly reworked.
+;;
+;; - do not default to RCS anymore when the current directory is not
+;;   controlled by any VCS and the user does C-x v v
+;;
+
 ;;; Code:
 
 (require 'vc-hooks)
@@ -907,13 +955,15 @@
   "An alternative output filter for async process P.
 One difference with the default filter is that this inserts S after markers.
 Another is that undo information is not kept."
-  (with-current-buffer (process-buffer p)
-    (save-excursion
-      (let ((buffer-undo-list t)
-            (inhibit-read-only t))
-	(goto-char (process-mark p))
-	(insert s)
-	(set-marker (process-mark p) (point))))))
+  (let ((buffer (process-buffer p)))
+    (when (buffer-live-p buffer)
+      (with-current-buffer buffer
+        (save-excursion
+          (let ((buffer-undo-list t)
+                (inhibit-read-only t))
+            (goto-char (process-mark p))
+            (insert s)
+            (set-marker (process-mark p) (point))))))))
 
 (defun vc-setup-buffer (&optional buf)
   "Prepare BUF for executing a VC command and make it current.
@@ -934,29 +984,39 @@
 (defvar vc-sentinel-movepoint)          ;Dynamically scoped.
 
 (defun vc-process-sentinel (p s)
-  (let ((previous (process-get p 'vc-previous-sentinel)))
-    (if previous (funcall previous p s))
-    (with-current-buffer (process-buffer p)
-      (let (vc-sentinel-movepoint)
-        ;; Normally, we want async code such as sentinels to not move point.
-        (save-excursion
-          (goto-char (process-mark p))
-          (let ((cmds (process-get p 'vc-sentinel-commands)))
-            (process-put p 'vc-sentinel-commands nil)
-            (dolist (cmd cmds)
-              ;; Each sentinel may move point and the next one should be run
-              ;; at that new point.  We could get the same result by having
-              ;; each sentinel read&set process-mark, but since `cmd' needs
-              ;; to work both for async and sync processes, this would be
-              ;; difficult to achieve.
-              (vc-exec-after cmd))))
-        ;; But sometimes the sentinels really want to move point.
-        (if vc-sentinel-movepoint
-            (let ((win (get-buffer-window (current-buffer) 0)))
-              (if (not win)
-                  (goto-char vc-sentinel-movepoint)
-                (with-selected-window win
-                  (goto-char vc-sentinel-movepoint)))))))))
+  (let ((previous (process-get p 'vc-previous-sentinel))
+        (buf (process-buffer p)))
+    ;; Impatient users sometime kill "slow" buffers; check liveness
+    ;; to avoid "error in process sentinel: Selecting deleted buffer".
+    (when (buffer-live-p buf)
+      (if previous (funcall previous p s))
+      (with-current-buffer buf
+        (setq mode-line-process
+              (let ((status (process-status p)))
+                ;; Leave mode-line uncluttered, normally.
+                ;; (Let known any weirdness in-form-ally. ;-)  --ttn
+                (unless (eq 'exit status)
+                  (format " (%s)" status))))
+        (let (vc-sentinel-movepoint)
+          ;; Normally, we want async code such as sentinels to not move point.
+          (save-excursion
+            (goto-char (process-mark p))
+            (let ((cmds (process-get p 'vc-sentinel-commands)))
+              (process-put p 'vc-sentinel-commands nil)
+              (dolist (cmd cmds)
+                ;; Each sentinel may move point and the next one should be run
+                ;; at that new point.  We could get the same result by having
+                ;; each sentinel read&set process-mark, but since `cmd' needs
+                ;; to work both for async and sync processes, this would be
+                ;; difficult to achieve.
+                (vc-exec-after cmd))))
+          ;; But sometimes the sentinels really want to move point.
+          (if vc-sentinel-movepoint
+              (let ((win (get-buffer-window (current-buffer) 0)))
+                (if (not win)
+                    (goto-char vc-sentinel-movepoint)
+                  (with-selected-window win
+                    (goto-char vc-sentinel-movepoint))))))))))
 
 (defun vc-exec-after (code)
   "Eval CODE when the current buffer's process is done.
@@ -975,6 +1035,17 @@
       (eval code))
      ;; If a process is running, add CODE to the sentinel
      ((eq (process-status proc) 'run)
+      (setq mode-line-process
+            ;; Deliberate overstatement, but power law respected.
+            ;; (The message is ephemeral, so we make it loud.)  --ttn
+            (propertize " (incomplete/in progress)"
+                        'face (if (featurep 'compile)
+                                  ;; ttn's preferred loudness
+                                  'compilation-warning
+                                ;; suitably available fallback
+                                font-lock-warning-face)
+			'help-echo
+			"A VC command is in progress in this buffer"))
       (let ((previous (process-sentinel proc)))
         (unless (eq previous 'vc-process-sentinel)
           (process-put proc 'vc-previous-sentinel previous))
@@ -1276,9 +1347,12 @@
                (unless (eq (vc-backend f) firstbackend)
                  (error "All members of a fileset must be under the same version-control system."))))
 	   marked))
-	((eq major-mode 'vc-status-mode)
-	 (vc-status-marked-files))
-	((vc-backend buffer-file-name)
+        ((eq major-mode 'vc-status-mode)
+         (let ((marked (vc-status-marked-files)))
+           (if marked
+               marked
+             (list (vc-status-current-file)))))
+ 	((vc-backend buffer-file-name)
 	 (list buffer-file-name))
 	((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer)
 				   (with-current-buffer vc-parent-buffer
@@ -1307,8 +1381,12 @@
 
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
-  (if vc-dired-mode
-      (set-buffer (find-file-noselect (dired-get-filename)))
+  (cond
+   (vc-dired-mode
+    (set-buffer (find-file-noselect (dired-get-filename))))
+   ((eq major-mode 'vc-status-mode)
+    (set-buffer (find-file-noselect (vc-status-current-file))))
+   (t
     (while (and vc-parent-buffer
                 (buffer-live-p vc-parent-buffer)
 		;; Avoid infinite looping when vc-parent-buffer and
@@ -1318,7 +1396,7 @@
     (if (not buffer-file-name)
 	(error "Buffer %s is not associated with a file" (buffer-name))
       (if (not (vc-backend buffer-file-name))
-	  (error "File %s is not under version control" buffer-file-name)))))
+	  (error "File %s is not under version control" buffer-file-name))))))
 
 ;;; Support for the C-x v v command.  This is where all the single-file-oriented
 ;;; code from before the fileset rewrite lives.
@@ -1404,9 +1482,9 @@
 	 revision)
     ;; Verify that the fileset is homogenous
     (dolist (file (cdr files))
-      (if (not (vc-compatible-state (vc-state file) state))
-	  (error "Fileset is in a mixed-up state"))
-      (if (not (eq (vc-checkout-model file) model))
+      (unless (vc-compatible-state (vc-state file) state)
+	(error "Fileset is in a mixed-up state"))
+      (unless (eq (vc-checkout-model file) model)
 	  (error "Fileset has mixed checkout models")))
     ;; Check for buffers in the fileset not matching the on-disk contents.
     (dolist (file files)
@@ -1428,13 +1506,15 @@
 		(error "Aborted"))
 	    ;; Now, check if we have unsaved changes.
 	    (vc-buffer-sync t)
-	    (if (buffer-modified-p)
-		(or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
-		    (error "Aborted")))))))
+	    (when (buffer-modified-p)
+	      (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
+		  (error "Aborted")))))))
     ;; Do the right thing
     (cond
      ;; Files aren't registered
-     ((not state)
+     ((or (not state)  ;; RCS uses nil for unregistered files.
+	  (eq state 'unregistered)
+	  (eq state 'ignored))
       (mapc 'vc-register files))
      ;; Files are up-to-date, or need a merge and user specified a revision
      ((or (eq state 'up-to-date) (and verbose (eq state 'needs-patch)))
@@ -1458,32 +1538,30 @@
       (let ((ready-for-commit files))
 	;; If files are edited but read-only, give user a chance to correct
 	(dolist (file files)
-	  (if (not (file-writable-p file))
-	      (progn
-		;; Make the file+buffer read-write.
-		(unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file))
-		  (error "Aborted"))
-		(set-file-modes file (logior (file-modes file) 128))
-		(let ((visited (get-file-buffer file)))
-		  (if visited
-		      (with-current-buffer visited
-			(toggle-read-only -1)))))))
+	  (unless (file-writable-p file)
+	    ;; Make the file+buffer read-write.
+	    (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file))
+	      (error "Aborted"))
+	    (set-file-modes file (logior (file-modes file) 128))
+	    (let ((visited (get-file-buffer file)))
+	      (when visited
+		(with-current-buffer visited
+		  (toggle-read-only -1))))))
 	;; Allow user to revert files with no changes
 	(save-excursion
           (dolist (file files)
             (let ((visited (get-file-buffer file)))
               ;; For files with locking, if the file does not contain
               ;; any changes, just let go of the lock, i.e. revert.
-              (if (and (not (eq model 'implicit))
-                       (vc-workfile-unchanged-p file)
-                       ;; If buffer is modified, that means the user just
-                       ;; said no to saving it; in that case, don't revert,
-                       ;; because the user might intend to save after
-                       ;; finishing the log entry and committing.
-                       (not (and visited (buffer-modified-p))))
-                  (progn
-                    (vc-revert-file file)
-                    (delete file ready-for-commit))))))
+              (when (and (not (eq model 'implicit))
+			 (vc-workfile-unchanged-p file)
+			 ;; If buffer is modified, that means the user just
+			 ;; said no to saving it; in that case, don't revert,
+			 ;; because the user might intend to save after
+			 ;; finishing the log entry and committing.
+			 (not (and visited (buffer-modified-p))))
+		(vc-revert-file file)
+		(delete file ready-for-commit)))))
 	;; Remaining files need to be committed
 	(if (not ready-for-commit)
 	    (message "No files remain to be committed")
@@ -1493,15 +1571,28 @@
 	      (setq revision (read-string "New revision or backend: "))
 	      (let ((vsym (intern (upcase revision))))
 		(if (member vsym vc-handled-backends)
-		    (vc-transfer-file file vsym)
+		    (dolist (file files) (vc-transfer-file file vsym))
 		  (vc-checkin ready-for-commit revision))))))))
      ;; locked by somebody else (locking VCSes only)
      ((stringp state)
-      (let ((revision
-	     (if verbose
-		 (read-string "Revision to steal: ")
-	       (vc-working-revision file))))
-	(dolist (file files) (vc-steal-lock file revision state))))
+      ;; In the old days, we computed the revision once and used it on
+      ;; the single file.  Then, for the 2007-2008 fileset rewrite, we
+      ;; computed the revision once (incorrectly, using a free var) and
+      ;; used it on all files.  To fix the free var bug, we can either
+      ;; use `(car files)' or do what we do here: distribute the
+      ;; revision computation among `files'.  Although this may be
+      ;; tedious for those backends where a "revision" is a trans-file
+      ;; concept, it is nonetheless correct for both those and (more
+      ;; importantly) for those where "revision" is a per-file concept.
+      ;; If the intersection of the former group and "locking VCSes" is
+      ;; non-empty [I vaguely doubt it --ttn], we can reinstate the
+      ;; pre-computation approach of yore.
+      (dolist (file files)
+        (vc-steal-lock
+         file (if verbose
+                  (read-string (format "%s revision to steal: " file))
+                (vc-working-revision file))
+         state)))
      ;; needs-patch
      ((eq state 'needs-patch)
       (dolist (file files)
@@ -1509,16 +1600,16 @@
 			  "%s is not up-to-date.  Get latest revision? "
 			  (file-name-nondirectory file)))
 	    (vc-checkout file (eq model 'implicit) t)
-	  (if (and (not (eq model 'implicit))
-		   (yes-or-no-p "Lock this revision? "))
-	      (vc-checkout file t)))))
+	  (when (and (not (eq model 'implicit))
+		     (yes-or-no-p "Lock this revision? "))
+	    (vc-checkout file t)))))
      ;; needs-merge
      ((eq state 'needs-merge)
       (dolist (file files)
-	(if (yes-or-no-p (format
+	(when (yes-or-no-p (format
 			  "%s is not up-to-date.  Merge in changes now? "
 			  (file-name-nondirectory file)))
-	    (vc-maybe-resolve-conflicts file (vc-call merge-news file)))))
+	  (vc-maybe-resolve-conflicts file (vc-call merge-news file)))))
 
      ;; unlocked-changes
      ((eq state 'unlocked-changes)
@@ -1667,7 +1758,7 @@
 entered COMMENT.  If COMMENT is t, also do action immediately with an
 empty comment.  Remember the file's buffer in `vc-parent-buffer'
 \(current one if no file).  AFTER-HOOK specifies the local value
-for vc-log-operation-hook."
+for `vc-log-after-operation-hook'."
   (let ((parent
          (if (eq major-mode 'vc-dired-mode)
              ;; If we are called from VC dired, the parent buffer is
@@ -1900,18 +1991,19 @@
 (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff))
 (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1")
 
-(defun vc-diff-sentinel (verbose rev1-name rev2-name)
+(defun vc-diff-finish (buffer-name verbose)
   ;; The empty sync output case has already been handled, so the only
-  ;; possibility of an empty output is for an async process, in which case
-  ;; it's important to insert the "diffs end here" message in the buffer
-  ;; since the user may miss a message in the echo area.
-  (when verbose
-    (let ((inhibit-read-only t))
-      (if (eq (buffer-size) 0)
-          (insert "No differences found.\n")
-        (insert (format "\n\nDiffs between %s and %s end here." rev1-name rev2-name)))))
-  (goto-char (point-min))
-  (shrink-window-if-larger-than-buffer))
+  ;; possibility of an empty output is for an async process.
+  (when (buffer-live-p buffer-name)
+    (with-current-buffer (get-buffer buffer-name)
+      (and verbose
+           (zerop (buffer-size))
+           (let ((inhibit-read-only t))
+             (insert "No differences found.\n")))
+      (goto-char (point-min))
+      (let ((window (get-buffer-window (current-buffer) t)))
+        (when window
+          (shrink-window-if-larger-than-buffer window))))))
 
 (defvar vc-diff-added-files nil
   "If non-nil, diff added files by comparing them to /dev/null.")
@@ -1970,7 +2062,7 @@
       ;; bindings are nicer for read only buffers. pcl-cvs does the
       ;; same thing.
       (setq buffer-read-only t)
-      (vc-exec-after `(vc-diff-sentinel ,verbose ,rev1-name ,rev2-name))
+      (vc-exec-after `(vc-diff-finish ,(buffer-name) ,verbose))
       ;; Display the buffer, but at the end because it can change point.
       (pop-to-buffer (current-buffer))
       ;; In the async case, we return t even if there are no differences
@@ -2486,8 +2578,6 @@
   (interactive "DDired under VC (directory): \nP")
   (let ((vc-dired-switches (concat vc-dired-listing-switches
                                    (if vc-dired-recurse "R" ""))))
-    (if (eq (string-match tramp-file-name-regexp dir) 0)
-        (error "Sorry, vc-directory does not work over Tramp"))
     (if read-switches
         (setq vc-dired-switches
               (read-string "Dired listing switches: "
@@ -2512,19 +2602,27 @@
 
 (defvar vc-status nil)
 
-(defun vc-status-insert-headers (backend dir)
-  (insert (format "VC backend :%s\n" backend))
-  (insert "Repository : The repository goes here\n")
-  (insert (format "Working dir: %s\n\n\n" dir)))
+(defun vc-status-headers (backend dir)
+  (concat
+   (format "VC backend : %s\n" backend)
+   "Repository : The repository goes here\n"
+   (format "Working dir: %s\n" dir)))
 
 (defun vc-status-printer (fileentry)
   "Pretty print FILEENTRY."
   (insert
+   ;; If you change this, change vc-status-move-to-goal-column.
    (format "%c   %-20s %s"
 	   (if (vc-status-fileinfo->marked fileentry) ?* ? )
 	   (vc-status-fileinfo->state fileentry)
 	   (vc-status-fileinfo->name fileentry))))
 
+(defun vc-status-move-to-goal-column ()
+  (beginning-of-line)
+  ;; Must be in sync with vc-status-printer.
+  (forward-char 25))
+
+;;;###autoload
 (defun vc-status (dir)
   "Show the VC status for DIR."
   (interactive "DVC status for directory: ")
@@ -2533,10 +2631,33 @@
   (cd dir)
   (vc-status-mode))
 
-(defvar vc-status-mode-map 
-  (let ((map (make-sparse-keymap)))
+(defvar vc-status-mode-map
+  (let ((map (make-keymap)))
+    (suppress-keymap map)
+    ;; Marking.
     (define-key map "m" 'vc-status-mark-file)
+    (define-key map "M" 'vc-status-mark-all-files)
     (define-key map "u" 'vc-status-unmark-file)
+    (define-key map "\C-?" 'vc-status-unmark-file-up)
+    (define-key map "\M-\C-?" 'vc-status-unmark-all-files)
+    ;; Movement.
+    (define-key map "n" 'vc-status-next-line)
+    (define-key map " " 'vc-status-next-line)
+    (define-key map "\t" 'vc-status-next-line)
+    (define-key map "p" 'vc-status-previous-line)
+    (define-key map [backtab] 'vc-status-previous-line)
+    ;; VC commands.
+    (define-key map "=" 'vc-diff)
+    (define-key map "a" 'vc-status-register)
+    ;; Can't be "g" (as in vc map), so "A" for "Annotate".
+    (define-key map "A" 'vc-annotate)
+    ;; vc-print-log uses the current buffer, not a file.
+    ;; (define-key map "l" 'vc-status-print-log)
+    ;; The remainder.
+    (define-key map "f" 'vc-status-find-file)
+    (define-key map "o" 'vc-status-find-file-other-window)
+    (define-key map "q" 'bury-buffer)
+    (define-key map "g" 'vc-status-refresh)
     map)
   "Keymap for VC status")
 
@@ -2552,38 +2673,128 @@
 	entries)
     (erase-buffer)
     (set (make-local-variable 'vc-status)
-	 (ewoc-create #'vc-status-printer))
-    (vc-status-insert-headers backend default-directory)
-    (setq entries (vc-call-backend backend 'dir-status default-directory))
+	 (ewoc-create #'vc-status-printer
+		      (vc-status-headers backend default-directory)))
+    (vc-status-refresh)))
+
+(put 'vc-status-mode 'mode-class 'special)
+
+(defun vc-update-vc-status-buffer (entries buffer)
+  (with-current-buffer buffer
     (dolist (entry entries)
-      (ewoc-enter-last 
-       vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))
+      (ewoc-enter-last vc-status
+		       (vc-status-create-fileinfo (cdr entry) (car entry))))
+    (ewoc-goto-node vc-status (ewoc-nth vc-status 0))))
+
+(defun vc-status-refresh ()
+  "Refresh the contents of the VC status buffer."
+  (interactive)
+  ;; This is not very efficient; ewoc could use a new function here.
+  (ewoc-filter vc-status (lambda (node) nil))
+  (let ((backend (vc-responsible-backend default-directory)))
+    ;; Call the dir-status backend function. dir-status is supposed to
+    ;; be asynchronous.  It should compute the results and call the
+    ;; function passed as a an arg to update the vc-status buffer with
+    ;; the results.
+    (vc-call-backend
+     backend 'dir-status default-directory
+     #'vc-update-vc-status-buffer (current-buffer))))
+
+(defun vc-status-next-line (arg)
+  "Go to the next line.
+If a prefix argument is given, move by that many lines."
+  (interactive "p")
+  (ewoc-goto-next vc-status arg)
+  (vc-status-move-to-goal-column))
+
+(defun vc-status-previous-line (arg)
+  "Go to the previous line.
+If a prefix argument is given, move by that many lines."
+  (interactive "p")
+  (ewoc-goto-prev vc-status arg)
+  (vc-status-move-to-goal-column))
 
 (defun vc-status-mark-file ()
-  "Mark the current file."
+  "Mark the current file and move to the next line."
   (interactive)
   (let* ((crt (ewoc-locate vc-status))
          (file (ewoc-data crt)))
     (setf (vc-status-fileinfo->marked file) t)
     (ewoc-invalidate vc-status crt)
-    (ewoc-goto-next vc-status 1)))
+    (vc-status-next-line 1)))
+
+(defun vc-status-mark-all-files ()
+  "Mark all files."
+  (interactive)
+   (ewoc-map
+    (lambda (file)
+      (unless (vc-status-fileinfo->marked file)
+	(setf (vc-status-fileinfo->marked file) t)
+	t))
+    vc-status))
 
 (defun vc-status-unmark-file ()
-  "Mark the current file."
+  "Unmark the current file and move to the next line."
   (interactive)
   (let* ((crt (ewoc-locate vc-status))
          (file (ewoc-data crt)))
     (setf (vc-status-fileinfo->marked file) nil)
     (ewoc-invalidate vc-status crt)
-    (ewoc-goto-next vc-status 1)))
+    (vc-status-next-line 1)))
+
+(defun vc-status-unmark-file-up ()
+  "Move to the previous line and unmark the file."
+  (interactive)
+  ;; If we're on the first line, we won't move up, but we will still
+  ;; remove the mark.  This seems a bit odd but it is what buffer-menu
+  ;; does.
+  (let* ((prev (ewoc-goto-prev vc-status 1))
+	 (file (ewoc-data prev)))
+    (setf (vc-status-fileinfo->marked file) nil)
+    (ewoc-invalidate vc-status prev)
+    (vc-status-move-to-goal-column)))
+
+(defun vc-status-unmark-all-files ()
+  "Unmark all files."
+  (interactive)
+   (ewoc-map
+    (lambda (file)
+      (when (vc-status-fileinfo->marked file)
+	(setf (vc-status-fileinfo->marked file) nil)
+	t))
+    vc-status))
+
+(defun vc-status-register ()
+  "Register the marked files, or the current file if no marks."
+  (interactive)
+  (let ((files (or (vc-status-marked-files)
+		   (list (vc-status-current-file)))))
+    (dolist (file files)
+      (vc-register file))))
+
+(defun vc-status-find-file ()
+  "Find the file on the current line."
+  (interactive)
+  (find-file (vc-status-current-file)))
+
+(defun vc-status-find-file-other-window ()
+  "Find the file on the current line, in another window."
+  (interactive)
+  (find-file-other-window (vc-status-current-file)))
+
+(defun vc-status-current-file ()
+  (let ((node (ewoc-locate vc-status)))
+    (unless node
+      (error "No file available."))
+    (expand-file-name (vc-status-fileinfo->name (ewoc-data node)))))
 
 (defun vc-status-marked-files ()
   "Return the list of marked files"
-  (mapcar 
+  (mapcar
    (lambda (elem)
      (expand-file-name (vc-status-fileinfo->name elem)))
    (ewoc-collect
-    vc-status 
+    vc-status
     (lambda (crt) (vc-status-fileinfo->marked crt)))))
 
 ;;; End experimental code.
@@ -2782,8 +2993,7 @@
 	(if (not (vc-find-backend-function (vc-backend file) 'merge-news))
 	    (error "Sorry, merging news is not implemented for %s"
 		   (vc-backend file))
-	  (vc-call merge-news file)
-	  (vc-resynch-buffer file t t))))))
+	  (vc-maybe-resolve-conflicts file (vc-call merge-news file)))))))
 
 (defun vc-version-backup-file (file &optional rev)
   "Return name of backup file for revision REV of FILE.
@@ -3024,9 +3234,6 @@
           ;; it should find all relevant files relative to
           ;; the default-directory.
 	  nil)))
-  (dolist (file (or args (list default-directory)))
-    (if (eq (string-match tramp-file-name-regexp file) 0)
-        (error "Sorry, vc-update-change-log does not work over Tramp")))
   (vc-call-backend (vc-responsible-backend default-directory)
                    'update-changelog args))
 
--- a/lisp/view.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/view.el	Wed Jan 30 07:57:28 2008 +0000
@@ -243,6 +243,16 @@
 
 ;;; Commands that enter or exit view mode.
 
+;; This is used when view mode is exited, to make sure we don't try to
+;; kill a buffer modified by the user.  A buffer in view mode can
+;; become modified if the user types C-x C-q, edits the buffer, then
+;; types C-x C-q again to return to view mode.
+(defun kill-buffer-if-not-modified (buf)
+  "Like `kill-buffer', but does nothing if the buffer is modified."
+  (let ((buf (get-buffer buf)))
+    (and buf (not (buffer-modified-p buf))
+	 (kill-buffer buf))))
+
 ;;;###autoload
 (defun view-file (file)
   "View FILE in View mode, returning to previous buffer when done.
@@ -263,41 +273,50 @@
 	(progn
 	  (switch-to-buffer buffer)
 	  (message "Not using View mode because the major mode is special"))
-      (view-buffer buffer (and (not had-a-buf) 'kill-buffer)))))
+      (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified)))))
 
 ;;;###autoload
 (defun view-file-other-window (file)
   "View FILE in View mode in another window.
-Return that window to its previous buffer when done.  Emacs commands
-editing the buffer contents are not available; instead, a special set of
-commands (mostly letters and punctuation) are defined for moving around
-in the buffer.
+When done, return that window to its previous buffer, and kill the
+buffer visiting FILE if unmodified and if it wasn't visited before.
+
+Emacs commands editing the buffer contents are not available; instead,
+a special set of commands (mostly letters and punctuation)
+are defined for moving around in the buffer.
 Space scrolls forward, Delete scrolls backward.
 For a list of all View commands, type H or h while viewing.
 
 This command runs the normal hook `view-mode-hook'."
   (interactive "fIn other window view file: ")
   (unless (file-exists-p file) (error "%s does not exist" file))
-  (let ((had-a-buf (get-file-buffer file)))
-    (view-buffer-other-window (find-file-noselect file) nil
-			      (and (not had-a-buf) 'kill-buffer))))
+  (let ((had-a-buf (get-file-buffer file))
+	(buf-to-view (find-file-noselect file)))
+    (view-buffer-other-window buf-to-view nil
+			      (and (not had-a-buf)
+				   'kill-buffer-if-not-modified))))
 
 ;;;###autoload
 (defun view-file-other-frame (file)
   "View FILE in View mode in another frame.
-Maybe delete other frame and/or return to previous buffer when done.
-Emacs commands editing the buffer contents are not available; instead, a
-special set of commands (mostly letters and punctuation) are defined for
-moving around in the buffer.
+When done, kill the buffer visiting FILE if unmodified and if it wasn't
+visited before; also, maybe delete other frame and/or return to previous
+buffer.
+
+Emacs commands editing the buffer contents are not available; instead,
+a special set of commands (mostly letters and punctuation)
+are defined for moving around in the buffer.
 Space scrolls forward, Delete scrolls backward.
 For a list of all View commands, type H or h while viewing.
 
 This command runs the normal hook `view-mode-hook'."
   (interactive "fIn other frame view file: ")
   (unless (file-exists-p file) (error "%s does not exist" file))
-  (let ((had-a-buf (get-file-buffer file)))
-    (view-buffer-other-frame (find-file-noselect file) nil
-			     (and (not had-a-buf) 'kill-buffer))))
+  (let ((had-a-buf (get-file-buffer file))
+	(buf-to-view (find-file-noselect file)))
+    (view-buffer-other-frame buf-to-view nil
+			     (and (not had-a-buf)
+				  'kill-buffer-if-not-modified))))
 
 
 ;;;###autoload
@@ -313,7 +332,12 @@
 
 Optional argument EXIT-ACTION is either nil or a function with buffer as
 argument.  This function is called when finished viewing buffer.  Use
-this argument instead of explicitly setting `view-exit-action'."
+this argument instead of explicitly setting `view-exit-action'.
+
+Do not set EXIT-ACTION to `kill-buffer' when BUFFER visits a
+file: Users may suspend viewing in order to modify the buffer.
+Exiting View mode will then discard the user's edits.  Setting
+EXIT-ACTION to `kill-buffer-if-not-modified' avoids this."
   (interactive "bView buffer: ")
   (let ((undo-window (list (window-buffer) (window-start) (window-point))))
     (switch-to-buffer buffer)
--- a/lisp/wdired.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/wdired.el	Wed Jan 30 07:57:28 2008 +0000
@@ -323,7 +323,11 @@
       (unless (eq beg end)
 	(if old
 	    (setq file (get-text-property beg 'old-name))
-	  (setq end (next-single-property-change (1+ beg) 'end-name))
+	  ;; In the following form changed `(1+ beg)' to `beg' so that
+	  ;; the filename end is found even when the filename is empty.
+	  ;; Fixes error and spurious newlines when marking files for
+	  ;; deletion.
+	  (setq end (next-single-property-change beg 'end-name))
 	  (setq file (buffer-substring-no-properties (1+ beg) end)))
 	(and file (setq file (wdired-normalize-filename file))))
       (if (or no-dir old)
--- a/lisp/whitespace.el	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,814 +0,0 @@
-;;; whitespace.el --- warn about and clean bogus whitespaces in the file
-
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-;; Author: Rajesh Vaidheeswarran <rv@gnu.org>
-;; Keywords: convenience
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-;;
-;; URL: http://www.dsmit.com/lisp/
-;;
-;; The whitespace library is intended to find and help fix five different types
-;; of whitespace problems that commonly exist in source code.
-;;
-;; 1. Leading space (empty lines at the top of a file).
-;; 2. Trailing space (empty lines at the end of a file).
-;; 3. Indentation space (8 or more spaces at beginning of line, that should be
-;;		      replaced with TABS).
-;; 4. Spaces followed by a TAB.  (Almost always, we never want that).
-;; 5. Spaces or TABS at the end of a line.
-;;
-;; Whitespace errors are reported in a buffer, and on the modeline.
-;;
-;; Modeline will show a W:<x>!<y> to denote a particular type of whitespace,
-;; where `x' and `y' can be one (or more) of:
-;;
-;; e - End-of-Line whitespace.
-;; i - Indentation whitespace.
-;; l - Leading whitespace.
-;; s - Space followed by Tab.
-;; t - Trailing whitespace.
-;;
-;; If any of the whitespace checks is turned off, the modeline will display a
-;; !<y>.
-;;
-;;     (since (3) is the most controversial one, here is the rationale: Most
-;;     terminal drivers and printer drivers have TAB configured or even
-;;     hardcoded to be 8 spaces.  (Some of them allow configuration, but almost
-;;     always they default to 8.)
-;;
-;;     Changing `tab-width' to other than 8 and editing will cause your code to
-;;     look different from within Emacs, and say, if you cat it or more it, or
-;;     even print it.
-;;
-;;     Almost all the popular programming modes let you define an offset (like
-;;     c-basic-offset or perl-indent-level) to configure the offset, so you
-;;     should never have to set your `tab-width' to be other than 8 in all
-;;     these modes.  In fact, with an indent level of say, 4, 2 TABS will cause
-;;     Emacs to replace your 8 spaces with one \t (try it).  If vi users in
-;;     your office complain, tell them to use vim, which distinguishes between
-;;     tabstop and shiftwidth (vi equivalent of our offsets), and also ask them
-;;     to set smarttab.)
-;;
-;; All the above have caused (and will cause) unwanted codeline integration and
-;; merge problems.
-;;
-;; whitespace.el will complain if it detects whitespaces on opening a file, and
-;; warn you on closing a file also (in case you had inserted any
-;; whitespaces during the process of your editing).
-;;
-;; Exported functions:
-;;
-;; `whitespace-buffer' - To check the current buffer for whitespace problems.
-;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer.
-;; `whitespace-region' - To check between point and mark for whitespace
-;;                       problems.
-;; `whitespace-cleanup-region' - To cleanup all whitespaces between point
-;;                               and mark in the current buffer.
-
-;;; Code:
-
-(defvar whitespace-version "3.5" "Version of the whitespace library.")
-
-(defvar whitespace-all-buffer-files nil
-  "An associated list of buffers and files checked for whitespace cleanliness.
-
-This is to enable periodic checking of whitespace cleanliness in the files
-visited by the buffers.")
-
-(defvar whitespace-rescan-timer nil
-  "Timer object used to rescan the files in buffers that have been modified.")
-
-;; Tell Emacs about this new kind of minor mode
-(defvar whitespace-mode nil
-  "Non-nil when Whitespace mode (a minor mode) is enabled.")
-(make-variable-buffer-local 'whitespace-mode)
-
-(defvar whitespace-mode-line nil
-  "String to display in the mode line for Whitespace mode.")
-(make-variable-buffer-local 'whitespace-mode-line)
-
-(defvar whitespace-check-buffer-leading nil
-  "Test leading whitespace for file in current buffer if t.")
-(make-variable-buffer-local 'whitespace-check-buffer-leading)
-;;;###autoload(put 'whitespace-check-buffer-leading 'safe-local-variable 'booleanp)
-
-(defvar whitespace-check-buffer-trailing nil
-  "Test trailing whitespace for file in current buffer if t.")
-(make-variable-buffer-local 'whitespace-check-buffer-trailing)
-;;;###autoload(put 'whitespace-check-buffer-trailing 'safe-local-variable 'booleanp)
-
-(defvar whitespace-check-buffer-indent nil
-  "Test indentation whitespace for file in current buffer if t.")
-(make-variable-buffer-local 'whitespace-check-buffer-indent)
-;;;###autoload(put 'whitespace-check-buffer-indent 'safe-local-variable 'booleanp)
-
-(defvar whitespace-check-buffer-spacetab nil
-  "Test Space-followed-by-TABS whitespace for file in current buffer if t.")
-(make-variable-buffer-local 'whitespace-check-buffer-spacetab)
-;;;###autoload(put 'whitespace-check-buffer-spacetab 'safe-local-variable 'booleanp)
-
-(defvar whitespace-check-buffer-ateol nil
-  "Test end-of-line whitespace for file in current buffer if t.")
-(make-variable-buffer-local 'whitespace-check-buffer-ateol)
-;;;###autoload(put 'whitespace-check-buffer-ateol 'safe-local-variable 'booleanp)
-
-(defvar whitespace-highlighted-space nil
-  "The variable to store the extent to highlight.")
-(make-variable-buffer-local 'whitespace-highlighted-space)
-
-(defalias 'whitespace-make-overlay
-  (if (featurep 'xemacs) 'make-extent 'make-overlay))
-(defalias 'whitespace-overlay-put
-  (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
-(defalias 'whitespace-delete-overlay
-  (if (featurep 'xemacs) 'delete-extent 'delete-overlay))
-(defalias 'whitespace-overlay-start
-  (if (featurep 'xemacs) 'extent-start 'overlay-start))
-(defalias 'whitespace-overlay-end
-  (if (featurep 'xemacs) 'extent-end 'overlay-end))
-(defalias 'whitespace-mode-line-update
-  (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update))
-
-(defgroup whitespace nil
-  "Check for and fix five different types of whitespaces in source code."
-  :version "21.1"
-  :link '(emacs-commentary-link "whitespace.el")
-  ;; Since XEmacs doesn't have a 'convenience group, use the next best group
-  ;; which is 'editing?
-  :group (if (featurep 'xemacs) 'editing 'convenience))
-
-(defcustom whitespace-check-leading-whitespace t
-  "Flag to check leading whitespace.  This is the global for the system.
-It can be overriden by setting a buffer local variable
-`whitespace-check-buffer-leading'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-check-trailing-whitespace t
-  "Flag to check trailing whitespace.  This is the global for the system.
-It can be overriden by setting a buffer local variable
-`whitespace-check-buffer-trailing'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-check-spacetab-whitespace t
-  "Flag to check space followed by a TAB.  This is the global for the system.
-It can be overriden by setting a buffer local variable
-`whitespace-check-buffer-spacetab'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-spacetab-regexp "[ ]+\t"
-  "Regexp to match one or more spaces followed by a TAB."
-  :type 'regexp
-  :group 'whitespace)
-
-(defcustom whitespace-check-indent-whitespace indent-tabs-mode
-  "Flag to check indentation whitespace.  This is the global for the system.
-It can be overriden by setting a buffer local variable
-`whitespace-check-buffer-indent'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-indent-regexp "^\t*\\(        \\)+"
-  "Regexp to match multiples of eight spaces near line beginnings.
-The default value ignores leading TABs."
-  :type 'regexp
-  :group 'whitespace)
-
-(defcustom whitespace-check-ateol-whitespace t
-  "Flag to check end-of-line whitespace.  This is the global for the system.
-It can be overriden by setting a buffer local variable
-`whitespace-check-buffer-ateol'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-ateol-regexp "[ \t]+$"
-  "Regexp to match one or more TABs or spaces at line ends."
-  :type 'regexp
-  :group 'whitespace)
-
-(defcustom whitespace-errbuf "*Whitespace Errors*"
-  "The name of the buffer where whitespace related messages will be logged."
-  :type 'string
-  :group 'whitespace)
-
-(defcustom whitespace-clean-msg "clean."
-  "If non-nil, this message will be displayed after a whitespace check
-determines a file to be clean."
-  :type 'string
-  :group 'whitespace)
-
-(defcustom whitespace-abort-on-error nil
-  "While writing a file, abort if the file is unclean.
-If `whitespace-auto-cleanup' is set, that takes precedence over
-this variable."
-  :type  'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-auto-cleanup nil
-  "Cleanup a buffer automatically on finding it whitespace unclean."
-  :type  'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-silent nil
-  "All whitespace errors will be shown only in the modeline when t.
-
-Note that setting this may cause all whitespaces introduced in a file to go
-unnoticed when the buffer is killed, unless the user visits the `*Whitespace
-Errors*' buffer before opening (or closing) another file."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-modes '(ada-mode asm-mode autoconf-mode awk-mode
-				       c-mode c++-mode cc-mode
-				       change-log-mode cperl-mode
-				       electric-nroff-mode emacs-lisp-mode
-				       f90-mode fortran-mode html-mode
-				       html3-mode java-mode jde-mode
-				       ksh-mode latex-mode LaTeX-mode
-				       lisp-mode m4-mode makefile-mode
-				       modula-2-mode nroff-mode objc-mode
-				       pascal-mode perl-mode prolog-mode
-				       python-mode scheme-mode sgml-mode
-				       sh-mode shell-script-mode simula-mode
-				       tcl-mode tex-mode texinfo-mode
-				       vrml-mode xml-mode)
-
-  "Major modes in which we turn on whitespace checking.
-
-These are mostly programming and documentation modes.  But you may add other
-modes that you want whitespaces checked in by adding something like the
-following to your `.emacs':
-
-\(setq whitespace-modes (cons 'my-mode (cons 'my-other-mode
-					    whitespace-modes))\)
-
-Or, alternately, you can use the Emacs `customize' command to set this."
-  :type '(repeat symbol)
-  :group 'whitespace)
-
-(defcustom whitespace-rescan-timer-time 600
-  "Period in seconds to rescan modified buffers for whitespace creep.
-
-This is the period after which the timer will fire causing
-`whitespace-rescan-files-in-buffers' to check for whitespace creep in
-modified buffers.
-
-To disable timer scans, set this to zero."
-  :type 'integer
-  :group 'whitespace)
-
-(defcustom whitespace-display-in-modeline t
-  "Display whitespace errors on the modeline."
-  :type 'boolean
-  :group 'whitespace)
-
-(defcustom whitespace-display-spaces-in-color t
-  "Display the bogus whitespaces by coloring them with the face
-`whitespace-highlight'."
-  :type 'boolean
-  :group 'whitespace)
-
-(defgroup whitespace-faces nil
-  "Faces used in whitespace."
-  :prefix "whitespace-"
-  :group 'whitespace
-  :group 'faces)
-
-(defface whitespace-highlight '((((class color) (background light))
-				 (:background "green1"))
-				(((class color) (background dark))
-				 (:background "sea green"))
-				(((class grayscale mono)
-				  (background light))
-				 (:background "black"))
-				(((class grayscale mono)
-				  (background dark))
-				 (:background "white")))
-  "Face used for highlighting the bogus whitespaces that exist in the buffer."
-  :group 'whitespace-faces)
-;; backward-compatibility alias
-(put 'whitespace-highlight-face 'face-alias 'whitespace-highlight)
-
-(if (not (assoc 'whitespace-mode minor-mode-alist))
-    (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line)
-				 minor-mode-alist)))
-
-(set-default 'whitespace-check-buffer-leading
-	     whitespace-check-leading-whitespace)
-(set-default 'whitespace-check-buffer-trailing
-	     whitespace-check-trailing-whitespace)
-(set-default 'whitespace-check-buffer-indent
-	     whitespace-check-indent-whitespace)
-(set-default 'whitespace-check-buffer-spacetab
-	     whitespace-check-spacetab-whitespace)
-(set-default 'whitespace-check-buffer-ateol
-	     whitespace-check-ateol-whitespace)
-
-(defun whitespace-check-whitespace-mode (&optional arg)
-  "Test and set the whitespace-mode in qualifying buffers."
-  (if (null whitespace-mode)
-      (setq whitespace-mode
-	    (if (or arg (member major-mode whitespace-modes))
-		t
-	      nil))))
-
-;;;###autoload
-(defun whitespace-toggle-leading-check ()
-  "Toggle the check for leading space in the local buffer."
-  (interactive)
-  (let ((current-val whitespace-check-buffer-leading))
-    (setq whitespace-check-buffer-leading (not current-val))
-    (message "Will%s check for leading space in buffer."
-	     (if whitespace-check-buffer-leading "" " not"))
-    (if whitespace-check-buffer-leading (whitespace-buffer-leading))))
-
-;;;###autoload
-(defun whitespace-toggle-trailing-check ()
-  "Toggle the check for trailing space in the local buffer."
-  (interactive)
-  (let ((current-val whitespace-check-buffer-trailing))
-    (setq whitespace-check-buffer-trailing (not current-val))
-    (message "Will%s check for trailing space in buffer."
-	     (if whitespace-check-buffer-trailing "" " not"))
-    (if whitespace-check-buffer-trailing (whitespace-buffer-trailing))))
-
-;;;###autoload
-(defun whitespace-toggle-indent-check ()
-  "Toggle the check for indentation space in the local buffer."
-  (interactive)
-  (let ((current-val whitespace-check-buffer-indent))
-    (setq whitespace-check-buffer-indent (not current-val))
-    (message "Will%s check for indentation space in buffer."
-	     (if whitespace-check-buffer-indent "" " not"))
-    (if whitespace-check-buffer-indent
-	(whitespace-buffer-search whitespace-indent-regexp))))
-
-;;;###autoload
-(defun whitespace-toggle-spacetab-check ()
-  "Toggle the check for space-followed-by-TABs in the local buffer."
-  (interactive)
-  (let ((current-val whitespace-check-buffer-spacetab))
-    (setq whitespace-check-buffer-spacetab (not current-val))
-    (message "Will%s check for space-followed-by-TABs in buffer."
-	     (if whitespace-check-buffer-spacetab "" " not"))
-    (if whitespace-check-buffer-spacetab
-	(whitespace-buffer-search whitespace-spacetab-regexp))))
-
-
-;;;###autoload
-(defun whitespace-toggle-ateol-check ()
-  "Toggle the check for end-of-line space in the local buffer."
-  (interactive)
-  (let ((current-val whitespace-check-buffer-ateol))
-    (setq whitespace-check-buffer-ateol (not current-val))
-    (message "Will%s check for end-of-line space in buffer."
-	     (if whitespace-check-buffer-ateol "" " not"))
-    (if whitespace-check-buffer-ateol
-	(whitespace-buffer-search whitespace-ateol-regexp))))
-
-
-;;;###autoload
-(defun whitespace-buffer (&optional quiet)
-  "Find five different types of white spaces in buffer.
-These are:
-1. Leading space \(empty lines at the top of a file\).
-2. Trailing space \(empty lines at the end of a file\).
-3. Indentation space \(8 or more spaces, that should be replaced with TABS\).
-4. Spaces followed by a TAB. \(Almost always, we never want that\).
-5. Spaces or TABS at the end of a line.
-
-Check for whitespace only if this buffer really contains a non-empty file
-and:
-1. the major mode is one of the whitespace-modes, or
-2. `whitespace-buffer' was explicitly called with a prefix argument."
-  (interactive)
-  (let ((whitespace-error nil))
-    (whitespace-check-whitespace-mode current-prefix-arg)
-    (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode)
-	(progn
-	  (whitespace-check-buffer-list (buffer-name) buffer-file-name)
-	  (whitespace-tickle-timer)
-	  (overlay-recenter (point-max))
-	  (remove-overlays nil nil 'face 'whitespace-highlight)
-	  (if whitespace-auto-cleanup
-	      (if buffer-read-only
-		  (if (not quiet)
-		      (message "Can't cleanup: %s is read-only" (buffer-name)))
-		(whitespace-cleanup-internal))
-	    (let ((whitespace-leading (if whitespace-check-buffer-leading
-					  (whitespace-buffer-leading)
-					nil))
-		  (whitespace-trailing (if whitespace-check-buffer-trailing
-					   (whitespace-buffer-trailing)
-					 nil))
-		  (whitespace-indent (if whitespace-check-buffer-indent
-					 (whitespace-buffer-search
-					  whitespace-indent-regexp)
-				       nil))
-		  (whitespace-spacetab (if whitespace-check-buffer-spacetab
-					   (whitespace-buffer-search
-					    whitespace-spacetab-regexp)
-					 nil))
-		  (whitespace-ateol (if whitespace-check-buffer-ateol
-					(whitespace-buffer-search
-					 whitespace-ateol-regexp)
-				      nil))
-		  (whitespace-errmsg nil)
-		  (whitespace-filename buffer-file-name)
-		  (whitespace-this-modeline ""))
-
-	      ;; Now let's complain if we found any of the above.
-	      (setq whitespace-error (or whitespace-leading whitespace-indent
-					 whitespace-spacetab whitespace-ateol
-					 whitespace-trailing))
-
-	      (if whitespace-error
-		  (progn
-		    (setq whitespace-errmsg
-			  (concat whitespace-filename " contains:\n"
-				  (if whitespace-leading
-				      "Leading whitespace\n")
-				  (if whitespace-indent
-				      (concat "Indentation whitespace"
-					      whitespace-indent "\n"))
-				  (if whitespace-spacetab
-				      (concat "Space followed by Tab"
-					      whitespace-spacetab "\n"))
-				  (if whitespace-ateol
-				      (concat "End-of-line whitespace"
-					      whitespace-ateol "\n"))
-				  (if whitespace-trailing
-				      "Trailing whitespace\n")
-				  "\ntype `M-x whitespace-cleanup' to "
-				  "cleanup the file."))
-		    (setq whitespace-this-modeline
-			  (concat (if whitespace-ateol "e")
-				  (if whitespace-indent "i")
-				  (if whitespace-leading "l")
-				  (if whitespace-spacetab "s")
-				  (if whitespace-trailing "t")))))
-	      (whitespace-update-modeline whitespace-this-modeline)
-	      (if (get-buffer whitespace-errbuf)
-		  (kill-buffer whitespace-errbuf))
-	      (with-current-buffer (get-buffer-create whitespace-errbuf)
-		(if whitespace-errmsg
-		    (progn
-		      (insert whitespace-errmsg)
-		      (if (not (or quiet whitespace-silent))
-			  (display-buffer (current-buffer) t))
-		      (if (not quiet)
-			  (message "Whitespaces: [%s%s] in %s"
-				   whitespace-this-modeline
-				   (let ((whitespace-unchecked
-					  (whitespace-unchecked-whitespaces)))
-				     (if whitespace-unchecked
-					 (concat "!" whitespace-unchecked)
-				       ""))
-				   whitespace-filename)))
-		  (if (and (not quiet) (not (equal whitespace-clean-msg "")))
-		      (message "%s %s" whitespace-filename
-			       whitespace-clean-msg))))))))
-    whitespace-error))
-
-;;;###autoload
-(defun whitespace-region (s e)
-  "Check the region for whitespace errors."
-  (interactive "r")
-  (save-excursion
-    (save-restriction
-      (narrow-to-region s e)
-      (whitespace-buffer))))
-
-;;;###autoload
-(defun whitespace-cleanup ()
-  "Cleanup the five different kinds of whitespace problems.
-It normally applies to the whole buffer, but in Transient Mark mode
-when the mark is active it applies to the region.
-See `whitespace-buffer' docstring for a summary of the problems."
-  (interactive)
-  (if (and transient-mark-mode mark-active)
-      (whitespace-cleanup-region (region-beginning) (region-end))
-    (whitespace-cleanup-internal)))
-
-(defun whitespace-cleanup-internal (&optional region-only)
-  ;; If this buffer really contains a file, then run, else quit.
-  (whitespace-check-whitespace-mode current-prefix-arg)
-  (if (and buffer-file-name whitespace-mode)
-      (let ((whitespace-any nil)
-	    (whitespace-tabwith 8)
-	    (whitespace-tabwith-saved tab-width))
-
-	;; since all printable TABS should be 8, irrespective of how
-	;; they are displayed.
-	(setq tab-width whitespace-tabwith)
-
-	(if (and whitespace-check-buffer-leading
-		 (whitespace-buffer-leading))
-	    (progn
-	      (whitespace-buffer-leading-cleanup)
-	      (setq whitespace-any t)))
-
-	(if (and whitespace-check-buffer-trailing
-		 (whitespace-buffer-trailing))
-	    (progn
-	      (whitespace-buffer-trailing-cleanup)
-	      (setq whitespace-any t)))
-
-	(if (and whitespace-check-buffer-indent
-		 (whitespace-buffer-search whitespace-indent-regexp))
-	    (progn
-	      (whitespace-indent-cleanup)
-	      (setq whitespace-any t)))
-
-	(if (and whitespace-check-buffer-spacetab
-		 (whitespace-buffer-search whitespace-spacetab-regexp))
-	    (progn
-	      (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t")
-	      (setq whitespace-any t)))
-
-	(if (and whitespace-check-buffer-ateol
-		 (whitespace-buffer-search whitespace-ateol-regexp))
-	    (progn
-	      (whitespace-buffer-cleanup whitespace-ateol-regexp "")
-	      (setq whitespace-any t)))
-
-	;; Call this recursively till everything is taken care of
-	(if whitespace-any
-	    (whitespace-cleanup-internal region-only)
-	  ;; if we are done, talk to the user
-	  (progn
-	    (unless whitespace-silent
-	      (if region-only
-		  (message "The region is now clean")
-		(message "%s is now clean" buffer-file-name)))
-	    (whitespace-update-modeline)))
-	(setq tab-width whitespace-tabwith-saved))))
-
-;;;###autoload
-(defun whitespace-cleanup-region (s e)
-  "Whitespace cleanup on the region."
-  (interactive "r")
-  (save-excursion
-    (save-restriction
-      (narrow-to-region s e)
-      (whitespace-cleanup-internal t))
-    (whitespace-buffer t)))
-
-(defun whitespace-buffer-leading ()
-  "Return t if the current buffer has leading newline characters.
-If highlighting is enabled, highlight these characters."
-  (save-excursion
-    (goto-char (point-min))
-    (skip-chars-forward "\n")
-    (unless (bobp)
-      (whitespace-highlight-the-space (point-min) (point))
-      t)))
-
-(defun whitespace-buffer-leading-cleanup ()
-  "Remove any leading newline characters from current buffer."
-  (save-excursion
-    (goto-char (point-min))
-    (skip-chars-forward "\n")
-    (delete-region (point-min) (point))))
-
-(defun whitespace-buffer-trailing ()
-  "Return t if the current buffer has extra trailing newline characters.
-If highlighting is enabled, highlight these characters."
-  (save-excursion
-    (goto-char (point-max))
-    (skip-chars-backward "\n")
-    (forward-line)
-    (unless (eobp)
-      (whitespace-highlight-the-space (point) (point-max))
-      t)))
-
-(defun whitespace-buffer-trailing-cleanup ()
-  "Remove extra trailing newline characters from current buffer."
-  (save-excursion
-    (goto-char (point-max))
-    (skip-chars-backward "\n")
-    (unless (eobp)
-      (forward-line)
-      (delete-region (point) (point-max)))))
-
-(defun whitespace-buffer-search (regexp)
-  "Search for any given whitespace REGEXP."
-  (with-local-quit
-    (let (whitespace-retval)
-      (save-excursion
-	(goto-char (point-min))
-	(while (re-search-forward regexp nil t)
-	  (whitespace-highlight-the-space (match-beginning 0) (match-end 0))
-	  (push (match-beginning 0) whitespace-retval)))
-      (when whitespace-retval
-	(format " %s" (nreverse whitespace-retval))))))
-
-(defun whitespace-buffer-cleanup (regexp newregexp)
-  "Search for any given whitespace REGEXP and replace it with the NEWREGEXP."
-  (save-excursion
-    (goto-char (point-min))
-    (while (re-search-forward regexp nil t)
-      (replace-match newregexp))))
-
-(defun whitespace-indent-cleanup ()
-  "Search for 8/more spaces at the start of a line and replace it with tabs."
-  (save-excursion
-    (goto-char (point-min))
-    (while (re-search-forward whitespace-indent-regexp nil t)
-      (let ((column (current-column))
-	    (indent-tabs-mode t))
-	(delete-region (match-beginning 0) (point))
-	(indent-to column)))))
-
-(defun whitespace-unchecked-whitespaces ()
-  "Return the list of whitespaces whose testing has been suppressed."
-  (let ((unchecked-spaces
-	 (concat (if (not whitespace-check-buffer-ateol) "e")
-		 (if (not whitespace-check-buffer-indent) "i")
-		 (if (not whitespace-check-buffer-leading) "l")
-		 (if (not whitespace-check-buffer-spacetab) "s")
-		 (if (not whitespace-check-buffer-trailing) "t"))))
-    (if (not (equal unchecked-spaces ""))
-	unchecked-spaces
-      nil)))
-
-(defun whitespace-update-modeline (&optional whitespace-err)
-  "Update modeline with whitespace errors.
-Also with whitespaces whose testing has been turned off."
-  (if whitespace-display-in-modeline
-      (progn
-	(setq whitespace-mode-line nil)
-	;; Whitespace errors
-	(if (and whitespace-err (not (equal whitespace-err "")))
-	    (setq whitespace-mode-line whitespace-err))
-	;; Whitespace suppressed errors
-	(let ((whitespace-unchecked (whitespace-unchecked-whitespaces)))
-	  (if whitespace-unchecked
-	      (setq whitespace-mode-line
-		    (concat whitespace-mode-line "!" whitespace-unchecked))))
-	;; Add the whitespace modeline prefix
-	(setq whitespace-mode-line (if whitespace-mode-line
-				       (concat " W:" whitespace-mode-line)
-				     nil))
-	(whitespace-mode-line-update))))
-
-(defun whitespace-highlight-the-space (b e)
-  "Highlight the current line, unhighlighting a previously jumped to line."
-  (if whitespace-display-spaces-in-color
-      (let ((ol (whitespace-make-overlay b e)))
-	(whitespace-overlay-put ol 'face 'whitespace-highlight))))
-
-(defun whitespace-unhighlight-the-space()
-  "Unhighlight the currently highlight line."
-  (if (and whitespace-display-spaces-in-color whitespace-highlighted-space)
-      (progn
-	(mapc 'whitespace-delete-overlay whitespace-highlighted-space)
-	(setq whitespace-highlighted-space nil))))
-
-(defun whitespace-check-buffer-list (buf-name buf-file)
-  "Add a buffer and its file to the whitespace monitor list.
-
-The buffer named BUF-NAME and its associated file BUF-FILE are now monitored
-periodically for whitespace."
-  (if (and whitespace-mode (not (member (list buf-file buf-name)
-					whitespace-all-buffer-files)))
-      (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name))))
-
-(defun whitespace-tickle-timer ()
-  "Tickle timer to periodically to scan qualifying files for whitespace creep.
-
-If timer is not set, then set it to scan the files in
-`whitespace-all-buffer-files' periodically (defined by
-`whitespace-rescan-timer-time') for whitespace creep."
-  (if (and whitespace-rescan-timer-time
-	   (/= whitespace-rescan-timer-time 0)
-	   (not whitespace-rescan-timer))
-      (setq whitespace-rescan-timer
-	    (add-timeout whitespace-rescan-timer-time
-			 'whitespace-rescan-files-in-buffers nil
-			 whitespace-rescan-timer-time))))
-
-(defun whitespace-rescan-files-in-buffers (&optional arg)
-  "Check monitored files for whitespace creep since last scan."
-  (let ((whitespace-all-my-files whitespace-all-buffer-files)
-	buffile bufname thiselt buf)
-    (if (not whitespace-all-my-files)
-	(progn
-	  (disable-timeout whitespace-rescan-timer)
-	  (setq whitespace-rescan-timer nil))
-      (while whitespace-all-my-files
-	(setq thiselt (car whitespace-all-my-files))
-	(setq whitespace-all-my-files (cdr whitespace-all-my-files))
-	(setq buffile (car thiselt))
-	(setq bufname (cadr thiselt))
-	(setq buf (get-buffer bufname))
-	(if (buffer-live-p buf)
-	    (save-excursion
-	      ;;(message "buffer %s live" bufname)
-	      (set-buffer bufname)
-	      (if whitespace-mode
-		  (progn
-		    ;;(message "checking for whitespace in %s" bufname)
-		    (if whitespace-auto-cleanup
-			(progn
-			  ;;(message "cleaning up whitespace in %s" bufname)
-			  (whitespace-cleanup-internal))
-		      (progn
-			;;(message "whitespace-buffer %s." (buffer-name))
-			(whitespace-buffer t))))
-		;;(message "Removing %s from refresh list" bufname)
-		(whitespace-refresh-rescan-list buffile bufname)))
-	  ;;(message "Removing %s from refresh list" bufname)
-	  (whitespace-refresh-rescan-list buffile bufname))))))
-
-(defun whitespace-refresh-rescan-list (buffile bufname)
-  "Refresh the list of files to be rescanned for whitespace creep."
-  (if whitespace-all-buffer-files
-      (setq whitespace-all-buffer-files
-	    (delete (list buffile bufname) whitespace-all-buffer-files))
-    (when whitespace-rescan-timer
-      (disable-timeout whitespace-rescan-timer)
-      (setq whitespace-rescan-timer nil))))
-
-;;;###autoload
-(defalias 'global-whitespace-mode 'whitespace-global-mode)
-
-;;;###autoload
-(define-minor-mode whitespace-global-mode
-  "Toggle using Whitespace mode in new buffers.
-With ARG, turn the mode on if ARG is positive, otherwise turn it off.
-
-When this mode is active, `whitespace-buffer' is added to
-`find-file-hook' and `kill-buffer-hook'."
-  :global t
-  :group 'whitespace
-  (if whitespace-global-mode
-      (progn
-	(add-hook 'find-file-hook 'whitespace-buffer)
-	(add-hook 'write-file-functions 'whitespace-write-file-hook nil t)
-	(add-hook 'kill-buffer-hook 'whitespace-buffer))
-    (remove-hook 'find-file-hook 'whitespace-buffer)
-    (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
-    (remove-hook 'kill-buffer-hook 'whitespace-buffer)))
-
-;;;###autoload
-(defun whitespace-write-file-hook ()
-  "Hook function to be called on the buffer when whitespace check is enabled.
-This is meant to be added buffer-locally to `write-file-functions'."
-  (let ((werr nil))
-    (if whitespace-auto-cleanup
-	(whitespace-cleanup-internal)
-      (setq werr (whitespace-buffer)))
-    (if (and whitespace-abort-on-error werr)
-	(error "Abort write due to whitespaces in %s"
-		       buffer-file-name)))
-  nil)
-
-(defun whitespace-unload-function ()
-  "Unload the whitespace library."
-  (if (unintern "whitespace-unload-hook")
-      ;; if whitespace-unload-hook is defined, let's get rid of it
-      ;; and recursively call `unload-feature'
-      (progn (unload-feature 'whitespace) t)
-    ;; this only happens in the recursive call
-    (whitespace-global-mode -1)
-    (save-current-buffer
-      (dolist (buf (buffer-list))
-	(set-buffer buf)
-	(remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
-    ;; continue standard unloading
-    nil))
-
-(defun whitespace-unload-hook ()
-  (remove-hook 'find-file-hook 'whitespace-buffer)
-  (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
-  (remove-hook 'kill-buffer-hook 'whitespace-buffer))
-
-(add-hook 'whitespace-unload-hook 'whitespace-unload-hook)
-
-(provide 'whitespace)
-
-;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c
-;;; whitespace.el ends here
--- a/lisp/winner.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/winner.el	Wed Jan 30 07:57:28 2008 +0000
@@ -51,7 +51,7 @@
     '(region-active-p)))
 
 (defsetf winner-active-region () (store)
-  (if (fboundp 'zmacs-activate-region)
+  (if (featurep 'xemacs)
       `(if ,store (zmacs-activate-region)
 	 (zmacs-deactivate-region))
     `(setq mark-active ,store)))
--- a/lisp/woman.el	Wed Jan 30 06:40:42 2008 +0000
+++ b/lisp/woman.el	Wed Jan 30 07:57:28 2008 +0000
@@ -3540,8 +3540,10 @@
 	     (setq value (funcall op value (woman-parse-numeric-value))))
 	    ((looking-at "[<=>]=?")	; relational operators
 	     (goto-char (match-end 0))
-	     (setq op (or (intern-soft (match-string 0))
-			 (intern-soft "=")))
+	     (setq op (intern-soft
+                       (if (string-equal (match-string 0) "==")
+                           "="
+                         (match-string 0))))
 	     (setq value (if (funcall op value (woman-parse-numeric-value))
 			     1 0)))
 	    ((memq (setq op (following-char)) '(?& ?:)) ; Boolean and / or
--- a/make-dist	Wed Jan 30 06:40:42 2008 +0000
+++ b/make-dist	Wed Jan 30 07:57:28 2008 +0000
@@ -85,6 +85,10 @@
     "--bzip2")
       default_gzip="bzip2"
     ;;
+    ## Same with lzma.
+    "--lzma")
+      default_gzip="lzma"
+    ;;
 
     "--snapshot")
       clean_up=yes
@@ -96,9 +100,10 @@
     "--help")
       echo "Usage: ${progname} [options]"
       echo ""
-      echo "  --bzip2		use bzip2 instead of gzip"
+      echo "  --bzip2	use bzip2 instead of gzip"
       echo "  --clean-up	delete staging directories when done"
       echo "  --compress	use compress instead of gzip"
+      echo "  --lzma	use lzma instead of gzip"
       echo "  --newer=TIME	don't include files older than TIME"
       echo "  --no-check	don't check for bad file names etc."
       echo "  --no-update	don't recompile or do analogous things"
@@ -750,6 +755,7 @@
   case "${default_gzip}" in
     bzip2)      gzip_extension=.bz2 ;;
     compress* ) gzip_extension=.Z ;;
+    lzma)       gzip_extension=.lzma ;;
     * )         gzip_extension=.gz ;;
   esac
   echo "Creating tar file"
--- a/nt/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/nt/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,8 @@
+2008-01-20  Jason Rumney  <jasonr@gnu.org>
+
+	* gmake.defs (CYGWIN) [USING_SH]: Disable mapping of file
+	permissions to NTFS ACLs.
+
 2007-11-01  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* config.nt: Remove HAVE_X11R5.
--- a/nt/gmake.defs	Wed Jan 30 06:40:42 2008 +0000
+++ b/nt/gmake.defs	Wed Jan 30 07:57:28 2008 +0000
@@ -99,6 +99,16 @@
 ifeq "$(sh_output)" ""
 NEW_CYGWIN = 1
 endif
+
+# By default, newer versions of Cygwin mess with NTFS ACLs in an
+# attempt to emulate traditional posix file permissions. This can
+# cause bad effects, such as .exe files that are missing the
+# FILE_EXECUTE/FILE_GENERIC_EXECUTE permissions when they are created
+# with Cygwin commands that don't expect to be creating executable
+# files. Then when we later use a non-Cygwin program to create the
+# real .exe, the previous Cygwin defined ACL sticks.
+CYGWIN=nontsec
+export CYGWIN
 endif
 
 ALL_DEPS	= $^
--- a/src/.gdbinit	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/.gdbinit	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,6 @@
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001,
-#   2002, 2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+#   2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
--- a/src/ChangeLog	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/ChangeLog	Wed Jan 30 07:57:28 2008 +0000
@@ -1,3 +1,215 @@
+2008-01-29  Miles Bader  <miles@gnu.org>
+
+	* macterm.c (XTset_vertical_scroll_bar): Fix merge mistake.
+
+2008-01-28  Jason Rumney  <jasonr@gnu.org>
+
+	* w32.c (stat): Don't double check for networked drive.
+
+2008-01-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* window.c (run_window_configuration_change_hook): New function.
+	Code extracted from set_window_buffer.  Set the selected frame.
+	(set_window_buffer): Use it.
+	* window.h (run_window_configuration_change_hook): Declare.
+	* dispnew.c (change_frame_size_1): Use it instead of set-window-buffer.
+
+	* keyboard.c (read_char): Yet another int/Lisp_Object mixup (YAILOM).
+
+2008-01-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* Makefile.in: Remove references to unused macros.
+
+2008-01-26  Eli Zaretskii  <eliz@gnu.org>
+
+	* w32.c (g_b_init_get_sid_sub_authority)
+	(g_b_init_get_sid_sub_authority_count): New static variables.
+	(GetSidSubAuthority_Proc, GetSidSubAuthorityCount_Proc): New typedefs.
+	(get_sid_sub_authority, get_sid_sub_authority_count): New functions.
+	(init_user_info): Use them to retrieve uid and gid.
+	Use 500/513, the Windows defaults, as Administrator's uid/gid.
+	(fstat): Use pw_uid and pw_gid from the_passwd structure for
+	st_uid and st_gid of the file.
+
+2008-01-26  Jason Rumney  <jasonr@gnu.org>
+
+	* w32.c (logon_network_drive): New function.
+	(stat): Use it.
+
+2008-01-26  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xdisp.c (pos_visible_p): Handle the case where charpos falls on
+	invisible text covered with an ellipsis.
+
+2008-01-25  Richard Stallman  <rms@gnu.org>
+
+	* xdisp.c (redisplay_window): Run Qwindow_text_change_functions and
+	jump back to beginning.  Move some other initializations after that.
+	(Qwindow_text_change_functions, Vwindow_text_change_functions):
+	New variables.
+	(syms_of_xdisp): Init them.
+
+	* keyboard.c (read_char): Restore echo_message_buffer after redisplay.
+
+	* buffer.c (reset_buffer_local_variables):
+	Implement `permanent-local-hook'.
+	(Qpermanent_local_hook): New variable.
+	(syms_of_buffer): Init and staticpro it.
+
+2008-01-25  Michael Albinus  <michael.albinus@gmx.de>
+
+	* dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
+
+2008-01-25  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* fns.c (Fclrhash): Return TABLE.
+
+2008-01-23  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macterm.c (x_scroll_bar_create): Initialize bar->redraw_needed_p.
+	(XTset_vertical_scroll_bar): Redraw scroll bar if bar->redraw_needed_p
+	is set even without positional changes.
+	(x_scroll_bar_clear): Set bar->redraw_needed_p.
+
+	* macterm.h (struct scroll_bar): New member `redraw_needed_p'.
+
+2008-01-23  Jason Rumney  <jasonr@gnu.org>
+
+	* xterm.c (handle_one_xevent): Revert to counting chars not bytes.
+
+	* w32term.c (w32_read_socket) <WM_CHAR>: Decode characters outside
+	the unicode range available in MULE by locale-coding-system.
+	Improve dbcs lead byte detection.  Set event timestamp and modifiers
+	earlier.
+
+2008-01-23  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c (mac_emacs_pid) [MAC_OSX]: New variable.
+	[MAC_OSX] (init_mac_osx_environment): Initialize it.
+	[MAC_OSX] (mac_try_close_socket) [SELECT_USE_CFSOCKET]:	Return 0
+	when used on child processes.
+
+2008-01-21  Michael Albinus  <michael.albinus@gmx.de>
+
+	* dbusbind.c (Fdbus_method_return_internal): Rename from
+	Fdbus_method_return.
+	(Fdbus_unregister_object): Move to dbus.el.
+	(Fdbus_call_method, Fdbus_method_return_internal)
+	(Fdbus_send_signal): Improve debug messages.
+
+2008-01-20  Martin Rudalics  <rudalics@gmx.at>
+
+	* undo.c (undo_inhibit_record_point): New variable.
+	(syms_of_undo): Initialize it.
+	(record_point): Don't record point when undo_inhibit_record_point
+	is set.
+
+2008-01-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* process.c (list_processes_1): Don't use SCHARS on a nil buffer name.
+
+	* xdisp.c (Qauto_hscroll_mode): New var.
+	(syms_of_xdisp): Initialize it.
+	(hscroll_window_tree): Use it to lookup `auto-hscroll-mode' in each
+	window's buffer.
+	(hscroll_windows): Don't check automatic_hscrolling_p here.
+
+	* window.c (set_window_buffer): Don't unnecessarily reset hscroll and
+	vscroll if we're setting window-buffer to the value it already has.
+
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* m/intel386.h: Remove references to XENIX.
+
+2008-01-17  Andreas Schwab  <schwab@suse.de>
+
+	* m/amdx86-64.h (START_FILES, LIB_STANDARD): Use HAVE_LIB64_DIR
+	instead of HAVE_X86_64_LIB64_DIR.
+	* m/ibms390x.h (START_FILES, LIB_STANDARD): Likewise.
+
+2008-01-17  Glenn Morris  <rgm@gnu.org>
+
+	* m/ibms390x.h (START_FILES, LIB_STANDARD): Adjust value according
+	to HAVE_X86_64_LIB64_DIR.
+
+2008-01-16  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* s/irix3-3.h:
+	* s/irix4-0.h:
+	* s/386-ix.h:
+	* s/domain.h:
+	* s/hpux9-x11r4.h:
+	* s/hpux9shxr4.h: Remove files for systems no longer supported.
+
+	* sysdep.c: Remove code containing references to symbols defined
+	by unsupported systems.
+
+2008-01-16  Glenn Morris  <rgm@gnu.org>
+
+	* coding.c (select-safe-coding-system-function): Doc fix.
+
+2008-01-15  Glenn Morris  <rgm@gnu.org>
+
+	* config.in: Revert 2008-01-13 change: this is a generated file.
+
+2008-01-13  Tom Tromey  <tromey@redhat.com>
+
+	* lisp.h: Fix typo.
+
+2008-01-13  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* m/sequent-ptx.h:
+	* m/sequent.h:
+	* s/ptx.h:
+	* s/ptx4-2.h:
+	* s/ptx4.h: Remove files for systems no longer supported.
+
+	* callproc.c (Fcall_process): Fix previous change.
+
+2008-01-13  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* unexsunos4.c: Remove file, system not supported anymore.
+
+	* src/m/mips.h:
+	* src/m/intel386.h:
+	* callproc.c:
+	* config.in:
+	* ecrt0.c:
+	* emacs.c:
+	* fileio.c:
+	* frame.c:
+	* getpagesize.h:
+	* keyboard.c:
+	* lread.c:
+	* process.c:
+	* puresize.h:
+	* sysdep.c:
+	* systty.h:
+	* syswait.h:
+	* unexec.c:
+	* xdisp.c:
+	* alloc.c: Remove code containing references to symbols defined by
+	unsupported systems.
+
+2008-01-11  Kenichi Handa  <handa@ni.aist.go.jp>
+
+	* coding.c (detect_coding_mask): Fix previous change.
+
+2008-01-10  Chong Yidong  <cyd@stupidchicken.com>
+
+	* process.c (wait_reading_process_output): Check for window
+	changes caused by timers.
+
+2008-01-09  Kenichi Handa  <handa@ni.aist.go.jp>
+
+	* coding.c (detect_coding_iso2022): New arg
+	latin_extra_code_state.  Allow Latin extra codes only
+	when *latin_extra_code_state is nonzero.
+	(detect_coding_mask): If there is a NULL byte, detect the encoding
+	as UTF-16 or binary.  If Latin extra codes exist, detect the
+	encoding as ISO-2022 only when there's no other proper encoding is
+	found.
+
 2008-01-08  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* frame.c (Fmake_terminal_frame): Use #ifdef MAC_OS8 instead of
@@ -1836,8 +2048,7 @@
 2007-08-29  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* callproc.c (child_setup, getenv_internal): Use the
-	display-environment-variable and term-environment-variable frame
-	params.
+	display-environment-variable and term-environment-variable frame params.
 	(set_initial_environment): Initialise Vprocess_environment.
 
 	* config.in: Disable multi-keyboard support on a mac.
--- a/src/ChangeLog.10	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/ChangeLog.10	Wed Jan 30 07:57:28 2008 +0000
@@ -27916,8 +27916,8 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2001, 2002, 2003, 2004, 2005,
-	2006, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+	2008 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
--- a/src/Makefile.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/Makefile.in	Wed Jan 30 07:57:28 2008 +0000
@@ -1032,11 +1032,6 @@
 prefix-args${EXEEXT}: prefix-args.c $(config_h)
 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) ${srcdir}/prefix-args.c -o prefix-args
 
-/* Do not lose if this was not defined.  */
-#ifndef OLDXMENU_OPTIONS
-#define OLDXMENU_OPTIONS
-#endif
-
 #if defined (HAVE_X_WINDOWS) && defined (HAVE_X11) && defined (HAVE_MENUS) && ! defined (HAVE_GTK)
 
 /* We use stamp-xmenu with these two deps
@@ -1082,7 +1077,7 @@
 C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE
 C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM
 really-oldXMenu:
-	cd ${oldXMenudir}; ${MAKE} ${MFLAGS} OLDXMENU_OPTIONS \
+	cd ${oldXMenudir}; ${MAKE} ${MFLAGS} \
     CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \
     "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \
     "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \
--- a/src/alloc.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/alloc.c	Wed Jan 30 07:57:28 2008 +0000
@@ -1928,11 +1928,7 @@
   consing_since_gc += sizeof *s;
 
 #ifdef GC_CHECK_STRING_BYTES
-  if (!noninteractive
-#ifdef MAC_OS8
-      && current_sblock
-#endif
-     )
+  if (!noninteractive)
     {
       if (++check_string_bytes_count == 200)
 	{
--- a/src/buffer.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/buffer.c	Wed Jan 30 07:57:28 2008 +0000
@@ -153,6 +153,7 @@
 int inhibit_modification_hooks;
 
 Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local;
+Lisp_Object Qpermanent_local_hook;
 
 Lisp_Object Qprotected_field;
 
@@ -762,13 +763,38 @@
     b->local_var_alist = Qnil;
   else
     {
-      Lisp_Object tmp, last = Qnil;
+      Lisp_Object tmp, prop, last = Qnil;
       for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp))
 	if (CONSP (XCAR (tmp))
 	    && SYMBOLP (XCAR (XCAR (tmp)))
-	    && !NILP (Fget (XCAR (XCAR (tmp)), Qpermanent_local)))
-	  /* If permanent-local, keep it.  */
-	  last = tmp;
+	    && !NILP (prop = Fget (XCAR (XCAR (tmp)), Qpermanent_local)))
+	  {
+	    /* If permanent-local, keep it.  */
+	    last = tmp;
+	    if (EQ (prop, Qpermanent_local_hook))
+	      {
+		/* This is a partially permanent hook variable.
+		   Preserve only the elements that want to be preserved.  */
+		Lisp_Object list, newlist;
+		list = XCDR (XCAR (tmp));
+		if (!CONSP (list))
+		  newlist = list;
+		else
+		  for (newlist = Qnil; CONSP (list); list = XCDR (list))
+		    {
+		      Lisp_Object elt = XCAR (list);
+		      /* Preserve element ELT if it's t,
+			 if it is a function with a `permanent-local-hook' property,
+			 or if it's not a symbol.  */
+		      if (! SYMBOLP (elt)
+			  || EQ (elt, Qt)
+			  || !NILP (Fget (elt, Qpermanent_local_hook)))
+			newlist = Fcons (elt, newlist);
+		    }
+		XSETCDR (XCAR (tmp), Fnreverse (newlist));
+	      }
+	  }
+	/* Delete this local variable.  */
 	else if (NILP (last))
 	  b->local_var_alist = XCDR (tmp);
 	else
@@ -5308,6 +5334,8 @@
   staticpro (&Vbuffer_alist);
   staticpro (&Qprotected_field);
   staticpro (&Qpermanent_local);
+  Qpermanent_local_hook = intern ("permanent-local-hook");
+  staticpro (&Qpermanent_local_hook);
   staticpro (&Qkill_buffer_hook);
   Qoverlayp = intern ("overlayp");
   staticpro (&Qoverlayp);
@@ -5335,6 +5363,7 @@
   staticpro (&Qbefore_change_functions);
   Qafter_change_functions = intern ("after-change-functions");
   staticpro (&Qafter_change_functions);
+  /* The next one is initialized in init_buffer_once.  */
   staticpro (&Qucs_set_table_for_input);
 
   Qkill_buffer_query_functions = intern ("kill-buffer-query-functions");
@@ -5575,7 +5604,8 @@
 
   DEFVAR_PER_BUFFER ("mode-name", &current_buffer->mode_name,
                      Qnil,
-		     doc: /* Pretty name of current buffer's major mode (a string).  */);
+		     doc: /* Pretty name of current buffer's major mode.
+Usually a string.  See `mode-line-format' for other possible forms.  */);
 
   DEFVAR_PER_BUFFER ("local-abbrev-table", &current_buffer->abbrev_table, Qnil,
 		     doc: /* Local (mode-specific) abbrev table of current buffer.  */);
--- a/src/callproc.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/callproc.c	Wed Jan 30 07:57:28 2008 +0000
@@ -160,14 +160,14 @@
 call_process_cleanup (fdpid)
      Lisp_Object fdpid;
 {
-#if defined (MSDOS) || defined (MAC_OS8)
+#if defined (MSDOS)
   /* for MSDOS fdpid is really (fd . tempfile)  */
   register Lisp_Object file;
   file = Fcdr (fdpid);
   emacs_close (XFASTINT (Fcar (fdpid)));
   if (strcmp (SDATA (file), NULL_DEVICE) != 0)
     unlink (SDATA (file));
-#else /* not MSDOS and not MAC_OS8 */
+#else /* not MSDOS */
   register int pid = XFASTINT (Fcdr (fdpid));
 
   if (call_process_exited)
@@ -244,10 +244,6 @@
   char *outf, *tempfile;
   int outfilefd;
 #endif
-#ifdef MAC_OS8
-  char *tempfile;
-  int outfilefd;
-#endif
 #if 0
   int mask;
 #endif
@@ -471,32 +467,11 @@
   fd[1] = outfilefd;
 #endif /* MSDOS */
 
-#ifdef MAC_OS8
-  /* Since we don't have pipes on the Mac, create a temporary file to
-     hold the output of the subprocess.  */
-  tempfile = (char *) alloca (SBYTES (Vtemp_file_name_pattern) + 1);
-  bcopy (SDATA (Vtemp_file_name_pattern), tempfile,
-	 SBYTES (Vtemp_file_name_pattern) + 1);
-
-  mktemp (tempfile);
-
-  outfilefd = creat (tempfile, S_IREAD | S_IWRITE);
-  if (outfilefd < 0)
-    {
-      close (filefd);
-      report_file_error ("Opening process output file",
-			 Fcons (build_string (tempfile), Qnil));
-    }
-  fd[0] = filefd;
-  fd[1] = outfilefd;
-#endif /* MAC_OS8 */
-
   if (INTEGERP (buffer))
     fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1;
   else
     {
 #ifndef MSDOS
-#ifndef MAC_OS8
       errno = 0;
       if (pipe (fd) == -1)
 	{
@@ -504,7 +479,6 @@
 	  report_file_error ("Creating process pipe", Qnil);
 	}
 #endif
-#endif
 #if 0
       /* Replaced by close_process_descs */
       set_exclusive_use (fd[0]);
@@ -562,52 +536,6 @@
 	report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil));
       }
 
-#ifdef MAC_OS8
-    {
-      /* Call run_mac_command in sysdep.c here directly instead of doing
-         a child_setup as for MSDOS and other platforms.  Note that this
-         code does not handle passing the environment to the synchronous
-         Mac subprocess.  */
-      char *infn, *outfn, *errfn, *currdn;
-
-      /* close these files so subprocess can write to them */
-      close (outfilefd);
-      if (fd_error != outfilefd)
-        close (fd_error);
-      fd1 = -1; /* No harm in closing that one! */
-
-      infn = SDATA (infile);
-      outfn = tempfile;
-      if (NILP (error_file))
-        errfn = NULL_DEVICE;
-      else if (EQ (Qt, error_file))
-        errfn = outfn;
-      else
-        errfn = SDATA (error_file);
-      currdn = SDATA (current_dir);
-      pid = run_mac_command (new_argv, currdn, infn, outfn, errfn);
-
-      /* Record that the synchronous process exited and note its
-         termination status.  */
-      synch_process_alive = 0;
-      synch_process_retcode = pid;
-      if (synch_process_retcode < 0)  /* means it couldn't be exec'ed */
-	{
-	  synchronize_system_messages_locale ();
-	  synch_process_death = strerror (errno);
-	}
-
-      /* Since CRLF is converted to LF within `decode_coding', we can
-         always open a file with binary mode.  */
-      fd[0] = open (tempfile, O_BINARY);
-      if (fd[0] < 0)
-	{
-	  unlink (tempfile);
-	  close (filefd);
-	  report_file_error ("Cannot re-open temporary file", Qnil);
-	}
-    }
-#else /* not MAC_OS8 */
 #ifdef MSDOS /* MW, July 1993 */
     /* Note that on MSDOS `child_setup' actually returns the child process
        exit status, not its PID, so we assign it to `synch_process_retcode'
@@ -670,7 +598,6 @@
     if (fd_error >= 0)
       emacs_close (fd_error);
 #endif /* not MSDOS */
-#endif /* not MAC_OS8 */
 
     environ = save_environ;
 
@@ -704,14 +631,14 @@
   /* Enable sending signal if user quits below.  */
   call_process_exited = 0;
 
-#if defined(MSDOS) || defined(MAC_OS8)
+#if defined(MSDOS)
   /* MSDOS needs different cleanup information.  */
   record_unwind_protect (call_process_cleanup,
 			 Fcons (make_number (fd[0]), build_string (tempfile)));
 #else
   record_unwind_protect (call_process_cleanup,
 			 Fcons (make_number (fd[0]), make_number (pid)));
-#endif /* not MSDOS and not MAC_OS8 */
+#endif /* not MSDOS */
 
 
   if (BUFFERP (buffer))
--- a/src/coding.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/coding.c	Wed Jan 30 07:57:28 2008 +0000
@@ -9810,7 +9810,9 @@
 
 If set, this function is called to force a user to select a proper
 coding system which can encode the text in the case that a default
-coding system used in each operation can't encode the text.
+coding system used in each operation can't encode the text.  The
+function should take care that the buffer is not modified while
+the coding system is being selected.
 
 The default value is `select-safe-coding-system' (which see).  */);
   Vselect_safe_coding_system_function = Qnil;
--- a/src/config.in	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/config.in	Wed Jan 30 07:57:28 2008 +0000
@@ -301,6 +301,9 @@
 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
 #undef HAVE_LANGINFO_CODESET
 
+/* Define to 1 if the directory /usr/lib64 exists. */
+#undef HAVE_LIB64_DIR
+
 /* Define to 1 if you have the `com_err' library (-lcom_err). */
 #undef HAVE_LIBCOM_ERR
 
@@ -720,9 +723,6 @@
 /* Define to 1 if you have the X11R6 or newer version of Xt. */
 #undef HAVE_X11XTR6
 
-/* Define to 1 if the file /usr/lib64 exists. */
-#undef HAVE_X86_64_LIB64_DIR
-
 /* Define to 1 if you have the Xaw3d library (-lXaw3d). */
 #undef HAVE_XAW3D
 
--- a/src/dbusbind.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/dbusbind.c	Wed Jan 30 07:57:28 2008 +0000
@@ -33,11 +33,10 @@
 /* Subroutines.  */
 Lisp_Object Qdbus_get_unique_name;
 Lisp_Object Qdbus_call_method;
-Lisp_Object Qdbus_method_return;
+Lisp_Object Qdbus_method_return_internal;
 Lisp_Object Qdbus_send_signal;
 Lisp_Object Qdbus_register_signal;
 Lisp_Object Qdbus_register_method;
-Lisp_Object Qdbus_unregister_object;
 
 /* D-Bus error symbol.  */
 Lisp_Object Qdbus_error;
@@ -595,10 +594,14 @@
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       {
+	/* Assignment to EMACS_INT stops GCC whining about limited
+	   range of data type.  */
 	dbus_uint32_t val;
+	EMACS_INT val1;
 	dbus_message_iter_get_basic (iter, &val);
 	XD_DEBUG_MESSAGE ("%c %d", dtype, val);
-	return make_fixnum_or_float (val);
+	val1 = val;
+	return make_fixnum_or_float (val1);
       }
 
     case DBUS_TYPE_INT64:
@@ -833,14 +836,22 @@
   /* Append parameters to the message.  */
   for (i = 5; i < nargs; ++i)
     {
-
-      XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
-      XD_DEBUG_MESSAGE ("Parameter%d %s",
-			i-4, SDATA (format2 ("%s", args[i], Qnil)));
-
       dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
       if (XD_DBUS_TYPE_P (args[i]))
-	++i;
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4,
+			    SDATA (format2 ("%s", args[i], Qnil)),
+			    SDATA (format2 ("%s", args[i+1], Qnil)));
+	  ++i;
+	}
+      else
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s", i-4,
+			    SDATA (format2 ("%s", args[i], Qnil)));
+	}
 
       /* Check for valid signature.  We use DBUS_TYPE_INVALID as
 	 indication that there is no parent type.  */
@@ -872,7 +883,8 @@
     {
       /* Loop over the parameters of the D-Bus reply message.  Construct a
 	 Lisp list, which is returned by `dbus-call-method'.  */
-      while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
+      while ((dtype = dbus_message_iter_get_arg_type (&iter))
+	     != DBUS_TYPE_INVALID)
 	{
 	  result = Fcons (xd_retrieve_arg (dtype, &iter), result);
 	  dbus_message_iter_next (&iter);
@@ -880,7 +892,7 @@
     }
   else
     {
-      /* No arguments: just return nil. */
+      /* No arguments: just return nil.  */
     }
 
   /* Cleanup.  */
@@ -895,12 +907,13 @@
     RETURN_UNGCPRO (Fnreverse (result));
 }
 
-DEFUN ("dbus-method-return", Fdbus_method_return, Sdbus_method_return,
+DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal,
+       Sdbus_method_return_internal,
        3, MANY, 0,
-       doc: /* Return to method SERIAL on the D-Bus BUS.
+       doc: /* Return for message SERIAL on the D-Bus BUS.
 This is an internal function, it shall not be used outside dbus.el.
 
-usage: (dbus-method-return BUS SERIAL SERVICE &rest ARGS)  */)
+usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS)  */)
      (nargs, args)
      int nargs;
      register Lisp_Object *args;
@@ -948,14 +961,22 @@
   /* Append parameters to the message.  */
   for (i = 3; i < nargs; ++i)
     {
-
-      XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
-      XD_DEBUG_MESSAGE ("Parameter%d %s",
-			i-2, SDATA (format2 ("%s", args[i], Qnil)));
-
       dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
       if (XD_DBUS_TYPE_P (args[i]))
-	++i;
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2,
+			    SDATA (format2 ("%s", args[i], Qnil)),
+			    SDATA (format2 ("%s", args[i+1], Qnil)));
+	  ++i;
+	}
+      else
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s", i-2,
+			    SDATA (format2 ("%s", args[i], Qnil)));
+	}
 
       /* Check for valid signature.  We use DBUS_TYPE_INVALID as
 	 indication that there is no parent type.  */
@@ -1064,13 +1085,22 @@
   /* Append parameters to the message.  */
   for (i = 5; i < nargs; ++i)
     {
-      XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
-      XD_DEBUG_MESSAGE ("Parameter%d %s",
-			i-4, SDATA (format2 ("%s", args[i], Qnil)));
-
       dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
       if (XD_DBUS_TYPE_P (args[i]))
-	++i;
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4,
+			    SDATA (format2 ("%s", args[i], Qnil)),
+			    SDATA (format2 ("%s", args[i+1], Qnil)));
+	  ++i;
+	}
+      else
+	{
+	  XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
+	  XD_DEBUG_MESSAGE ("Parameter%d %s", i-4,
+			    SDATA (format2 ("%s", args[i], Qnil)));
+	}
 
       /* Check for valid signature.  We use DBUS_TYPE_INVALID as
 	 indication that there is no parent type.  */
@@ -1392,56 +1422,6 @@
   return list2 (key, list3 (service, path, handler));
 }
 
-DEFUN ("dbus-unregister-object", Fdbus_unregister_object,
-       Sdbus_unregister_object,
-       1, 1, 0,
-       doc: /* Unregister OBJECT from the D-Bus.
-OBJECT must be the result of a preceding `dbus-register-signal' or
-`dbus-register-method' call.  It returns t if OBJECT has been
-unregistered, nil otherwise.  */)
-     (object)
-     Lisp_Object object;
-{
-  Lisp_Object value;
-  struct gcpro gcpro1;
-
-  /* Check parameter.  */
-  if (!(CONSP (object) && (!NILP (CAR_SAFE (object)))
-	&& CONSP (CDR_SAFE (object))))
-    wrong_type_argument (intern ("D-Bus"), object);
-
-  /* Find the corresponding entry in the hash table.  */
-  value = Fgethash (CAR_SAFE (object), Vdbus_registered_functions_table, Qnil);
-
-  /* Loop over the registered functions.  */
-  while (!NILP (value))
-    {
-      GCPRO1 (value);
-
-      /* (car value) has the structure (UNAME SERVICE PATH HANDLER).
-	 (cdr object) has the structure ((SERVICE PATH HANDLER) ...).  */
-      if (!NILP (Fequal (CDR_SAFE (CAR_SAFE (value)),
-			 CAR_SAFE (CDR_SAFE (object)))))
-	{
-	  /* Compute new hash value.  */
-	  value = Fdelete (CAR_SAFE (value),
-			   Fgethash (CAR_SAFE (object),
-				     Vdbus_registered_functions_table, Qnil));
-	  if (NILP (value))
-	    Fremhash (CAR_SAFE (object), Vdbus_registered_functions_table);
-	  else
-	    Fputhash (CAR_SAFE (object), value,
-		      Vdbus_registered_functions_table);
-	  RETURN_UNGCPRO (Qt);
-	}
-      UNGCPRO;
-      value = CDR_SAFE (value);
-    }
-
-  /* Return.  */
-  return Qnil;
-}
-
 
 void
 syms_of_dbusbind ()
@@ -1455,9 +1435,9 @@
   staticpro (&Qdbus_call_method);
   defsubr (&Sdbus_call_method);
 
-  Qdbus_method_return = intern ("dbus-method-return");
-  staticpro (&Qdbus_method_return);
-  defsubr (&Sdbus_method_return);
+  Qdbus_method_return_internal = intern ("dbus-method-return-internal");
+  staticpro (&Qdbus_method_return_internal);
+  defsubr (&Sdbus_method_return_internal);
 
   Qdbus_send_signal = intern ("dbus-send-signal");
   staticpro (&Qdbus_send_signal);
@@ -1471,10 +1451,6 @@
   staticpro (&Qdbus_register_method);
   defsubr (&Sdbus_register_method);
 
-  Qdbus_unregister_object = intern ("dbus-unregister-object");
-  staticpro (&Qdbus_unregister_object);
-  defsubr (&Sdbus_unregister_object);
-
   Qdbus_error = intern ("dbus-error");
   staticpro (&Qdbus_error);
   Fput (Qdbus_error, Qerror_conditions,
--- a/src/dispnew.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/dispnew.c	Wed Jan 30 07:57:28 2008 +0000
@@ -6386,9 +6386,7 @@
 
   record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
 
-  /* This isn't quite a no-op: it runs window-configuration-change-hook.  */
-  Fset_window_buffer (FRAME_SELECTED_WINDOW (f),
-		      XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer, Qt);
+  run_window_configuration_change_hook (f);
 
   unbind_to (count, Qnil);
 }
--- a/src/ecrt0.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/ecrt0.c	Wed Jan 30 07:57:28 2008 +0000
@@ -84,146 +84,6 @@
 static start1 ();
 #endif
 
-#ifdef APOLLO
-extern	char   *malloc(), *realloc(), *(*_libc_malloc) (), *(*_libc_realloc)();
-extern	void	free(),	(*_libc_free) (); extern int main();
-std_$call void  unix_$main();
-
-_start()
-{
-	_libc_malloc = malloc;
-	_libc_realloc = realloc;
-	_libc_free = free;
-	unix_$main(main);	/* no return */
-}
-#endif /* APOLLO */
-
-#if defined(orion) || defined(pyramid) || defined(celerity) || defined(ALLIANT) || defined(clipper) || defined(sps7)
-
-#if defined(sps7) && defined(V3x)
-        asm("	section	10");
-        asm("	ds.b	0xb0");
-#endif
-
-#ifdef ALLIANT
-/* _start must initialize _curbrk and _minbrk on the first startup;
-   when starting up after dumping, it must initialize them to what they were
-   before the dumping, since they are in the shared library and
-   are not dumped.  See ADJUST_EXEC_HEADER in m-alliant.h.  */
-extern unsigned char *_curbrk, *_minbrk;
-extern unsigned char end;
-unsigned char *_setbrk = &end;
-#ifdef ALLIANT_2800
-unsigned char *_end = &end;
-#endif
-#endif
-
-#ifndef DUMMIES
-#define DUMMIES
-#endif
-
-_start (DUMMIES argc, argv, envp)
-     int argc;
-     char **argv, **envp;
-{
-#ifdef ALLIANT
-#ifdef ALLIANT_2800
-  _curbrk = _end;
-  _minbrk = _end;
-#else
-  _curbrk = _setbrk;
-  _minbrk = _setbrk;
-#endif
-#endif
-
-  environ = envp;
-
-  exit (main (argc, argv, envp));
-}
-
-#endif /* orion or pyramid or celerity or alliant or clipper */
-
-#if defined (ns16000) && !defined (sequent) && !defined (UMAX) && !defined (CRT0_DUMMIES)
-
-_start ()
-{
-/* On 16000, _start pushes fp onto stack */
-  start1 ();
-}
-
-/* ignore takes care of skipping the fp value pushed in start.  */
-static
-start1 (ignore, argc, argv)
-     int ignore;
-     int argc;
-     register char **argv;
-{
-  environ = argv + argc + 1;
-
-  if (environ == *argv)
-    environ--;
-  exit (main (argc, argv, environ));
-}
-#endif /* ns16000, not sequent and not UMAX, and not the CRT0_DUMMIES method */
-
-#ifdef UMAX
-_start()
-{
-	asm("	exit []			# undo enter");
-	asm("	.set	exitsc,1");
-	asm("	.set	sigcatchall,0x400");
-
-	asm("	.globl	_exit");
-	asm("	.globl	start");
-	asm("	.globl	__start");
-	asm("	.globl	_main");
-	asm("	.globl	_environ");
-	asm("	.globl	_sigvec");
-	asm("	.globl	sigentry");
-
-	asm("start:");
-	asm("	br	.xstart");
-	asm("	.org	0x20");
-	asm("	.double	p_glbl,0,0xf00000,0");
-	asm("	.org	0x30");
-	asm(".xstart:");
-	asm("	adjspb	$8");
-	asm("	movd	8(sp),0(sp)	# argc");
-	asm("	addr	12(sp),r0");
-	asm("	movd	r0,4(sp)	# argv");
-	asm("L1:");
-	asm("	movd	r0,r1");
-	asm("	addqd	$4,r0");
-	asm("	cmpqd	$0,0(r1)	# null args term ?");
-	asm("	bne	L1");
-	asm("	cmpd	r0,0(4(sp))	# end of 'env' or 'argv' ?");
-	asm("	blt	L2");
-	asm("	addqd	$-4,r0		# envp's are in list");
-	asm("L2:");
-	asm("	movd	r0,8(sp)	# env");
-	asm("	movd	r0,@_environ	# indir is 0 if no env ; not 0 if env");
-	asm("	movqd	$0,tos		# setup intermediate signal handler");
-	asm("	addr	@sv,tos");
-	asm("	movzwd	$sigcatchall,tos");
-	asm("	jsr	@_sigvec");
-	asm("	adjspb	$-12");
-	asm("	jsr	@_main");
-	asm("	adjspb	$-12");
-	asm("	movd	r0,tos");
-	asm("	jsr	@_exit");
-	asm("	adjspb	$-4");
-	asm("	addr	@exitsc,r0");
-	asm("	svc");
-	asm("	.align	4		# sigvec arg");
-	asm("sv:");
-	asm("	.double	sigentry");
-	asm("	.double	0");
-	asm("	.double	0");
-
-	asm("	.comm	p_glbl,1");
-}
-#endif /* UMAX */
-
 #ifdef CRT0_DUMMIES
 
 /* Define symbol "start": here; some systems want that symbol.  */
@@ -295,21 +155,10 @@
 	asm ("	global	_start");
 	asm ("	text");
 	asm ("_start:");
-#ifndef NU
-#ifdef STRIDE
-	asm ("	comm	havefpu%,2");
-#else /* m68k, not STRIDE */
 	asm ("  comm	splimit%,4");
-#endif /* STRIDE */
 	asm ("	global	exit");
 	asm ("	text");
-#ifdef STRIDE
-	asm ("	trap	&3");
-	asm ("	mov.w	%d0,havefpu%");
-#else /* m68k, not STRIDE */
   	asm ("	mov.l	%d0,splimit%");
-#endif /* STRIDE */
-#endif /* not NU */
 	asm ("	jsr	start1");
 	asm ("	mov.l	%d0,(%sp)");
 	asm ("	jsr	exit");
@@ -319,32 +168,6 @@
 
 #ifdef m68000
 
-#ifdef ISI68K
-/* Added by ESM Sun May 24 12:44:02 1987 to get new ISI library to work */
-/* Edited by Ray Mon May 15 15:59:56 EST 1989 so we can compile with gcc */
-#if defined(BSD4_3) && !defined(__GNUC__)
-static foo () {
-#endif
-	asm ("	.globl  is68020");
-	asm ("is68020:");
-#ifndef BSD4_3
-	asm ("	.long   0x00000000");
-	asm ("	.long   0xffffffff");
-/* End of stuff added by ESM */
-#endif
-	asm ("	.text");
-	asm ("	.globl	__start");
-	asm ("__start:");
-	asm ("	.word 0");
-	asm ("	link	a6,#0");
-	asm ("	jbsr	_start1");
-	asm ("	unlk	a6");
-	asm ("	rts");
-#if defined(BSD4_3) && !defined(__GNUC__)
-      }
-#endif
-#else /* not ISI68K */
-
 _start ()
 {
 #ifdef sun
@@ -353,7 +176,6 @@
 /* On 68000, _start pushes a6 onto stack  */
   start1 ();
 }
-#endif /* not ISI68k */
 #endif /* m68000 */
 #endif /* m68k */
 
@@ -373,15 +195,6 @@
 
   if ((char *)environ == xargv)
     environ--;
-#ifdef sun_68881
-  asm("    jsr     f68881_used");
-#endif
-#ifdef sun_fpa
-  asm("    jsr     ffpa_used");
-#endif
-#ifdef sun_soft
-  asm("    jsr     start_float");
-#endif
   exit (main (argc, argv, environ));
 }
 
@@ -503,85 +316,6 @@
 #endif /* new hp assembler */
 #endif /* hp9000s300 */
 
-#ifdef GOULD
-
-/* startup code has to be in near text rather
-   than fartext as allocated by the C compiler. */
-	asm("	.text");
-	asm("	.align	2");
-	asm("	.globl	__start");
-	asm("	.text");
-	asm("__start:");
-/* setup base register b1 (function base). */
-	asm("	.using	b1,.");
-	asm("	tpcbr	b1");
-/* setup base registers b3 through b7 (data references). */
-	asm("	file	basevals,b3");
-/* setup base register b2 (stack pointer); it should be
-   aligned on a 8-word boundary; but because it is pointing
-   to argc, its value should be remembered (in r5). */
-	asm("	movw	b2,r4");
-	asm("	movw	b2,r5");
-	asm("	andw	#~0x1f,r4");
-	asm("	movw	r4,b2");
-/* allocate stack frame to do some work. */
-	asm("	subea	16w,b2");
-/* initialize signal catching for UTX/32 1.2; this is
-   necessary to make restart from saved image work. */
-	asm("	movea	sigcatch,r1");
-	asm("	movw	r1,8w[b2]");
-	asm("	svc	#1,#150");
-/* setup address of argc for start1. */
-	asm("	movw	r5,8w[b2]");
-	asm("   func	#1,_start1");
-	asm("	halt");
-/* space for ld to store base register initial values. */
-	asm("	.align	5");
-	asm("basevals:");
-	asm("	.word	__base3,__base4,__base5,__base6,__base7");
-
-static
-start1 (xargc)
-     int *xargc;
-{
-  register int	argc;
-  register char **argv;
-
-  argc = *xargc;
-  argv = (char **)(xargc) + 1;
-  environ = argv + argc + 1;
-
-  if (environ == argv)
-    environ--;
-  exit (main (argc, argv, environ));
-
-}
-
-#endif /* GOULD */
-
-#ifdef elxsi
-#include <elxsi/argvcache.h>
-
-extern char **environ;
-extern int	errno;
-extern void	_init_doscan(), _init_iob();
-extern char	end[];
-char		*_init_brk = end;
-
-_start()
-{
-  environ = exec_cache.ac_envp;
-  brk (_init_brk);
-  errno = 0;
-  _init_doscan ();
-  _init_iob ();
-  _exit (exit (main (exec_cache.ac_argc,
-		     exec_cache.ac_argv,
-		     exec_cache.ac_envp)));
-}
-#endif /* elxsi */
-
-
 #ifdef sparc
 asm (".global __start");
 asm (".text");
--- a/src/emacs.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/emacs.c	Wed Jan 30 07:57:28 2008 +0000
@@ -1364,9 +1364,7 @@
 #ifdef CLASH_DETECTION
   init_filelock ();
 #endif
-#ifndef MAC_OS8
   init_atimer ();
-#endif
   running_asynch_code = 0;
 
   /* Handle --unibyte and the EMACS_UNIBYTE envvar,
@@ -1559,7 +1557,6 @@
       /* The basic levels of Lisp must come first.  */
       /* And data must come first of all
 	 for the sake of symbols like error-message.  */
-#ifndef MAC_OS8
       /* Called before init_window_once for Mac OS Classic.  */
       syms_of_data ();
 #endif
@@ -1577,8 +1574,6 @@
       syms_of_casetab ();
       syms_of_callproc ();
       syms_of_category ();
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_ccl ();
 #endif
       syms_of_character ();
@@ -1600,11 +1595,8 @@
       syms_of_marker ();
       syms_of_minibuf ();
       syms_of_process ();
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_search ();
       syms_of_frame ();
-#endif
       syms_of_syntax ();
       syms_of_terminal ();
       syms_of_term ();
@@ -1612,10 +1604,7 @@
 #ifdef HAVE_SOUND
       syms_of_sound ();
 #endif
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_textprop ();
-#endif
       syms_of_composite ();
 #ifdef VMS
       syms_of_vmsproc ();
@@ -1700,10 +1689,7 @@
 
   init_editfns (); /* init_process uses Voperating_system_release. */
   init_process (); /* init_display uses add_keyboard_wait_descriptor. */
-#ifndef MAC_OS8
-  /* Called before init_window_once for Mac OS Classic.  */
   init_keyboard ();	/* This too must precede init_sys_modes.  */
-#endif
 #ifdef VMS
   init_vmsproc ();	/* And this too.  */
 #endif /* VMS */
--- a/src/fileio.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/fileio.c	Wed Jan 30 07:57:28 2008 +0000
@@ -68,10 +68,6 @@
 #endif
 #endif
 
-#ifdef APOLLO
-#include <sys/time.h>
-#endif
-
 #include "lisp.h"
 #include "intervals.h"
 #include "buffer.h"
@@ -814,12 +810,6 @@
   /* Process as Unix format: just remove any final slash.
      But leave "/" unchanged; do not change it to "".  */
   strcpy (dst, src);
-#ifdef APOLLO
-  /* Handle // as root for apollo's.  */
-  if ((slen > 2 && dst[slen - 1] == '/')
-      || (slen > 1 && dst[0] != '/' && dst[slen - 1] == '/'))
-    dst[slen - 1] = 0;
-#else
   if (slen > 1
       && IS_DIRECTORY_SEP (dst[slen - 1])
 #ifdef DOS_NT
@@ -827,7 +817,6 @@
 #endif
       )
     dst[slen - 1] = 0;
-#endif
 #ifdef DOS_NT
   CORRECT_DIR_SEPS (dst);
 #endif
@@ -1802,10 +1791,6 @@
       while (*p)
 	{
 	  if (p[0] == '/' && p[1] == '/'
-#ifdef APOLLO
-	      /* // at start of filename is meaningful on Apollo system.  */
-	      && nm != p
-#endif /* APOLLO */
 	      )
 	    nm = p + 1;
 	  if (p[0] == '/' && p[1] == '~')
@@ -2037,10 +2022,6 @@
 	  *o++ = *p++;
 	}
       else if (!strncmp (p, "//", 2)
-#ifdef APOLLO
-	       /* // at start of filename is meaningful in Apollo system.  */
-	       && o != target
-#endif /* APOLLO */
 	       )
 	{
 	  o = target;
@@ -2056,11 +2037,6 @@
 	{
 	  while (o != target && *--o != '/')
 	    ;
-#ifdef APOLLO
-	  if (o == target + 1 && o[-1] == '/' && o[0] == '/')
-	    ++o;
-	  else
-#endif /* APOLLO */
 	  if (o == target && *o == '/')
 	    ++o;
 	  p += 3;
@@ -2111,11 +2087,11 @@
 #endif /* VMS */
 	   || IS_DIRECTORY_SEP (p[-1]))
 	  && file_name_absolute_p (p)
-#if defined (APOLLO) || defined (WINDOWSNT) || defined(CYGWIN)
+#if defined (WINDOWSNT) || defined(CYGWIN)
 	  /* // at start of file name is meaningful in Apollo,
 	     WindowsNT and Cygwin systems.  */
 	  && !(IS_DIRECTORY_SEP (p[0]) && p - 1 == nm)
-#endif /* not (APOLLO || WINDOWSNT || CYGWIN) */
+#endif /* not (WINDOWSNT || CYGWIN) */
 	      )
 	{
 	  for (s = p; *s && (!IS_DIRECTORY_SEP (*s)
@@ -3801,12 +3777,7 @@
   }
   if (total < 0)
 #else
-#ifndef APOLLO
   if (stat (SDATA (filename), &st) < 0)
-#else
-  if ((fd = emacs_open (SDATA (filename), O_RDONLY, 0)) < 0
-      || fstat (fd, &st) < 0)
-#endif /* not APOLLO */
 #endif /* WINDOWSNT */
     {
       if (fd >= 0) emacs_close (fd);
@@ -4652,9 +4623,6 @@
     {
       if (!EQ (current_buffer->undo_list, Qt))
 	current_buffer->undo_list = Qnil;
-#ifdef APOLLO
-      stat (SDATA (filename), &st);
-#endif
 
       if (NILP (handler))
 	{
@@ -5330,16 +5298,14 @@
      but who knows about all the other machines with NFS?)  */
 #if 0
 
-  /* On VMS and APOLLO, must do the stat after the close
+  /* On VMS, must do the stat after the close
      since closing changes the modtime.  */
 #ifndef VMS
-#ifndef APOLLO
   /* Recall that #if defined does not work on VMS.  */
 #define FOO
   fstat (desc, &st);
 #endif
 #endif
-#endif
 
   /* NFS can report a write failure now.  */
   if (emacs_close (desc) < 0)
--- a/src/fns.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/fns.c	Wed Jan 30 07:57:28 2008 +0000
@@ -4779,12 +4779,13 @@
 
 
 DEFUN ("clrhash", Fclrhash, Sclrhash, 1, 1, 0,
-       doc: /* Clear hash table TABLE.  */)
+       doc: /* Clear hash table TABLE and return it.  */)
      (table)
      Lisp_Object table;
 {
   hash_clear (check_hash_table (table));
-  return Qnil;
+  /* Be compatible with XEmacs.  */
+  return table;
 }
 
 
@@ -5200,9 +5201,10 @@
 
   DEFVAR_BOOL ("use-file-dialog", &use_file_dialog,
     doc: /* *Non-nil means mouse commands use a file dialog to ask for files.
-This applies to commands from menus and tool bar buttons.  The value of
-`use-dialog-box' takes precedence over this variable, so a file dialog is only
-used if both `use-dialog-box' and this variable are non-nil.  */);
+This applies to commands from menus and tool bar buttons even when
+they are initiated from the keyboard.  The value of `use-dialog-box'
+takes precedence over this variable, so a file dialog is only used if
+both `use-dialog-box' and this variable are non-nil.  */);
   use_file_dialog = 1;
 
   defsubr (&Sidentity);
--- a/src/frame.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/frame.c	Wed Jan 30 07:57:28 2008 +0000
@@ -604,9 +604,6 @@
   else
     f->output_method = output_termcap;
 #else
-#ifdef MAC_OS8
-  make_mac_terminal_frame (f);
-#else
   {
     f->output_method = output_termcap;
     f->terminal = terminal;
@@ -631,7 +628,6 @@
   FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
   FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
 #endif
-#endif /* MAC_OS8 */
 #endif /* MSDOS */
 
   if (!noninteractive)
@@ -698,7 +694,7 @@
     abort ();
 #else /* not MSDOS */
 
-#if 0 /* #ifdef MAC_OS8 */
+#if 0
   /* This can happen for multi-tty when using both terminal frames and
      Carbon frames. */
   if (sf->output_method != output_mac)
@@ -1370,13 +1366,7 @@
   if (! FRAME_LIVE_P (f))
     return Qnil;
 
-  if (NILP (force) && !other_visible_frames (f)
-#ifdef MAC_OS8
-      /* Terminal frame deleted before any other visible frames are
-	 created.  */
-      && strcmp (SDATA (f->name), "F1") != 0
-#endif
-     )
+  if (NILP (force) && !other_visible_frames (f))
     error ("Attempt to delete the sole visible or iconified frame");
 
 #if 0
--- a/src/getpagesize.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/getpagesize.h	Wed Jan 30 07:57:28 2008 +0000
@@ -43,13 +43,9 @@
 #      define CLSIZE 1
 #     endif /* no CLSIZE */
 #    else /* no NBPG */
-#     ifdef NBPC
-#      define getpagesize() NBPC
-#     else /* no NBPC */
 #      ifdef PAGESIZE
 #       define getpagesize() PAGESIZE
 #      endif /* PAGESIZE */
-#     endif /* no NBPC */
 #    endif /* no NBPG */
 #   endif /* no EXEC_PAGESIZE */
 #  else /* no HAVE_SYS_PARAM_H */
--- a/src/keyboard.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/keyboard.c	Wed Jan 30 07:57:28 2008 +0000
@@ -95,18 +95,7 @@
    during the current critical section.  */
 int interrupt_input_pending;
 
-
-#ifdef HAVE_WINDOW_SYSTEM
-/* Make all keyboard buffers much bigger when using X windows.  */
-#ifdef MAC_OS8
-/* But not too big (local data > 32K error) if on Mac OS Classic.  */
-#define KBD_BUFFER_SIZE 512
-#else
 #define KBD_BUFFER_SIZE 4096
-#endif
-#else	/* No X-windows, character input */
-#define KBD_BUFFER_SIZE 4096
-#endif	/* No X-windows */
 
 #ifdef MULTI_KBOARD
 KBOARD *initial_kboard;
@@ -2715,6 +2704,8 @@
   /* if redisplay was requested */
   if (commandflag >= 0)
     {
+      int echo_current = EQ (echo_message_buffer, echo_area_buffer[0]);
+
 	/* If there is pending input, process any events which are not
 	   user-visible, such as X selection_request events.  */
       if (input_pending
@@ -2738,6 +2729,12 @@
 	  swallow_events (0);
 	  /* If that cleared input_pending, try again to redisplay.  */
 	}
+
+      /* Prevent the redisplay we just did
+	 from messing up echoing of the input after the prompt.  */
+      if (commandflag == 0 && echo_current)
+	echo_message_buffer = echo_area_buffer[0];
+
     }
 
   /* Message turns off echoing unless more keystrokes turn it on again.
@@ -7234,7 +7231,7 @@
   if (n_to_read > sizeof cbuf)
     n_to_read = sizeof cbuf;
 #else /* no FIONREAD */
-#if defined (USG) || defined (DGUX) || defined(CYGWIN)
+#if defined (USG) || defined(CYGWIN)
   /* Read some input if available, but don't wait.  */
   n_to_read = sizeof cbuf;
   fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
@@ -7284,9 +7281,9 @@
          );
 
 #ifndef FIONREAD
-#if defined (USG) || defined (DGUX) || defined (CYGWIN)
+#if defined (USG) || defined (CYGWIN)
   fcntl (fileno (tty->input), F_SETFL, 0);
-#endif /* USG or DGUX or CYGWIN */
+#endif /* USG or CYGWIN */
 #endif /* no FIONREAD */
 
   if (nread <= 0)
--- a/src/lisp.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/lisp.h	Wed Jan 30 07:57:28 2008 +0000
@@ -1413,7 +1413,7 @@
    All callers should assure that at least this size of memory is
    allocated at the place pointed by the second argument.
 
-   Thers are 6 modifiers, each consumes 2 chars.
+   There are 6 modifiers, each consumes 2 chars.
    The octal form of a character code consumes
    (1 + CHARACTERBITS / 3 + 1) chars (including backslash at the head).
    We need one more byte for string terminator `\0'.  */
--- a/src/lread.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/lread.c	Wed Jan 30 07:57:28 2008 +0000
@@ -1336,9 +1336,6 @@
   return (IS_DIRECTORY_SEP (s[0])
 	  || (SCHARS (pathname) > 2
 	      && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))
-#ifdef ALTOS
-	  || *s == '@'
-#endif
 #ifdef VMS
 	  || index (s, ':')
 #endif /* VMS */
--- a/src/m/amdx86-64.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/m/amdx86-64.h	Wed Jan 30 07:57:28 2008 +0000
@@ -146,7 +146,7 @@
 #else /* !__OpenBSD__ && !__FreeBSD__ && !__NetBSD__ && !sun */
 
 #undef START_FILES
-#ifdef HAVE_X86_64_LIB64_DIR
+#ifdef HAVE_LIB64_DIR
 #define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o
 #else
 #define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o
@@ -158,7 +158,7 @@
    versions of ld are one-pass linkers, we need to mention -lgcc twice,
    or else we risk getting unresolved externals.  */
 #undef LIB_STANDARD
-#ifdef HAVE_X86_64_LIB64_DIR
+#ifdef HAVE_LIB64_DIR
 #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o
 #else
 #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o
--- a/src/m/ibms390x.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/m/ibms390x.h	Wed Jan 30 07:57:28 2008 +0000
@@ -152,10 +152,18 @@
 #define XPNTR(a) XUINT (a)
 
 #undef START_FILES
+#ifdef HAVE_LIB64_DIR
 #define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o
+#else
+#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o
+#endif
 
 #undef LIB_STANDARD
+#ifdef HAVE_LIB64_DIR
 #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o
+#else
+#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o
+#endif
 
 /* arch-tag: 4b87653c-6add-4663-8691-7d9dc17b5519
    (do not change this comment) */
--- a/src/m/intel386.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/m/intel386.h	Wed Jan 30 07:57:28 2008 +0000
@@ -85,17 +85,6 @@
 
 #define DOT_GLOBAL_START
 
-#ifdef XENIX
-/* Data type of load average, as read out of kmem.  */
-#define LOAD_AVE_TYPE short
-
-/* Convert that into an integer that is 100 for a load average of 1.0  */
-#define LOAD_AVE_CVT(x) (((double) (x)) * 100.0 / FSCALE)
-
-#define FSCALE 256.0         /* determined by experimentation...  */
-#endif
-
-
 #ifdef SOLARIS2
 /* Data type of load average, as read out of kmem.  */
 #define LOAD_AVE_TYPE long
@@ -153,28 +142,6 @@
 
 /* #define VIRT_ADDR_VARIES */
 
-#ifdef XENIX
-/* Define NO_REMAP if memory segmentation makes it not work well
-   to change the boundary between the text section and data section
-   when Emacs is dumped.  If you define this, the preloaded Lisp
-   code will not be sharable; but that's better than failing completely.  */
-
-#define NO_REMAP
-
-/* Since cannot purify, use standard Xenix 386 startup code. */
-
-#define START_FILES	/lib/386/Sseg.o pre-crt0.o /lib/386/Scrt0.o
-
-/* These really use terminfo.  */
-
-#define LIBS_TERMCAP /lib/386/Slibcurses.a  \
-   /lib/386/Slibtinfo.a /lib/386/Slibx.a
-
-/* Standard libraries for this machine.  Since `-l' doesn't work in `ld'.  */
-/* '__fltused' is unresolved w/o Slibcfp.a */
-#define LIB_STANDARD /lib/386/Slibcfp.a /lib/386/Slibc.a
-#else /* not XENIX */
-
 /* this brings in alloca() if we're using cc */
 #ifdef USG
 #ifndef LIB_STANDARD
@@ -188,7 +155,6 @@
 #define NO_REMAP
 #define TEXT_START 0
 #endif /* USG */
-#endif /* not XENIX */
 
 #ifdef USG5_4
 #define DATA_SEG_BITS 0x08000000
--- a/src/m/mips.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/m/mips.h	Wed Jan 30 07:57:28 2008 +0000
@@ -130,7 +130,7 @@
 
 /* Alter some of the options used when linking.  */
 
-#if !defined(NEWSOS5) && !defined(__linux__)
+#if !defined(__linux__)
 #ifdef BSD_SYSTEM
 
 /* DECstations don't have this library.
@@ -161,7 +161,7 @@
 #endif
 
 #endif /* not BSD_SYSTEM */
-#endif /* not NEWSOS5 && not __linux__ */
+#endif /* not __linux__ */
 
 /* The standard definitions of these macros would work ok,
    but these are faster because the constants are short.  */
@@ -173,7 +173,7 @@
    ((int)(type) << VALBITS)						\
    + (((unsigned) (ptr) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS)))
 
-#if !defined (NEWSOS5) && !defined (__linux__)
+#if !defined (__linux__)
 #ifdef USG
 
 /* Cancel certain parts of standard sysV support.  */
@@ -213,7 +213,7 @@
 #undef HAVE_UNION_WAIT
 #endif /* BSD_SYSTEM */
 
-#endif /* not NEWSOS5 && not __linux__ */
+#endif /* not __linux__ */
 
 /* arch-tag: 8fd020ee-78a7-4d87-96ce-6129f52f7bee
    (do not change this comment) */
--- a/src/m/sequent-ptx.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/* machine description file for SEQUENT machines running DYNIX/ptx
-   Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-
-/* The following line tells the configuration script what sort of
-   operating system this machine is likely to run.
-   USUAL-OPSYS="ptx"  */
-
-#include "intel386.h"
-
-/* Define how to take a char and sign-extend into an int.
-   On machines where char is signed, this is a no-op.  */
-/* CHECK THIS */
-#define SIGN_EXTEND_CHAR(c) (c)
-
-/* Now define a symbol for the cpu type, if your compiler
-   does not define it automatically:
-   Ones defined so far include vax, m68000, ns16000, pyramid,
-   orion, tahoe, APOLLO and many others.  */
-
-/* BTW: ptx defines _SEQUENT_, i386 */
-
-/* Use type int rather than a union, to represent Lisp_Object */
-/* This is desirable for most machines.  */
-
-#define NO_UNION_TYPE
-
-/* crt0.c should use the vax-bsd style of entry, with these dummy args.  */
-/* Already defined.  Assume prior definition works for PTX.  */
-#if 0
-#undef CRT0_DUMMIES
-#define CRT0_DUMMIES dummy1, dummy2, dummy3,
-#endif
-
-/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
-   the 24-bit bit field into an int.  In other words, if bit fields
-   are always unsigned.
-
-   If you use NO_UNION_TYPE, this flag does not matter.  */
-
-#define EXPLICIT_SIGN_EXTEND
-
-/* Data type of load average, as read out of kmem.  */
-
-#undef LOAD_AVE_TYPE
-#define LOAD_AVE_TYPE unsigned long
-
-/* Convert that into an integer that is 100 for a load average of 1.0  */
-
-#undef FSCALE
-#define	FSCALE	1000.0
-#undef LOAD_AVE_CVT
-#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
-
-/* Define CANNOT_DUMP on machines where unexec does not work.
-   Then the function dump-emacs will not be defined
-   and temacs will do (load "loadup") automatically unless told otherwise.  */
-
-/* #define CANNOT_DUMP */
-
-/* Define VIRT_ADDR_VARIES if the virtual addresses of
-   pure and impure space as loaded can vary, and even their
-   relative order cannot be relied on.
-
-   Otherwise Emacs assumes that text space precedes data space,
-   numerically.  */
-
-/* #define VIRT_ADDR_VARIES */
-
-/* Define NO_REMAP if memory segmentation makes it not work well
-   to change the boundary between the text section and data section
-   when Emacs is dumped.  If you define this, the preloaded Lisp
-   code will not be sharable; but that's better than failing completely.  */
-/* On PTX, can't seem to get a valid executable unless NO_REMAP is
-   defined.  This did work in the Sequent patched Emacs 18.57.  */
-#ifndef NO_REMAP
-#define NO_REMAP
-#endif
-/* #undef NO_REMAP */
-
-/* If a valid PTX executable could be dumped without NO_REMAP defined,
-   here's a guess at some defines to make it work.  */
-#ifndef NO_REMAP
-
-/* PTX has getpagesize() but it returns 296. Using the default method of
-   including getpagesize.h in unexec.c returns 4096 which seems more
-   reasonable.  */
-#undef HAVE_GETPAGESIZE
-
-/* Override magic number for a.out header.  */
-#define EXEC_MAGIC 0411		/* from a.out.h: separated I&D */
-
-#define ADJUST_TEXT_SCNHDR_SIZE
-#define ADJUST_TEXTBASE
-
-/* The file sections in the Symmetry a.out must be on 4K boundaries.  */
-/* #define DATA_SECTION_ALIGNMENT       (4096-1) */
-
-#endif  /* ifndef NO_REMAP */
-
-/* Avoids a compiler bug.  */
-#define TAHOE_REGISTER_BUG
-
-/* (short) negative-int doesn't sign-extend correctly.  */
-#define SHORT_CAST_BUG
-
-/* Cause compilations to be done in parallel in ymakefile.  */
-#define MAKE_PARALLEL $&
-
-/* Use terminfo library.  */
-#define LIBS_TERMCAP -ltermlib
-
-/* arch-tag: 0494629b-7e11-4f6f-865f-62254ac46099
-   (do not change this comment) */
--- a/src/m/sequent.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/* machine description file for SEQUENT BALANCE machines
-   Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-
-/* The following line tells the configuration script what sort of
-   operating system this machine is likely to run.
-   USUAL-OPSYS="note"
-
-NOTE-START
-Use -opsystem=bsd4-2, or -opsystem=bsd4-3 on newer systems.
-NOTE-END */
-
-/* NOTE: this file works for DYNIX release 2.0
-	  (not tested on 1.3) on NS32000's */
-
-/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word
-   is the most significant byte.  */
-
-#undef WORDS_BIG_ENDIAN
-
-/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
- * group of arguments and treat it as an array of the arguments.  */
-
-/* #define NO_ARG_ARRAY */
-
-/* Define WORD_MACHINE if addresses and such have
- * to be corrected before they can be used as byte counts.  */
-
-/* #define WORD_MACHINE */
-
-/* Now define a symbol for the cpu type, if your compiler
-   does not define it automatically:
-   vax, m68000, ns16000, pyramid, orion, tahoe and APOLLO
-   are the ones defined so far.  */
-
-/* BTW: DYNIX defines sequent, ns32000, and ns16000 (GENIX compatibility) */
-#ifndef	sequent		/* pre DYNIX 2.1 releases */
-# define sequent
-#endif
-
-/* Use type int rather than a union, to represent Lisp_Object */
-/* This is desirable for most machines.  */
-
-#define NO_UNION_TYPE
-
-/* crt0.c should use the vax-bsd style of entry, with these dummy args.  */
-
-#define CRT0_DUMMIES bogus_fp,
-
-/* crt0.c should define a symbol `start' and do .globl with a dot.  */
-
-#define DOT_GLOBAL_START
-
-/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
-   the 24-bit bit field into an int.  In other words, if bit fields
-   are always unsigned.
-
-   If you use NO_UNION_TYPE, this flag does not matter.  */
-
-#define EXPLICIT_SIGN_EXTEND
-
-/* Data type of load average, as read out of kmem.  */
-
-#define LOAD_AVE_TYPE unsigned long
-
-/* Convert that into an integer that is 100 for a load average of 1.0  */
-
-#define	FSCALE	1000.0
-#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
-
-/* Define CANNOT_DUMP on machines where unexec does not work.
-   Then the function dump-emacs will not be defined
-   and temacs will do (load "loadup") automatically unless told otherwise.  */
-
-/* #define CANNOT_DUMP */
-
-/* Define VIRT_ADDR_VARIES if the virtual addresses of
-   pure and impure space as loaded can vary, and even their
-   relative order cannot be relied on.
-
-   Otherwise Emacs assumes that text space precedes data space,
-   numerically.  */
-
-/* #define VIRT_ADDR_VARIES */
-
-/* Name of file the to look in
-   for the kernel symbol table (for load average) */
-
-#undef KERNEL_FILE
-#define KERNEL_FILE "/dynix"
-
-/* Avoids a compiler bug */
-
-#define TAHOE_REGISTER_BUG
-
-/* Say that the text segment of a.out includes the header;
-   the header actually occupies the first few bytes of the text segment
-   and is counted in hdr.a_text.  Furthermore, the value written
-   in the a_text in the file must have N_ADDRADJ added to it.  */
-
-#define A_TEXT_OFFSET(HDR) (sizeof (HDR) + N_ADDRADJ (HDR))
-
-/* This is the offset of the executable's text, from the start of the file.  */
-
-#define A_TEXT_SEEK(HDR) (N_TXTOFF (hdr) + sizeof (hdr))
-
-/* (short) negative-int doesn't sign-extend correctly */
-#define SHORT_CAST_BUG
-
-/* Cause compilations to be done in parallel in ymakefile.  */
-#define MAKE_PARALLEL &
-
-/* Say that mailer interlocking uses flock.  */
-#define MAIL_USE_FLOCK
-
-/* On many 4.2-based systems, there's a rather tricky bug
- * with the interpretation of the pid/pgrp value given to
- * the F_SETOWN fcntl() call.  It works as documented EXCEPT
- * when applied to filedescriptors for sockets, in which case
- * the sign must be reversed.  If your emacs subprocesses get
- * SIGIO's when they shouldn't, while running on a socket
- * (e.g. under X windows), you should probably define this.
- */
-
-#define F_SETOWN_SOCK_NEG
-
-/* Some really obscure 4.2-based systems (like Sequent DYNIX)
- * do not support asynchronous I/O (using SIGIO) on sockets,
- * even though it works fine on tty's.  If you have one of
- * these systems, define the following, and then use it in
- * config.h (or elsewhere) to decide when (not) to use SIGIO.
- */
-
-#define NO_SOCK_SIGIO
-
-/* Define how to search all pty names.
-   This is for Dynix 3.0; delete next 5 definitions for older systems.  */
-
-#define PTY_MAJOR "pqrstuvwPQRSTUVW"
-#define PTY_MINOR "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define PTY_ITERATION					\
-  register int ma, mi;					\
-  for (ma = 0; ma < sizeof(PTY_MAJOR) - 1; ma++)	\
-    for (mi = 0; mi < sizeof(PTY_MINOR) - 1; mi++)
-#define PTY_NAME_SPRINTF \
-  sprintf (ptyname, "/dev/pty%c%c", PTY_MAJOR[ma], PTY_MINOR[mi]);
-#define PTY_TTY_NAME_SPRINTF \
-  sprintf (ptyname, "/dev/tty%c%c", PTY_MAJOR[ma], PTY_MINOR[mi]);
-
-/* arch-tag: 81caea48-aa64-4021-9544-e969dea71ee8
-   (do not change this comment) */
--- a/src/mac.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/mac.c	Wed Jan 30 07:57:28 2008 +0000
@@ -5008,6 +5008,9 @@
    sys_select.  */
 static CFMutableDictionaryRef cfsockets_for_select;
 
+/* Process ID of Emacs.  */
+static pid_t mac_emacs_pid;
+
 static void
 socket_callback (s, type, address, data, info)
      CFSocketRef s;
@@ -5103,7 +5106,7 @@
      int fd;
 {
 #if SELECT_USE_CFSOCKET
-  if (cfsockets_for_select)
+  if (getpid () == mac_emacs_pid && cfsockets_for_select)
     {
       void *key = (void *) fd;
       CFSocketRef socket =
@@ -5339,6 +5342,8 @@
   char *p, *q;
   struct stat st;
 
+  mac_emacs_pid = getpid ();
+
   /* Initialize locale related variables.  */
   mac_system_script_code =
     (ScriptCode) GetScriptManagerVariable (smSysScript);
--- a/src/macterm.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/macterm.c	Wed Jan 30 07:57:28 2008 +0000
@@ -5071,6 +5071,7 @@
 #ifdef MAC_OSX
   bar->fringe_extended_p = Qnil;
 #endif
+  bar->redraw_needed_p = Qnil;
 #ifdef USE_TOOLKIT_SCROLL_BARS
   bar->track_top = Qnil;
   bar->track_height = Qnil;
@@ -5287,14 +5288,24 @@
       BLOCK_INPUT;
 
       /* If already correctly positioned, do nothing.  */
-      if (!(XINT (bar->left) == sb_left
-	    && XINT (bar->top) == top
-	    && XINT (bar->width) == sb_width
-	    && XINT (bar->height) == height
+      if (XINT (bar->left) == sb_left
+	  && XINT (bar->top) == top
+	  && XINT (bar->width) == sb_width
+	  && XINT (bar->height) == height
 #ifdef MAC_OSX
-	    && !NILP (bar->fringe_extended_p) == fringe_extended_p
-#endif
-	    ))
+	  && !NILP (bar->fringe_extended_p) == fringe_extended_p
+#endif
+	  )
+	{
+	  if (!NILP (bar->redraw_needed_p))
+	    {
+#if USE_CG_DRAWING
+	      mac_prepare_for_quickdraw (f);
+#endif
+	      Draw1Control (SCROLL_BAR_CONTROL_REF (bar));
+	    }
+	}
+      else
 	{
 	  /* Since toolkit scroll bars are smaller than the space reserved
 	     for them on the frame, we have to clear "under" them.  */
@@ -5336,6 +5347,8 @@
   bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil;
 #endif
 
+  bar->redraw_needed_p = Qnil;
+
 #ifdef USE_TOOLKIT_SCROLL_BARS
   if (NILP (bar->track_top))
     {
@@ -5693,8 +5706,15 @@
 x_scroll_bar_clear (f)
      FRAME_PTR f;
 {
-  XTcondemn_scroll_bars (f);
-  XTjudge_scroll_bars (f);
+  Lisp_Object bar;
+
+  /* We can have scroll bars even if this is 0,
+     if we just turned off scroll bar mode.
+     But in that case we should not clear them.  */
+  if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
+    for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
+	 bar = XSCROLL_BAR (bar)->next)
+      XSCROLL_BAR (bar)->redraw_needed_p = Qt;
 }
 
 
--- a/src/macterm.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/macterm.h	Wed Jan 30 07:57:28 2008 +0000
@@ -457,6 +457,9 @@
   Lisp_Object fringe_extended_p;
 #endif
 
+  /* t if redraw needed in the next XTset_vertical_scroll_bar call.  */
+  Lisp_Object redraw_needed_p;
+
 #ifdef USE_TOOLKIT_SCROLL_BARS
   /* The position and size of the scroll bar handle track area in
      pixels, relative to the frame.  */
--- a/src/process.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/process.c	Wed Jan 30 07:57:28 2008 +0000
@@ -78,7 +78,7 @@
 #include <client.h>
 #endif
 
-/* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
+/* On some systems, inet_addr returns a 'struct in_addr'. */
 #ifdef HAVE_BROKEN_INET_ADDR
 #define IN_ADDR struct in_addr
 #define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
@@ -87,12 +87,12 @@
 #define NUMERIC_ADDR_ERROR (numeric_addr == -1)
 #endif
 
-#if defined(BSD_SYSTEM) || defined(STRIDE)
+#if defined(BSD_SYSTEM)
 #include <sys/ioctl.h>
 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
 #include <fcntl.h>
 #endif /* HAVE_PTYS and no O_NDELAY */
-#endif /* BSD_SYSTEM || STRIDE */
+#endif /* BSD_SYSTEM */
 
 #ifdef BROKEN_O_NONBLOCK
 #undef O_NONBLOCK
@@ -596,7 +596,6 @@
 #else
             sprintf (pty_name, "/dev/tty%c%x", c, i);
 #endif /* no PTY_TTY_NAME_SPRINTF */
-#ifndef UNIPLUS
 	    if (access (pty_name, 6) != 0)
 	      {
 		emacs_close (fd);
@@ -606,7 +605,6 @@
 		return -1;
 # endif /* IRIS */
 	      }
-#endif /* not UNIPLUS */
 	    setup_pty (fd);
 	    return fd;
 	  }
@@ -1360,8 +1358,11 @@
 	w_proc = i;
       if (!NILP (p->buffer))
 	{
-	  if (NILP (XBUFFER (p->buffer)->name) && w_buffer < 8)
-	    w_buffer = 8;  /* (Killed) */
+	  if (NILP (XBUFFER (p->buffer)->name))
+	    {
+	      if (w_buffer < 8)
+		w_buffer = 8;  /* (Killed) */
+	    }
 	  else if ((i = SCHARS (XBUFFER (p->buffer)->name), (i > w_buffer)))
 	    w_buffer = i;
 	}
@@ -1888,12 +1889,12 @@
 #endif
       if (forkin < 0)
 	report_file_error ("Opening pty", Qnil);
-#if defined (RTU) || defined (UNIPLUS) || defined (DONT_REOPEN_PTY)
+#if defined (DONT_REOPEN_PTY)
       /* In the case that vfork is defined as fork, the parent process
 	 (Emacs) may send some data before the child process completes
 	 tty options setup.  So we setup tty before forking.  */
       child_setup_tty (forkout);
-#endif /* RTU or UNIPLUS or DONT_REOPEN_PTY */
+#endif /* DONT_REOPEN_PTY */
 #else
       forkin = forkout = -1;
 #endif /* not USG, or USG_SUBTTY_WORKS */
@@ -1934,15 +1935,6 @@
   set_exclusive_use (outchannel);
 #endif
 
-/* Stride people say it's a mystery why this is needed
-   as well as the O_NDELAY, but that it fails without this.  */
-#if defined (STRIDE) || (defined (pfa) && defined (HAVE_PTYS))
-  {
-    int one = 1;
-    ioctl (inchannel, FIONBIO, &one);
-  }
-#endif
-
 #ifdef O_NONBLOCK
   fcntl (inchannel, F_SETFL, O_NONBLOCK);
   fcntl (outchannel, F_SETFL, O_NONBLOCK);
@@ -1992,7 +1984,7 @@
 #ifdef BSD4_1
   sighold (SIGCHLD);
 #else /* not BSD4_1 */
-#if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX)
+#if defined (BSD_SYSTEM) || defined (HPUX)
   sigsetmask (sigmask (SIGCHLD));
 #else /* ordinary USG */
 #if 0
@@ -2106,7 +2098,7 @@
 	  }
 #endif /* TIOCNOTTY */
 
-#if !defined (RTU) && !defined (UNIPLUS) && !defined (DONT_REOPEN_PTY)
+#if !defined (DONT_REOPEN_PTY)
 /*** There is a suggestion that this ought to be a
      conditional on TIOCSPGRP,
      or !(defined (HAVE_SETSID) && defined (TIOCSCTTY)).
@@ -2140,7 +2132,7 @@
 	    ioctl (xforkout, TIOCSPGRP, &pgrp);
 #endif
 	  }
-#endif /* not UNIPLUS and not RTU and not DONT_REOPEN_PTY */
+#endif /* not DONT_REOPEN_PTY */
 
 #ifdef SETUP_SLAVE_PTY
 	if (pty_flag)
@@ -2167,7 +2159,7 @@
 #ifdef BSD4_1
 	sigrelse (SIGCHLD);
 #else /* not BSD4_1 */
-#if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX)
+#if defined (BSD_SYSTEM) || defined (HPUX)
 	sigsetmask (SIGEMPTYMASK);
 #else /* ordinary USG */
 #if 0
@@ -2178,10 +2170,10 @@
 #endif /* SIGCHLD */
 #endif /* !POSIX_SIGNALS */
 
-#if !defined (RTU) && !defined (UNIPLUS) && !defined (DONT_REOPEN_PTY)
+#if !defined (DONT_REOPEN_PTY)
 	if (pty_flag)
 	  child_setup_tty (xforkout);
-#endif /* not RTU and not UNIPLUS and not DONT_REOPEN_PTY */
+#endif /* not DONT_REOPEN_PTY */
 #ifdef WINDOWSNT
 	pid = child_setup (xforkin, xforkout, xforkout,
 			   new_argv, 1, current_dir);
@@ -2259,7 +2251,7 @@
 #ifdef BSD4_1
   sigrelse (SIGCHLD);
 #else /* not BSD4_1 */
-#if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX)
+#if defined (BSD_SYSTEM) || defined (HPUX)
   sigsetmask (SIGEMPTYMASK);
 #else /* ordinary USG */
 #if 0
@@ -4650,12 +4642,6 @@
 	  else if (xerrno == ENOMEM)
 	    no_avail = 1;
 #endif
-#ifdef ALLIANT
-	  /* This happens for no known reason on ALLIANT.
-	     I am guessing that this is the right response. -- RMS.  */
-	  else if (xerrno == EFAULT)
-	    no_avail = 1;
-#endif
 	  else if (xerrno == EBADF)
 	    {
 #ifdef AIX
@@ -4717,6 +4703,7 @@
 	{
 	  int old_timers_run = timers_run;
 	  struct buffer *old_buffer = current_buffer;
+	  Lisp_Object old_window = selected_window;
 	  int leave = 0;
 
 	  if (detect_input_pending_run_timers (do_display))
@@ -4730,7 +4717,8 @@
 	     an alike.  Make read_key_sequence aware of that.  */
 	  if (timers_run != old_timers_run
 	      && waiting_for_user_input_p == -1
-	      && old_buffer != current_buffer)
+	      && (old_buffer != current_buffer
+	      || !EQ (old_window, selected_window)))
 	    record_asynch_buffer_change ();
 
 	  if (leave)
--- a/src/puresize.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/puresize.h	Wed Jan 30 07:57:28 2008 +0000
@@ -70,7 +70,7 @@
 /* Define PURE_P.  */
 
 #if defined(VIRT_ADDR_VARIES) || defined(CYGWIN)
-/* For machines like APOLLO where text and data can go anywhere
+/* For machines where text and data can go anywhere
    in virtual memory.  */
 
 extern EMACS_INT pure[];
--- a/src/s/386-ix.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Interactive 386/ix.  */
-
-#include "usg5-3.h"
-
-#define BROKEN_TIOCGETC
-
-/* There are some reports that the following is needed
-   with some version of this system.
-#undef LIBX11_SYSTEM
-#define LIBX11_SYSTEM -linet
-*/
-
-/* This is said to be needed as a result of having _insque rather
-   than insque in -loldX.  This may not always be the right thing.  */
-#define WRONG_NAME_INSQUE
-
-/* arch-tag: c2fc2d64-46fd-4a87-933b-85eff622829c
-   (do not change this comment) */
--- a/src/s/domain.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#include "bsd4-3.h"
-
-/* Inhibit using -X, which is the default.  */
-#define LD_SWITCH_SYSTEM
-
-/* arch-tag: 08941c4f-d0b6-4ad6-b7e3-7e7fe76c0e94
-   (do not change this comment) */
--- a/src/s/hpux9-x11r4.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/* System description file for hpux version 9 using X11R4.  */
-
-#include "hpux9.h"
-
-#undef  C_SWITCH_X_SYSTEM
-#define C_SWITCH_X_SYSTEM -I/usr/include/Motif1.1
-
-#undef  LD_SWITCH_X_DEFAULT
-#define LD_SWITCH_X_DEFAULT -L/usr/lib/Motif1.1
-
-/* arch-tag: 47664d7b-23ce-43e6-acdd-044a4be08da3
-   (do not change this comment) */
--- a/src/s/hpux9shxr4.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#include "hpux9shr.h"
-
-#undef  C_SWITCH_X_SYSTEM
-#define C_SWITCH_X_SYSTEM -I/usr/include/Motif1.1
-
-#undef  LD_SWITCH_X_DEFAULT
-#define LD_SWITCH_X_DEFAULT -L/usr/lib/Motif1.1
-
-/* arch-tag: 7f68b8b6-c733-4e6c-81df-39d8d13fb656
-   (do not change this comment) */
--- a/src/s/irix3-3.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/* Definitions file for GNU Emacs running on Silicon Graphics Irix system 3.3.
-   Copyright (C) 1987, 1990, 1999, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-
-/*
- *	Define symbols to identify the version of Unix this is.
- *	Define all the symbols that apply correctly.
- */
-
-#define USG
-#define USG5
-#define IRIS
-#ifndef IRIX
-#define IRIX
-#endif
-
-/* SYSTEM_TYPE should indicate the kind of system you are using.
- It sets the Lisp variable system-type.  */
-
-#define SYSTEM_TYPE "irix"
-
-/* nomultiplejobs should be defined if your system's shell
- does not have "job control" (the ability to stop a program,
- run some other program, then continue the first one).  */
-
-/* #define NOMULTIPLEJOBS */
-
-/* Default is to set interrupt_input to 0: don't do input buffering within Emacs */
-
-/* #define INTERRUPT_INPUT */
-
-/* Letter to use in finding device name of first pty,
-  if system supports pty's.  'a' means it is /dev/ptya0  */
-
-#define FIRST_PTY_LETTER 'a'
-
-/*
- *	Define HAVE_TERMIO if the system provides sysV-style ioctls
- *	for terminal control.
- */
-
-#define HAVE_TERMIO
-
-/*
- *	Define HAVE_PTYS if the system supports pty devices.
- */
-
-#define HAVE_PTYS
-
-/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets.  */
-
-#define HAVE_SOCKETS
-
-/*
- *	Define NONSYSTEM_DIR_LIBRARY to make Emacs emulate
- *      The 4.2 opendir, etc., library functions.
- */
-
-/* #define NONSYSTEM_DIR_LIBRARY */
-
-/* Define this symbol if your system has the functions bcopy, etc. */
-
-#define BSTRING
-
-/* subprocesses should be defined if you want to
-   have code for asynchronous subprocesses
-   (as used in M-x compile and M-x shell).
-   This is generally OS dependent, and not supported
-   under most USG systems. */
-
-#define subprocesses
-
-/* If your system uses COFF (Common Object File Format) then define the
-   preprocessor symbol "COFF". */
-
-/* #define COFF */
-
-/* define MAIL_USE_FLOCK if the mailer uses flock
-   to interlock access to /usr/spool/mail/$USER.
-   The alternative is that a lock file named
-   /usr/spool/mail/$USER.lock.  */
-
-#define MAIL_USE_FLOCK
-
-/* Define CLASH_DETECTION if you want lock files to be written
-   so that Emacs can tell instantly when you try to modify
-   a file that someone else has modified in his Emacs.  */
-
-/* #define CLASH_DETECTION */
-
-/* The file containing the kernel's symbol table is called /unix.  */
-
-#define KERNEL_FILE "/unix"
-
-/* The symbol in the kernel where the load average is found
-   is named _avenrun.  */
-
-#define LDAV_SYMBOL "avenrun"
-
-
-/* setjmp and longjmp can safely replace _setjmp and _longjmp,
-   but they will run slower.  */
-
-#define _setjmp setjmp
-#define _longjmp longjmp
-
-/* On USG systems these have different names */
-
-#define index strchr
-#define rindex strrchr
-
-/* USG systems tend to put everything declared static
-   into the initialized data area, which becomes pure after dumping Emacs.
-   Foil this.  Emacs carefully avoids static vars inside functions.  */
-
-/* #define static */
-
-/* This is how to get the device name of the tty end of a pty.  */
-#define PTY_TTY_NAME_SPRINTF \
- 	    sprintf (ptyname, "/dev/ttyq%d", minor (stb.st_rdev));
-
-
-#define HAVE_SYSVIPC
-
-/* sioctl.h should be included where appropriate.  */
-
-#define NEED_SIOCTL
-
-/* This affects child_setup.  */
-
-#define SETPGRP_RELEASES_CTTY
-
-/* This was formerly in LIBS_MACHINE in iris4d.h,
-   but it is not needed for newer system versions.  */
-#define LIBS_SYSTEM -lsun
-
-/* arch-tag: cccdd761-2ae9-4e71-a33e-749681c01889
-   (do not change this comment) */
--- a/src/s/irix4-0.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* Definitions file for GNU Emacs running on Silicon Graphics Irix system 4.0
-
-   Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006,
-                 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-
-#include "irix3-3.h"
-
-#define USG5_3
-#define IRIX4
-/* XPointer is not defined in the older X headers  -- JPff@maths.bath.ac.uk */
-#define XPointer caddr_t
-
-#undef NEED_SIOCTL
-
-/* Include unistd.h, even though we don't define POSIX.  */
-#define NEED_UNISTD_H
-
-/* Make process_send_signal work by "typing" a signal character on the pty.  */
-#define SIGNALS_VIA_CHARACTERS
-
-#ifndef __GNUC__
-/* use K&R C */
-/* We need to increase the expression tree space with -Wf,-XNh
-   (ghazi@caip.rutgers.edu 7/8/97.)
-*/
-#define C_SWITCH_SYSTEM -cckr -Wf,-XNh4000
-#endif
-
-/* SGI has all the fancy wait stuff, but we can't include sys/wait.h
-   because it defines BIG_ENDIAN and LITTLE_ENDIAN (ugh!.)  Instead
-   we'll just define WNOHANG right here.
-   (An implicit decl is good enough for wait3.)  */
-
-#define WNOHANG		0x1
-
-/* No need to use sprintf to get the tty name--we get that from _getpty.  */
-#undef PTY_TTY_NAME_SPRINTF
-#define PTY_TTY_NAME_SPRINTF
-/* No need to get the pty name at all.  */
-#define PTY_NAME_SPRINTF
-/* We need only try once to open a pty.  */
-#define PTY_ITERATION
-/* Here is how to do it.  */
-/* It is necessary to prevent SIGCHLD signals within _getpty.
-   So we block them. */
-#define PTY_OPEN						\
-{								\
-  int mask = sigblock (sigmask (SIGCHLD));			\
-  char *name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0);	\
-  sigsetmask(mask);						\
-  if (name == 0)						\
-    return -1;							\
-  if (fd < 0)							\
-    return -1;							\
-  if (fstat (fd, &stb) < 0)					\
-    return -1;							\
-  strcpy (pty_name, name);					\
-}
-
-/* arch-tag: cfd7e200-a4dc-4f67-9a32-4184c10b0c57
-   (do not change this comment) */
--- a/src/s/ptx.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/* Definitions file for GNU Emacs running on Sequent DYNIX/ptx 1.x/2.x
-   Copyright (C) 1987, 1990, 1999, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-/* This file was written by Bill Burton <billb@progress.com>.  Parts were
-   adapted from m-ptx1-2.h and process.c as distributed with the Emacs 18.57
-   on the Sequent Public software tape. Other parts were adapted from
-   usg5-4.h. */
-
-/* Use the SysVr3 file for base configuration even though much is changed.  */
-#include "usg5-3.h"
-
-/* Undo these defines because they are incorrect or need to be changed.  */
-#undef LIB_X11_LIB
-#undef LIBX11_SYSTEM
-#undef USG_SHARED_LIBRARIES
-
-/* <sys/stat.h> *defines* stat as a static function.  If "static"
-   is blank, then many files will have a public definition for stat.  */
-#undef static
-
-/* PTX supports job control.  */
-#undef NOMULTIPLEJOBS
-
-/* PTX has System V streams.  */
-#define SYSV_STREAMS
-
-/* Leave out -lPW since it conflicts with term.o and because we're not sure
-   if the alloca found there by autoconf should be trusted on PTX.  */
-#define LIB_STANDARD -lc
-
-/* Local define.  If TCP/IP is not installed, comment this out.  */
-#define TCPIP_INSTALLED
-
-#ifdef TCPIP_INSTALLED
-#define HAVE_SOCKETS
-#else
-#undef subprocesses
-#endif
-
-#ifdef HAVE_X_WINDOWS
-
-#define LIBX11_SYSTEM -lsocket -linet -lnsl
-/* This is also defined so that lib-src/profile can link.  */
-#define LIBS_SYSTEM -lseq
-
-#else /* ! HAVE_X_WINDOWS */
-
-#ifdef HAVE_SOCKETS
-#define LIBS_SYSTEM -lsocket -linet -lnsl -lseq
-#else
-#define LIBS_SYSTEM -lseq
-#endif
-
-#endif /* ! HAVE_X_WINDOWS */
-
-/* No <sioctl.h> */
-#define NO_SIOCTL_H
-
-/* If we have X windows, configure should find gettimeofday in -lX11.
-   Since we emulate gettimeofday below, we really have it anyway.  */
-#ifndef HAVE_GETTIMEOFDAY
-#define HAVE_GETTIMEOFDAY
-#endif
-
-#ifdef emacs
-#include <sys/stropts.h>	/* Support for pty's */
-#include <sys/conf.h>
-
-/*#define BROKEN_SIGIO*/	/* BROKEN_SIGIO is already defined. PTX
-                                   has SIGIO, but it's just an alias for
-                                   SIGPOLL.  */
-
-/* Emulate gettimeofday() except for the time zone information which Emacs
-   doesn't use anyway.  Get_process_stats() is in -lseq.  */
-#include <sys/procstats.h>
-#define gettimeofday(tp, tzp) get_process_stats (tp, PS_SELF, 0, 0)
-
-/* Define timezone since it's not in sys/time.h.  Unfortunately, this causes
-   trouble when building with X since this struct is defined in
-   <X11/Xos.h>.  */
-struct timezone
-{
-  int tz_minuteswest;
-  int tz_dsttime;
-};
-
-/* Unfortunately, this define is not checked in all files including
-   <X11/Xos.h> so we can't use it.  */
-/* #define XOS_NEEDS_TIME_H */
-
-/* In ptx/WINDOWS, this prevents problems with the timezone struct being
-   redefined in <X11/Xos.h>.  It seems the necessary include files are
-   included via systime.h so leaving them out here is not a problem.  This
-   may not work in X11R5 or X11R6.  */
-#define __TIMEVAL__
-
-#endif  /* emacs */
-
-/* PTX doesn't have FIONREAD at all. */
-#undef INTERRUPT_INPUT
-#define BROKEN_FIONREAD
-
-/* We can support this */
-#define CLASH_DETECTION
-
-/* PTX has termios */
-#define HAVE_TERMIOS
-#undef HAVE_TERMIO
-#undef BROKEN_TIOCGWINSZ
-#undef BROKEN_TIOCGETC
-
-/* It is possible to receive SIGCHLD when there are no children
-   waiting, because a previous waitsys cleaned up the carcass of child
-   without clearing the SIGCHLD pending info.  So, use a non-blocking
-   wait3 instead, which maps to waitpid in SysVr4.  */
-/* Not sure if this is used but PTX does support waitpid.  */
-/*#define HAVE_WAIT_HEADER*/
-/*#define WAITTYPE int*/
-#define wait3(status, options, rusage) \
-  waitpid ((pid_t) -1, (status), (options))
-/*#define WRETCODE(w) (w >> 8)*/
-
-/* PTX has pty's but not like System V */
-#define HAVE_PTYS
-#undef SYSV_PTYS
-
-/* Provide pty support which is defined into process.c:allocate_pty.
-   Basic ideas for handling getpseudotty were lifted from process.c in
-   Emacs 18.57 included on the Sequent Public Software tape.  However, this
-   implementation bears almost no resemblance to the original and does not
-   require that process.c be patched.  */
-#define PTY_ITERATION						\
-  char *mastername, *slavename;					\
-  while (1)
-
-#define PTY_OPEN						\
-  if (failed_count++ >= 5) break;				\
-  if ((fd = getpseudotty (&slavename, &mastername)) < 0) {	\
-    error("Out of ptys.");					\
-    continue;							\
-  }								\
-  strcpy (pty_name, slavename);
-
-/* Define these to prevent the default logic in process.c:allocate_pty
-   from being used.  */
-#define PTY_NAME_SPRINTF
-#define PTY_TTY_NAME_SPRINTF
-
-/* PTX doesn't seem to have memmove.  */
-#define MEMMOVE_MISSING
-
-/* Kenneth Stailey <kstailey@eagle.dol-esa.gov> says this is needed.  */
-#define POSIX_SIGNALS
-
-/* arch-tag: 4f5e3abc-643b-413a-bae6-ed212d3af997
-   (do not change this comment) */
--- a/src/s/ptx4-2.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-#include "ptx4.h"
-
-/* Gelling Kevan (gellingk.eurostar@ems.rail.co.uk)
-   says that PTX 4.2.3 needs this version.  */
-#undef SETUP_SLAVE_PTY
-#define SETUP_SLAVE_PTY \
-    if (ioctl (xforkin, I_PUSH, "ptem") == -1)    \
-      fatal ("ioctl I_PUSH ptem", errno);        \
-    if (ioctl (xforkin, I_PUSH, "ldterm") == -1)  \
-      fatal ("ioctl I_PUSH ldterm", errno);
-
-/* Gelling Kevan (gellingk.eurostar@ems.rail.co.uk)
-   says that gmalloc.c needs _POSIX_SOURCE.
-   This defines _POSIX_SOURCE only for gmalloc.c.  */
-#ifdef _MALLOC_INTERNAL
-#define _POSIX_SOURCE
-#endif
-
-/* arch-tag: 10a9fab3-9e84-4e9e-9535-6ff42baf9e77
-   (do not change this comment) */
--- a/src/s/ptx4.h	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/* s/ file for Sequent "ptx 4", which is a modified SVR5.4.
-
-Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-  2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-
-/* Tell usg5-4.h not to include filio.h.  */
-#define NO_FILIO_H
-
-#include "usg5-4.h"
-
-/* Marcus Daniels <marcus@sysc.pdx.edu> says that SIGINFO is defined
-   on ptx4 but it is not a signal.  Prevent process.c from doing the
-   wrong thing.  */
-#define BROKEN_SIGINFO
-
-/* pae@dim.com (Phil Ernhardt) says this correction to
-   the definition in usg5-4.h is needed to prevent
-   all asynchronous subprocesses from exiting right away.  */
-
-/* James Youngman <jay@gnu.org> found that on "DYNIX/ptx ARNIE 4.0
- * V4.4.2 i386", the push of the ttcompat module would fail.  It seems
- * that PTX 4.4.2 doesn't have that module, so if the push fails we
- * don't kill ourselves.  While this version lacks ttcompat, it also
- * has ptem, but the manual page for ptem indicates that it should
- * be pushed onto the slave side before the line discipline module.
- * See also the streampty manual page, if you're curious (and have
- * a ptx system).
- */
-
-/* rms: I hope that older versions which do have ttcompat
-   will not get confused by the code to use ptem.  */
-
-#undef SETUP_SLAVE_PTY
-#define SETUP_SLAVE_PTY \
-  if (ioctl (xforkin, I_PUSH, "ptem") == -1 && errno != EINVAL) \
-    fatal ("ioctl I_PUSH ptem", errno);     \
-  if (ioctl (xforkin, I_PUSH, "ldterm") == -1)	\
-    fatal ("ioctl I_PUSH ldterm", errno);	\
-  if (ioctl (xforkin, I_PUSH, "ttcompat") == -1 && errno != EINVAL) \
-    fatal ("ioctl I_PUSH ttcompat", errno);
-
-/* arch-tag: 14621824-8dca-432b-a97a-049fc4ce0e9f
-   (do not change this comment) */
--- a/src/sysdep.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/sysdep.c	Wed Jan 30 07:57:28 2008 +0000
@@ -49,15 +49,6 @@
 
 #include "blockinput.h"
 
-#ifdef MAC_OS8
-#include <sys/param.h>
-
-#ifndef subprocesses
-/* Nonzero means delete a process right away if it exits (process.c).  */
-static int delete_exited_processes;
-#endif
-#endif  /* MAC_OS8 */
-
 #ifdef WINDOWSNT
 #define read sys_read
 #define write sys_write
@@ -151,12 +142,12 @@
 #undef TIOCSWINSZ
 #endif
 
-#if defined (USG) || defined (DGUX)
+#if defined (USG)
 #include <sys/utsname.h>
 #ifndef MEMORY_IN_STRING_H
 #include <memory.h>
 #endif
-#if defined (TIOCGWINSZ) || defined (ISC4_0)
+#if defined (TIOCGWINSZ)
 #ifdef NEED_SIOCTL
 #include <sys/sioctl.h>
 #endif
@@ -164,8 +155,8 @@
 #include <sys/stream.h>
 #include <sys/ptem.h>
 #endif
-#endif /* TIOCGWINSZ or ISC4_0 */
-#endif /* USG or DGUX */
+#endif /* TIOCGWINSZ */
+#endif /* USG */
 
 extern int quit_char;
 
@@ -345,17 +336,6 @@
 	    &buf.main, 0, 0, terminator_mask, 0, 0);
   queue_kbd_input ();
 #else /* not VMS */
-#ifdef APOLLO
-  {
-    struct tty_display_info *tty;
-    for (tty = tty_list; tty; tty = tty->next)
-      {
-        int zero = 0;
-        if (tty->input)
-          ioctl (fileno (tty->input), TIOCFLUSH, &zero);
-      }
-  }
-#else /* not Apollo */
 #ifdef MSDOS    /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
   while (dos_keyread () != -1)
     ;
@@ -372,7 +352,6 @@
       }
   }
 #endif /* not MSDOS */
-#endif /* not Apollo */
 #endif /* not VMS */
 #endif /* not WINDOWSNT */
 }
@@ -532,11 +511,6 @@
       else
 	sigpause (SIGEMPTYMASK);
 #else /* not BSD_SYSTEM, and not HPUX version >= 6 */
-#if defined (UNIPLUS)
-      if (0 > kill (pid, 0))
-	break;
-      wait (0);
-#else /* neither BSD_SYSTEM nor UNIPLUS: random sysV */
 #ifdef POSIX_SIGNALS    /* would this work for GNU/Linux as well? */
       sigblock (sigmask (SIGCHLD));
       errno = 0;
@@ -570,7 +544,6 @@
 #endif /* not WINDOWSNT */
 #endif /* not HAVE_SYSV_SIGPAUSE */
 #endif /* not POSIX_SIGNALS */
-#endif /* not UNIPLUS */
 #endif /* not BSD_SYSTEM, and not HPUX version >= 6 */
 #endif /* not VMS */
 #else /* not subprocesses */
@@ -727,12 +700,6 @@
   if (interrupt_input)
     reset_sigio (0);
 #endif /* BSD4_1 */
-#ifdef RTU
-  {
-    int zero = 0;
-    ioctl (out, FIOASYNC, &zero);
-  }
-#endif /* RTU */
 #endif /* not DOS_NT */
 }
 #endif /* not VMS */
@@ -821,7 +788,6 @@
 
 /* Fork a subshell.  */
 
-#ifndef MAC_OS8
 void
 sys_subshell ()
 {
@@ -957,7 +923,6 @@
   synch_process_alive = 0;
 #endif /* !VMS */
 }
-#endif /* !MAC_OS8 */
 
 static void
 save_signal_handlers (saved_handlers)
@@ -1066,69 +1031,6 @@
 }
 
 #else /* no FASYNC */
-#ifdef STRIDE		/* Stride doesn't have FASYNC - use FIOASYNC */
-
-void
-request_sigio ()
-{
-  int on = 1;
-
-  if (noninteractive || read_socket_hook)
-    return;
-
-  /* XXX CURTTY() is bogus here. */
-  ioctl (fileno (CURTTY ()->input), FIOASYNC, &on);
-  interrupts_deferred = 0;
-}
-
-void
-unrequest_sigio ()
-{
-  int off = 0;
-
-  if (noninteractive || read_socket_hook)
-    return;
-
-  /* XXX CURTTY() is bogus here. */
-  ioctl (fileno (CURTTY ()->input), FIOASYNC, &off);
-  interrupts_deferred = 1;
-}
-
-#else /* not FASYNC, not STRIDE */
-
-#ifdef _CX_UX
-
-#include <termios.h>
-
-void
-request_sigio ()
-{
-  int on = 1;
-  sigset_t st;
-
-  if (noninteractive || read_socket_hook)
-    return;
-
-  sigemptyset (&st);
-  sigaddset (&st, SIGIO);
-  ioctl (0, FIOASYNC, &on);     /* XXX This fails for multiple ttys. */
-  interrupts_deferred = 0;
-  sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0);
-}
-
-void
-unrequest_sigio ()
-{
-  int off = 0;
-
-  if (noninteractive || read_socket_hook)
-    return;
-
-  ioctl (0, FIOASYNC, &off);  /* XXX This fails for multiple ttys. */
-  interrupts_deferred = 1;
-}
-
-#else /* ! _CX_UX */
 #ifndef MSDOS
 
 void
@@ -1150,8 +1052,6 @@
 }
 
 #endif /* MSDOS */
-#endif /* _CX_UX */
-#endif /* STRIDE */
 #endif /* FASYNC */
 #endif /* F_SETFL */
 #endif /* SIGIO */
@@ -1486,10 +1386,6 @@
 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
   XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
 
-#ifdef DGUX
-  /* This allows meta to be sent on 8th bit.  */
-  tty.main.c_iflag &= ~INPCK;	/* don't check input for parity */
-#endif
   tty.main.c_iflag |= (IGNBRK);	/* Ignore break condition */
   tty.main.c_iflag &= ~ICRNL;	/* Disable map of CR to NL on input */
 #ifdef INLCR  /* I'm just being cautious,
@@ -1703,11 +1599,9 @@
 #ifdef TCXONC
   if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TCXONC, 1);
 #endif
-#ifndef APOLLO
 #ifdef TIOCSTART
   if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
 #endif
-#endif
 
 #if defined (HAVE_TERMIOS) || defined (HPUX9)
 #ifdef TCOON
@@ -2085,14 +1979,6 @@
   }
 #endif
 #endif
-#ifdef IBMRTAIX
-  /* On AIX, the parent gets SIGHUP when a pty attached child dies.  So, we */
-  /* ignore SIGHUP once we've started a child on a pty.  Note that this may */
-  /* cause EMACS not to die when it should, i.e., when its own controlling  */
-  /* tty goes away.  I've complained to the AIX developers, and they may    */
-  /* change this behavior, but I'm not going to hold my breath.             */
-  signal (SIGHUP, SIG_IGN);
-#endif
 }
 #endif /* HAVE_PTYS */
 
@@ -2377,13 +2263,8 @@
 #ifdef TEXT_START
   return ((char *) TEXT_START);
 #else
-#ifdef GOULD
-  extern csrt ();
-  return ((char *) csrt);
-#else /* not GOULD */
   extern int _start ();
   return ((char *) _start);
-#endif /* GOULD */
 #endif /* TEXT_START */
 }
 #endif /* not HAVE_TEXT_START */
@@ -3324,16 +3205,6 @@
   return val & ((1L << VALBITS) - 1);
 }
 
-#ifdef WRONG_NAME_INSQUE
-
-insque (q,p)
-     caddr_t q,p;
-{
-  _insque (q,p);
-}
-
-#endif
-
 #ifdef VMS
 
 #ifdef getenv
--- a/src/systty.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/systty.h	Wed Jan 30 07:57:28 2008 +0000
@@ -26,9 +26,6 @@
 
 /* Include the proper files.  */
 #ifdef HAVE_TERMIO
-#ifdef __DGUX
-#include <sys/ioctl.h>
-#endif
 #ifndef NO_TERMIO
 #include <termio.h>
 #endif /* not NO_TERMIO */
@@ -130,42 +127,18 @@
 #ifdef SYSV_PTYS
 #include <sys/types.h>
 #include <sys/tty.h>
-#ifdef titan
-#include <sys/ttyhw.h>
-#include <sys/stream.h>
-#endif
 #ifndef NO_PTY_H
 #include <sys/pty.h>
 #endif
 #endif
 
-/* saka@pfu.fujitsu.co.JP writes:
-   FASYNC defined in this file. But, FASYNC don't working.
-   so no problem, because unrequest_sigio only need. */
-#if defined (pfa)
-#include <sys/file.h>
-#endif
-
 
 /* Special cases - inhibiting the use of certain features.  */
 
-#ifdef APOLLO
-#undef TIOCSTART
-#endif
-
-#ifdef XENIX
-#undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
-#endif
-
 #ifdef BROKEN_TIOCGETC
 #undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
 #endif
 
-/* UNIPLUS systems may have FIONREAD.  */
-#ifdef UNIPLUS
-#include <sys.ioctl.h>
-#endif
-
 /* Allow m- file to inhibit use of FIONREAD.  */
 #ifdef BROKEN_FIONREAD
 #undef FIONREAD
--- a/src/syswait.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/syswait.h	Wed Jan 30 07:57:28 2008 +0000
@@ -79,7 +79,7 @@
 
 #else /* not WAIT_USE_INT */
 
-#if (!defined (BSD_SYSTEM) && !defined (UNIPLUS) && !defined (STRIDE) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
+#if (!defined (BSD_SYSTEM) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
 #define WAITTYPE int
 #define WIFSTOPPED(w) ((w&0377) == 0177)
 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
@@ -129,7 +129,7 @@
 #ifndef WIFEXITED
 #define WIFEXITED(w) (WTERMSIG (w) == 0)
 #endif
-#endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */
+#endif /* BSD_SYSTEM || HPUX */
 #endif /* not WAIT_USE_INT */
 #endif /* no WAITTYPE */
 
--- a/src/terminal.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/terminal.c	Wed Jan 30 07:57:28 2008 +0000
@@ -1,5 +1,5 @@
 /* Functions related to terminal devices.
-   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
--- a/src/undo.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/undo.c	Wed Jan 30 07:57:28 2008 +0000
@@ -53,8 +53,12 @@
    an undo-boundary.  */
 Lisp_Object pending_boundary;
 
+/* Nonzero means do not record point in record_point.  */
+
+int undo_inhibit_record_point;
+
 /* Record point as it was at beginning of this command (if necessary)
-   And prepare the undo info for recording a change.
+   and prepare the undo info for recording a change.
    PT is the position of point that will naturally occur as a result of the
    undo record that will be added just after this command terminates.  */
 
@@ -64,6 +68,14 @@
 {
   int at_boundary;
 
+  /* Don't record position of pt when undo_inhibit_record_point holds.
+     Needed to avoid inserting a position record in buffer-undo-list
+     when last_point_position has not been set up correctly by
+     command_loop_1, for example, when running a repeat-repeat-char
+     event.  */
+  if (undo_inhibit_record_point)
+    return;
+
   /* Allocate a cons cell to be the undo boundary after this command.  */
   if (NILP (pending_boundary))
     pending_boundary = Fcons (Qnil, Qnil);
@@ -719,6 +731,10 @@
 Garbage collection is inhibited around the call to this function,
 so it must make sure not to do a lot of consing.  */);
   Vundo_outer_limit_function = Qnil;
+
+  DEFVAR_BOOL ("undo-inhibit-record-point", &undo_inhibit_record_point,
+	       doc: /* Non-nil means do not record `point' in `buffer-undo-list'.  */);
+  undo_inhibit_record_point = 0;
 }
 
 /* arch-tag: d546ee01-4aed-4ffb-bb8b-eefaae50d38a
--- a/src/unexec.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/unexec.c	Wed Jan 30 07:57:28 2008 +0000
@@ -975,92 +975,9 @@
   lseek (new, (long) N_TXTOFF (hdr), 0);
 #endif /* no A_TEXT_SEEK */
 
-#ifdef RISCiX
-
-  /* Acorn's RISC-iX has a wacky way of initialising the position of the heap.
-   * There is a little table in crt0.o that is filled at link time with
-   * the min and current brk positions, among other things.  When start
-   * runs, it copies the table to where these parameters live during
-   * execution.  This data is in text space, so it cannot be modified here
-   * before saving the executable, so the data is written manually.  In
-   * addition, the table does not have a label, and the nearest accessible
-   * label (mcount) is not prefixed with a '_', thus making it inaccessible
-   * from within C programs.  To overcome this, emacs's executable is passed
-   * through the command 'nm %s | fgrep mcount' into a pipe, and the
-   * resultant output is then used to find the address of 'mcount'.  As far as
-   * is possible to determine, in RISC-iX releases prior to 1.2, the negative
-   * offset of the table from mcount is 0x2c, whereas from 1.2 onwards it is
-   * 0x30.  bss_end has been rounded up to page boundary.  This solution is
-   * based on suggestions made by Kevin Welton and Steve Hunt of Acorn, and
-   * avoids the need for a custom version of crt0.o for emacs which has its
-   * table in data space.
-   */
-
-  {
-    char command[1024];
-    char errbuf[1024];
-    char address_text[32];
-    int  proforma[4];
-    FILE *pfile;
-    char *temp_ptr;
-    char c;
-    int mcount_address, mcount_offset, count;
-    extern char *_execname;
-
-
-    /* The use of _execname is incompatible with RISCiX 1.1 */
-    sprintf (command, "nm %s | fgrep mcount", _execname);
-
-    if ( (pfile = popen(command, "r")) == NULL)
-    {
-      sprintf (errbuf, "Could not open pipe");
-      PERROR (errbuf);
-    }
-
-    count=0;
-    while ( ((c=getc(pfile)) != EOF) && (c != ' ') && (count < 31))
-      address_text[count++]=c;
-    address_text[count]=0;
-
-    if ((count == 0) || pclose(pfile) != NULL)
-    {
-      sprintf (errbuf, "Failed to execute the command '%s'\n", command);
-      PERROR (errbuf);
-    }
-
-    sscanf(address_text, "%x", &mcount_address);
-    ptr = (char *) unexec_text_start;
-    mcount_offset = (char *)mcount_address - ptr;
-
-#ifdef RISCiX_1_1
-#define EDATA_OFFSET 0x2c
-#else
-#define EDATA_OFFSET 0x30
-#endif
-
-    end = ptr + mcount_offset - EDATA_OFFSET;
-
-    write_segment (new, ptr, end);
-
-    proforma[0] = bss_end;	/* becomes _edata */
-    proforma[1] = bss_end;	/* becomes _end */
-    proforma[2] = bss_end;	/* becomes _minbrk */
-    proforma[3] = bss_end;	/* becomes _curbrk */
-
-    write (new, proforma, 16);
-
-    temp_ptr = ptr;
-    ptr = end + 16;
-    end = temp_ptr + hdr.a_text;
-
-    write_segment (new, ptr, end);
-  }
-
-#else /* !RISCiX */
   ptr = (char *) unexec_text_start;
   end = ptr + hdr.a_text;
   write_segment (new, ptr, end);
-#endif /* RISCiX */
 
   ptr = (char *) unexec_data_start;
   end = ptr + hdr.a_data;
@@ -1175,13 +1092,8 @@
 {
   register int nsyms;
   register int new;
-#if defined (amdahl_uts) || defined (pfa)
-  SYMENT symentry;
-  AUXENT auxentry;
-#else
   struct syment symentry;
   union auxent auxentry;
-#endif
 
   if (!lnnoptr || !f_hdr.f_symptr)
     return 0;
--- a/src/unexsunos4.c	Wed Jan 30 06:40:42 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-/* Unexec for Sunos 4 using shared libraries.
-   Copyright (C) 1990, 1994, 1999, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-/* Contributed by Viktor Dukhovni.  */
-/*
- * Unexec for Berkeley a.out format + SUNOS shared libraries
- * The unexeced executable contains the __DYNAMIC area from the
- * original text file,  and then the rest of data + bss + malloced area of
- * the current process.  (The __DYNAMIC area is at the top of the process
- * data segment,  we use "data_start" defined externally to mark the start
- * of the "real" data segment.)
- *
- * For programs that want to remap some of the data segment read only
- * a run_time_remap is provided.  This attempts to remap largest area starting
- * and ending on page boundaries between "data_start" and "bndry"
- * For this it to figure out where the text file is located.  A path search
- * is attempted after trying argv[0] and if all fails we simply do not remap
- *
- * One feature of run_time_remap () is mandatory:  reseting the break.
- *
- *  Note that we can no longer map data into the text segment,  as this causes
- *  the __DYNAMIC struct to become read only,  breaking the runtime loader.
- *  Thus we no longer need to mess with a private crt0.c,  the standard one
- *  will do just fine,  since environ can live in the writable area between
- *  __DYNAMIC and data_start,  just make sure that pre-crt0.o (the name
- *  is somewhat abused here) is loaded first!
- *
- */
-
-#ifdef emacs
-#include <config.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdio.h>
-#include <a.out.h>
-
-#if defined (SUNOS4) || defined (__FreeBSD__) || defined (__NetBSD__)
-#define UNDO_RELOCATION
-#endif
-
-#ifdef UNDO_RELOCATION
-#include <link.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-/* NetBSD needs this bit, but SunOS does not have it.  */
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
-
-/*
- * for programs other than emacs
- * define data_start + initialized here,  and make sure
- * this object is loaded first!
- * emacs will define these elsewhere,  and load the object containing
- * data_start (pre-crt0.o or firstfile.o?) first!
- * The custom crt0.o *must not* be loaded!
- */
-#ifndef emacs
-  static int data_start = 0;
-  static int initialized = 0;
-#else
-  extern int initialized;
-  extern unsigned data_start;
-  extern int pureptr;
-#endif
-
-extern char *getenv ();
-static unsigned brk_value;
-static struct exec nhdr;
-static int rd_only_len;
-static long cookie;
-
-
-unexec (new_name, a_name, bndry, bss_start, entry)
-     char *new_name, *a_name;
-     unsigned bndry, bss_start, entry;
-{
-  int fd, new;
-  char *old;
-  struct exec ohdr;		/* Allocate on the stack,  not needed in the next life */
-  struct stat stat;
-
-  if ((fd = open (a_name, O_RDONLY)) < 0)
-    {
-      fprintf (stderr, "%s: open: ", a_name);
-      perror (a_name);
-      exit (1);
-    }
-  if ((new = open (new_name, O_WRONLY | O_CREAT, 0666)) == -1)
-    {
-      fprintf (stderr, "%s: open: ", a_name);
-      perror (new_name);
-      exit (1);
-    }
-
-  if ((fstat (fd, &stat) == -1))
-    {
-      fprintf (stderr, "%s: ", a_name);
-      perror ("fstat");
-      exit (1);
-    }
-
-  old = (char *)mmap (0, stat.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0);
-  if (old == (char *)-1)
-    {
-      fprintf (stderr, "%s: ", a_name);
-      perror ("mmap");
-      exit (1);
-    }
-  close (fd);
-
-  nhdr = ohdr = (*(struct exec *)old);
-
-
-  /*
-   * Remember a magic cookie so we know we've got the right binary
-   * when remapping.
-   */
-  cookie = time (0);
-
-  /* Save the break, it is reset to &_end (by ld.so?).  */
-  brk_value = (unsigned) sbrk (0);
-
-  /*
-   * Round up data start to a page boundary (Lose if not a 2 power!)
-   */
-  data_start = ((((int)&data_start) - 1) & ~(N_PAGSIZ (nhdr) - 1)) + N_PAGSIZ (nhdr);
-
-  /*
-   * Round down read only pages to a multiple of the page size
-   */
-  if (bndry)
-    rd_only_len = ((int)bndry & ~(N_PAGSIZ (nhdr) - 1)) - data_start;
-
-#ifndef emacs
-  /* Have to do this some time before dumping the data */
-  initialized = 1;
-#endif
-
-  /* Handle new data and bss sizes and optional new entry point.
-     No one actually uses bss_start and entry,  but tradition compels
-     one to support them.
-     Could complain if bss_start > brk_value,
-     but the caller is *supposed* to know what she is doing.  */
-  nhdr.a_data = (bss_start ? bss_start : brk_value) - N_DATADDR (nhdr);
-  nhdr.a_bss  = bss_start ? brk_value - bss_start : 0;
-  if (entry)
-    nhdr.a_entry = entry;
-
-  /*
-   * Write out the text segment with new header
-   * Dynamic executables are ZMAGIC with N_TXTOFF==0 and the header
-   * part of the text segment, but no need to rely on this.
-   * So write the TEXT first,  then go back replace the header.
-   * Doing it in the other order is less general!
-   */
-  lseek (new, N_TXTOFF (nhdr), L_SET);
-  write (new, old + N_TXTOFF (ohdr), N_TXTOFF (ohdr) + ohdr.a_text);
-  lseek (new, 0L, L_SET);
-  write (new, &nhdr, sizeof (nhdr));
-
-  /*
-   * Write out the head of the old data segment from the file not
-   * from core, this has the unresolved __DYNAMIC relocation data
-   * we need to reload
-   */
-  lseek (new, N_DATOFF (nhdr), L_SET);
-  write (new, old + N_DATOFF (ohdr), (int)&data_start - N_DATADDR (ohdr));
-
-  /*
-   * Copy the rest of the data from core
-   */
-  write (new, &data_start, N_BSSADDR (nhdr) - (int)&data_start);
-
-  /*
-   * Copy the symbol table and line numbers
-   */
-  lseek (new, N_TRELOFF (nhdr), L_SET);
-  write (new, old + N_TRELOFF (ohdr), stat.st_size - N_TRELOFF (ohdr));
-
-  /* Some other BSD systems use this file.
-     We don't know whether this change is right for them.  */
-#ifdef UNDO_RELOCATION
-  /* Undo the relocations done at startup by ld.so.
-     It will do these relocations again when we start the dumped Emacs.
-     Doing them twice gives incorrect results.  */
-  {
-    unsigned long daddr = N_DATADDR (ohdr);
-    unsigned long rel, erel;
-#ifdef SUNOS4
-#ifdef SUNOS4_SHARED_LIBRARIES
-    extern struct link_dynamic _DYNAMIC;
-
-    /*  SunOS4.x's ld_rel is relative to N_TXTADDR. */
-    if (!ohdr.a_dynamic)
-      /* This was statically linked.  */
-      rel = erel = 0;
-    else if (_DYNAMIC.ld_version < 2)
-      {
-	rel = _DYNAMIC.ld_un.ld_1->ld_rel + N_TXTADDR (ohdr);
-	erel = _DYNAMIC.ld_un.ld_1->ld_hash + N_TXTADDR (ohdr);
-      }
-    else
-      {
-	rel = _DYNAMIC.ld_un.ld_2->ld_rel + N_TXTADDR (ohdr);
-	erel = _DYNAMIC.ld_un.ld_2->ld_hash + N_TXTADDR (ohdr);
-      }
-#else /* not SUNOS4_SHARED_LIBRARIES */
-    rel = erel = 0;
-#endif /* not SUNOS4_SHARED_LIBRARIES */
-#ifdef sparc
-#define REL_INFO_TYPE		struct reloc_info_sparc
-#else
-#define REL_INFO_TYPE		struct relocation_info
-#endif /* sparc */
-#define REL_TARGET_ADDRESS(r)	(((REL_INFO_TYPE *)(r))->r_address)
-#endif /* SUNOS4 */
-#if defined (__FreeBSD__) || defined (__NetBSD__)
-    extern struct _dynamic _DYNAMIC;
-
-    /*  FreeBSD's LD_REL is a virtual address itself. */
-    rel = LD_REL (&_DYNAMIC);
-    erel = rel + LD_RELSZ (&_DYNAMIC);
-#define REL_INFO_TYPE		struct relocation_info
-#define REL_TARGET_ADDRESS(r)	(((REL_INFO_TYPE *)(r))->r_address)
-#endif
-
-    for (; rel < erel; rel += sizeof (REL_INFO_TYPE))
-      {
-	/*  This is the virtual address where ld.so will do relocation.  */
-	unsigned long target = REL_TARGET_ADDRESS (rel);
-	/*  This is the offset in the data segment.  */
-	unsigned long segoffset = target - daddr;
-
-	/*  If it is located below data_start, we have to do nothing here,
-	    because the old data has been already written to the location. */
-	if (target < (unsigned long)&data_start)
-	    continue;
-
-	lseek (new, N_DATOFF (nhdr) + segoffset, L_SET);
-	write (new, old + N_DATOFF (ohdr) + segoffset, sizeof (unsigned long));
-      }
-  }
-#endif /* UNDO_RELOCATION */
-
-  fchmod (new, 0755);
-}
-
-void
-run_time_remap (progname)
-     char *progname;
-{
-  char aout[MAXPATHLEN];
-  register char *path, *p;
-
-  /* Just in case */
-  if (!initialized)
-    return;
-
-  /* Restore the break */
-  brk ((char *) brk_value);
-
-  /*  If nothing to remap:  we are done! */
-  if (rd_only_len == 0)
-    return;
-
-  /*
-   * Attempt to find the executable
-   * First try argv[0],  will almost always succeed as shells tend to give
-   * the full path from the hash list rather than using execvp ()
-   */
-  if (is_it (progname))
-    return;
-
-  /*
-   * If argv[0] is a full path and does not exist,  not much sense in
-   * searching further
-   */
-  if (strchr (progname, '/'))
-    return;
-
-  /*
-   * Try to search for  argv[0] on the PATH
-   */
-  path = getenv ("PATH");
-  if (path == NULL)
-    return;
-
-  while (*path)
-    {
-      /* copy through ':' or end */
-      for (p = aout; *p = *path; ++p, ++path)
-	if (*p == ':')
-	  {
-	    ++path;		/* move past ':' */
-	    break;
-	  }
-      *p++ = '/';
-      strcpy (p, progname);
-      /*
-       * aout is a candidate full path name
-       */
-      if (is_it (aout))
-	return;
-    }
-}
-
-is_it (filename)
-  char *filename;
-{
-  int fd;
-  long filenames_cookie;
-  struct exec hdr;
-
-  /*
-   * Open an executable  and check for a valid header!
-   * Can't bcmp the header with what we had,  it may have been stripped!
-   * so we may save looking at non executables with the same name, mostly
-   * directories.
-   */
-  fd = open (filename, O_RDONLY);
-  if (fd != -1)
-    {
-      if (read (fd, &hdr, sizeof (hdr)) == sizeof (hdr)
-	  && !N_BADMAG (hdr) && N_DATOFF (hdr) == N_DATOFF (nhdr)
-	  && N_TRELOFF (hdr) == N_TRELOFF (nhdr))
-	{
-	  /* compare cookies */
-	  lseek (fd, N_DATOFF (hdr) + (int)&cookie - N_DATADDR (hdr), L_SET);
-	  read (fd, &filenames_cookie, sizeof (filenames_cookie));
-	  if (filenames_cookie == cookie)
-	    {			/* Eureka */
-
-	      /*
-	       * Do the mapping
-	       * The PROT_EXEC may not be needed,  but it is safer this way.
-	       * should the shared library decide to indirect through
-	       * addresses in the data segment not part of __DYNAMIC
-	       */
-	      mmap ((char *) data_start, rd_only_len, PROT_READ | PROT_EXEC,
-		    MAP_FILE | MAP_SHARED | MAP_FIXED, fd,
-		    N_DATOFF (hdr) + data_start - N_DATADDR (hdr));
-	      close (fd);
-	      return 1;
-	    }
-	}
-      close (fd);
-    }
-  return 0;
-}
-
-/* arch-tag: 30227420-2c6f-4700-a4f8-9e45e52f53b1
-   (do not change this comment) */
--- a/src/w32.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/w32.c	Wed Jan 30 07:57:28 2008 +0000
@@ -120,6 +120,8 @@
 static BOOL g_b_init_get_token_information;
 static BOOL g_b_init_lookup_account_sid;
 static BOOL g_b_init_get_sid_identifier_authority;
+static BOOL g_b_init_get_sid_sub_authority;
+static BOOL g_b_init_get_sid_sub_authority_count;
 
 /*
   BEGIN: Wrapper functions around OpenProcessToken
@@ -161,6 +163,12 @@
     PSID_NAME_USE peUse);
 typedef PSID_IDENTIFIER_AUTHORITY (WINAPI * GetSidIdentifierAuthority_Proc) (
     PSID pSid);
+typedef PDWORD (WINAPI * GetSidSubAuthority_Proc) (
+    PSID pSid,
+    DWORD n);
+typedef PUCHAR (WINAPI * GetSidSubAuthorityCount_Proc) (
+    PSID pSid);
+
 
   /* ** A utility function ** */
 static BOOL
@@ -349,6 +357,57 @@
   return (s_pfn_Get_Sid_Identifier_Authority (pSid));
 }
 
+PDWORD WINAPI get_sid_sub_authority (
+    PSID pSid,
+    DWORD n)
+{
+  static GetSidSubAuthority_Proc s_pfn_Get_Sid_Sub_Authority = NULL;
+  static DWORD zero = 0U;
+  HMODULE hm_advapi32 = NULL;
+  if (is_windows_9x () == TRUE)
+    {
+      return &zero;
+    }
+  if (g_b_init_get_sid_sub_authority == 0)
+    {
+      g_b_init_get_sid_sub_authority = 1;
+      hm_advapi32 = LoadLibrary ("Advapi32.dll");
+      s_pfn_Get_Sid_Sub_Authority =
+        (GetSidSubAuthority_Proc) GetProcAddress (
+            hm_advapi32, "GetSidSubAuthority");
+    }
+  if (s_pfn_Get_Sid_Sub_Authority == NULL)
+    {
+      return &zero;
+    }
+  return (s_pfn_Get_Sid_Sub_Authority (pSid, n));
+}
+
+PUCHAR WINAPI get_sid_sub_authority_count (
+    PSID pSid)
+{
+  static GetSidSubAuthorityCount_Proc s_pfn_Get_Sid_Sub_Authority_Count = NULL;
+  static UCHAR zero = 0U;
+  HMODULE hm_advapi32 = NULL;
+  if (is_windows_9x () == TRUE)
+    {
+      return &zero;
+    }
+  if (g_b_init_get_sid_sub_authority_count == 0)
+    {
+      g_b_init_get_sid_sub_authority_count = 1;
+      hm_advapi32 = LoadLibrary ("Advapi32.dll");
+      s_pfn_Get_Sid_Sub_Authority_Count =
+        (GetSidSubAuthorityCount_Proc) GetProcAddress (
+            hm_advapi32, "GetSidSubAuthorityCount");
+    }
+  if (s_pfn_Get_Sid_Sub_Authority_Count == NULL)
+    {
+      return &zero;
+    }
+  return (s_pfn_Get_Sid_Sub_Authority_Count (pSid));
+}
+
 /*
   END: Wrapper functions around OpenProcessToken
   and other functions in advapi32.dll that are only
@@ -547,39 +606,47 @@
 			     domain, &dlength, &user_type))
     {
       strcpy (the_passwd.pw_name, name);
-      /* Determine a reasonable uid value. */
+      /* Determine a reasonable uid value.  */
       if (stricmp ("administrator", name) == 0)
 	{
-	  the_passwd.pw_uid = 0;
-	  the_passwd.pw_gid = 0;
+	  the_passwd.pw_uid = 500; /* well-known Administrator uid */
+	  the_passwd.pw_gid = 513; /* well-known None gid */
 	}
       else
 	{
-	  SID_IDENTIFIER_AUTHORITY * pSIA;
-
-	  pSIA = get_sid_identifier_authority (*((PSID *) user_sid));
-	  /* I believe the relative portion is the last 4 bytes (of 6)
-	     with msb first. */
-	  the_passwd.pw_uid = ((pSIA->Value[2] << 24) +
-			       (pSIA->Value[3] << 16) +
-			       (pSIA->Value[4] << 8)  +
-			       (pSIA->Value[5] << 0));
-	  /* restrict to conventional uid range for normal users */
-	  the_passwd.pw_uid = the_passwd.pw_uid % 60001;
+	  /* Use the last sub-authority value of the RID, the relative
+	     portion of the SID, as user/group ID. */
+	  DWORD n_subauthorities =
+	    *get_sid_sub_authority_count (*((PSID *) user_sid));
+
+	  if (n_subauthorities < 1)
+	    the_passwd.pw_uid = 0;	/* the "World" RID */
+	  else
+	    {
+	      the_passwd.pw_uid =
+		*get_sid_sub_authority (*((PSID *) user_sid),
+					n_subauthorities - 1);
+	      /* Restrict to conventional uid range for normal users.  */
+	      the_passwd.pw_uid %= 60001;
+	    }
 
 	  /* Get group id */
 	  if (get_token_information (token, TokenPrimaryGroup,
 				     (PVOID) user_sid, sizeof (user_sid), &trash))
 	    {
-	      SID_IDENTIFIER_AUTHORITY * pSIA;
-
-	      pSIA = get_sid_identifier_authority (*((PSID *) user_sid));
-	      the_passwd.pw_gid = ((pSIA->Value[2] << 24) +
-				   (pSIA->Value[3] << 16) +
-				   (pSIA->Value[4] << 8)  +
-				   (pSIA->Value[5] << 0));
-	      /* I don't know if this is necessary, but for safety... */
-	      the_passwd.pw_gid = the_passwd.pw_gid % 60001;
+	      n_subauthorities =
+		*get_sid_sub_authority_count (*((PSID *) user_sid));
+
+	      if (n_subauthorities < 1)
+		the_passwd.pw_gid = 0;	/* the "World" RID */
+	      else
+		{
+		  the_passwd.pw_gid =
+		    *get_sid_sub_authority (*((PSID *) user_sid),
+					    n_subauthorities - 1);
+		  /* I don't know if this is necessary, but for safety...  */
+		  the_passwd.pw_gid %= 60001;
+		}
 	    }
 	  else
 	    the_passwd.pw_gid = the_passwd.pw_uid;
@@ -1938,6 +2005,36 @@
   return attrs;
 }
 
+/* Ensure a network connection is authenticated.  */
+static void
+logon_network_drive (const char *path)
+{
+  NETRESOURCE resource;
+  char share[MAX_PATH];
+  int i, n_slashes;
+
+  /* Only logon to networked drives.  */
+  if (!IS_DIRECTORY_SEP (path[0]) || !IS_DIRECTORY_SEP (path[1]))
+    return;
+  n_slashes = 2;
+  strncpy (share, path, MAX_PATH);
+  /* Truncate to just server and share name.  */
+  for (i = 2; i < MAX_PATH; i++)
+    {
+      if (IS_DIRECTORY_SEP (share[i]) && ++n_slashes > 3)
+        {
+          share[i] = '\0';
+          break;
+        }
+    }
+
+  resource.dwType = RESOURCETYPE_DISK;
+  resource.lpLocalName = NULL;
+  resource.lpRemoteName = share;
+  resource.lpProvider = NULL;
+
+  WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE);
+}
 
 /* Shadow some MSVC runtime functions to map requests for long filenames
    to reasonable short names if necessary.  This was originally added to
@@ -2495,6 +2592,8 @@
 	}
       else
 	{
+          logon_network_drive (name);
+
 	  fh = FindFirstFile (name, &wfd);
 	  if (fh == INVALID_HANDLE_VALUE)
 	    {
@@ -2668,8 +2767,8 @@
     buf->st_ino = fake_inode;
 
   /* consider files to belong to current user */
-  buf->st_uid = 0;
-  buf->st_gid = 0;
+  buf->st_uid = the_passwd.pw_uid;
+  buf->st_gid = the_passwd.pw_gid;
 
   buf->st_dev = info.dwVolumeSerialNumber;
   buf->st_rdev = info.dwVolumeSerialNumber;
--- a/src/window.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/window.c	Wed Jan 30 07:57:28 2008 +0000
@@ -3307,6 +3307,25 @@
 EXFUN (Fset_window_fringes, 4);
 EXFUN (Fset_window_scroll_bars, 4);
 
+void
+run_window_configuration_change_hook (struct frame *f)
+{
+  if (! NILP (Vwindow_configuration_change_hook)
+      && ! NILP (Vrun_hooks))
+    {
+      int count = SPECPDL_INDEX ();
+      if (SELECTED_FRAME () != f)
+	{
+	  Lisp_Object frame;
+	  XSETFRAME (frame, f);
+	  record_unwind_protect (Fselect_frame, Fselected_frame ());
+	  Fselect_frame (frame);
+	}
+      call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+      unbind_to (count, Qnil);
+    }
+}
+
 /* Make WINDOW display BUFFER as its contents.  RUN_HOOKS_P non-zero
    means it's allowed to run hooks.  See make_frame for a case where
    it's not allowed.  KEEP_MARGINS_P non-zero means that the current
@@ -3321,6 +3340,7 @@
   struct window *w = XWINDOW (window);
   struct buffer *b = XBUFFER (buffer);
   int count = SPECPDL_INDEX ();
+  int samebuf = EQ (buffer, w->buffer);
 
   w->buffer = buffer;
 
@@ -3339,16 +3359,28 @@
   XSETFASTINT (w->window_end_vpos, 0);
   bzero (&w->last_cursor, sizeof w->last_cursor);
   w->window_end_valid = Qnil;
-  w->hscroll = w->min_hscroll = make_number (0);
-  w->vscroll = 0;
-  set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b));
-  set_marker_restricted (w->start,
-			 make_number (b->last_window_start),
-			 buffer);
-  w->start_at_line_beg = Qnil;
-  w->force_start = Qnil;
-  XSETFASTINT (w->last_modified, 0);
-  XSETFASTINT (w->last_overlay_modified, 0);
+  if (!(keep_margins_p && samebuf))
+    { /* If we're not actually changing the buffer, Don't reset hscroll and
+	 vscroll.  This case happens for example when called from
+	 change_frame_size_1, where we use a dummy call to
+	 Fset_window_buffer on the frame's selected window (and no other)
+	 just in order to run window-configuration-change-hook.
+	 Resetting hscroll and vscroll here is problematic for things like
+	 image-mode and doc-view-mode since it resets the image's position
+	 whenever we resize the frame.  */
+      w->hscroll = w->min_hscroll = make_number (0);
+      w->vscroll = 0;
+      set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b));
+      set_marker_restricted (w->start,
+			     make_number (b->last_window_start),
+			     buffer);
+      w->start_at_line_beg = Qnil;
+      w->force_start = Qnil;
+      XSETFASTINT (w->last_modified, 0);
+      XSETFASTINT (w->last_overlay_modified, 0);
+    }
+  /* Maybe we could move this into the `if' but it's not obviously safe and
+     I doubt it's worth the trouble.  */
   windows_or_buffers_changed++;
 
   /* We must select BUFFER for running the window-scroll-functions.
@@ -3395,10 +3427,7 @@
       if (! NILP (Vwindow_scroll_functions))
 	run_hook_with_args_2 (Qwindow_scroll_functions, window,
 			      Fmarker_position (w->start));
-
-      if (! NILP (Vwindow_configuration_change_hook)
-	  && ! NILP (Vrun_hooks))
-	call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+      run_window_configuration_change_hook (XFRAME (WINDOW_FRAME (w)));
     }
 
   unbind_to (count, Qnil);
--- a/src/window.h	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/window.h	Wed Jan 30 07:57:28 2008 +0000
@@ -790,6 +790,7 @@
 extern void grow_mini_window P_ ((struct window *, int));
 extern void shrink_mini_window P_ ((struct window *));
 
+void run_window_configuration_change_hook (struct frame *f);
 
 /* Make WINDOW display BUFFER as its contents.  RUN_HOOKS_P non-zero
    means it's allowed to run hooks.  See make_frame for a case where
--- a/src/xdisp.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/xdisp.c	Wed Jan 30 07:57:28 2008 +0000
@@ -239,6 +239,7 @@
 
 Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
 Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
+Lisp_Object Qwindow_text_change_functions, Vwindow_text_change_functions;
 Lisp_Object Qredisplay_end_trigger_functions, Vredisplay_end_trigger_functions;
 Lisp_Object Qinhibit_point_motion_hooks;
 Lisp_Object QCeval, QCfile, QCdata, QCpropertize;
@@ -696,6 +697,7 @@
    point visible.  */
 
 int automatic_hscrolling_p;
+Lisp_Object Qauto_hscroll_mode;
 
 /* How close to the margin can point get before the window is scrolled
    horizontally.  */
@@ -1328,6 +1330,28 @@
 	  visible_p = 1;
       if (visible_p)
 	{
+	  Lisp_Object window, prop;
+
+	  XSETWINDOW (window, w);
+	  prop = Fget_char_property (make_number (it.position.charpos),
+				     Qinvisible, window);
+
+	  /* If charpos coincides with invisible text covered with an
+	     ellipsis, use the first glyph of the ellipsis to compute
+	     the pixel positions.  */
+	  if (TEXT_PROP_MEANS_INVISIBLE (prop) == 2)
+	    {
+	      struct glyph_row *row = it.glyph_row;
+	      struct glyph *glyph = row->glyphs[TEXT_AREA];
+	      struct glyph *end = glyph + row->used[TEXT_AREA];
+	      int x = row->x;
+
+	      for (; glyph < end && glyph->charpos < charpos; glyph++)
+		x += glyph->pixel_width;
+
+	      top_x = x;
+	    }
+
 	  *x = top_x;
 	  *y = max (top_y + max (0, it.max_ascent - it.ascent), window_top_y);
 	  *rtop = max (0, window_top_y - top_y);
@@ -8936,8 +8960,6 @@
   if (!FRAME_VISIBLE_P (f) || !f->glyphs_initialized_p)
     return 0;
 
-/* The terminal frame is used as the first Emacs frame on the Mac OS.  */
-#ifndef MAC_OS8
 #ifdef HAVE_WINDOW_SYSTEM
   /* When Emacs starts, selected_frame may be the initial terminal
      frame.  If we let this through, a message would be displayed on
@@ -8945,7 +8967,6 @@
   if (FRAME_INITIAL_P (XFRAME (selected_frame)))
     return 0;
 #endif /* HAVE_WINDOW_SYSTEM */
-#endif
 
   /* Redraw garbaged frames.  */
   if (frame_garbaged)
@@ -10535,11 +10556,12 @@
 	  /* Scroll when cursor is inside this scroll margin.  */
 	  h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w);
 
-	  if ((XFASTINT (w->hscroll)
-	       && w->cursor.x <= h_margin)
-	      || (cursor_row->enabled_p
-		  && cursor_row->truncated_on_right_p
-		  && (w->cursor.x >= text_area_width - h_margin)))
+	  if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->buffer))
+	      && ((XFASTINT (w->hscroll)
+		   && w->cursor.x <= h_margin)
+		  || (cursor_row->enabled_p
+		      && cursor_row->truncated_on_right_p
+		      && (w->cursor.x >= text_area_width - h_margin))))
 	    {
 	      struct it it;
 	      int hscroll;
@@ -10629,16 +10651,9 @@
 hscroll_windows (window)
      Lisp_Object window;
 {
-  int hscrolled_p;
-
-  if (automatic_hscrolling_p)
-    {
-      hscrolled_p = hscroll_window_tree (window);
-      if (hscrolled_p)
-	clear_desired_matrices (XFRAME (WINDOW_FRAME (XWINDOW (window))));
-    }
-  else
-    hscrolled_p = 0;
+  int hscrolled_p = hscroll_window_tree (window);
+  if (hscrolled_p)
+    clear_desired_matrices (XFRAME (WINDOW_FRAME (XWINDOW (window))));
   return hscrolled_p;
 }
 
@@ -13032,8 +13047,7 @@
   *w->desired_matrix->method = 0;
 #endif
 
-  specbind (Qinhibit_point_motion_hooks, Qt);
-
+ restart:
   reconsider_clip_changes (w, buffer);
 
   /* Has the mode line to be updated?  */
@@ -13084,10 +13098,6 @@
   /* Really select the buffer, for the sake of buffer-local
      variables.  */
   set_buffer_internal_1 (XBUFFER (w->buffer));
-  SET_TEXT_POS (opoint, PT, PT_BYTE);
-
-  beg_unchanged = BEG_UNCHANGED;
-  end_unchanged = END_UNCHANGED;
 
   current_matrix_up_to_date_p
     = (!NILP (w->window_end_valid)
@@ -13096,6 +13106,23 @@
        && XFASTINT (w->last_modified) >= MODIFF
        && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF);
 
+  /* Run the window-bottom-change-functions
+     if it is possible that the text on the screen has changed
+     (either due to modification of the text, or any other reason).  */
+  if (!current_matrix_up_to_date_p
+      && !NILP (Vwindow_text_change_functions))
+    {
+      safe_run_hooks (Qwindow_text_change_functions);
+      goto restart;
+    }
+
+  beg_unchanged = BEG_UNCHANGED;
+  end_unchanged = END_UNCHANGED;
+
+  SET_TEXT_POS (opoint, PT, PT_BYTE);
+
+  specbind (Qinhibit_point_motion_hooks, Qt);
+
   buffer_unchanged_p
     = (!NILP (w->window_end_valid)
        && !current_buffer->clip_changed
@@ -24288,6 +24315,9 @@
   staticpro (&Qwindow_scroll_functions);
   Qwindow_scroll_functions = intern ("window-scroll-functions");
 
+  staticpro (&Qwindow_text_change_functions);
+  Qwindow_text_change_functions = intern ("window-text-change-functions");
+
   staticpro (&Qredisplay_end_trigger_functions);
   Qredisplay_end_trigger_functions = intern ("redisplay-end-trigger-functions");
 
@@ -24599,6 +24629,11 @@
 is not valid when these functions are called.  */);
   Vwindow_scroll_functions = Qnil;
 
+  DEFVAR_LISP ("window-text-change-functions",
+	       &Vwindow_text_change_functions,
+    doc: /* Functions to call in redisplay when text in the window might change.  */);
+  Vwindow_text_change_functions = Qnil;
+
   DEFVAR_LISP ("redisplay-end-trigger-functions", &Vredisplay_end_trigger_functions,
     doc: /* Functions called when redisplay of a window reaches the end trigger.
 Each function is called with two arguments, the window and the end trigger value.
@@ -24708,6 +24743,8 @@
   DEFVAR_BOOL ("auto-hscroll-mode", &automatic_hscrolling_p,
     doc: /* *Non-nil means scroll the display automatically to make point visible.  */);
   automatic_hscrolling_p = 1;
+  Qauto_hscroll_mode = intern ("auto-hscroll-mode");
+  staticpro (&Qauto_hscroll_mode);
 
   DEFVAR_INT ("hscroll-margin", &hscroll_margin,
     doc: /* *How many columns away from the window edge point is allowed to get
--- a/src/xterm.c	Wed Jan 30 06:40:42 2008 +0000
+++ b/src/xterm.c	Wed Jan 30 07:57:28 2008 +0000
@@ -6776,9 +6776,7 @@
 		kbd_buffer_store_event_hold (&inev.ie, hold_quit);
 	      }
 
-	    /* Previous code updated count by nchars rather than nbytes,
-	       but that seems bogus to me.  ++kfs  */
-	    count += nbytes;
+	    count += nchars;
 
 	    inev.ie.kind = NO_EVENT;  /* Already stored above.  */
 
@@ -7275,7 +7273,9 @@
    We return as soon as there are no more events to be read.
 
    We return the number of characters stored into the buffer,
-   thus pretending to be `read'.
+   thus pretending to be `read' (except the characters we store
+   in the keyboard buffer can be multibyte, so are not necessarily
+   C chars).
 
    EXPECTED is nonzero if the caller knows input is available.  */