changeset 80990:30ac55694a48

Merge from emacs--rel--22 Patches applied: * emacs--rel--22 (patch 20-21) - Update from CVS 2007-05-18 Richard Stallman <rms@gnu.org> * lisp/simple.el (push-mark): Doc fix. 2007-05-18 Rob Riepel <riepel@Stanford.EDU> * lisp/emulation/tpu-edt.el (CSI-map, SS3-map) Moved from global-map to tpu-global-map. (tpu-original-global-map) Variable deleted. (tpu-control-keys-map) New keymap variable. (tpu-set-control-keys) Use tpu-reset-control-keys rather than setting keymapping directly. (tpu-reset-control-keys) Use tpu-control-keys-map instead of tpu-global-map. (tpu-edt-on): Activate the tpu-global-map. (tpu-edt-off): Deactivate the tpu-global-map. 2007-05-18 Ryan Yeske <rcyeske@gmail.com> * lisp/textmodes/ispell.el (ispell-get-word): Return markers for start and end positions. (ispell-word): Assume END is a marker. 2007-05-19 Stefan Monnier <monnier@iro.umontreal.ca> * src/syntax.c (skip_chars): Update syntax-table only after we checked that the new location is valid. 2007-05-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * src/macterm.c (x_calc_absolute_position): Add BLOCK_INPUT around mac_get_window_bounds. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-759
author Miles Bader <miles@gnu.org>
date Sun, 20 May 2007 03:12:22 +0000
parents ce6c8b83a99a (diff) 06e7a6c4759e (current diff)
children dfd811e95adc
files admin/FOR-RELEASE configure lisp/ChangeLog lisp/t-mouse.el src/ChangeLog
diffstat 73 files changed, 2546 insertions(+), 1287 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,7 +1,22 @@
+2007-05-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* configure.in (AC_CHECK_HEADERS) Add gpm.h.
+	(AC_CHECK_LIB): Add -lgpm.
+	* configure: Regenerate.
+
 2007-05-03  Glenn Morris  <rgm@gnu.org>
 
 	* configure: Tweak message about the absence of shell functions.
 
+2007-04-27  Andreas Schwab  <schwab@suse.de>
+
+	* Makefile.in (config.status): Depend on
+	${srcdir}/lisp/version.el.
+
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* README: Increase version to 22.1.50.
+
 2007-04-24  Juanma Barranquero  <lekktu@gmail.com>
 
 	* INSTALL (DETAILED BUILDING AND INSTALLATION): Fix typo.
--- a/MAINTAINERS	Sat May 19 22:31:10 2007 +0000
+++ b/MAINTAINERS	Sun May 20 03:12:22 2007 +0000
@@ -112,6 +112,12 @@
 Thien-Thi Nguyen
 	VMS
 
+Juanma Barranquero
+       lisp/bs.el
+       lisp/server.el
+       lib-src/emacsclient.c
+       lib-src/grep-changelog
+
 ==============================================================================
 3.
 ==============================================================================
@@ -149,13 +155,16 @@
 src/filemode.c
 src/firstfile.c
 src/floatfns.c
+src/fringe.c
 src/fns.c
 src/fontset.c
 src/getloadavg.c
 src/gmalloc.c
+src/gtkutil.c
 src/hftctl.c
 src/indent.c
 src/insdel.c
+src/image.c
 src/lastfile.c
 src/lread.c
 src/m/
--- a/Makefile.in	Sat May 19 22:31:10 2007 +0000
+++ b/Makefile.in	Sun May 20 03:12:22 2007 +0000
@@ -311,7 +311,7 @@
 Makefile: $(srcdir)/Makefile.in config.status
 	./config.status
 
-config.status: ${srcdir}/configure
+config.status: ${srcdir}/configure ${srcdir}/lisp/version.el
 	./config.status --recheck
 
 AUTOCONF_INPUTS = @MAINT@ $(srcdir)/configure.in $(srcdir)/m4/getopt.m4
--- a/README	Sat May 19 22:31:10 2007 +0000
+++ b/README	Sun May 20 03:12:22 2007 +0000
@@ -3,7 +3,7 @@
 See the end of the file for license conditions.
 
 
-This directory tree holds version 22.0.990 of GNU Emacs, the extensible,
+This directory tree holds version 22.1.50 of GNU Emacs, the extensible,
 customizable, self-documenting real-time display editor.
 
 The file INSTALL in this directory says how to build and install GNU
--- a/admin/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/admin/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,3 +1,7 @@
+2007-04-25  Nick Roberts  <nickrob@snap.net.nz>
+
+	* make-tarball.txt: Add note about cutting the branch.
+
 2007-02-03  Eli Zaretskii  <eliz@gnu.org>
 
 	* nt/makedist.bat: Change EOL format to DOS.  Don't use
--- a/admin/FOR-RELEASE	Sat May 19 22:31:10 2007 +0000
+++ b/admin/FOR-RELEASE	Sun May 20 03:12:22 2007 +0000
@@ -22,6 +22,10 @@
 
 Reminders sent out on 2006-06-08.
 
+** Remove temporary +++/--- lines in NEWS.
+
+** Try to reorder NEWS: most important things first, related items together.
+
 * WINDOWS SUPPORT BUGS.
 
 These don't need to be fixed before a release, but we call the
@@ -36,6 +40,16 @@
 
 * BUGS
 
+See the copy of this file on the EMACS_22_BASE branch.
+
+** rcyeske@gmail.com, April 22: Failure to build on OpenBSD macppc.
+OpenBSD compilation works on i386.
+http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00932.html
+
+** Spurious redisplay bug not fixed.
+http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00443.html
+http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00732.html
+
 ** michael.ewe@arcor.de, Apr 24: 22.0.98  not starting on Solaris 10/I386
 http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg01113.html
 
--- a/admin/make-tarball.txt	Sat May 19 22:31:10 2007 +0000
+++ b/admin/make-tarball.txt	Sun May 20 03:12:22 2007 +0000
@@ -76,7 +76,22 @@
 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>.
-    For a release, Richard should prepare the announcement himself,
+
+15. Shortly before the release, cut the branch with the following commands:
+
+    cvs rtag EMACS_`NUMBER'_BASE
+    cvs rtag -b EMACS_`NUMBER'_RC -r EMACS_`NUMBER'_BASE
+
+where `NUMBER' is the major version number of the release.  This makes it
+easier to  see what changes have been applied to the branch with:
+
+    cvs diff -r EMACS_`NUMBER'_BASE -r EMACS_`NUMBER'_RC
+
+or merge changes back to the trunk with "cvs update -j", if necessary.
+
+After doing this, increase the version number on the trunk as per step 4.
+
+16. For a release, Richard should prepare the announcement himself,
     possibly starting from a previous announcment.
 
 # arch-tag: c23c771f-ca26-4584-8a04-50ecf0989390
--- a/configure	Sat May 19 22:31:10 2007 +0000
+++ b/configure	Sun May 20 03:12:22 2007 +0000
@@ -721,6 +721,7 @@
 machfile
 opsysfile
 carbon_appdir
+LIBGPM
 LTLIBOBJS'
 ac_subst_files=''
       ac_precious_vars='build_alias
@@ -6522,11 +6523,12 @@
 
 
 
+
 for ac_header in sys/select.h sys/timeb.h sys/time.h unistd.h utime.h \
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   termcap.h stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h
+  sys/utsname.h pwd.h gpm.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -17907,11 +17909,13 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+#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);
   ;
   return 0;
 }
@@ -17951,11 +17955,13 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <stdio.h>
-int
-main ()
-{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+#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);
   ;
   return 0;
 }
@@ -23065,6 +23071,73 @@
 
 fi
 
+{ echo "$as_me:$LINENO: checking for Gpm_Open in -lgpm" >&5
+echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6; }
+if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char Gpm_Open ();
+int
+main ()
+{
+return Gpm_Open ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_gpm_Gpm_Open=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_gpm_Gpm_Open=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6; }
+if test $ac_cv_lib_gpm_Gpm_Open = yes; then
+  LIBGPM=-lgpm
+fi
+
+
+
 
 
 
@@ -23941,10 +24014,11 @@
 machfile!$machfile$ac_delim
 opsysfile!$opsysfile$ac_delim
 carbon_appdir!$carbon_appdir$ac_delim
+LIBGPM!$LIBGPM$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 8; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--- a/configure.in	Sat May 19 22:31:10 2007 +0000
+++ b/configure.in	Sun May 20 03:12:22 2007 +0000
@@ -1630,7 +1630,7 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   termcap.h stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h)
+  sys/utsname.h pwd.h gpm.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
 AC_TRY_COMPILE([#include <sys/personality.h>], [personality (PER_LINUX32)],
@@ -2938,6 +2938,9 @@
 	     buffer space.])
 fi
 
+AC_CHECK_LIB(gpm, Gpm_Open, LIBGPM=-lgpm)
+AC_SUBST(LIBGPM)
+
 AH_TOP([/* GNU Emacs site configuration template file.
    Copyright (C) 1988, 1993, 1994, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
              Free Software Foundation, Inc.
--- a/etc/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/etc/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,3 +1,10 @@
+2007-05-19  Glenn Morris  <rgm@gnu.org>
+
+	* images/cancel.pbm: Convert from PGM to PBM.
+
+	* images/copy.pbm, images/next-node.pbm, images/prev-node.pbm:
+	* images/save.pbm, images/up-node.pbm: Convert from PPM to PBM.
+
 2007-05-17  Glenn Morris  <rgm@gnu.org>
 
 	* PROBLEMS (Dumping): Mention OpenBSD macppc problem.
--- a/etc/DEBUG	Sat May 19 22:31:10 2007 +0000
+++ b/etc/DEBUG	Sun May 20 03:12:22 2007 +0000
@@ -64,10 +64,10 @@
 Put a breakpoint early in `main', or suspend the Emacs,
 to get an opportunity to do the set command.
 
-When Emacs is running in a terminal, it is useful to use a separate terminal
-for the debug session.  This can be done by starting Emacs as usual, then
-attaching to it from gdb with the `attach' command which is explained in the
-node "Attach" of the GDB manual.
+When Emacs is running in a terminal, it is sometimes useful to use a separate
+terminal for the debug session.  This can be done by starting Emacs as usual,
+then attaching to it from gdb with the `attach' command which is explained in
+the node "Attach" of the GDB manual.
 
 ** Examining Lisp object values.
 
--- a/etc/TODO	Sat May 19 22:31:10 2007 +0000
+++ b/etc/TODO	Sun May 20 03:12:22 2007 +0000
@@ -594,6 +594,33 @@
 
 * Other known bugs:
 
+** The \\{...} keymap dump output does not correctly remove shadowed entries:
+From: "Drew Adams" <drew.adams@oracle.com>
+
+(define-key minibuffer-local-map [(control ?=)] 'foo)
+(define-key minibuffer-local-completion-map [(control ?=)] 'foo)
+
+(defun toto () "\\{minibuffer-local-completion-map}"  4)
+
+C-h f toto shows a duplicate entry for C-=:
+
+toto is a Lisp function.
+(toto)
+
+key             binding
+- ---             -------
+
+C-g		abort-recursive-edit
+TAB		minibuffer-complete
+C-j		exit-minibuffer
+RET		exit-minibuffer
+ESC		Prefix Command
+SPC		minibuffer-complete-word
+?		minibuffer-completion-help
+C-=		foo
+C-=		foo
+...
+
 ** a two-char comment-starter whose two chars are symbol constituents will
 not be noticed if it appears within a word.
 
--- a/etc/fr-refcard.ps	Sat May 19 22:31:10 2007 +0000
+++ b/etc/fr-refcard.ps	Sun May 20 03:12:22 2007 +0000
@@ -12,7 +12,7 @@
 %DVIPSCommandLine: dvips -t a4 -t landscape fr-refcard.dvi -o
 %+ fr-refcard.ps
 %DVIPSParameters: dpi=600
-%DVIPSSource:  TeX output 2007.05.15:0316
+%DVIPSSource:  TeX output 2007.05.15:0314
 %%BeginProcSet: tex.pro 0 0
 %!
 /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
Binary file etc/images/cancel.pbm has changed
Binary file etc/images/copy.pbm has changed
Binary file etc/images/next-node.pbm has changed
Binary file etc/images/prev-node.pbm has changed
Binary file etc/images/save.pbm has changed
Binary file etc/images/up-node.pbm has changed
--- a/lib-src/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/lib-src/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,3 +1,15 @@
+2007-05-18  Francesco Potort,Al(B  <pot@gnu.org>
+
+	* etags.c: Extern definitions of some more pointer functions for
+	standalone compilation, especially important for 64bit platforms.
+	(main, print_help): --members is now the default for etags.
+	(C_entries): Parse start of C comment as a space == end of token.
+	This is not necessary for C++ comment, already parsed as newline.
+
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* makefile.w32-in (VERSION): Increase to 22.1.50.
+
 2007-02-26  Francesco Potort,Al(B  <pot@gnu.org>
 
 	* Makefile.in (etags, ctags): Define EMACS_NAME as "GNU Emacs".
@@ -1845,7 +1857,7 @@
 	[WINDOWSNT]: #undef DOS_NT and #define it even if built with
 	HAVE_CONFIG_H.  This change does nothing in Emacs, as DOS_NT is
 	always defined when HAVE_CONFIG_H and WINDOWS are both defined.
-	[!HAVE_UNISTD_H]: use defined(WINDOWSNT) instead of the bare
+	[!HAVE_UNISTD_H]: Use defined(WINDOWSNT) instead of the bare
 	WINDOWSNT, as this is the correct way to use it.
 
 2001-01-28  Francesco Potort,Al(B  <pot@gnu.org>
@@ -2996,7 +3008,7 @@
 
 1997-03-14  Francesco Potort,Al(B  <F.Potorti@cnuce.cnr.it>
 
-	* etags.c (add_regex): reset *putbuf before using it.
+	* etags.c (add_regex): Reset *putbuf before using it.
 
 1997-02-23  Jonathan I. Kamens  <jik@kamens.brookline.ma.us>
 
@@ -3560,7 +3572,7 @@
 
 1995-12-04  Francesco Potort,Al(B  <pot@cnuce.cnr.it>
 
-	* Makefile.in (ctags): depend on etags only for simplicity;
+	* Makefile.in (ctags): Depend on etags only for simplicity;
 	compile with regexp support enabled.
 
 1995-11-24  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
@@ -3685,13 +3697,13 @@
 
 1995-06-27  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (plain_C_entries): new function.
-	(lowcase): new macro.
-	(tail, Fortran_functions, Pascal_functions): use new macro lowcase.
-	(lang_suffixes): new suffix ".pc" for Pro*C files.
-	(consider_token): don't tag all tokens beginning with DEFUN & Co..
-	(tail): look for the end of the token when comparing.
-	(takeprec): since now tail behaves differently, use strneq.
+	* etags.c (plain_C_entries): New function.
+	(lowcase): New macro.
+	(tail, Fortran_functions, Pascal_functions): Use new macro lowcase.
+	(lang_suffixes): New suffix ".pc" for Pro*C files.
+	(consider_token): Don't tag all tokens beginning with DEFUN & Co..
+	(tail): Look for the end of the token when comparing.
+	(takeprec): Since now tail behaves differently, use strneq.
 
 1995-07-08  Paul Eggert  <eggert@twinsun.com>
 
@@ -3723,13 +3735,13 @@
 
 1995-06-27  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (plain_C_entries): new function.
-	(lowcase): new macro.
-	(tail, Fortran_functions, Pascal_functions): use new macro lowcase.
-	(lang_suffixes): new suffix ".pc" for Pro*C files.
-	(consider_token): don't tag all tokens beginning with DEFUN & Co..
-	(tail): look for the end of the token when comparing.
-	(takeprec): since now tail behaves differently, use strneq.
+	* etags.c (plain_C_entries): New function.
+	(lowcase): New macro.
+	(tail, Fortran_functions, Pascal_functions): Use new macro lowcase.
+	(lang_suffixes): New suffix ".pc" for Pro*C files.
+	(consider_token): Don't tag all tokens beginning with DEFUN & Co..
+	(tail): Look for the end of the token when comparing.
+	(takeprec): Since now tail behaves differently, use strneq.
 
 1995-06-26  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
@@ -3906,7 +3918,7 @@
 
 1995-03-13  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (process_file): free (filename) after using it.
+	* etags.c (process_file): Free (filename) after using it.
 	(readline_internal): Do not access the char before start of line.
 
 1995-02-22  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
@@ -4039,8 +4051,8 @@
 
 1994-11-22  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (print_help): print --regex usage for ctags also.
-	(main): use -h in addition to -H as abbreviation for --help.
+	* etags.c (print_help): Print --regex usage for ctags also.
+	(main): Use -h in addition to -H as abbreviation for --help.
 
 1994-11-16  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
@@ -4105,9 +4117,9 @@
 
 1994-10-21  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (prestr, substr): return a logical type.
+	* etags.c (prestr, substr): Return a logical type.
 	(consider_token): Comment out "EXFUN".  Use "DEFUN" instead of "DEF".
-	(consider_token): set funcdef to fignore when a DEFUN is met.
+	(consider_token): Set funcdef to fignore when a DEFUN is met.
 	(C_entries): Now we can use Tom Hageman patch for extern "C".
 
 1994-10-20  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
@@ -4190,8 +4202,8 @@
 
 1994-10-17  Francesco Potort,Al(B  (pot@fly.cnuce.cnr.it)
 
-	* Makefile.in.in (etags): add dependency on regex.o, link with it.
-	(REGEXPOBJ, REGEXPDEPS, regex.o): target and macros added.
+	* Makefile.in.in (etags): Add dependency on regex.o, link with it.
+	(REGEXPOBJ, REGEXPDEPS, regex.o): Target and macros added.
 
 1994-10-12  David J. MacKenzie  (djm@duality.gnu.ai.mit.edu)
 
@@ -4341,7 +4353,7 @@
 
 1994-07-08  Dave Love  (d.love@dl.ac.uk)
 
-	* etags.c (takeprec): recognise `character*(*) function'
+	* etags.c (takeprec): Recognise `character*(*) function'.
 
 1994-07-08  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
@@ -4489,11 +4501,11 @@
 
 1994-04-18  Francesco Potort,Al(B  (pot@fly.cnuce.cnr.it)
 
-	* etags.c (main, print_help): eliminate the -F option.
+	* etags.c (main, print_help): Eliminate the -F option.
 
 1994-04-18  Francesco Potort,Al(B  (pot@fly.cnuce.cnr.it)
 
-	* etags.c (absolute_filename): compare against '\0' instead of NULL.
+	* etags.c (absolute_filename): Compare against '\0' instead of NULL.
 
 1994-04-16  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -4527,21 +4539,21 @@
 
 1994-04-08  Francesco Potort,Al(B  (pot@fly.cnuce.cnr.it)
 
-	* etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
-	(PF_funcs, Asm_funcs, L_funcs, PAS_funcs, TEX_funcs,
-	Scheme_funcs, prolog_funcs): renamed to Fortran_functions,
+	* etags.c (outf, outfiledir): Renamed to tagf, tagfiledir.
+	(PF_funcs, Asm_funcs, L_funcs, PAS_funcs, TEX_funcs)
+	(Scheme_funcs, prolog_funcs): Renamed to Fortran_functions,
 	Asm_labels, Lisp_functions, Pascal_functions, Scheme_functions,
 	TeX_functions, Prolog_functions.
-	(inf): no more a global variable.
-	(C_entries): take 2nd parameter `inf' instead of using the global one.
-	(find_entries): added the cp1 var for optimisation.
-	(find_entries): added more suffixes for assembler files.
+	(inf): No more a global variable.
+	(C_entries): Take 2nd parameter `inf' instead of using the global one.
+	(find_entries): Added the cp1 var for optimisation.
+	(find_entries): Added more suffixes for assembler files.
 	(Asm_funcs): Now finds labels even without an ending colon.
 
 1994-03-30  Francesco Potort,Al(B  (pot@fly.cnuce.cnr.it)
 
-	* etags.c (main): use etags_getcwd for compatibility.
-	(etags_getcwd): new function.
+	* etags.c (main): Use etags_getcwd for compatibility.
+	(etags_getcwd): New function.
 
 1994-03-25  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -4549,22 +4561,22 @@
 
 1994-03-25  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (emacs_tags_format, ETAGS): removed.  Use CTAGS instead.
-	(main): don't allow the use of -t and -T in etags mode.
-	(print_help): don't show options enabled by default.
-	(print_version): show the emacs version number if VERSION is #defined.
-	(find_entries): add "ss" as suffix for Chez Scheme.
+	* etags.c (emacs_tags_format, ETAGS): Removed.  Use CTAGS instead.
+	(main): Don't allow the use of -t and -T in etags mode.
+	(print_help): Don't show options enabled by default.
+	(print_version): Show the emacs version number if VERSION is #defined.
+	(find_entries): Add "ss" as suffix for Chez Scheme.
 
 1994-03-23  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (cwd, outfiledir): vars added.
+	* etags.c (cwd, outfiledir): Vars added.
 	(relative_filename, absolute_filename, absolute_dirname):
 	functions added to compute filenames in tags files.
-	(process_file): filenames in tags file are relative to the
+	(process_file): Filenames in tags file are relative to the
 	directory where the tags file is (useful with the -o option).
-	(main): initialise the outfiledir var.
-	(TYPEDST): added the `tignore' value.
-	(C_entries): corrected various small bugs.
+	(main): Initialise the outfiledir var.
+	(TYPEDST): Added the `tignore' value.
+	(C_entries): Corrected various small bugs.
 
 1994-03-19  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -4579,8 +4591,8 @@
 
 1994-03-14  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (TYPEDST): added the `tignore' value.
-	(C_entries): corrected various bugs, now correctly parses the
+	* etags.c (TYPEDST): Added the `tignore' value.
+	(C_entries): Corrected various bugs, now correctly parses the
 	`extern "C" {' construction (patch by Tom R.Hageman).
 
 1994-03-05  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
@@ -4621,7 +4633,7 @@
 1994-02-22  Karl Heuer  (kwzh@gnu.ai.mit.edu)
 
 	* profile.c (get_time): Simplify; avoid calling index.
-	(main): exit on EOF.
+	(main): Exit on EOF.
 
 1994-02-17  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
@@ -4633,11 +4645,11 @@
 
 1994-02-14  Francesco Potort,Al(B  (pot@fly)
 
-	* etags.c (absolute_pathnames, cwd): added global vars.
-	(longopts, print_help, main, process_file): put absolute filenames
+	* etags.c (absolute_pathnames, cwd): Added global vars.
+	(longopts, print_help, main, process_file): Put absolute filenames
 	in the tag file if the -A --absolute-pathnames option is used.
-	(print_help): alfabetically order the options.
-	(malloc, realloc, strcpy, strncpy, strcmp): remove extern declar.
+	(print_help): Alfabetically order the options.
+	(malloc, realloc, strcpy, strncpy, strcmp): Remove extern declar.
 
 1994-02-09  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -4666,15 +4678,15 @@
 1994-01-14  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
 	* etags.c (stab_entry, stab_create, stab_find, stab_search,
-	stab_type, add_keyword, C_reate_stab, C_create_stabs): deleted.
+	stab_type, add_keyword, C_reate_stab, C_create_stabs): Deleted.
 	Use gperf generated hash table instead of linked list.
-	(C_stab_entry, hash, in_word_set, get_C_stab, C_symtype): added.
+	(C_stab_entry, hash, in_word_set, get_C_stab, C_symtype): Added.
 	Mostly code generated by gperf.
-	(consider_token): removed unused parameter `lp'.
-	(PF_funcs, getit): allow subroutine and similar declarations
+	(consider_token): Removed unused parameter `lp'.
+	(PF_funcs, getit): Allow subroutine and similar declarations
 	to span multiple lines.
-	(C_entries): check for newline if inchar to avoid bus errors.
-	(process_file, find_entries): distinguish among nonexistent
+	(C_entries): Check for newline if inchar to avoid bus errors.
+	(process_file, find_entries): Distinguish among nonexistent
 	and not regular file.
 
 1994-01-14  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
@@ -4811,14 +4823,14 @@
 	functions returning a pointer to a function, a la `signal', can be
 	parsed.  This also required new state `fstartlist' to `FUNCST'.
 	(SAVE_TOKEN, RESTORE_TOKEN, TOKEN_SAVED_P): 1-deep token save stack.
-	(C_entries, CNL): use it to isolate preprocessor directive processing
+	(C_entries, CNL): Use it to isolate preprocessor directive processing
 	from the other state engines.
-	(begtk): add '~', for C++ class destructors.
+	(begtk): Add '~', for C++ class destructors.
 
 1993-11-02  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (consider_token): removed unused variable firsttok.
-	(prolog_getit): call pfnote with the right number of arguments.
+	* etags.c (consider_token): Removed unused variable firsttok.
+	(prolog_getit): Call pfnote with the right number of arguments.
 
 1993-10-19  Paul Eggert  (eggert@twinsun.com)
 
@@ -4837,9 +4849,9 @@
 
 1993-10-01  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (process_file): dead code removed.
+	* etags.c (process_file): Dead code removed.
 	(S_ISREG): #define it using S_IFREG if not defined.
-	(process_file): regular files have nothing to do with symlinks.
+	(process_file): Regular files have nothing to do with symlinks.
 
 1993-09-28  Brian Fox  (bfox@ai.mit.edu)
 
@@ -4922,10 +4934,10 @@
 
 1993-08-04  Francesco Potort,Al(B  (pot@spiff.gnu.ai.mit.edu)
 
-	* etags.c (L_isdef, L_isquote, L_getit): small optimisations.
-	(L_funcs): the (foo::defmumble stuff now should work.
-	(consider_token): function returned random value--corrected.
-	(C_entries): corrected == versus = typo.
+	* etags.c (L_isdef, L_isquote, L_getit): Small optimisations.
+	(L_funcs): The (foo::defmumble stuff now should work.
+	(consider_token): Function returned random value--corrected.
+	(C_entries): Corrected == versus = typo.
 
 1993-08-01  Roland McGrath  (roland@churchy.gnu.ai.mit.edu)
 
@@ -4941,11 +4953,11 @@
 	* etags.c (FINCST): Added the fignore status.  Means we are
 	after the parameter list and before the open curly brace.
 	Allows correct parsing of C++ constructors.
-	(C_entries, consider_token): make use of fignore.
-	(consider_token): reset funcdef when next_token_is_func: when in
+	(C_entries, consider_token): Make use of fignore.
+	(consider_token): Reset funcdef when next_token_is_func: when in
 	ctags mode makes DEFVAR and others work better.
-	(L_isquote): function that recognises the "(quote" string.
-	(L_getit): ignore quoting via "'" or "(quote".  Useful for defalias.
+	(L_isquote): Function that recognises the "(quote" string.
+	(L_getit): Ignore quoting via "'" or "(quote".  Useful for defalias.
 
 1993-07-29  Paul Eggert  (eggert@twinsun.com)
 
@@ -4977,20 +4989,20 @@
 
 1993-07-08  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (alloca): removed all references to it.
-	(main): now calls xnew instead of alloca for portability.
-	(../src/config.h): included only if HAVE_CONFIG_H.
-	(const): void definition removed--config.h takes care of it.
+	* etags.c (alloca): Removed all references to it.
+	(main): Now calls xnew instead of alloca for portability.
+	(../src/config.h): Included only if HAVE_CONFIG_H.
+	(const): Void definition removed--config.h takes care of it.
 
 1993-07-08  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (consider_token): was `==', now is `='.
+	* etags.c (consider_token): Was `==', now is `='.
 	(consider_token): DEFUNs now treated like funcs in ctags mode.
 
-	* etags.c (LEVEL_OK_FOR_FUNCDEF): removed.
-	(C_entries): optimized the test that used LEVEL_OK_FOR_FUNCDEF.
-	(C_entries): removed a piece of useless code.
-	(C_entries): making typedef tags is delayed until a semicolon
+	* etags.c (LEVEL_OK_FOR_FUNCDEF): Removed.
+	(C_entries): Optimized the test that used LEVEL_OK_FOR_FUNCDEF.
+	(C_entries): Removed a piece of useless code.
+	(C_entries): Making typedef tags is delayed until a semicolon
 	is met.  This handles "typedef int X, Y, Z;" correctly.
 
 1993-07-06  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
@@ -5266,38 +5278,38 @@
 
 1993-03-22  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (YACC): flag added to c_ext.
-	(c_ext): no more a synonim for c_ext&C_PLPL because of YACC.
-	(find_entries): consistently use streq when reasonable.
-	(find_entries): a .y file is a yacc file.
+	* etags.c (YACC): Flag added to c_ext.
+	(c_ext): No more a synonim for c_ext&C_PLPL because of YACC.
+	(find_entries): Consistently use streq when reasonable.
+	(find_entries): A .y file is a yacc file.
 	(get_C_stab): c_ext becomes c_ext&C_PLPL.
-	(C_entries): logical cplpl means c_ext&C_PLPL.
-	(C_entries): logical yacc_rules means we are after the first %%.
-	(C_entries): added logic for yacc files.
+	(C_entries): Logical cplpl means c_ext&C_PLPL.
+	(C_entries): Logical yacc_rules means we are after the first %%.
+	(C_entries): Added logic for yacc files.
 
 1993-03-16  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
 	* etags.c (C_entries): ':' case moved to the second switch.
-	(C_entries): do not examine token if structdef==scolonseen.
+	(C_entries): Do not examine token if structdef==scolonseen.
 	(consider_token): structtag set to null string for enum.
 
 1993-03-12  Francesco Potort,Al(B  (pot@cnuce.cnr.it)
 
-	* etags.c (GET_COOKIE): and related macros removed.
-	(logical): is now int, no more a char.
-	(reg): define deleted.
-	(isgood, _gd, notgd): deleted.
-	(gotone): deleted.
-	(TOKEN): member linestart removed.
-	(linepos, prev_linepos, lb1): deleted.
-	(main): call initbuffer on lbs array instead of lb1.
-	(init): removed the initialisation of the logical _gd array;
-	(find_entries): a .sa suffix means assembler file.
+	* etags.c (GET_COOKIE): And related macros removed.
+	(logical): Is now int, no more a char.
+	(reg): Define deleted.
+	(isgood, _gd, notgd): Deleted.
+	(gotone): Deleted.
+	(TOKEN): Member linestart removed.
+	(linepos, prev_linepos, lb1): Deleted.
+	(main): Call initbuffer on lbs array instead of lb1.
+	(init): Removed the initialisation of the logical _gd array;
+	(find_entries): A .sa suffix means assembler file.
 	(C_create_stab): "auto", "void", "extern", "static" are st_C_typespec.
 	All C state machines rewritten.
-	(C_entries): complete rewrite.
-	(condider_token): complete rewrite.
-	(getline): deleted.
+	(C_entries): Complete rewrite.
+	(condider_token): Complete rewrite.
+	(getline): Deleted.
 
 1993-03-01  Francesco Potort,Al(B  (pot@fly.CNUCE.CNR.IT)
 
@@ -5311,7 +5323,7 @@
 
 1993-03-19  Eric S. Raymond  (eric@geech.gnu.ai.mit.edu)
 
-	* Makefile.in (EXECUTABLES): added rcs-checkin.
+	* Makefile.in (EXECUTABLES): Added rcs-checkin.
 
 	* Makefile.in (unlock, relock): New productions.
 
@@ -5594,7 +5606,7 @@
 
 1992-05-04  Jim Blandy  (jimb@pogo.cs.oberlin.edu)
 
-	* Makefile.in: flags in CC invocations rearranged for no reason.
+	* Makefile.in: Flags in CC invocations rearranged for no reason.
 
 1992-04-20  Jim Blandy  (jimb@pogo.cs.oberlin.edu)
 
@@ -6007,13 +6019,13 @@
 
 1989-04-18  Richard Stallman  (rms@sugar-bombs.ai.mit.edu)
 
-	* loadst.c: on bsd4.3, use gettimeofday instead of CPUSTATES.
+	* loadst.c: On bsd4.3, use gettimeofday instead of CPUSTATES.
 
 1989-03-15  Jeff Peck  (rms@sugar-bombs.ai.mit.edu)
 
 	* emacstool.c: setenv IN_EMACSTOOL=t, TERM=sun, TERMCAP=.
 
-	* emacsstool.1: update to document environment variables.
+	* emacsstool.1: Update to document environment variables.
 
 1989-02-21  Richard Stallman  (rms@sugar-bombs.ai.mit.edu)
 
@@ -6114,7 +6126,7 @@
 
 1988-09-24  Richard Stallman  (rms@gluteus.ai.mit.edu)
 
-	* etags.c (main): default setting of eflag was backwards.
+	* etags.c (main): Default setting of eflag was backwards.
 
 1988-09-23  Richard Stallman  (rms@sugar-bombs.ai.mit.edu)
 
@@ -6197,7 +6209,7 @@
 1988-04-28  Richard Stallman  (rms@frosted-flakes.ai.mit.edu)
 
 	* movemail.c: #undef close, since config can #define it on V.3.
-	* emacsclient.c, fakemail.c, loadst.c, server.c: likewise.
+	* emacsclient.c, fakemail.c, loadst.c, server.c: Likewise.
 
 1988-04-26  Richard Stallman  (rms@lucky-charms.ai.mit.edu)
 
@@ -6208,9 +6220,9 @@
 
 1988-03-20  Richard M. Stallman  (rms@wilson)
 
-	* server.c [not BSD and not HAVE_SYSVIPC]: fix error message.
-
-	* loadst.c (main) [XENIX]: use /usr/spool/mail, not /usr/mail.
+	* server.c [not BSD and not HAVE_SYSVIPC]: Fix error message.
+
+	* loadst.c (main) [XENIX]: Use /usr/spool/mail, not /usr/mail.
 
 ;; Local Variables:
 ;; coding: iso-2022-7bit
--- a/lib-src/etags.c	Sat May 19 22:31:10 2007 +0000
+++ b/lib-src/etags.c	Sun May 20 03:12:22 2007 +0000
@@ -60,10 +60,10 @@
 
 /*
  * Authors:
- *	Ctags originally by Ken Arnold.
- *	Fortran added by Jim Kleckner.
- *	Ed Pelegri-Llopart added C typedefs.
- *	Gnu Emacs TAGS format and modifications by RMS?
+ * 1983	Ctags originally by Ken Arnold.
+ * 1984	Fortran added by Jim Kleckner.
+ * 1984	Ed Pelegri-Llopart added C typedefs.
+ * 1985	Emacs TAGS format by Richard Stallman.
  * 1989	Sam Kendall added C++.
  * 1992 Joseph B. Wells improved C and C++ parsing.
  * 1993	Francesco Potortì reorganised C and C++.
@@ -80,7 +80,7 @@
  * configuration file containing regexp definitions for etags.
  */
 
-char pot_etags_version[] = "@(#) pot revision number is 17.26";
+char pot_etags_version[] = "@(#) pot revision number is 17.31";
 
 #define	TRUE	1
 #define	FALSE	0
@@ -159,7 +159,14 @@
 #  include <stdlib.h>
 #  include <string.h>
 # else /* no standard C headers */
-    extern char *getenv ();
+   extern char *getenv ();
+   extern char *strcpy ();
+   extern char *strncpy ();
+   extern char *strcat ();
+   extern char *strncat ();
+   extern unsigned long strlen ();
+   extern PTR malloc ();
+   extern PTR realloc ();
 #  ifdef VMS
 #   define EXIT_SUCCESS	1
 #   define EXIT_FAILURE	0
@@ -483,7 +490,7 @@
   *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
 
 static bool append_to_tagfile;	/* -a: append to tags */
-/* The next four default to TRUE for etags, but to FALSE for ctags.  */
+/* The next five default to TRUE for etags, but to FALSE for ctags.  */
 static bool typedefs;		/* -t: create tags for C and Ada typedefs */
 static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
 				/* 0 struct/enum/union decls, and C++ */
@@ -875,7 +882,7 @@
 # define EMACS_NAME "standalone"
 #endif
 #ifndef VERSION
-# define VERSION "version"
+# define VERSION "17.31"
 #endif
 static void
 print_version ()
@@ -969,7 +976,11 @@
     puts ("--no-globals\n\
 	Do not create tag entries for global variables in some\n\
 	languages.  This makes the tags file smaller.");
-  puts ("--no-members\n\
+  if (CTAGS)
+    puts ("--members\n\
+	Create tag entries for members of structures in some languages.");
+  else
+    puts ("--no-members\n\
 	Do not create tag entries for members of structures\n\
 	in some languages.");
 
@@ -1215,7 +1226,7 @@
   if (!CTAGS)
     {
       typedefs = typedefs_or_cplusplus = constantypedefs = TRUE;
-      globals = TRUE;
+      globals = members = TRUE;
     }
 
   /* When the optstring begins with a '-' getopt_long does not rearrange the
@@ -3397,17 +3408,15 @@
 	case '/':
 	  if (*lp == '*')
 	    {
+	      incomm = TRUE;
 	      lp++;
-	      incomm = TRUE;
-	      continue;
+	      c = ' ';
 	    }
 	  else if (/* cplpl && */ *lp == '/')
 	    {
 	      c = '\0';
-	      break;
 	    }
-	  else
-	    break;
+	  break;
 	case '%':
 	  if ((c_ext & YACC) && *lp == '%')
 	    {
--- a/lib-src/makefile.w32-in	Sat May 19 22:31:10 2007 +0000
+++ b/lib-src/makefile.w32-in	Sun May 20 03:12:22 2007 +0000
@@ -24,7 +24,7 @@
 
 .PHONY: $(ALL)
 
-VERSION		= 22.0.990
+VERSION		= 22.1.50
 
 LOCAL_FLAGS	= -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \
 		  -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \
--- a/lisp/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,3 +1,25 @@
+2007-05-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* t-mouse.el: Reduce to a minor-mode macro call.
+
+2007-05-19  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* files.el (auto-mode-alist): Change the regexp so that
+	ChangeLog.unicode and ChangeLog.multi-tty use change-log-mode.
+
+2007-05-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* paren.el (show-paren-function): Undo 2007-04-19 and 2007-04-20
+	changes.
+
+2007-05-19  Kevin Ryde  <user42@zip.com.au>
+
+	* info.el (Info-fontify-node): Fontify https as well as http and ftp.
+
+2007-05-18  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* textmodes/sgml-mode.el: Revert last change.
+
 2007-05-18  Richard Stallman  <rms@gnu.org>
 
 	* simple.el (push-mark): Doc fix.
@@ -23,21 +45,39 @@
 
 2007-05-17  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
-	* ps-print.el: Use default color when foreground or background color
-	are unspecified.  Reported by Leo <sdl.web@gmail.com>.
-	(ps-print-version): New version 6.7.4.
-	(ps-rgb-color): New argument.  Use default color when color is
-	unspecified.
-	(ps-begin-job): Fix code.
+	* printing.el: Group together all XEmacs/Emacs definitions.
+	(pr-version): New version 6.9.
+	(pr-global-menubar, pr-menu-char-height, pr-menu-char-width): New funs.
+	(pr-menu-char-height, pr-menu-char-width): Fix initialization code.
+	(pr-menu-bind): Fix code.
+	(pr-e-frame-char-height, pr-e-frame-char-width)
+	(pr-e-mouse-pixel-position, pr-x-add-submenu, pr-x-event-function)
+	(pr-x-event-object, pr-x-find-menu-item, pr-x-font-height)
+	(pr-x-font-width, pr-x-get-popup-menu-response, pr-x-make-event)
+	(pr-x-misc-user-event-p, pr-x-relabel-menu-item, pr-x-event-x-pixel)
+	(pr-x-event-y-pixel): Aliases eliminated.
+	(pr-xemacs-global-menubar): Macro moved.
+	(current-menubar, current-mouse-event, zmacs-region-stays)
+	(deactivate-mark, pr-menu-position, pr-menu-state, pr-ps-name-old)
+	(pr-txt-name-old, pr-ps-utility-old, pr-even-or-odd-old, pr-temp-menu):
+	Vars moved.
+	(pr-region-active-p, pr-menu-position, pr-menu-lookup, pr-menu-lock)
+	(pr-update-mode-line, pr-do-update-menus, pr-menu-alist)
+	(pr-relabel-menu-item, pr-menu-set-ps-title, pr-menu-set-txt-title)
+	(pr-menu-set-utility-title, pr-even-or-odd-pages)
+	(pr-f-set-keymap-parents, pr-f-set-keymap-name, pr-f-read-string)
+	(pr-keep-region-active, pr-menu-get-item, pr-menu-set-item-name): Funs
+	moved.
+
+2007-05-17  Christian Plate  <cplate@web.de>  (tiny change)
+
+	* textmodes/sgml-mode.el (sgml-tag):
+	Fix bug: Call sgml-transformation-function.
 
 2007-05-17  Martin Rudalics  <rudalics@gmx.at>
 
-	* textmodes/ispell.el (ispell-start-process): Defend against bad
-	default-directory.
-
-2007-05-17  Stefan Monnier  <monnier@iro.umontreal.ca>
-
-	* vc-hooks.el (vc-find-root): Stop searching when the user changes.
+	* hilit-chg.el (highlight-changes-rotate-faces): Don't set
+	modified flag of buffer.  Use `inhibit-modification-hooks'.
 
 2007-05-16  Richard Stallman  <rms@gnu.org>
 
@@ -75,22 +115,43 @@
 	* view.el (view-inhibit-help-message): Fix typo in docstring.
 	(view-scroll-auto-exit, view-try-extend-at-buffer-end): Doc fixes.
 
+2007-05-16  Martin Rudalics  <rudalics@gmx.at>
+
+	* textmodes/ispell.el (ispell-start-process): Defend against bad
+	default-directory.
+
 2007-05-14  Eli Zaretskii  <eliz@gnu.org>
 
 	* mail/rmail.el (rmail-convert-to-babyl-format): Check
-	content-transfer-encoding _last_, because we need its position in
-	base64-header-field-end.
+	content-transfer-encoding _last_, because it's its position that
+	we need as value of base64-header-field-end.
 
 2007-05-14  Juanma Barranquero  <lekktu@gmail.com>
 
 	* files.el (mode-require-final-newline, require-final-newline)
 	(enable-local-variables, enable-local-eval): Doc fixes.
 
-2007-05-10  Edward O'Connor  <hober0@gmail.com>  (tiny change)
-
-	* progmodes/python.el (python-font-lock-keywords)
-	(python-open-block-statement-p, python-mode): Add support for the new
-	"with" keyword.
+2007-05-13  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* ps-print.el: Use default color when foreground or background color
+	are unspecified.  Reported by Leo <sdl.web@gmail.com>.
+	(ps-print-version): New version 6.7.4.
+	(ps-rgb-color): New argument.  Use default color when color is
+	unspecified.
+	(ps-begin-job): Fix code.
+
+2007-05-12  Chong Yidong  <cyd@stupidchicken.com>
+
+	* longlines.el (longlines-mode): Make longlines-auto-wrap
+	buffer-local.  Add hooks unconditionally.
+	(longlines-auto-wrap): Toggle wrapping.
+	(longlines-after-change-function)
+	(longlines-post-command-function): Check longlines-auto-wrap.
+
+2007-05-12  Nick Roberts  <nickrob@snap.net.nz>
+
+	* xt-mouse.el (xterm-mouse-debug-buffer): New variable.
+	(xterm-mouse-translate): Use it.
 
 2007-05-10  Richard Stallman  <rms@gnu.org>
 
@@ -111,11 +172,60 @@
 	(set-auto-mode): Handle file-start-mode-alist.
 	A little cleanup of structure.
 
-2007-05-10  Davis Herring  <herring@lanl.gov>
-
-	* calendar/timeclock.el (timeclock-in): Fix non-interactive
-	workday specifications.
-	(timeclock-log): Don't kill the log buffer if it already existed.
+2007-05-10  Micha,Ak(Bl Cadilhac  <michael@cadilhac.name>
+
+	* man.el (Man-next-section): Don't consider the last line of the page
+	as being part of any section.
+
+2007-05-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* textmodes/sgml-mode.el (sgml-value): Fix handling of attributes which
+	can take any number of values.
+
+2007-05-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* textmodes/tex-mode.el (tex-font-lock-keywords-2): Add citet and citep
+	to the list of citation commands.
+
+2007-05-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc-hooks.el (vc-find-root): Stop searching when the user changes.
+
+2007-05-09  Edward O'Connor  <hober0@gmail.com>  (tiny change)
+
+	* progmodes/python.el (python-font-lock-keywords)
+	(python-open-block-statement-p, python-mode): Add support for the new
+	"with" keyword.
+
+2007-05-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* diff-mode.el (diff-apply-hunk, diff-test-hunk): Don't do by default
+	the exact opposite of diff-goto-source.
+
+	* emacs-lisp/advice.el (ad-special-forms): Remove.
+	(ad-special-form-p): Use subr-arity.
+
+	* newcomment.el (comment-search-forward): Make sure we search forward.
+	(comment-enter-backward): Try and distinguish the non-matching case at
+	EOB from the non-matching case with a missing comment-end-skip for
+	a 2-char comment ender.
+	(comment-choose-indent): New function extracted from comment-indent.
+	Improve the alignment algorithm.
+	(comment-indent): Use it.
+
+	* textmodes/sgml-mode.el (sgml-lexical-context): Add handling of
+	XML style Processing Instructions.
+	(sgml-parse-tag-backward): Handle XML-style PIs.  Also ensure progress.
+	(sgml-calculate-indent): Handle `pi' context.
+
+	* vc.el: Ensure that update-changelog issues an error when used with
+	a backend that does not implement it.
+	(vc-update-changelog-rcs2log): Rename from vc-default-update-changelog.
+	Remove `backend' argument.  Use expand-file-name.
+	(vc-cvs-update-changelog, vc-rcs-update-changelog): New aliases.
+
+	* progmodes/python.el (python-end-of-block): Revert last change.
+	(python-end-of-statement): Make sure we move *forward*.
 
 2007-05-08  Richard Stallman  <rms@gnu.org>
 
@@ -136,6 +246,29 @@
 
 	* emacs-lisp/eldoc.el (turn-on-eldoc-mode): Doc fix.
 
+2007-05-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* diff.el (diff): Use buffer-local vars diff-old-file and diff-new-file
+	rather than storing their value in the revert-buffer function.
+
+2007-05-04  Nick Roberts  <nickrob@snap.net.nz>
+
+	* t-mouse.el (t-mouse-mode): Do nothing on a graphical display
+	when disabling t-mouse-mode.
+
+2007-05-01  Davis Herring  <herring@lanl.gov>
+
+	* calendar/timeclock.el: Update version number.
+	(timeclock-modeline-display): Mention timeclock-use-display-time
+	in explanatory message.
+	(timeclock-in): Fix non-interactive workday specifications.
+	(timeclock-log): Don't kill the log buffer if it already existed.
+	Suppress warnings when finding the log.  Don't check for a nil
+	project twice.  Run hooks after killing the buffer (if applicable).
+	(timeclock-geometric-mean): Rename to `timeclock-mean' (it never
+	was geometric).  All uses changed.
+	(timeclock-generate-report): Support prefix argument.
+
 2007-05-03  Ryan Yeske  <rcyeske@gmail.com>
 
 	* net/rcirc.el (rcirc-timeout-seconds): Increase to prevent unwanted
@@ -145,11 +278,6 @@
 
 	* dired-x.el: Revert 2007-04-06 change.
 
-2007-04-30  Nick Roberts  <nickrob@snap.net.nz>
-
-	* progmodes/gud.el (gud-menu-map): Pdb can't handle SIGINT so
-	don't put stop on toolbar.
-
 2007-04-29  Stephen Berman  <Stephen.Berman@gmx.net>
 
 	* find-dired.el (find-dired-filter): Propertize all text down to eob.
@@ -167,6 +295,11 @@
 
 	* progmodes/sh-script.el (sh-mode): Recognize .profile as sh style.
 
+2007-04-28  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el (gud-menu-map): Pdb can't handle SIGINT so
+	don't put stop on toolbar.
+
 2007-04-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* vc-hooks.el (vc-ignore-dir-regexp): Add /.../ for the DFS filesystem.
@@ -176,8 +309,6 @@
 	* makefile.w32-in ($(lisp)/mh-e/mh-loaddefs.el): Use ./mh-e
 	instead of $(lisp)/mh-e.
 
-	* textmodes/fill.el (fill-paragraph): Doc fix.
-
 2007-04-28  Glenn Morris  <rgm@gnu.org>
 
 	* image-dired.el (image-dired-cmd-create-thumbnail-options)
@@ -189,10 +320,13 @@
 	* textmodes/flyspell.el (flyspell-auto-correct-previous-word):
 	Use window-start and window-end.
 
-2007-04-26  Glenn Morris  <rgm@gnu.org>
-
-	* progmodes/python.el: Restore file pending consideration of legal
-	status.
+2007-04-27  Andreas Schwab  <schwab@suse.de>
+
+	* emacs-lisp/sregex.el (sregexq): Fix doc string quoting.
+
+2007-04-27  Eli Zaretskii  <eliz@gnu.org>
+
+	* textmodes/fill.el (fill-paragraph): Doc fix.
 
 2007-04-26  Luc Teirlinck  <teirllm@dms.auburn.edu>
 
@@ -203,6 +337,8 @@
 	* button.el (button): Use underline if supported, else fall back
 	to color.
 
+	* version.el (emacs-version): Increase to 22.1.50.
+
 2007-04-25  Richard Stallman  <rms@gnu.org>
 
 	* hi-lock.el (hi-lock-file-patterns-policy): Default to `ask'.
@@ -223,10 +359,6 @@
 
 	* custom.el (defface): Doc fix.
 
-2007-04-24  Chong Yidong  <cyd@stupidchicken.com>
-
-	* progmodes/python.el: Remove due to unclear legal issues.
-
 2007-04-24  J.D. Smith  <jdsmith@as.arizona.edu>
 
 	* progmodes/idlw-shell.el (idlwave-shell-clear-all-bp):
@@ -13770,8 +13902,8 @@
 
 2006-01-29  Edward O'Connor  <ted@oconnor.cx>
 
-	* emulation/viper.el (viper-major-mode-modifier-list): Add
-	insert-state and vi-state entries for erc-mode.
+	* emulation/viper.el (viper-major-mode-modifier-list):
+	Add insert-state and vi-state entries for erc-mode.
 	(viper-go-away, viper-set-hooks): Add and remove
 	viper-comint-mode-hook from erc-mode-hook as appropriate.
 
--- a/lisp/calendar/timeclock.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/calendar/timeclock.el	Sun May 20 03:12:22 2007 +0000
@@ -5,7 +5,7 @@
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Created: 25 Mar 1999
-;; Version: 2.6
+;; Version: 2.6.1
 ;; Keywords: calendar data
 
 ;; This file is part of GNU Emacs.
@@ -304,8 +304,8 @@
                 ;; Update immediately so there is a visible change
                 ;; on calling this function.
                 (if display-time-mode (timeclock-update-modeline)
-                  (message "Activate `display-time-mode' to see \
-timeclock information"))
+                  (message "Activate `display-time-mode' or turn off \
+`timeclock-use-display-time' to see timeclock information"))
                 (add-hook 'display-time-hook 'timeclock-update-modeline))
 	    (setq timeclock-update-timer
 		  (run-at-time nil 60 'timeclock-update-modeline))))
@@ -589,6 +589,38 @@
 	(message "%s" string)
       string)))
 
+(defun timeclock-make-hours-explicit (old-default)
+  "Specify all workday lengths in `timeclock-file'.
+OLD-DEFAULT hours are set for every day that has no number indicated."
+  (interactive "P")
+  (if old-default (setq old-default (prefix-numeric-value old-default))
+    (error "timelog-make-hours-explicit requires an explicit argument"))
+  (let ((extant-timelog (find-buffer-visiting timeclock-file))
+	current-date)
+    (with-current-buffer (find-file-noselect timeclock-file t)
+      (unwind-protect
+	  (save-excursion
+	    (save-restriction
+	      (widen)
+	      (goto-char (point-min))
+	      (while (progn (skip-chars-forward "\n") (not (eobp)))
+		;; This is just a variant of `timeclock-moment-regexp'.
+		(unless (looking-at
+			 (concat "^\\([bhioO]\\) \\([0-9]+/[0-9]+/[0-9]+\\) "
+				 "\\([0-9]+:[0-9]+:[0-9]+\\)"))
+		  (error "Can't parse `%s'" timeclock-file))
+		(let ((this-date (match-string 2)))
+		  (unless (or (and current-date
+				   (string= this-date current-date))
+			      (string= (match-string 1) "h"))
+		    (insert (format "h %s %s %s\n" (match-string 2)
+				    (match-string 3) old-default)))
+		  (if (string-match "^[ih]" (match-string 1)) ; ignore logouts
+		      (setq current-date this-date)))
+		(forward-line))
+	      (save-buffer)))
+	(unless extant-timelog (kill-buffer (current-buffer)))))))
+
 ;;; Internal Functions:
 
 (defvar timeclock-project-list nil)
@@ -653,7 +685,7 @@
 If PROJECT is a string, it represents the project which the event is
 being logged for.  Normally only \"in\" events specify a project."
   (let ((extant-timelog (find-buffer-visiting timeclock-file)))
-    (with-current-buffer (find-file-noselect timeclock-file)
+    (with-current-buffer (find-file-noselect timeclock-file t)
       (save-excursion
 	(save-restriction
 	  (widen)
@@ -663,8 +695,7 @@
 	  (let ((now (current-time)))
 	    (insert code " "
 		    (format-time-string "%Y/%m/%d %H:%M:%S" now)
-		    (or (and project
-			     (stringp project)
+		    (or (and (stringp project)
 			     (> (length project) 0)
 			     (concat " " project))
 			"")
@@ -679,8 +710,8 @@
 			 timeclock-last-period)))
 	    (setq timeclock-last-event (list code now project)))))
       (save-buffer)
-      (run-hooks 'timeclock-event-hook)
-      (unless extant-timelog (kill-buffer (current-buffer))))))
+      (unless extant-timelog (kill-buffer (current-buffer)))))
+  (run-hooks 'timeclock-event-hook))
 
 (defvar timeclock-moment-regexp
   (concat "\\([bhioO]\\)\\s-+"
@@ -1152,8 +1183,8 @@
     (setcar (nthcdr 2 decoded) 0)
     (apply 'encode-time decoded)))
 
-(defun timeclock-geometric-mean (l)
-  "Compute the geometric mean of the values in the list L."
+(defun timeclock-mean (l)
+  "Compute the arithmetic mean of the values in the list L."
   (let ((total 0)
 	(count 0))
     (while l
@@ -1168,7 +1199,7 @@
   "Generate a summary report based on the current timelog file.
 By default, the report is in plain text, but if the optional argument
 HTML-P is non-nil, HTML markup is added."
-  (interactive)
+  (interactive "P")
   (let ((log (timeclock-log-data))
 	(today (timeclock-day-base)))
     (if html-p (insert "<p>"))
@@ -1300,14 +1331,10 @@
 	  ;; average statistics
 	  (let ((i 0) (l 5))
 	    (while (< i l)
-	      (aset time-in i (timeclock-geometric-mean
-			       (cdr (aref time-in i))))
-	      (aset time-out i (timeclock-geometric-mean
-				(cdr (aref time-out i))))
-	      (aset breaks i (timeclock-geometric-mean
-			      (cdr (aref breaks i))))
-	      (aset workday i (timeclock-geometric-mean
-			       (cdr (aref workday i))))
+	      (aset time-in i (timeclock-mean (cdr (aref time-in i))))
+	      (aset time-out i (timeclock-mean (cdr (aref time-out i))))
+	      (aset breaks i (timeclock-mean (cdr (aref breaks i))))
+	      (aset workday i (timeclock-mean (cdr (aref workday i))))
 	      (setq i (1+ i))))
 	  ;; Output the HTML table
 	  (insert "<tr>\n")
--- a/lisp/dabbrev.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/dabbrev.el	Sun May 20 03:12:22 2007 +0000
@@ -128,7 +128,7 @@
 		 (const :tag "off" nil))
   :group 'dabbrev)
 
-(defcustom dabbrev--eliminate-newlines t
+(defcustom dabbrev-eliminate-newlines t
   "*Non-nil means dabbrev should not insert newlines.
 Instead it converts them to spaces."
   :type 'boolean
@@ -913,10 +913,12 @@
 			  ((equal abbrev (downcase abbrev)) 'downcase)))))
 
     ;; Convert whitespace to single spaces.
-    (if dabbrev--eliminate-newlines
-	;; Start searching at end of ABBREV so that any whitespace
-	;; carried over from the existing text is not changed.
-	(let ((pos (length abbrev)))
+    (if dabbrev-eliminate-newlines
+	(let ((pos
+	       (if (equal abbrev " ") 0 (length abbrev))))
+	  ;; If ABBREV is real, search after the end of it.
+	  ;; If ABBREV is space and we are copying successive words,
+	  ;; search starting at the front.
 	  (while (string-match "[\n \t]+" expansion pos)
 	    (setq pos (1+ (match-beginning 0)))
 	    (setq expansion (replace-match " " nil nil expansion)))))
--- a/lisp/diff-mode.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/diff-mode.el	Sun May 20 03:12:22 2007 +0000
@@ -72,7 +72,7 @@
   :group 'diff-mode)
 
 (defcustom diff-jump-to-old-file nil
-  "*Non-nil means `diff-goto-source' jumps to the old file.
+  "Non-nil means `diff-goto-source' jumps to the old file.
 Else, it jumps to the new file."
   :type 'boolean
   :group 'diff-mode)
@@ -1276,7 +1276,7 @@
 	(if (> (- (car forw) orig) (- orig (car back))) back forw)
       (or back forw))))
 
-(defsubst diff-xor (a b) (if a (not b) b))
+(defsubst diff-xor (a b) (if a (if (not b) a) b))
 
 (defun diff-find-source-location (&optional other-file reverse)
   "Find out (BUF LINE-OFFSET POS SRC DST SWITCHED).
@@ -1358,8 +1358,15 @@
 With a prefix argument, REVERSE the hunk."
   (interactive "P")
   (destructuring-bind (buf line-offset pos old new &optional switched)
-      ;; If REVERSE go to the new file, otherwise go to the old.
-      (diff-find-source-location (not reverse) reverse)
+      ;; Sometimes we'd like to have the following behavior: if REVERSE go
+      ;; to the new file, otherwise go to the old.  But that means that by
+      ;; default we use the old file, which is the opposite of the default
+      ;; for diff-goto-source, and is thus confusing.  Also when you don't
+      ;; know about it it's pretty surprising.
+      ;; TODO: make it possible to ask explicitly for this behavior.
+      ;; 
+      ;; This is duplicated in diff-test-hunk.
+      (diff-find-source-location nil reverse)
     (cond
      ((null line-offset)
       (error "Can't find the text to patch"))
@@ -1403,8 +1410,7 @@
 With a prefix argument, try to REVERSE the hunk."
   (interactive "P")
   (destructuring-bind (buf line-offset pos src dst &optional switched)
-      ;; If REVERSE go to the new file, otherwise go to the old.
-      (diff-find-source-location (not reverse) reverse)
+      (diff-find-source-location nil reverse)
     (set-window-point (display-buffer buf) (+ (car pos) (cdr src)))
     (diff-hunk-status-msg line-offset (diff-xor reverse switched) t)))
 
--- a/lisp/diff.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/diff.el	Sun May 20 03:12:22 2007 +0000
@@ -124,9 +124,13 @@
 	(erase-buffer))
       (buffer-enable-undo (current-buffer))
       (diff-mode)
+      ;; Use below 2 vars for backward-compatibility.
+      (set (make-local-variable 'diff-old-file) old)
+      (set (make-local-variable 'diff-new-file) new)
+      (set (make-local-variable 'diff-extra-args) (list switches no-async))
       (set (make-local-variable 'revert-buffer-function)
-	   `(lambda (ignore-auto noconfirm)
-	      (diff ',old ',new ',switches ',no-async)))
+	   (lambda (ignore-auto noconfirm)
+             (apply 'diff diff-old-file diff-new-file diff-extra-args)))
       (set (make-local-variable 'diff-old-temp-file) old-alt)
       (set (make-local-variable 'diff-new-temp-file) new-alt)
       (setq default-directory thisdir)
@@ -186,5 +190,5 @@
 
 (provide 'diff)
 
-;;; arch-tag: 7de2c29b-7ea5-4b85-9b9d-72dd860de2bd
+;; arch-tag: 7de2c29b-7ea5-4b85-9b9d-72dd860de2bd
 ;;; diff.el ends here
--- a/lisp/emacs-lisp/advice.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/emacs-lisp/advice.el	Sun May 20 03:12:22 2007 +0000
@@ -2467,23 +2467,11 @@
   "Take a macro function DEFINITION and make a lambda out of it."
   `(cdr ,definition))
 
-;; There is no way to determine whether some subr is a special form or not,
-;; hence we need this list (which is probably out of date):
-(defvar ad-special-forms
-  (let ((tem '(and catch cond condition-case defconst defmacro
-		   defun defvar function if interactive let let*
-		   or prog1 prog2 progn quote save-current-buffer
-		   save-excursion save-restriction save-window-excursion
-		   setq setq-default unwind-protect while
-		   with-output-to-temp-buffer)))
-    ;; track-mouse could be void in some configurations.
-    (if (fboundp 'track-mouse)
-	(push 'track-mouse tem))
-    (mapcar 'symbol-function tem)))
-
-(defmacro ad-special-form-p (definition)
-  ;;"non-nil if DEFINITION is a special form."
-  (list 'memq definition 'ad-special-forms))
+(defun ad-special-form-p (definition)
+  "Non-nil iff DEFINITION is a special form."
+  (if (and (symbolp definition) (fboundp definition))
+      (setq definition (indirect-function definition)))
+  (and (subrp definition) (eq (cdr (subr-arity definition)) 'unevalled)))
 
 (defmacro ad-interactive-p (definition)
   ;;"non-nil if DEFINITION can be called interactively."
--- a/lisp/emacs-lisp/sregex.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/emacs-lisp/sregex.el	Sun May 20 03:12:22 2007 +0000
@@ -436,11 +436,11 @@
   or end of a word.
 
 - the symbol `bow'
-  Stands for \"\\\\\\=<\", matching the empty string at the beginning of a
+  Stands for \"\\\\=\\<\", matching the empty string at the beginning of a
   word.
 
 - the symbol `eow'
-  Stands for \"\\\\\\=>\", matching the empty string at the end of a word.
+  Stands for \"\\\\=\\>\", matching the empty string at the end of a word.
 
 - the symbol `wordchar'
   Stands for the regex \"\\\\w\", matching a word-constituent character
--- a/lisp/files.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/files.el	Sun May 20 03:12:22 2007 +0000
@@ -1924,7 +1924,7 @@
      ("\\.[sS]\\'" . asm-mode)
      ("\\.asm\\'" . asm-mode)
      ("[cC]hange\\.?[lL]og?\\'" . change-log-mode)
-     ("[cC]hange[lL]og[-.][0-9]+\\'" . change-log-mode)
+     ("[cC]hange[lL]og[-.][-0-9a-z]+\\'" . change-log-mode)
      ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
      ("\\.scm\\.[0-9]*\\'" . scheme-mode)
      ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
--- a/lisp/gnus/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/gnus/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,3 +1,8 @@
+2007-05-10  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus-art.el (gnus-article-mode): Fix comment about displaying
+	non-break space.
+
 2007-05-09  Didier Verna  <didier@xemacs.org>
 
 	* gnus-diary.el, nndiary.el: Remove the description comment (nndiary is
--- a/lisp/gnus/gnus-art.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/gnus/gnus-art.el	Sun May 20 03:12:22 2007 +0000
@@ -3925,7 +3925,8 @@
   (make-local-variable 'gnus-article-image-alist)
   (make-local-variable 'gnus-article-charset)
   (make-local-variable 'gnus-article-ignored-charsets)
-  ;; Prevent recent Emacsen from displaying non-break space as "\ ".
+  ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
+  ;; face.
   (set (make-local-variable 'nobreak-char-display) nil)
   (setq cursor-in-non-selected-windows nil)
   (gnus-set-default-directory)
--- a/lisp/hilit-chg.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/hilit-chg.el	Sun May 20 03:12:22 2007 +0000
@@ -790,17 +790,37 @@
   (interactive)
   ;; If not in active mode do nothing but don't complain because this
   ;; may be bound to a hook.
-  (if (eq highlight-changes-mode 'active)
-      (let ((after-change-functions nil))
-	;; ensure hilit-chg-list is made and up to date
-	(hilit-chg-make-list)
-	;; remove our existing overlays
-	(hilit-chg-hide-changes)
-	;; for each change text property, increment it
-	(hilit-chg-map-changes 'hilit-chg-bump-change)
-	;; and display them all if active
-	(if (eq highlight-changes-mode 'active)
-	    (hilit-chg-display-changes))))
+  (when (eq highlight-changes-mode 'active)
+    (let ((modified (buffer-modified-p))
+	  (inhibit-modification-hooks t))
+      ;; The `modified' related code tries to combine two goals: (1) Record the
+      ;; rotation in `buffer-undo-list' and (2) avoid setting the modified flag
+      ;; of the current buffer due to the rotation.  We do this by inserting (in
+      ;; `buffer-undo-list') entries restoring buffer-modified-p to nil before
+      ;; and after the entry for the rotation.
+      (unless modified
+	;; Install the "before" entry.
+	(setq buffer-undo-list
+	      (cons '(apply restore-buffer-modified-p nil)
+		    buffer-undo-list)))
+      (unwind-protect
+	  (progn
+	    ;; ensure hilit-chg-list is made and up to date
+	    (hilit-chg-make-list)
+	    ;; remove our existing overlays
+	    (hilit-chg-hide-changes)
+	    ;; for each change text property, increment it
+	    (hilit-chg-map-changes 'hilit-chg-bump-change)
+	    ;; and display them all if active
+	    (if (eq highlight-changes-mode 'active)
+		(hilit-chg-display-changes)))
+	(unless modified
+	  ;; Install the "after" entry.
+	  (setq buffer-undo-list
+		(cons '(apply restore-buffer-modified-p nil)
+		      buffer-undo-list))
+
+	  (restore-buffer-modified-p nil)))))
   ;; This always returns nil so it is safe to use in write-file-functions
   nil)
 
--- a/lisp/info.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/info.el	Sun May 20 03:12:22 2007 +0000
@@ -4074,7 +4074,8 @@
       ;; Fontify http and ftp references
       (goto-char (point-min))
       (when not-fontified-p
-        (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
+        (while (re-search-forward "\\(https?\\|ftp\\)://[^ \t\n\"`({<>})']+"
+                                  nil t)
           (add-text-properties (match-beginning 0) (match-end 0)
                                '(font-lock-face info-xref
                                                 mouse-face highlight
--- a/lisp/longlines.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/longlines.el	Sun May 20 03:12:22 2007 +0000
@@ -110,6 +110,7 @@
         (add-hook 'change-major-mode-hook 'longlines-mode-off nil t)
 	(add-hook 'before-revert-hook 'longlines-before-revert-hook nil t)
         (make-local-variable 'buffer-substring-filters)
+        (make-local-variable 'longlines-auto-wrap)
 	(set (make-local-variable 'isearch-search-fun-function)
 	     'longlines-search-function)
         (add-to-list 'buffer-substring-filters 'longlines-encode-string)
@@ -149,12 +150,10 @@
 	       (add-to-list 'message-indent-citation-function
 			    'longlines-decode-region t)))
 
+	(add-hook 'after-change-functions 'longlines-after-change-function nil t)
+	(add-hook 'post-command-hook 'longlines-post-command-function nil t)
         (when longlines-auto-wrap
-          (auto-fill-mode 0)
-          (add-hook 'after-change-functions
-                    'longlines-after-change-function nil t)
-          (add-hook 'post-command-hook
-                    'longlines-post-command-function nil t)))
+          (auto-fill-mode 0)))
     ;; Turn off longlines mode
     (setq buffer-file-format (delete 'longlines buffer-file-format))
     (if longlines-showing
@@ -365,29 +364,27 @@
 ;; Auto wrap
 
 (defun longlines-auto-wrap (&optional arg)
-  "Turn on automatic line wrapping, and wrap the entire buffer.
-With optional argument ARG, turn off line wrapping."
+  "Toggle automatic line wrapping.
+With optional argument ARG, turn on line wrapping if and only if ARG is positive.
+If automatic line wrapping is turned on, wrap the entire buffer."
   (interactive "P")
-  (remove-hook 'after-change-functions 'longlines-after-change-function t)
-  (remove-hook 'post-command-hook 'longlines-post-command-function t)
-  (if arg
-      (progn (setq longlines-auto-wrap nil)
-             (message "Auto wrap disabled."))
-    (setq longlines-auto-wrap t)
-    (add-hook 'after-change-functions
-              'longlines-after-change-function nil t)
-    (add-hook 'post-command-hook
-              'longlines-post-command-function nil t)
-    (let ((mod (buffer-modified-p)))
-      (longlines-wrap-region (point-min) (point-max))
-      (set-buffer-modified-p mod))
-    (message "Auto wrap enabled.")))
+  (and (null arg)
+       (null longlines-auto-wrap)
+       (setq arg 1))
+  (if (> (prefix-numeric-value arg) 0)
+      (let ((mod (buffer-modified-p)))
+	(setq longlines-auto-wrap t)
+	(longlines-wrap-region (point-min) (point-max))
+	(set-buffer-modified-p mod)
+	(message "Auto wrap enabled."))
+    (setq longlines-auto-wrap nil)
+    (message "Auto wrap disabled.")))
 
 (defun longlines-after-change-function (beg end len)
   "Update `longlines-wrap-beg' and `longlines-wrap-end'.
 This is called by `after-change-functions' to keep track of the region
 that has changed."
-  (unless undo-in-progress
+  (when (and longlines-auto-wrap (not undo-in-progress))
     (setq longlines-wrap-beg
           (if longlines-wrap-beg (min longlines-wrap-beg beg) beg))
     (setq longlines-wrap-end
@@ -396,7 +393,7 @@
 (defun longlines-post-command-function ()
   "Perform line wrapping on the parts of the buffer that have changed.
 This is called by `post-command-hook' after each command."
-  (when longlines-wrap-beg
+  (when (and longlines-auto-wrap longlines-wrap-beg)
     (if (or (eq this-command 'yank)
 	    (eq this-command 'yank-pop))
 	(longlines-decode-region (point) (mark t)))
--- a/lisp/man.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/man.el	Sun May 20 03:12:22 2007 +0000
@@ -1296,7 +1296,9 @@
 	(forward-line 1))
     (if (re-search-forward Man-heading-regexp (point-max) t n)
 	(beginning-of-line)
-      (goto-char (point-max)))))
+      (goto-char (point-max))
+      ;; The last line doesn't belong to any section.
+      (forward-line -1))))
 
 (defun Man-previous-section (n)
   "Move point to Nth previous section (default 1)."
--- a/lisp/newcomment.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/newcomment.el	Sun May 20 03:12:22 2007 +0000
@@ -97,10 +97,10 @@
 ;;;###autoload
 (defcustom comment-column 32
   "Column to indent right-margin comments to.
-Each mode establishes a different default value for this variable; you
+Each mode may establish a different default value for this variable; you
 can set the value for a particular mode using that mode's hook.
-Comments might be indented to a value smaller than this in order
-not to go beyond `comment-fill-column'."
+Comments might be indented to a different value in order not to go beyond
+`comment-fill-column' or in order to align them with surrounding comments."
   :type 'integer
   :group 'comment)
 (make-variable-buffer-local 'comment-column)
@@ -491,16 +491,24 @@
         (goto-char (point-min))
         (re-search-forward (concat comment-end-skip "\\'") nil t))
       (goto-char (match-beginning 0)))
-     ;; comment-end-skip not found.  Maybe we're at EOB which implicitly
-     ;; closes the comment.
-     ((eobp) (skip-syntax-backward " "))
-     (t
-      ;; else comment-end-skip was not found probably because it was not
-      ;; set right.  Since \\s> should catch the single-char case, we'll
-      ;; blindly assume we're at the end of a two-char comment-end.
+     ;; comment-end-skip not found probably because it was not set
+     ;; right.  Since \\s> should catch the single-char case, let's
+     ;; check that we're looking at a two-char comment ender.
+     ((not (or (<= (- (point-max) (line-beginning-position)) 1)
+               (zerop (logand (car (syntax-after (- (point) 1)))
+                              ;; Here we take advantage of the fact that
+                              ;; the syntax class " " is encoded to 0,
+                              ;; so "  4" gives us just the 4 bit.
+                              (car (string-to-syntax "  4"))))
+               (zerop (logand (car (syntax-after (- (point) 2)))
+                              (car (string-to-syntax "  3"))))))
       (backward-char 2)
       (skip-chars-backward (string (char-after)))
-      (skip-syntax-backward " ")))))
+      (skip-syntax-backward " "))
+     ;; No clue what's going on: maybe we're really not right after the
+     ;; end of a comment.  Maybe we're at the "end" because of EOB rather
+     ;; than because of a marker.
+     (t (skip-syntax-backward " ")))))
 
 ;;;;
 ;;;; Commands
@@ -516,6 +524,58 @@
 	      (and (> comment-add 0) (looking-at "\\s<\\(\\S<\\|\\'\\)")))
       comment-column)))
 
+(defun comment-choose-indent (&optional indent)
+  "Choose the indentation to use for a right-hand-side comment.
+The criteria are (in this order):
+- try to keep the comment's text within `comment-fill-column'.
+- try to align with surrounding comments.
+- prefer INDENT (or `comment-column' if nil).
+Point is expected to be at the start of the comment."
+  (unless indent (setq indent comment-column))
+  ;; Avoid moving comments past the fill-column.
+  (let ((max (+ (current-column)
+                (- (or comment-fill-column fill-column)
+                   (save-excursion (end-of-line) (current-column)))))
+        (other nil)
+        (min (save-excursion (skip-chars-backward " \t")
+                             (1+ (current-column)))))
+    ;; Fix up the range.
+    (if (< max min) (setq max min))
+    ;; Don't move past the fill column.
+    (if (<= max indent) (setq indent max))
+    ;; We can choose anywhere between min..max.
+    ;; Let's try to align to a comment on the previous line.
+    (save-excursion
+      (when (and (zerop (forward-line -1))
+                 (setq other (comment-search-forward
+                              (line-end-position) t)))
+        (goto-char other) (setq other (current-column))))
+    (if (and other (<= other max) (>= other min))
+        ;; There is a comment and it's in the range: bingo!
+        other
+      ;; Can't align to a previous comment: let's try to align to comments
+      ;; on the following lines, then.  These have not been re-indented yet,
+      ;; so we can't directly align ourselves with them.  All we do is to try
+      ;; and choose an indentation point with which they will be able to
+      ;; align themselves.
+      (save-excursion
+        (while (and (zerop (forward-line 1))
+                    (setq other (comment-search-forward
+                                 (line-end-position) t)))
+          (goto-char other)
+          (let ((omax (+ (current-column)
+                         (- (or comment-fill-column fill-column)
+                            (save-excursion (end-of-line) (current-column)))))
+                (omin (save-excursion (skip-chars-backward " \t")
+                                      (1+ (current-column)))))
+            (if (and (>= omax min) (<= omin max))
+                (progn (setq min (max omin min))
+                       (setq max (min omax max)))
+              ;; Can't align with this anyway, so exit the loop.
+              (goto-char (point-max))))))
+      ;; Return the closest point to indent within min..max.
+      (max min (min max indent)))))
+
 ;;;###autoload
 (defun comment-indent (&optional continue)
   "Indent this line's comment to `comment-column', or insert an empty comment.
@@ -569,38 +629,9 @@
       (if (not indent)
 	  ;; comment-indent-function refuses: delegate to line-indent.
 	  (indent-according-to-mode)
-	;; If the comment is at the left of code, adjust the indentation.
+	;; If the comment is at the right of code, adjust the indentation.
 	(unless (save-excursion (skip-chars-backward " \t") (bolp))
-	  ;; Avoid moving comments past the fill-column.
-	  (let ((max (+ (current-column)
-			(- (or comment-fill-column fill-column)
-			   (save-excursion (end-of-line) (current-column))))))
-	    (if (<= max indent)
-		(setq indent max)	;Don't move past the fill column.
-	      ;; We can choose anywhere between indent..max.
-	      ;; Let's try to align to a comment on the previous line.
-	      (let ((other nil)
-		    (min (max indent
-			      (save-excursion (skip-chars-backward " \t")
-					      (1+ (current-column))))))
-		(save-excursion
-		  (when (and (zerop (forward-line -1))
-			     (setq other (comment-search-forward
-					 (line-end-position) t)))
-		    (goto-char other) (setq other (current-column))))
-		(if (and other (<= other max) (>= other min))
-		    ;; There is a comment and it's in the range: bingo.
-		    (setq indent other)
-		  ;; Let's try to align to a comment on the next line, then.
-		  (let ((other nil))
-		    (save-excursion
-		      (when (and (zerop (forward-line 1))
-				 (setq other (comment-search-forward
-					     (line-end-position) t)))
-			(goto-char other) (setq other (current-column))))
-		    (if (and other (<= other max) (> other min))
-			;; There is a comment and it's in the range: bingo.
-			(setq indent other))))))))
+          (setq indent (comment-choose-indent indent)))
 	;; Update INDENT to leave at least one space
 	;; after other nonwhite text on the line.
 	(save-excursion
--- a/lisp/printing.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/printing.el	Sun May 20 03:12:22 2007 +0000
@@ -6,11 +6,11 @@
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Keywords: wp, print, PostScript
-;; Version: 6.8.4
+;; Version: 6.9
 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
 
-(defconst pr-version "6.8.4"
-  "printing.el, v 6.8.4 <2005/06/11 vinicius>
+(defconst pr-version "6.9"
+  "printing.el, v 6.9 <2007/02/11 vinicius>
 
 Please send all bug fixes and enhancements to
 	Vinicius Jose Latorre <viniciusjl@ig.com.br>
@@ -1093,46 +1093,456 @@
 	  (set-default-file-modes umask)))))
 
 
-;; GNU Emacs
-(defalias 'pr-e-frame-char-height    'frame-char-height)
-(defalias 'pr-e-frame-char-width     'frame-char-width)
-(defalias 'pr-e-mouse-pixel-position 'mouse-pixel-position)
-;; XEmacs
-(defalias 'pr-x-add-submenu             'add-submenu)
-(defalias 'pr-x-event-function          'event-function)
-(defalias 'pr-x-event-object            'event-object)
-(defalias 'pr-x-find-menu-item          'find-menu-item)
-(defalias 'pr-x-font-height             'font-height)
-(defalias 'pr-x-font-width              'font-width)
-(defalias 'pr-x-get-popup-menu-response 'get-popup-menu-response)
-(defalias 'pr-x-make-event              'make-event)
-(defalias 'pr-x-misc-user-event-p       'misc-user-event-p)
-(defalias 'pr-x-relabel-menu-item       'relabel-menu-item)
-(defalias 'pr-x-event-x-pixel           'event-x-pixel)
-(defalias 'pr-x-event-y-pixel           'event-y-pixel)
+
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; XEmacs Definitions
+
 
 (cond
  ((featurep 'xemacs)			; XEmacs
-  (defvar current-menubar     nil)
-  (defvar current-mouse-event nil)
-  (defvar zmacs-region-stays  nil)
+  ;; XEmacs
   (defalias 'pr-f-set-keymap-parents 'set-keymap-parents)
   (defalias 'pr-f-set-keymap-name    'set-keymap-name)
+
+  ;; XEmacs
   (defun pr-f-read-string (prompt initial history default)
     (let ((str (read-string prompt initial)))
       (if (and str (not (string= str "")))
 	  str
 	default)))
+
+  ;; XEmacs
+  (defvar zmacs-region-stays  nil)
+
+  ;; XEmacs
   (defun pr-keep-region-active ()
-    (setq zmacs-region-stays t)))
-
+    (setq zmacs-region-stays t))
+
+  ;; XEmacs
+  (defun pr-region-active-p ()
+    (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p)))
+
+  ;; XEmacs
+  (defun pr-menu-char-height ()
+    (font-height (face-font 'default)))
+
+  ;; XEmacs
+  (defun pr-menu-char-width ()
+    (font-width (face-font 'default)))
+
+  ;; XEmacs
+  (defmacro pr-xemacs-global-menubar (&rest body)
+    `(save-excursion
+       (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
+	 ;; be sure to access global menubar
+	 (set-buffer temp)
+	 ,@body
+	 (kill-buffer temp))))
+
+  ;; XEmacs
+  (defun pr-global-menubar (pr-menu-spec)
+    ;; Menu binding
+    (pr-xemacs-global-menubar
+     (add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
+    (setq pr-menu-print-item nil))
+
+  ;; XEmacs
+  (defvar current-mouse-event nil)
+  (defun pr-menu-position (entry index horizontal)
+    (make-event
+     'button-release
+     (list 'button 1
+	   'x (- (event-x-pixel current-mouse-event) ; X
+		 (* horizontal pr-menu-char-width))
+	   'y (- (event-y-pixel current-mouse-event) ; Y
+		 (* (pr-menu-index entry index) pr-menu-char-height)))))
+
+  (defvar pr-menu-position nil)
+  (defvar pr-menu-state nil)
+
+  ;; XEmacs
+  (defvar current-menubar nil)		; to avoid compilation gripes
+  (defun pr-menu-lookup (path)
+    (car (find-menu-item current-menubar (cons "Printing" path))))
+
+  ;; XEmacs
+  (defun pr-menu-lock (entry index horizontal state path)
+    (when pr-menu-lock
+      (or (and pr-menu-position (eq state pr-menu-state))
+	  (setq pr-menu-position (pr-menu-position entry index horizontal)
+		pr-menu-state    state))
+      (let* ((menu   (pr-menu-lookup path))
+	     (result (get-popup-menu-response menu pr-menu-position)))
+	(and (misc-user-event-p result)
+	     (funcall (event-function result)
+		      (event-object result))))
+      (setq pr-menu-position nil)))
+
+  ;; XEmacs
+  (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
+
+  ;; XEmacs
+  (defvar pr-ps-name-old     "PostScript Printers")
+  (defvar pr-txt-name-old    "Text Printers")
+  (defvar pr-ps-utility-old  "PostScript Utility")
+  (defvar pr-even-or-odd-old "Print All Pages")
+
+  ;; XEmacs
+  (defun pr-do-update-menus (&optional force)
+    (pr-menu-alist pr-ps-printer-alist
+		   'pr-ps-name
+		   'pr-menu-set-ps-title
+		   '("Printing")
+		   'pr-ps-printer-menu-modified
+		   force
+		   pr-ps-name-old
+		   'postscript 2)
+    (pr-menu-alist pr-txt-printer-alist
+		   'pr-txt-name
+		   'pr-menu-set-txt-title
+		   '("Printing")
+		   'pr-txt-printer-menu-modified
+		   force
+		   pr-txt-name-old
+		   'text 2)
+    (let ((save-var pr-ps-utility-menu-modified))
+      (pr-menu-alist pr-ps-utility-alist
+		     'pr-ps-utility
+		     'pr-menu-set-utility-title
+		     '("Printing" "PostScript Print" "File")
+		     'save-var
+		     force
+		     pr-ps-utility-old
+		     nil 1))
+    (pr-menu-alist pr-ps-utility-alist
+		   'pr-ps-utility
+		   'pr-menu-set-utility-title
+		   '("Printing" "PostScript Preview" "File")
+		   'pr-ps-utility-menu-modified
+		   force
+		   pr-ps-utility-old
+		   nil 1)
+    (pr-even-or-odd-pages ps-even-or-odd-pages force))
+
+  ;; XEmacs
+  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
+			      entry index)
+    (when (and alist (or force (symbol-value modified-sym)))
+      (pr-xemacs-global-menubar
+       (add-submenu menu-path
+		    (pr-menu-create name alist var-sym
+				    fun entry index)))
+      (funcall fun (symbol-value var-sym))
+      (set modified-sym nil)))
+
+  ;; XEmacs
+  (defun pr-relabel-menu-item (newname var-sym)
+    (pr-xemacs-global-menubar
+     (relabel-menu-item
+      (list "Printing" (symbol-value var-sym))
+      newname)
+     (set var-sym newname)))
+
+  ;; XEmacs
+  (defun pr-menu-set-ps-title (value &optional item entry index)
+    (pr-relabel-menu-item (format "PostScript Printer: %s" value)
+			  'pr-ps-name-old)
+    (pr-ps-set-printer value)
+    (and index
+	 (pr-menu-lock entry index 12 'toggle nil)))
+
+  ;; XEmacs
+  (defun pr-menu-set-txt-title (value &optional item entry index)
+    (pr-relabel-menu-item (format "Text Printer: %s" value)
+			  'pr-txt-name-old)
+    (pr-txt-set-printer value)
+    (and index
+	 (pr-menu-lock entry index 12 'toggle nil)))
+
+  ;; XEmacs
+  (defun pr-menu-set-utility-title (value &optional item entry index)
+    (pr-xemacs-global-menubar
+     (let ((newname (format "%s" value)))
+       (relabel-menu-item
+	(list "Printing" "PostScript Print" "File" pr-ps-utility-old)
+	newname)
+       (relabel-menu-item
+	(list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
+	newname)
+       (setq pr-ps-utility-old newname)))
+    (pr-ps-set-utility value)
+    (and index
+	 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
+
+  ;; XEmacs
+  (defun pr-even-or-odd-pages (value &optional no-lock)
+    (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
+			  'pr-even-or-odd-old)
+    (setq ps-even-or-odd-pages value)
+    (or no-lock
+	(pr-menu-lock 'postscript-options 8 12 'toggle nil)))
+
+  )
  (t					; GNU Emacs
-  (defvar deactivate-mark nil)
+  ;; Do nothing
+  ))					; end cond featurep
+
+
+
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; GNU Emacs Definitions
+
+
+(cond
+ ((featurep 'xemacs)			; XEmacs
+  ;; Do nothing
+  )
+ (t					; GNU Emacs
+  ;; GNU Emacs
   (defalias 'pr-f-set-keymap-parents 'set-keymap-parent)
   (defalias 'pr-f-set-keymap-name    'ignore)
   (defalias 'pr-f-read-string        'read-string)
+
+  ;; GNU Emacs
+  (defvar deactivate-mark nil)
+
+  ;; GNU Emacs
   (defun pr-keep-region-active ()
-    (setq deactivate-mark nil))))
+    (setq deactivate-mark nil))
+
+  ;; GNU Emacs
+  (defun pr-region-active-p ()
+    (and pr-auto-region transient-mark-mode mark-active))
+
+  ;; GNU Emacs
+  (defun pr-menu-char-height ()
+    (frame-char-height))
+
+  ;; GNU Emacs
+  (defun pr-menu-char-width ()
+    (frame-char-width))
+
+  ;; GNU Emacs
+  ;; Menu binding
+  (require 'easymenu)
+  ;; Replace existing "print" item by "Printing" item.
+  ;; If you're changing this file, you'll load it a second,
+  ;; third... time, but "print" item exists only in the first load.
+  (eval-and-compile
+    (cond
+     ;; GNU Emacs 20
+     ((< emacs-major-version 21)
+      (defun pr-global-menubar (pr-menu-spec)
+	(easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item)
+	(when pr-menu-print-item
+	  (easy-menu-remove-item nil '("tools") pr-menu-print-item)
+	  (setq pr-menu-print-item nil
+		pr-menu-bar (vector 'menu-bar 'tools
+				    (pr-get-symbol "Printing")))))
+      )
+     ;; GNU Emacs 21 & 22
+     (t
+      (defun pr-global-menubar (pr-menu-spec)
+	(let ((menu-file (if (= emacs-major-version 21)
+			     '("menu-bar" "files") ; GNU Emacs 21
+			   '("menu-bar" "file")))) ; GNU Emacs 22 or higher
+	  (cond
+	   (pr-menu-print-item
+	    (easy-menu-add-item global-map menu-file
+				(easy-menu-create-menu "Print" pr-menu-spec)
+				"print-buffer")
+	    (dolist (item '("print-buffer"          "print-region"
+			    "ps-print-buffer-faces" "ps-print-region-faces"
+			    "ps-print-buffer"       "ps-print-region"))
+	      (easy-menu-remove-item global-map menu-file item))
+	    (setq pr-menu-print-item nil
+		  pr-menu-bar (vector 'menu-bar
+				      (pr-get-symbol (nth 1 menu-file))
+				      (pr-get-symbol "Print"))))
+	   (t
+	    (easy-menu-add-item global-map menu-file
+				(easy-menu-create-menu "Print" pr-menu-spec)))
+	   )))
+      )))
+
+  (eval-and-compile
+    (cond
+     (ps-windows-system
+      ;; GNU Emacs for Windows 9x/NT
+      (defun pr-menu-position (entry index horizontal)
+	(let ((pos (cdr (mouse-pixel-position))))
+	  (list
+	   (list (or (car pos) 0)	; X
+		 (- (or (cdr pos) 0)	; Y
+		    (* (pr-menu-index entry index) pr-menu-char-height)))
+	   (selected-frame))))		; frame
+      )
+     (t
+      ;; GNU Emacs
+      (defun pr-menu-position (entry index horizontal)
+	(let ((pos (cdr (mouse-pixel-position))))
+	  (list
+	   (list (- (or (car pos) 0)	; X
+		    (* horizontal pr-menu-char-width))
+		 (- (or (cdr pos) 0)	; Y
+		    (* (pr-menu-index entry index) pr-menu-char-height)))
+	   (selected-frame))))		; frame
+      )))
+
+  (defvar pr-menu-position nil)
+  (defvar pr-menu-state nil)
+
+  ;; GNU Emacs
+  (defun pr-menu-lookup (path)
+    (lookup-key global-map
+		(if path
+		    (vconcat pr-menu-bar
+			     (mapcar 'pr-get-symbol
+				     (if (listp path)
+					 path
+				       (list path))))
+		  pr-menu-bar)))
+
+  ;; GNU Emacs
+  (defun pr-menu-lock (entry index horizontal state path)
+    (when pr-menu-lock
+      (or (and pr-menu-position (eq state pr-menu-state))
+	  (setq pr-menu-position (pr-menu-position entry index horizontal)
+		pr-menu-state    state))
+      (let* ((menu   (pr-menu-lookup path))
+	     (result (x-popup-menu pr-menu-position menu)))
+	(and result
+	     (let ((command (lookup-key menu (vconcat result))))
+	       (if (fboundp command)
+		   (funcall command)
+		 (eval command)))))
+      (setq pr-menu-position nil)))
+
+  ;; GNU Emacs
+  (defalias 'pr-update-mode-line 'force-mode-line-update)
+
+  ;; GNU Emacs
+  (defun pr-do-update-menus (&optional force)
+    (pr-menu-alist pr-ps-printer-alist
+		   'pr-ps-name
+		   'pr-menu-set-ps-title
+		   "PostScript Printers"
+		   'pr-ps-printer-menu-modified
+		   force
+		   "PostScript Printers"
+		   'postscript 2)
+    (pr-menu-alist pr-txt-printer-alist
+		   'pr-txt-name
+		   'pr-menu-set-txt-title
+		   "Text Printers"
+		   'pr-txt-printer-menu-modified
+		   force
+		   "Text Printers"
+		   'text 2)
+    (let ((save-var pr-ps-utility-menu-modified))
+      (pr-menu-alist pr-ps-utility-alist
+		     'pr-ps-utility
+		     'pr-menu-set-utility-title
+		     '("PostScript Print" "File" "PostScript Utility")
+		     'save-var
+		     force
+		     "PostScript Utility"
+		     nil 1))
+    (pr-menu-alist pr-ps-utility-alist
+		   'pr-ps-utility
+		   'pr-menu-set-utility-title
+		   '("PostScript Preview" "File" "PostScript Utility")
+		   'pr-ps-utility-menu-modified
+		   force
+		   "PostScript Utility"
+		   nil 1)
+    (pr-even-or-odd-pages ps-even-or-odd-pages force))
+
+  ;; GNU Emacs
+  (defun pr-menu-get-item (name-list)
+    ;; NAME-LIST is a string or a list of strings.
+    (or (listp name-list)
+	(setq name-list (list name-list)))
+    (and name-list
+	 (let* ((reversed (reverse name-list))
+		(name (pr-get-symbol (car reversed)))
+		(path (nreverse (cdr reversed)))
+		(menu (lookup-key
+		       global-map
+		       (vconcat pr-menu-bar
+				(mapcar 'pr-get-symbol path)))))
+	   (assq name (nthcdr 2 menu)))))
+
+  ;; GNU Emacs
+  (defvar pr-temp-menu nil)
+
+  ;; GNU Emacs
+  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
+			      entry index)
+    (when (and alist (or force (symbol-value modified-sym)))
+      (easy-menu-define pr-temp-menu nil ""
+	(pr-menu-create name alist var-sym fun entry index))
+      (let ((item (pr-menu-get-item menu-path)))
+	(and item
+	     (let* ((binding     (nthcdr 3 item))
+		    (key-binding (cdr binding)))
+	       (setcar binding pr-temp-menu)
+	       (and key-binding (listp (car key-binding))
+		    (setcdr binding (cdr key-binding)))	; skip KEY-BINDING
+	       (funcall fun (symbol-value var-sym) item))))
+      (set modified-sym nil)))
+
+  ;; GNU Emacs
+  (defun pr-menu-set-item-name (item name)
+    (and item
+	 (setcar (nthcdr 2 item) name))) ; ITEM-NAME
+
+  ;; GNU Emacs
+  (defun pr-menu-set-ps-title (value &optional item entry index)
+    (pr-menu-set-item-name (or item
+			       (pr-menu-get-item "PostScript Printers"))
+			   (format "PostScript Printer: %s" value))
+    (pr-ps-set-printer value)
+    (and index
+	 (pr-menu-lock entry index 12 'toggle nil)))
+
+  ;; GNU Emacs
+  (defun pr-menu-set-txt-title (value &optional item entry index)
+    (pr-menu-set-item-name (or item
+			       (pr-menu-get-item "Text Printers"))
+			   (format "Text Printer: %s" value))
+    (pr-txt-set-printer value)
+    (and index
+	 (pr-menu-lock entry index 12 'toggle nil)))
+
+  ;; GNU Emacs
+  (defun pr-menu-set-utility-title (value &optional item entry index)
+    (let ((name (symbol-name value)))
+      (if item
+	  (pr-menu-set-item-name item name)
+	(pr-menu-set-item-name
+	 (pr-menu-get-item
+	  '("PostScript Print"   "File" "PostScript Utility"))
+	 name)
+	(pr-menu-set-item-name
+	 (pr-menu-get-item
+	  '("PostScript Preview" "File" "PostScript Utility"))
+	 name)))
+    (pr-ps-set-utility value)
+    (and index
+	 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
+
+  ;; GNU Emacs
+  (defun pr-even-or-odd-pages (value &optional no-lock)
+    (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
+			   (cdr (assq value pr-even-or-odd-alist)))
+    (setq ps-even-or-odd-pages value)
+    (or no-lock
+	(pr-menu-lock 'postscript-options 8 12 'toggle nil)))
+
+  ))					; end cond featurep
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1592,7 +2002,7 @@
 
 		   (VARIABLE . VALUE)
 
-		That associates VARIABLE with VALUE.  when this entry is
+		Which associates VARIABLE with VALUE.  When this entry is
 		selected, it's executed the following command:
 
 		   (set VARIABLE (eval VALUE))
@@ -2147,7 +2557,7 @@
 
 		   (VARIABLE-SYM . VALUE)
 
-		That associates VARIABLE-SYM with VALUE.  when this entry is
+		Which associates VARIABLE-SYM with VALUE.  When this entry is
 		selected, it's executed the following command:
 
 		   (set (make-local-variable VARIABLE-SYM) (eval VALUE))
@@ -2327,7 +2737,7 @@
 
 		   (VARIABLE . VALUE)
 
-		That associates VARIABLE with VALUE.  when this entry is
+		Which associates VARIABLE with VALUE.  When this entry is
 		selected, it's executed the following command:
 
 		   (set VARIABLE (eval VALUE))
@@ -2452,11 +2862,7 @@
   :group 'printing)
 
 
-(defcustom pr-menu-char-height
-  (cond ((featurep 'xemacs)		; XEmacs
-	 (pr-x-font-height (face-font 'default)))
-	(t				; GNU Emacs
-	 (pr-e-frame-char-height)))
+(defcustom pr-menu-char-height (pr-menu-char-height)
   "*Specify menu char height in pixels.
 
 This variable is used to guess which vertical position should be locked the
@@ -2468,11 +2874,7 @@
   :group 'printing)
 
 
-(defcustom pr-menu-char-width
-  (cond ((featurep 'xemacs)		; XEmacs
-	 (pr-x-font-width (face-font 'default)))
-	(t				; GNU Emacs
-	 (pr-e-frame-char-width)))
+(defcustom pr-menu-char-width (pr-menu-char-width)
   "*Specify menu char width in pixels.
 
 This variable is used to guess which horizontal position should be locked the
@@ -2544,7 +2946,7 @@
 
 		   (VARIABLE . VALUE)
 
-		That associates VARIABLE with VALUE.  when this entry is
+		Which associates VARIABLE with VALUE.  When this entry is
 		selected, it's executed the following command:
 
 		  * If LOCAL is non-nil:
@@ -2772,15 +3174,6 @@
 ;; Keys & Menus
 
 
-(defmacro pr-xemacs-global-menubar (&rest body)
-  `(save-excursion
-     (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
-       ;; be sure to access global menubar
-       (set-buffer temp)
-       ,@body
-       (kill-buffer temp))))
-
-
 (defsubst pr-visible-p (key)
   (memq key pr-visible-entry-list))
 
@@ -2802,16 +3195,6 @@
       'easy-menu-intern
     (lambda (s) (if (stringp s) (intern s) s))))
 
-(cond
- ((featurep 'xemacs)			; XEmacs
-  (defvar zmacs-region-stays nil)	; to avoid compilation gripes
-  (defun pr-region-active-p ()
-    (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))))
-
- (t					; GNU Emacs
-  (defun pr-region-active-p ()
-    (and pr-auto-region transient-mark-mode mark-active))))
-
 
 (defconst pr-menu-spec
   ;; Menu mapping:
@@ -3070,51 +3453,7 @@
 
 Calls `pr-update-menus' to adjust menus."
   (interactive)
-  (cond
-   ((featurep 'xemacs)			; XEmacs
-    ;; Menu binding
-    (pr-xemacs-global-menubar
-     (pr-x-add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
-    (setq pr-menu-print-item nil))
-
-
-   (t					; GNU Emacs
-    ;; Menu binding
-    (require 'easymenu)
-    ;; Replace existing "print" item by "Printing" item.
-    ;; If you're changing this file, you'll load it a second,
-    ;; third... time, but "print" item exists only in the first load.
-    (cond
-     ;; Emacs 20
-     ((< emacs-major-version 21)
-      (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item)
-      (when pr-menu-print-item
-	(easy-menu-remove-item nil '("tools") pr-menu-print-item)
-	(setq pr-menu-print-item nil
-	      pr-menu-bar (vector 'menu-bar 'tools
-				  (pr-get-symbol "Printing")))))
-     ;; Emacs 21 & 22
-     (t
-      (let ((menu-file (if (= emacs-major-version 21)
-			   '("menu-bar" "files") ; Emacs 21
-			 '("menu-bar" "file")))) ; Emacs 22 or higher
-	(cond
-	 (pr-menu-print-item
-	  (easy-menu-add-item global-map menu-file
-			      (easy-menu-create-menu "Print" pr-menu-spec)
-			      "print-buffer")
-	  (dolist (item '("print-buffer"          "print-region"
-			  "ps-print-buffer-faces" "ps-print-region-faces"
-			  "ps-print-buffer"       "ps-print-region"))
-	    (easy-menu-remove-item global-map menu-file item))
-	  (setq pr-menu-print-item nil
-		pr-menu-bar (vector 'menu-bar
-				    (pr-get-symbol (nth 1 menu-file))
-				    (pr-get-symbol "Print"))))
-	 (t
-	  (easy-menu-add-item global-map menu-file
-			      (easy-menu-create-menu "Print" pr-menu-spec)))
-	 ))))))
+  (pr-global-menubar pr-menu-spec)
   (pr-update-menus t))
 
 
@@ -4841,94 +5180,6 @@
   (+ index 2))
 
 
-(defvar pr-menu-position nil)
-(defvar pr-menu-state nil)
-
-
-(cond
- ((featurep 'xemacs)
-  ;; XEmacs
-  (defvar current-mouse-event nil)	; to avoid compilation gripes
-  (defun pr-menu-position (entry index horizontal)
-    (pr-x-make-event
-     'button-release
-     (list 'button 1
-	   'x (- (pr-x-event-x-pixel current-mouse-event) ; X
-		 (* horizontal pr-menu-char-width))
-	   'y (- (pr-x-event-y-pixel current-mouse-event) ; Y
-		 (* (pr-menu-index entry index) pr-menu-char-height)))))
-  )
- (ps-windows-system
-  ;; GNU Emacs for Windows 9x/NT
-  (defun pr-menu-position (entry index horizontal)
-    (let ((pos (cdr (pr-e-mouse-pixel-position))))
-      (list
-       (list (or (car pos) 0)		; X
-	     (- (or (cdr pos) 0)	; Y
-		(* (pr-menu-index entry index) pr-menu-char-height)))
-       (selected-frame))))		; frame
-  )
- (t
-  ;; GNU Emacs
-  (defun pr-menu-position (entry index horizontal)
-    (let ((pos (cdr (pr-e-mouse-pixel-position))))
-      (list
-       (list (- (or (car pos) 0)	; X
-		(* horizontal pr-menu-char-width))
-	     (- (or (cdr pos) 0)	; Y
-		(* (pr-menu-index entry index) pr-menu-char-height)))
-       (selected-frame))))		; frame
-  ))
-
-(cond
- ((featurep 'xemacs)
-  ;; XEmacs
-  (defvar current-menubar nil)		; to avoid compilation gripes
-  (defun pr-menu-lookup (path)
-    (car (pr-x-find-menu-item current-menubar (cons "Printing" path))))
-
-  ;; XEmacs
-  (defun pr-menu-lock (entry index horizontal state path)
-    (when pr-menu-lock
-      (or (and pr-menu-position (eq state pr-menu-state))
-	  (setq pr-menu-position (pr-menu-position entry index horizontal)
-		pr-menu-state    state))
-      (let* ((menu   (pr-menu-lookup path))
-	     (result (pr-x-get-popup-menu-response menu pr-menu-position)))
-	(and (pr-x-misc-user-event-p result)
-	     (funcall (pr-x-event-function result)
-		      (pr-x-event-object result))))
-      (setq pr-menu-position nil))))
-
-
- (t
-  ;; GNU Emacs
-  (defun pr-menu-lookup (path)
-    (lookup-key global-map
-		(if path
-		    (vconcat pr-menu-bar
-			     (mapcar 'pr-get-symbol
-				     (if (listp path)
-					 path
-				       (list path))))
-		  pr-menu-bar)))
-
-  ;; GNU Emacs
-  (defun pr-menu-lock (entry index horizontal state path)
-    (when pr-menu-lock
-      (or (and pr-menu-position (eq state pr-menu-state))
-	  (setq pr-menu-position (pr-menu-position entry index horizontal)
-		pr-menu-state    state))
-      (let* ((menu   (pr-menu-lookup path))
-	     (result (x-popup-menu pr-menu-position menu)))
-	(and result
-	     (let ((command (lookup-key menu (vconcat result))))
-	       (if (fboundp command)
-		   (funcall command)
-		 (eval command)))))
-      (setq pr-menu-position nil)))))
-
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Printer & Utility Selection
 
@@ -4991,237 +5242,6 @@
 	 alist)))
 
 
-(cond
- ((featurep 'xemacs)
-  ;; XEmacs
-  (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
-
-  ;; XEmacs
-  (defvar pr-ps-name-old     "PostScript Printers")
-  (defvar pr-txt-name-old    "Text Printers")
-  (defvar pr-ps-utility-old  "PostScript Utility")
-  (defvar pr-even-or-odd-old "Print All Pages")
-
-  ;; XEmacs
-  (defun pr-do-update-menus (&optional force)
-    (pr-menu-alist pr-ps-printer-alist
-		   'pr-ps-name
-		   'pr-menu-set-ps-title
-		   '("Printing")
-		   'pr-ps-printer-menu-modified
-		   force
-		   pr-ps-name-old
-		   'postscript 2)
-    (pr-menu-alist pr-txt-printer-alist
-		   'pr-txt-name
-		   'pr-menu-set-txt-title
-		   '("Printing")
-		   'pr-txt-printer-menu-modified
-		   force
-		   pr-txt-name-old
-		   'text 2)
-    (let ((save-var pr-ps-utility-menu-modified))
-      (pr-menu-alist pr-ps-utility-alist
-		     'pr-ps-utility
-		     'pr-menu-set-utility-title
-		     '("Printing" "PostScript Print"   "File")
-		     'save-var
-		     force
-		     pr-ps-utility-old
-		     nil 1))
-    (pr-menu-alist pr-ps-utility-alist
-		   'pr-ps-utility
-		   'pr-menu-set-utility-title
-		   '("Printing" "PostScript Preview" "File")
-		   'pr-ps-utility-menu-modified
-		   force
-		   pr-ps-utility-old
-		   nil 1)
-    (pr-even-or-odd-pages ps-even-or-odd-pages force))
-
-  ;; XEmacs
-  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
-			      entry index)
-    (when (and alist (or force (symbol-value modified-sym)))
-      (pr-xemacs-global-menubar
-       (pr-x-add-submenu menu-path
-			 (pr-menu-create name alist var-sym
-					 fun entry index)))
-      (funcall fun (symbol-value var-sym))
-      (set modified-sym nil)))
-
-  ;; XEmacs
-  (defun pr-relabel-menu-item (newname var-sym)
-    (pr-xemacs-global-menubar
-     (pr-x-relabel-menu-item
-      (list "Printing" (symbol-value var-sym))
-      newname)
-     (set var-sym newname)))
-
-  ;; XEmacs
-  (defun pr-menu-set-ps-title (value &optional item entry index)
-    (pr-relabel-menu-item (format "PostScript Printer: %s" value)
-			  'pr-ps-name-old)
-    (pr-ps-set-printer value)
-    (and index
-	 (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; XEmacs
-  (defun pr-menu-set-txt-title (value &optional item entry index)
-    (pr-relabel-menu-item (format "Text Printer: %s" value)
-			  'pr-txt-name-old)
-    (pr-txt-set-printer value)
-    (and index
-	 (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; XEmacs
-  (defun pr-menu-set-utility-title (value &optional item entry index)
-    (pr-xemacs-global-menubar
-     (let ((newname (format "%s" value)))
-       (pr-x-relabel-menu-item
-	(list "Printing" "PostScript Print" "File" pr-ps-utility-old)
-	newname)
-       (pr-x-relabel-menu-item
-	(list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
-	newname)
-       (setq pr-ps-utility-old newname)))
-    (pr-ps-set-utility value)
-    (and index
-	 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
-
-  ;; XEmacs
-  (defun pr-even-or-odd-pages (value &optional no-lock)
-    (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
-			  'pr-even-or-odd-old)
-    (setq ps-even-or-odd-pages value)
-    (or no-lock
-	(pr-menu-lock 'postscript-options 8 12 'toggle nil))))
-
-
- (t
-  ;; GNU Emacs
-  (defalias 'pr-update-mode-line 'force-mode-line-update)
-
-  ;; GNU Emacs
-  (defun pr-do-update-menus (&optional force)
-    (pr-menu-alist pr-ps-printer-alist
-		   'pr-ps-name
-		   'pr-menu-set-ps-title
-		   "PostScript Printers"
-		   'pr-ps-printer-menu-modified
-		   force
-		   "PostScript Printers"
-		   'postscript 2)
-    (pr-menu-alist pr-txt-printer-alist
-		   'pr-txt-name
-		   'pr-menu-set-txt-title
-		   "Text Printers"
-		   'pr-txt-printer-menu-modified
-		   force
-		   "Text Printers"
-		   'text 2)
-    (let ((save-var pr-ps-utility-menu-modified))
-      (pr-menu-alist pr-ps-utility-alist
-		     'pr-ps-utility
-		     'pr-menu-set-utility-title
-		     '("PostScript Print"   "File" "PostScript Utility")
-		     'save-var
-		     force
-		     "PostScript Utility"
-		     nil 1))
-    (pr-menu-alist pr-ps-utility-alist
-		   'pr-ps-utility
-		   'pr-menu-set-utility-title
-		   '("PostScript Preview" "File" "PostScript Utility")
-		   'pr-ps-utility-menu-modified
-		   force
-		   "PostScript Utility"
-		   nil 1)
-    (pr-even-or-odd-pages ps-even-or-odd-pages force))
-
-  ;; GNU Emacs
-  (defun pr-menu-get-item (name-list)
-    ;; NAME-LIST is a string or a list of strings.
-    (or (listp name-list)
-	(setq name-list (list name-list)))
-    (and name-list
-	 (let* ((reversed (reverse name-list))
-		(name (pr-get-symbol (car reversed)))
-		(path (nreverse (cdr reversed)))
-		(menu (lookup-key
-		       global-map
-		       (vconcat pr-menu-bar
-				(mapcar 'pr-get-symbol path)))))
-	   (assq name (nthcdr 2 menu)))))
-
-  ;; GNU Emacs
-  (defvar pr-temp-menu nil)
-
-  ;; GNU Emacs
-  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
-			      entry index)
-    (when (and alist (or force (symbol-value modified-sym)))
-      (easy-menu-define pr-temp-menu nil ""
-	(pr-menu-create name alist var-sym fun entry index))
-      (let ((item (pr-menu-get-item menu-path)))
-	(and item
-	     (let* ((binding     (nthcdr 3 item))
-		    (key-binding (cdr binding)))
-	       (setcar binding pr-temp-menu)
-	       (and key-binding (listp (car key-binding))
-		    (setcdr binding (cdr key-binding)))	; skip KEY-BINDING
-	       (funcall fun (symbol-value var-sym) item))))
-      (set modified-sym nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-item-name (item name)
-    (and item
-	 (setcar (nthcdr 2 item) name))) ; ITEM-NAME
-
-  ;; GNU Emacs
-  (defun pr-menu-set-ps-title (value &optional item entry index)
-    (pr-menu-set-item-name (or item
-			       (pr-menu-get-item "PostScript Printers"))
-			   (format "PostScript Printer: %s" value))
-    (pr-ps-set-printer value)
-    (and index
-	 (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-txt-title (value &optional item entry index)
-    (pr-menu-set-item-name (or item
-			       (pr-menu-get-item "Text Printers"))
-			   (format "Text Printer: %s" value))
-    (pr-txt-set-printer value)
-    (and index
-	 (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-utility-title (value &optional item entry index)
-    (let ((name (symbol-name value)))
-      (if item
-	  (pr-menu-set-item-name item name)
-	(pr-menu-set-item-name
-	 (pr-menu-get-item
-	  '("PostScript Print"   "File" "PostScript Utility"))
-	 name)
-	(pr-menu-set-item-name
-	 (pr-menu-get-item
-	  '("PostScript Preview" "File" "PostScript Utility"))
-	 name)))
-    (pr-ps-set-utility value)
-    (and index
-	 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
-
-  ;; GNU Emacs
-  (defun pr-even-or-odd-pages (value &optional no-lock)
-    (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
-			   (cdr (assq value pr-even-or-odd-alist)))
-    (setq ps-even-or-odd-pages value)
-    (or no-lock
-	(pr-menu-lock 'postscript-options 8 12 'toggle nil)))))
-
-
 (defun pr-ps-set-utility (value)
   (let ((item (cdr (assq value pr-ps-utility-alist))))
     (or item
--- a/lisp/progmodes/compile.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/progmodes/compile.el	Sun May 20 03:12:22 2007 +0000
@@ -1860,7 +1860,24 @@
           (let* ((name (read-file-name
                         (format "Find this %s in (default %s): "
                                 compilation-error filename)
-                        spec-dir filename t nil))
+                        spec-dir filename t nil
+                        ;; The predicate below is fine when called from
+                        ;; minibuffer-complete-and-exit, but it's too
+                        ;; restrictive otherwise, since it also prevents the
+                        ;; user from completing "fo" to "foo/" when she
+                        ;; wants to enter "foo/bar".
+                        ;; 
+                        ;; Try to make sure the user can only select
+                        ;; a valid answer.  This predicate may be ignored,
+                        ;; tho, so we still have to double-check afterwards.
+                        ;; TODO: We should probably fix read-file-name so
+                        ;; that it never ignores this predicate, even when
+                        ;; using popup dialog boxes.
+                        ;; (lambda (name)
+                        ;;   (if (file-directory-p name)
+                        ;;       (setq name (expand-file-name filename name)))
+                        ;;   (file-exists-p name))
+                        ))
                  (origname name))
             (cond
              ((not (file-exists-p name))
--- a/lisp/progmodes/python.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/progmodes/python.el	Sun May 20 03:12:22 2007 +0000
@@ -883,10 +883,13 @@
 			   nil)
 			  ((eq 'string (syntax-ppss-context s))
 			   ;; Go to start of string and skip it.
-			   (goto-char (nth 8 s))
-			   (condition-case () ; beware invalid syntax
-			       (progn (forward-sexp) t)
-			     (error (end-of-line))))
+                           (let ((pos (point)))
+                             (goto-char (nth 8 s))
+                             (condition-case () ; beware invalid syntax
+                                 (progn (forward-sexp) t)
+                               ;; If there's a mismatched string, make sure
+                               ;; we still overall move *forward*.
+                               (error (goto-char pos) (end-of-line)))))
 			  ((python-skip-out t s))))
 	     (end-of-line))
 	   (unless comment
@@ -981,15 +984,11 @@
 		       (_ (if (python-comment-line-p)
 			      (python-skip-comments/blanks t)))
 		       (ci (current-indentation))
-		       (open (python-open-block-statement-p))
-		       opoint)
+		       (open (python-open-block-statement-p)))
 		  (if (and (zerop ci) (not open))
 		      (not (goto-char point))
 		    (catch 'done
-		      (setq opoint (point))
-		      (while (and (zerop (python-next-statement))
-		      		  (not (= opoint (point))))
-			(setq opoint (point))
+                      (while (zerop (python-next-statement))
 			(when (or (and open (<= (current-indentation) ci))
 				  (< (current-indentation) ci))
 			  (python-skip-comments/blanks t)
--- a/lisp/t-mouse.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/t-mouse.el	Sun May 20 03:12:22 2007 +0000
@@ -1,7 +1,7 @@
 ;;; t-mouse.el --- mouse support within the text terminal
 
-;; Authors: Alessandro Rubini and Ian T Zimmerman
-;; Maintainer: Nick Roberts <nickrob@gnu.org>
+;; Author: Nick Roberts <nickrob@gnu.org>
+;; Maintainer: FSF
 ;; Keywords: mouse gpm linux
 
 ;; Copyright (C) 1994, 1995, 1998, 2006, 2007 Free Software Foundation, Inc.
@@ -25,249 +25,20 @@
 
 ;;; Commentary:
 
-;; This package provides access to mouse event as reported by the
-;; gpm-Linux package.  It uses the program "mev" to get mouse events.
-;; It tries to reproduce the functionality offered by Emacs under X.
+;; This package provides access to mouse event as reported by the gpm-Linux
+;; package. It tries to reproduce the functionality offered by Emacs under X.
 ;; The "gpm" server runs under Linux, so this package is rather
 ;; Linux-dependent.
 
-;; Modified by Nick Roberts for Emacs 22.  In particular, the mode-line is
-;; now position sensitive.
-
-(defvar t-mouse-process nil
-  "Embeds the process which passes mouse events to Emacs.
-It is used by the program t-mouse.")
-
-(defvar t-mouse-filter-accumulator ""
-  "Accumulates input from the mouse reporting process.")
-
-(defvar t-mouse-debug-buffer nil
-  "Events normally posted to command queue are printed here in debug mode.
-See `t-mouse-start-debug'.")
-
-(defvar t-mouse-current-xy '(0 . 0)
-  "Stores the last mouse position t-mouse has been told about.")
+;; The file, t-mouse was originally written by Alessandro Rubini and Ian T
+;; Zimmerman and communicated with Emacs through the client program mev.  Now
+;; the interface with gpm is directly through a Unix socket, so this file is
+;; reduced to a minor mode macro call.
 
-(defvar t-mouse-drag-start nil
-  "Whenever a drag starts in a special part of a window
-\(not the text), the `translated' starting coordinates including the
-window and part involved are saved here.  This is necessary lest they
-get re-translated when the button goes up, at which time window
-configuration may have changed.")
-
-(defvar t-mouse-prev-set-selection-function 'x-set-selection)
-(defvar t-mouse-prev-get-selection-function 'x-get-selection)
-
-(defvar t-mouse-swap-alt-keys nil
-  "When set, Emacs will handle mouse events with the right Alt
-\(a.k.a.  Alt-Ger) modifier, not with the regular left Alt modifier.
-Useful for people who play strange games with their keyboard tables.")
-
-(defvar t-mouse-fix-21 nil
-  "Enable brain-dead chords for 2 button mice.")
-
+;; 
 
 ;;; Code:
 
-;; get the number of the current virtual console
-
-(defun t-mouse-tty ()
-  "Return number of virtual terminal Emacs is running on, as a string.
-For example, \"2\" for /dev/tty2."
-  (with-temp-buffer
-    (call-process "ps" nil t nil "h" (format "%s" (emacs-pid)))
-    (goto-char (point-min))
-    (if (or
-	 ;; Many versions of "ps", all different....
-	 (re-search-forward " +tty\\(.?[0-9a-f]\\)" nil t)
-	 (re-search-forward "p \\([0-9a-f]\\)" nil t)
-	 (re-search-forward "v0\\([0-9a-f]\\)" nil t)
-	 (re-search-forward "[0-9]+ +\\([0-9]+\\)" nil t)
-	 (re-search-forward "[\\t ]*[0-9]+[\\t ]+\\([0-9]+\\)" nil t)
-	 (re-search-forward " +vc/\\(.?[0-9a-f]\\)" nil t)
-	 (re-search-forward " +pts/\\(.?[0-9a-f]\\)" nil t))
-	(buffer-substring (match-beginning 1) (match-end 1)))))
-
-
-;; due to a horrible kludge in Emacs' keymap handler
-;; (read_key_sequence) mouse clicks on funny parts of windows generate
-;; TWO events, the first being a dummy of the sort '(mode-line).
-;; That's why Per Abrahamsen's code in xt-mouse.el doesn't work for
-;; the modeline, for instance.
-
-;; now get this:  the Emacs C code that generates these fake events
-;; depends on certain things done by the very lowest level input
-;; handlers; namely the symbols for the events (for instance
-;; 'C-S-double-mouse-2) must have an 'event-kind property, set to
-;; 'mouse-click.  Since events from unread-command-events do not pass
-;; through the low level handlers, they don't get this property unless
-;; I set it myself.  I imagine this has caused innumerable attempts by
-;; hackers to do things similar to t-mouse to lose.
-
-;; The next page of code is devoted to fixing this ugly problem.
-
-;; WOW! a fully general powerset generator
-;; (C) Ian Zimmerman Mon Mar 23 12:00:16 PST 1998 :-)
-(defun t-mouse-powerset (l)
-  (if (null l) '(nil)
-    (let ((l1 (t-mouse-powerset (cdr l)))
-          (first (nth 0 l)))
-      (append
-       (mapcar (function (lambda (l) (cons first l))) l1) l1))))
-
-;; and a slightly less general cartesian product
-(defun t-mouse-cartesian (l1 l2)
-  (if (null l1) l2
-    (append (mapcar (function (lambda (x) (append (nth 0 l1) x))) l2)
-            (t-mouse-cartesian (cdr l1) l2))))
-
-(let* ((modifier-sets (t-mouse-powerset '(control meta shift)))
-       (typed-sets (t-mouse-cartesian '((down) (drag))
-                                      '((mouse-1) (mouse-2) (mouse-3))))
-       (multipled-sets (t-mouse-cartesian '((double) (triple)) typed-sets))
-       (all-sets (t-mouse-cartesian modifier-sets multipled-sets)))
-  (while all-sets
-    (let ((event-sym (event-convert-list (nth 0 all-sets))))
-      (if (not (get event-sym 'event-kind))
-          (put event-sym 'event-kind 'mouse-click)))
-    (setq all-sets (cdr all-sets))))
-
-(defun t-mouse-make-event-element (x-dot-y-avec-time)
-  (let* ((x-dot-y (nth 0 x-dot-y-avec-time))
-	 (time (nth 1 x-dot-y-avec-time))
-         (x (car x-dot-y))
-         (y (cdr x-dot-y))
-         (w (window-at x y))
-         (ltrb (window-edges w))
-         (left (nth 0 ltrb))
-         (top (nth 1 ltrb))
-	 (event (if w
-		    (posn-at-x-y (- x left) (- y top) w t)
-		  (append (list nil 'menu-bar)
-			  (nthcdr 2 (posn-at-x-y x y))))))
-    (setcar (nthcdr 3 event) time)
-    event))
-
-;;; This fun is partly Copyright (C) 1994 Per Abrahamsen <abraham@iesd.auc.dk>
-(defun t-mouse-make-event ()
-  "Make a Lisp style event from the contents of mouse input accumulator.
-Also trim the accumulator by all the data used to build the event."
-  (let (ob (ob-pos (condition-case nil
-		       (progn
-			 ;; this test is just needed for Fedora Core 3
-			 (if (string-match "STILL RUNNING_1\n"
-					   t-mouse-filter-accumulator)
-			     (setq t-mouse-filter-accumulator
-				   (substring
-				    t-mouse-filter-accumulator (match-end 0))))
-			 (read-from-string t-mouse-filter-accumulator))
-                     (error nil))))
-    ;; this test is just needed for Fedora Core 3
-    (if (or (eq (car ob-pos) 'STILL) (eq (car ob-pos) '***) (not ob-pos))
-	nil
-      (setq ob (car ob-pos))
-      (if (string-match "mev:$" (prin1-to-string ob))
-	  (error "Can't open mouse connection"))
-      (setq t-mouse-filter-accumulator
-            (substring t-mouse-filter-accumulator (cdr ob-pos)))
-
-      ;;now the real work
-
-      (let ((event-type (nth 0 ob))
-            (current-xy-avec-time (nth 1 ob))
-            (type-switch (length ob)))
- 	(if t-mouse-fix-21
-            (let
-                ;;Acquire the event's symbol's name.
-                ((event-name-string (symbol-name event-type))
-                 end-of-root-event-name
-                 new-event-name-string)
-
-              (if (string-match "-\\(21\\|\\12\\)$" event-name-string)
-
-                  ;;Transform the name to what it should have been.
-                  (progn
-                    (setq end-of-root-event-name (match-beginning 0))
-                    (setq new-event-name-string
-                          (concat (substring
-                                   event-name-string 0
-                                   end-of-root-event-name) "-3"))
-
-                    ;;Change the event to the symbol that corresponds to the
-                    ;;name we made. The proper symbol already exists.
-                    (setq event-type
-                          (intern new-event-name-string))))))
-
-        ;;store current position for mouse-position
-
-        (setq t-mouse-current-xy (nth 0 current-xy-avec-time))
-
-        ;;events have many types but fortunately they differ in length
-
-        (cond
-         ((= type-switch 4)             ;must be drag
-          (let ((count (nth 2 ob))
-                (start-element
-                 (or t-mouse-drag-start
-                     (t-mouse-make-event-element (nth 3 ob))))
-                (end-element
-                 (t-mouse-make-event-element current-xy-avec-time)))
-            (setq t-mouse-drag-start nil)
-            (list event-type start-element end-element count)))
-         ((= type-switch 3)             ;down or up
-          (let ((count (nth 2 ob))
-                (element
-                 (t-mouse-make-event-element current-xy-avec-time)))
-            (if (and (not t-mouse-drag-start)
-                     (symbolp (nth 1 element)))
-                ;; OUCH! GOTCHA! emacs uses setc[ad]r on these!
-                (setq t-mouse-drag-start (copy-sequence element))
-              (setq t-mouse-drag-start nil))
-            (list event-type element count)))
-         ((= type-switch 2)             ;movement
-          (list (if (eq 'vertical-scroll-bar
-                        (nth 1 t-mouse-drag-start)) 'scroll-bar-movement
-                  'mouse-movement)
-                (t-mouse-make-event-element current-xy-avec-time))))))))
-
-(defun t-mouse-process-filter (proc string)
-  (setq t-mouse-filter-accumulator
-        (concat t-mouse-filter-accumulator string))
-  (let ((event (t-mouse-make-event)))
-    (while event
-      (if (or track-mouse
-              (not (eq 'mouse-movement (event-basic-type event))))
-          (setq unread-command-events
-                (nconc unread-command-events (list event))))
-      (if t-mouse-debug-buffer
-          (print unread-command-events t-mouse-debug-buffer))
-      (setq event (t-mouse-make-event)))))
-
-(defun t-mouse-mouse-position-function (pos)
-  "Return the t-mouse-position unless running with a window system.
-The (secret) scrollbar interface is not implemented yet."
-  (setcdr pos t-mouse-current-xy)
-  pos)
-
-;; It should be possible to just send SIGTSTP to the inferior with
-;; stop-process.  That doesn't work; mev receives the signal fine but
-;; is not really stopped: instead it returns from
-;; kill(getpid(), SIGTSTP) immediately.  I don't understand what's up
-;; itz Tue Mar 24 14:27:38 PST 1998.
-
-(add-hook 'suspend-hook
-          (function (lambda ()
-                      (and t-mouse-process
-                           ;(stop-process t-mouse-process)
-                           (process-send-string
-                            t-mouse-process "push -enone -dall -Mnone\n")))))
-
-(add-hook 'suspend-resume-hook
-          (function (lambda ()
-                      (and t-mouse-process
-                           ;(continue-process t-mouse-process)
-                           (process-send-string t-mouse-process "pop\n")))))
-
 ;;;###autoload
 (define-minor-mode t-mouse-mode
   "Toggle t-mouse mode to use the mouse in Linux consoles.
@@ -277,32 +48,15 @@
 same way as you can use the mouse under X11.
 It requires the `mev' program, part of the `gpm' utilities."
   nil " Mouse" nil :global t
-  (if t-mouse-mode
-      ;; Turn it on
-      (unless window-system
-        ;; Starts getting a stream of mouse events from an asynchronous process.
-        ;; Only works if Emacs is running on a virtual terminal without a window system.
+  (unless window-system
+    (if t-mouse-mode
 	(progn
-	 (setq mouse-position-function #'t-mouse-mouse-position-function)
-	 (let ((tty (t-mouse-tty))
-	       (process-connection-type t))
-	   (if (not (stringp tty))
-	       (error "Cannot find a virtual terminal"))
-	   (setq t-mouse-process
-		 (start-process "t-mouse" nil
-				"mev" "-i" "-E" "-C" tty
-				(if t-mouse-swap-alt-keys
-				    "-M-leftAlt" "-M-rightAlt")
-				"-e-move"
-				"-dall" "-d-hard"
-				"-f")))
-	 (setq t-mouse-filter-accumulator "")
-	 (set-process-filter t-mouse-process 't-mouse-process-filter)
-	 (set-process-query-on-exit-flag t-mouse-process nil)))
-    ;; Turn it off
-    (setq mouse-position-function nil)
-    (delete-process t-mouse-process)
-    (setq t-mouse-process nil)))
+	  (unless (fboundp 'term-open-connection)
+	    (error "Emacs must be built with Gpm to use this mode"))
+	  (unless (term-open-connection)
+	    (error "Can't open mouse connection")))
+      ;; Turn it off
+      (term-close-connection))))
 
 (provide 't-mouse)
 
--- a/lisp/textmodes/sgml-mode.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/textmodes/sgml-mode.el	Sun May 20 03:12:22 2007 +0000
@@ -45,12 +45,12 @@
   :group 'languages)
 
 (defcustom sgml-basic-offset 2
-  "*Specifies the basic indentation level for `sgml-indent-line'."
+  "Specifies the basic indentation level for `sgml-indent-line'."
   :type 'integer
   :group 'sgml)
 
 (defcustom sgml-transformation-function 'identity
-  "*Default value for `skeleton-transformation-function' in SGML mode."
+  "Default value for `skeleton-transformation-function' in SGML mode."
   :type 'function
   :group 'sgml)
 
@@ -166,7 +166,7 @@
   "Syntax table used to parse SGML tags.")
 
 (defcustom sgml-name-8bit-mode nil
-  "*When non-nil, insert non-ASCII characters as named entities."
+  "When non-nil, insert non-ASCII characters as named entities."
   :type 'boolean
   :group 'sgml)
 
@@ -225,7 +225,7 @@
 ;; The -s option suppresses output.
 
 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
-  "*The command to validate an SGML document.
+  "The command to validate an SGML document.
 The file name of current buffer file name will be appended to this,
 separated by a space."
   :type 'string
@@ -238,7 +238,7 @@
 ;; I doubt that null end tags are used much for large elements,
 ;; so use a small distance here.
 (defcustom sgml-slash-distance 1000
-  "*If non-nil, is the maximum distance to search for matching `/'."
+  "If non-nil, is the maximum distance to search for matching `/'."
   :type '(choice (const nil) integer)
   :group 'sgml)
 
@@ -318,7 +318,7 @@
     ("!doctype")
     ("!element")
     ("!entity"))
-  "*Alist of tag names for completing read and insertion rules.
+  "Alist of tag names for completing read and insertion rules.
 This alist is made up as
 
   ((\"tag\" . TAGRULE)
@@ -348,15 +348,14 @@
     ("!doctype" . "Document type (DTD) declaration")
     ("!element" . "Tag declaration")
     ("!entity" . "Entity (macro) declaration"))
-  "*Alist of tag name and short description."
+  "Alist of tag name and short description."
   :type '(repeat (cons (string :tag "Tag Name")
 		       (string :tag "Description")))
   :group 'sgml)
 
 (defcustom sgml-xml-mode nil
-  "*When non-nil, tag insertion functions will be XML-compliant.
-If this variable is customized, the custom value is used always.
-Otherwise, it is set to be buffer-local when the file has
+  "When non-nil, tag insertion functions will be XML-compliant.
+It is set to be buffer-local when the file has
 a DOCTYPE or an XML declaration."
   :type 'boolean
   :version "22.1"
@@ -937,7 +936,7 @@
 (defun sgml-lexical-context (&optional limit)
   "Return the lexical context at point as (TYPE . START).
 START is the location of the start of the lexical element.
-TYPE is one of `string', `comment', `tag', `cdata', or `text'.
+TYPE is one of `string', `comment', `tag', `cdata', `pi', or `text'.
 
 Optional argument LIMIT is the position to start parsing from.
 If nil, start from a preceding tag at indentation."
@@ -964,12 +963,19 @@
                   (let ((cdata-start (point)))
                     (unless (search-forward "]]>" pos 'move)
                       (list 0 nil nil 'cdata nil nil nil nil cdata-start))))
+                 ((and sgml-xml-mode (looking-at "<\\?"))
+                  ;; Processing Instructions.
+                  ;; In SGML, it's basically a normal tag of the form
+                  ;; <?NAME ...> but in XML, it takes the form <? ... ?>.
+                  (let ((pi-start (point)))
+                    (unless (search-forward "?>" pos 'move)
+                      (list 0 nil nil 'pi nil nil nil nil pi-start))))
                  (t
                   ;; We've reached a tag.  Parse it.
                   ;; FIXME: Handle net-enabling start-tags
                   (parse-partial-sexp (point) pos 0))))))
       (cond
-       ((eq (nth 3 state) 'cdata) (cons 'cdata (nth 8 state)))
+       ((memq (nth 3 state) '(cdata pi)) (cons (nth 3 state) (nth 8 state)))
        ((nth 3 state) (cons 'string (nth 8 state)))
        ((nth 4 state) (cons 'comment (nth 8 state)))
        ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
@@ -1003,8 +1009,10 @@
 	      (insert alist ?\")
 	    (delete-backward-char 2)))
       (insert "=\"")
-      (when alist
-        (insert (skeleton-read '(completing-read "Value: " alist))))
+      (if (cdr alist)
+          (insert (skeleton-read '(completing-read "Value: " alist)))
+        (when (null alist)
+          (insert (skeleton-read '(read-string "Value: ")))))
       (insert ?\"))))
 
 (defun sgml-quote (start end &optional unquotep)
@@ -1093,9 +1101,15 @@
       (when (eq (char-after) ?<)
 	;; Oops!! Looks like we were not in a textual context after all!.
 	;; Let's try to recover.
+        ;; Remember the tag-start so we don't need to look for it later.
+	;; This is not just an optimization but also makes sure we don't get
+	;; stuck in infloops in cases where "looking back for <" would not go
+	;; back far enough.
+        (setq tag-start (point))
 	(with-syntax-table sgml-tag-syntax-table
 	  (let ((pos (point)))
 	    (condition-case nil
+                ;; FIXME: This does not correctly skip over PI an CDATA tags.
 		(forward-sexp)
 	      (scan-error
 	       ;; This < seems to be just a spurious one, let's ignore it.
@@ -1110,33 +1124,41 @@
       (cond
        ((sgml-looking-back-at "--")	; comment
 	(setq tag-type 'comment
-	      tag-start (search-backward "<!--" nil t)))
+	      tag-start (or tag-start (search-backward "<!--" nil t))))
        ((sgml-looking-back-at "]]")	; cdata
 	(setq tag-type 'cdata
-	      tag-start (re-search-backward "<!\\[[A-Z]+\\[" nil t)))
+	      tag-start (or tag-start
+                            (re-search-backward "<!\\[[A-Z]+\\[" nil t))))
+       ((sgml-looking-back-at "?")      ; XML processing-instruction
+        (setq tag-type 'pi
+              ;; IIUC: SGML processing instructions take the form <?foo ...>
+              ;; i.e. a "normal" tag, handled below.  In XML this is changed
+              ;; to <?foo ... ?> where "..." can contain < and > and even <?
+              ;; but not ?>.  This means that when parsing backward, there's
+              ;; no easy way to make sure that we find the real beginning of
+              ;; the PI.
+	      tag-start (or tag-start (search-backward "<?" nil t))))
        (t
-	(setq tag-start
-	      (with-syntax-table sgml-tag-syntax-table
-		(goto-char tag-end)
-		(condition-case nil
-		    (backward-sexp)
-		  (scan-error
-		   ;; This > isn't really the end of a tag. Skip it.
-		   (goto-char (1- tag-end))
-		   (throw 'found (sgml-parse-tag-backward limit))))
-		(point)))
+        (unless tag-start
+          (setq tag-start
+                (with-syntax-table sgml-tag-syntax-table
+                  (goto-char tag-end)
+                  (condition-case nil
+                      (backward-sexp)
+                    (scan-error
+                     ;; This > isn't really the end of a tag. Skip it.
+                     (goto-char (1- tag-end))
+                     (throw 'found (sgml-parse-tag-backward limit))))
+                  (point))))
 	(goto-char (1+ tag-start))
 	(case (char-after)
-	  (?!				; declaration
-	   (setq tag-type 'decl))
-	  (??				; processing-instruction
-	   (setq tag-type 'pi))
+	  (?! (setq tag-type 'decl))    ; declaration
+	  (?? (setq tag-type 'pi))      ; processing-instruction
+	  (?% (setq tag-type 'jsp))	; JSP tags
 	  (?/				; close-tag
 	   (forward-char 1)
 	   (setq tag-type 'close
 		 name (sgml-parse-tag-name)))
-	  (?%				; JSP tags
-	   (setq tag-type 'jsp))
 	  (t				; open or empty tag
 	   (setq tag-type 'open
 		 name (sgml-parse-tag-name))
@@ -1331,6 +1353,8 @@
 
     ;; We don't know how to indent it.  Let's be honest about it.
     (cdata nil)
+    ;; We don't know how to indent it.  Let's be honest about it.
+    (pi nil)
 
     (tag
      (goto-char (1+ (cdr lcon)))
--- a/lisp/textmodes/tex-mode.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/textmodes/tex-mode.el	Sun May 20 03:12:22 2007 +0000
@@ -527,6 +527,8 @@
 	    (citations (regexp-opt
 			'("label" "ref" "pageref" "vref" "eqref"
 			  "cite" "nocite" "index" "glossary" "bibitem"
+                          ;; natbib's two variants of \cite:
+                          "citep" "citet"
 			  ;; These are text, rather than citations.
 			  ;; "caption" "footnote" "footnotemark" "footnotetext"
 			  )
--- a/lisp/vc.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/vc.el	Sun May 20 03:12:22 2007 +0000
@@ -2909,7 +2909,11 @@
   (vc-call-backend (vc-responsible-backend default-directory)
                    'update-changelog args))
 
-(defun vc-default-update-changelog (backend files)
+(defalias 'vc-cvs-update-changelog 'vc-update-changelog-rcs2log)
+(defalias 'vc-rcs-update-changelog 'vc-update-changelog-rcs2log)
+;; FIXME: This should probably be moved to vc-rcs.el and replaced in
+;; vc-cvs.el by code using cvs2cl.
+(defun vc-update-changelog-rcs2log (files)
   "Default implementation of update-changelog.
 Uses `rcs2log' which only works for RCS and CVS."
   ;; FIXME: We (c|sh)ould add support for cvs2cl
@@ -2950,9 +2954,7 @@
                                     (mapcar
                                      (lambda (f)
                                        (file-relative-name
-                                        (if (file-name-absolute-p f)
-                                            f
-                                          (concat odefault f))))
+                                        (expand-file-name f odefault)))
                                      files)))
                        "done"
 		     (pop-to-buffer (get-buffer-create "*vc*"))
--- a/lisp/version.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/version.el	Sun May 20 03:12:22 2007 +0000
@@ -27,7 +27,7 @@
 
 ;;; Code:
 
-(defconst emacs-version "22.0.990" "\
+(defconst emacs-version "22.1.50" "\
 Version numbers of this version of Emacs.")
 
 (defconst emacs-major-version
--- a/lisp/xt-mouse.el	Sat May 19 22:31:10 2007 +0000
+++ b/lisp/xt-mouse.el	Sun May 20 03:12:22 2007 +0000
@@ -43,6 +43,8 @@
 
 ;;; Code:
 
+(defvar xterm-mouse-debug-buffer nil)
+
 (define-key function-key-map "\e[M" 'xterm-mouse-translate)
 
 (defvar xterm-mouse-last)
@@ -95,6 +97,8 @@
 		       (list (intern (format "drag-mouse-%d"
 					     (+ 1 xterm-mouse-last)))
 			     down-data click-data)))))
+	    (if xterm-mouse-debug-buffer
+		(print unread-command-events xterm-mouse-debug-buffer))
 	    (if (and (symbolp down-where)
 		     (consp down-where))
 		(vector (list down-where down-data) down)
--- a/lispref/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/lispref/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -18,6 +18,20 @@
 
 	* modes.texi (Auto Major Mode): Document file-start-mode-alist.
 
+2007-05-10  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* elisp.texi (Top): Remove "Saving Properties" from detailed menu.
+	* files.texi (Format Conversion): Expand intro; add menu.
+	(Format Conversion Overview, Format Conversion Round-Trip)
+	(Format Conversion Piecemeal): New nodes/subsections.
+	* hooks.texi: Xref "Format Conversion" , not "Saving Properties".
+	* text.texi (Text Properties): Remove "Saving Properties" from menu.
+	(Saving Properties): Delete node/subsection.
+
+2007-05-07  Karl Berry  <karl@gnu.org>
+
+	* elisp.texi (EMACSVER): back to 22.
+
 2007-05-06  Richard Stallman  <rms@gnu.org>
 
 	* processes.texi (Accepting Output): Revert most of previous change.
@@ -36,7 +50,7 @@
 	* tips.texi (Documentation Tips): Rearrange items to place the
 	more important ones first.  Add an index entry for hyperlinks.
 
-2007-05-03  Karl Berry  <karl@tug.org>
+2007-05-03  Karl Berry  <karl@gnu.org>
 
 	* elisp.texi (\urlcolor, \linkcolor) [smallbook]: \Black for printing.
 	 (EMACSVER) [smallbook]: 22 for printed version.
@@ -44,6 +58,10 @@
 	* control.texi (Signaling Errors) <signal>: texinfo.tex is fixed,
 	so restore anchor to normal position after defun.  Found by Kevin Ryde.
 
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* elisp.texi (EMACSVER): Increase to 22.1.50.
+
 2007-04-28  Karl Berry  <karl@gnu.org>
 
 	* elisp.texi: Improve line breaks on copyright page,
@@ -397,7 +415,7 @@
 
 	* loading.texi (How Programs Do Loading): Fix anchor position at
 	load-read-function definition doc. (tiny change)
-	
+
 2007-02-21  Kim F. Storm  <storm@cua.dk>
 
 	* strings.texi (Text Comparison): Mention that assoc-string
--- a/lispref/elisp.texi	Sat May 19 22:31:10 2007 +0000
+++ b/lispref/elisp.texi	Sun May 20 03:12:22 2007 +0000
@@ -29,11 +29,13 @@
 @tex
 @ifset smallbook
 @fonttextsize 10
-@set EMACSVER 22.1
+@set EMACSVER 22
 \global\let\urlcolor=\Black % don't print links in grayscale
 \global\let\linkcolor=\Black
 @end ifset
 \global\hbadness=6666 % don't worry about not-too-underfull boxes
+\global\let\urlcolor=\Black % don't print links in grayscale
+\global\let\linkcolor=\Black
 @end tex
 
 @c Combine indices.
@@ -1064,8 +1066,6 @@
 * Format Properties::       Properties for representing formatting of text.
 * Sticky Properties::       How inserted text gets properties from
                               neighboring text.
-* Saving Properties::       Saving text properties in files, and reading
-                              them back.
 * Lazy Properties::         Computing text properties in a lazy fashion
                               only when text is examined.
 * Clickable Text::          Using text properties to make regions of text
--- a/lispref/files.texi	Sat May 19 22:31:10 2007 +0000
+++ b/lispref/files.texi	Sun May 20 03:12:22 2007 +0000
@@ -374,8 +374,7 @@
 @end deffn
 
   Saving a buffer runs several hooks.  It also performs format
-conversion (@pxref{Format Conversion}), and may save text properties in
-``annotations'' (@pxref{Saving Properties}).
+conversion (@pxref{Format Conversion}).
 
 @defvar write-file-functions
 The value of this variable is a list of functions to be called before
@@ -496,9 +495,9 @@
 
 The function @code{insert-file-contents} checks the file contents
 against the defined file formats, and converts the file contents if
-appropriate.  @xref{Format Conversion}.  It also calls the functions in
-the list @code{after-insert-file-functions}; see @ref{Saving
-Properties}.  Normally, one of the functions in the
+appropriate and also calls the functions in
+the list @code{after-insert-file-functions}.  @xref{Format Conversion}.
+Normally, one of the functions in the
 @code{after-insert-file-functions} list determines the coding system
 (@pxref{Coding Systems}) used for decoding the file's contents,
 including end-of-line conversion.
@@ -620,9 +619,10 @@
 @var{filename} and @var{visit} for that purpose.
 
 The function @code{write-region} converts the data which it writes to
-the appropriate file formats specified by @code{buffer-file-format}.
-@xref{Format Conversion}.  It also calls the functions in the list
-@code{write-region-annotate-functions}; see @ref{Saving Properties}.
+the appropriate file formats specified by @code{buffer-file-format}
+and also calls the functions in the list
+@code{write-region-annotate-functions}.
+@xref{Format Conversion}.
 
 Normally, @code{write-region} displays the message @samp{Wrote
 @var{filename}} in the echo area.  If @var{visit} is neither @code{t}
@@ -2802,23 +2802,70 @@
 @cindex file format conversion
 @cindex encoding file formats
 @cindex decoding file formats
-  The variable @code{format-alist} defines a list of @dfn{file formats},
-which describe textual representations used in files for the data (text,
-text-properties, and possibly other information) in an Emacs buffer.
-Emacs performs format conversion if appropriate when reading and writing
-files.
+@cindex text properties in files
+@cindex saving text properties
+  Emacs performs several steps to convert the data in a buffer (text,
+text properties, and possibly other information) to and from a
+representation suitable for storing into a file.  This section describes
+the fundamental functions that perform this @dfn{format conversion},
+namely @code{insert-file-contents} for reading a file into a buffer,
+and @code{write-region} for writing a buffer into a file.
+
+@menu
+* Overview: Format Conversion Overview.     @code{insert-file-contents} and @code{write-region}
+* Round-Trip: Format Conversion Round-Trip. Using @code{format-alist}.
+* Piecemeal: Format Conversion Piecemeal.   Specifying non-paired conversion.
+@end menu
+
+@node Format Conversion Overview
+@subsection Overview
+@noindent
+The function @code{insert-file-contents}:
+
+@itemize
+@item initially, inserts bytes from the file into the buffer;
+@item decodes bytes to characters as appropriate;
+@item processes formats as defined by entries in @code{format-alist}; and
+@item calls functions in @code{after-insert-file-functions}.
+@end itemize
+
+@noindent
+The function @code{write-region}:
+
+@itemize
+@item initially, calls functions in @code{write-region-annotate-functions};
+@item processes formats as defined by entries in @code{format-alist};
+@item encodes characters to bytes as appropriate; and
+@item modifies the file with the bytes.
+@end itemize
+
+  This shows the symmetry of the lowest-level operations; reading and
+writing handle things in opposite order.  The rest of this section
+describes the two facilities surrounding the three variables named
+above, as well as some related functions.  @ref{Coding Systems}, for
+details on character encoding and decoding.
+
+@node Format Conversion Round-Trip
+@subsection Round-Trip Specification
+
+  The most general of the two facilities is controlled by the variable
+@code{format-alist}, a list of @dfn{file format} specifications, which
+describe textual representations used in files for the data in an Emacs
+buffer.  The descriptions for reading and writing are paired, which is
+why we call this ``round-trip'' specification
+(@pxref{Format Conversion Piecemeal}, for non-paired specification).
 
 @defvar format-alist
 This list contains one format definition for each defined file format.
-@end defvar
-
-@cindex format definition
 Each format definition is a list of this form:
 
 @example
 (@var{name} @var{doc-string} @var{regexp} @var{from-fn} @var{to-fn} @var{modify} @var{mode-fn})
 @end example
-
+@end defvar
+
+@cindex format definition
+@noindent
 Here is what the elements in a format definition mean:
 
 @table @var
@@ -2957,6 +3004,89 @@
 in all buffers.
 @end defvar
 
+@node Format Conversion Piecemeal
+@subsection Piecemeal Specification
+
+  In contrast to the round-trip specification described in the previous
+subsection (@pxref{Format Conversion Round-Trip}), you can use the variables
+@code{after-insert-file-functions} and @code{write-region-annotate-functions}
+to separately control the respective reading and writing conversions.
+
+  Conversion starts with one representation and produces another
+representation.  When there is only one conversion to do, there is no
+conflict about what to start with.  However, when there are multiple
+conversions involved, conflict may arise when two conversions need to
+start with the same data.
+
+  This situation is best understood in the context of converting text
+properties during @code{write-region}.  For example, the character at
+position 42 in a buffer is @samp{X} with a text property @code{foo}.  If
+the conversion for @code{foo} is done by inserting into the buffer, say,
+@samp{FOO:}, then that changes the character at position 42 from
+@samp{X} to @samp{F}.  The next conversion will start with the wrong
+data straight away.
+
+  To avoid conflict, cooperative conversions do not modify the buffer,
+but instead specify @dfn{annotations}, a list of elements of the form
+@code{(@var{position} . @var{string})}, sorted in order of increasing
+@var{position}.
+
+  If there is more than one conversion, @code{write-region} merges their
+annotations destructively into one sorted list.  Later, when the text
+from the buffer is actually written to the file, it intermixes the
+specified annotations at the corresponding positions.  All this takes
+place without modifying the buffer.
+
+@c ??? What about ``overriding'' conversions like those allowed
+@c ??? for `write-region-annotate-functions', below?  --ttn
+
+  In contrast, when reading, the annotations intermixed with the text
+are handled immediately.  @code{insert-file-contents} sets point to the
+beginning of some text to be converted, then calls the conversion
+functions with the length of that text.  These functions should always
+return with point at the beginning of the inserted text.  This approach
+makes sense for reading because annotations removed by the first
+converter can't be mistakenly processed by a later converter.
+
+  Each conversion function should scan for the annotations it
+recognizes, remove the annotation, modify the buffer text (to set a text
+property, for example), and return the updated length of the text, as it
+stands after those changes.  The value returned by one function becomes
+the argument to the next function.
+
+@defvar write-region-annotate-functions
+A list of functions for @code{write-region} to call.  Each function in
+the list is called with two arguments: the start and end of the region
+to be written.  These functions should not alter the contents of the
+buffer.  Instead, they should return annotations.
+
+@c ??? Following adapted from comment in `build_annotations' (fileio.c).
+@c ??? Perhaps this is intended for internal use only?
+@c ??? Someone who understands this, please reword it. --ttn
+As a special case, if a function returns with a different buffer
+current, Emacs takes it to mean the current buffer contains altered text
+to be output, and discards all previous annotations because they should
+have been dealt with by this function.
+@end defvar
+
+@defvar after-insert-file-functions
+Each function in this list is called by @code{insert-file-contents}
+with one argument, the number of characters inserted, and should
+return the new character count, leaving point the same.
+@c ??? The docstring mentions a handler from `file-name-handler-alist'
+@c     "intercepting" `insert-file-contents'.  Hmmm.  --ttn
+@end defvar
+
+  We invite users to write Lisp programs to store and retrieve text
+properties in files, using these hooks, and thus to experiment with
+various data formats and find good ones.  Eventually we hope users
+will produce good, general extensions we can install in Emacs.
+
+  We suggest not trying to handle arbitrary Lisp objects as text property
+names or values---because a program that general is probably difficult
+to write, and slow.  Instead, choose a set of possible data types that
+are reasonably flexible, and not too hard to encode.
+
 @ignore
    arch-tag: 141f74ce-6ae3-40dc-a6c4-ef83fc4ec35c
 @end ignore
--- a/lispref/hooks.texi	Sat May 19 22:31:10 2007 +0000
+++ b/lispref/hooks.texi	Sun May 20 03:12:22 2007 +0000
@@ -48,7 +48,7 @@
 @xref{Init File}.
 
 @item after-insert-file-functions
-@xref{Saving Properties}.
+@xref{Format Conversion}.
 
 @item after-make-frame-functions
 @xref{Creating Frames}.
@@ -330,7 +330,7 @@
 @xref{Saving Buffers}.
 
 @item write-region-annotate-functions
-@xref{Saving Properties}.
+@xref{Format Conversion}.
 @end table
 
 @ignore
--- a/lispref/text.texi	Sat May 19 22:31:10 2007 +0000
+++ b/lispref/text.texi	Sun May 20 03:12:22 2007 +0000
@@ -2574,8 +2574,6 @@
 * Format Properties::      Properties for representing formatting of text.
 * Sticky Properties::      How inserted text gets properties from
                              neighboring text.
-* Saving Properties::      Saving text properties in files, and reading
-                             them back.
 * Lazy Properties::        Computing text properties in a lazy fashion
                              only when text is examined.
 * Clickable Text::         Using text properties to make regions of text
@@ -3396,75 +3394,6 @@
   @xref{Insertion}, for the ordinary insertion functions which do not
 inherit.
 
-@node Saving Properties
-@subsection Saving Text Properties in Files
-@cindex text properties in files
-@cindex saving text properties
-
-  You can save text properties in files (along with the text itself),
-and restore the same text properties when visiting or inserting the
-files, using these two hooks:
-
-@defvar write-region-annotate-functions
-This variable's value is a list of functions for @code{write-region} to
-run to encode text properties in some fashion as annotations to the text
-being written in the file.  @xref{Writing to Files}.
-
-Each function in the list is called with two arguments: the start and
-end of the region to be written.  These functions should not alter the
-contents of the buffer.  Instead, they should return lists indicating
-annotations to write in the file in addition to the text in the
-buffer.
-
-Each function should return a list of elements of the form
-@code{(@var{position} . @var{string})}, where @var{position} is an
-integer specifying the relative position within the text to be written,
-and @var{string} is the annotation to add there.
-
-Each list returned by one of these functions must be already sorted in
-increasing order by @var{position}.  If there is more than one function,
-@code{write-region} merges the lists destructively into one sorted list.
-
-When @code{write-region} actually writes the text from the buffer to the
-file, it intermixes the specified annotations at the corresponding
-positions.  All this takes place without modifying the buffer.
-@end defvar
-
-@defvar after-insert-file-functions
-This variable holds a list of functions for @code{insert-file-contents}
-to call after inserting a file's contents.  These functions should scan
-the inserted text for annotations, and convert them to the text
-properties they stand for.
-
-Each function receives one argument, the length of the inserted text;
-point indicates the start of that text.  The function should scan that
-text for annotations, delete them, and create the text properties that
-the annotations specify.  The function should return the updated length
-of the inserted text, as it stands after those changes.  The value
-returned by one function becomes the argument to the next function.
-
-These functions should always return with point at the beginning of
-the inserted text.
-
-The intended use of @code{after-insert-file-functions} is for converting
-some sort of textual annotations into actual text properties.  But other
-uses may be possible.
-@end defvar
-
-We invite users to write Lisp programs to store and retrieve text
-properties in files, using these hooks, and thus to experiment with
-various data formats and find good ones.  Eventually we hope users
-will produce good, general extensions we can install in Emacs.
-
-We suggest not trying to handle arbitrary Lisp objects as text property
-names or values---because a program that general is probably difficult
-to write, and slow.  Instead, choose a set of possible data types that
-are reasonably flexible, and not too hard to encode.
-
-@xref{Format Conversion}, for a related feature.
-
-@c ??? In next edition, merge this info Format Conversion.
-
 @node Lazy Properties
 @subsection Lazy Computation of Text Properties
 
--- a/mac/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/mac/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -3,6 +3,11 @@
 	* INSTALL: Fix description about using colors in terminal.
 	Fix typos (/Application -> /Applications).
 
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings:
+	* src/Emacs.r: Increase version to 22.1.50.
+
 2007-04-09  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* make-package (compver): Don't hardcode processor type.
--- a/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings	Sat May 19 22:31:10 2007 +0000
+++ b/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings	Sun May 20 03:12:22 2007 +0000
@@ -1,5 +1,5 @@
 /* Localized versions of Info.plist keys */
 
 CFBundleName = "Emacs";
-CFBundleShortVersionString = "22.0.990";
-CFBundleGetInfoString = "22.0.990, Copyright (C) 2007 Free Software Foundation, Inc.";
+CFBundleShortVersionString = "22.1.50";
+CFBundleGetInfoString = "22.1.50, Copyright (C) 2007 Free Software Foundation, Inc.";
--- a/mac/src/Emacs.r	Sat May 19 22:31:10 2007 +0000
+++ b/mac/src/Emacs.r	Sun May 20 03:12:22 2007 +0000
@@ -219,12 +219,12 @@
 
 resource 'vers' (1) {
 	0x22,		/* Major revision in BCD */
-	0x0,		/* Minor revision in BCD */
-	alpha,	/* development, alpha, beta, or final (release) */
-	990,		/* Non-final release # */
+	0x1,		/* Minor revision in BCD */
+	development,	/* development, alpha, beta, or final (release) */
+	50,		/* Non-final release # */
 	0,		/* Region code */
-	"22.0.990",	/* Short version number */
-	"22.0.990, Copyright \0xa9 2007 "
+	"22.1.50",	/* Short version number */
+	"22.1.50, Copyright \0xa9 2007 "
 	"Free Software Foundation, Inc." /* Long version number */
 };
 
--- a/man/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/man/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -1,22 +1,30 @@
-2007-05-10  Reiner Steib  <Reiner.Steib@gmx.de>
+2007-05-09  Reiner Steib  <Reiner.Steib@gmx.de>
 
 	* gnus.texi (Running NNDiary): Use ~/.gnus.el instead of gnusrc.
 
-2007-05-10  Didier Verna  <didier@xemacs.org>
+2007-05-09  Didier Verna  <didier@xemacs.org>
 
 	* gnus.texi (Email Based Diary): New. Proper documentation for the
 	nndiary back end and the gnus-diary library.
 
+2007-05-07  Karl Berry  <karl@gnu.org>
+
+	* emacs.texi (EMACSVER): back to 22.
+
+2007-05-06  Richard Stallman  <rms@gnu.org>
+
+	* maintaining.texi (Create Tags Table): Clean up previous change.
+
 2007-05-05  Francesco Potort,Al(B  <pot@gnu.org>
 
 	* maintaining.texi (Create Tags Table): Add text about the dangers of
-	making symbolic links to tags files.  (Clarified by RMS.)
-
-2007-05-04  Karl Berry  <karl@tug.org>
+	making symbolic links to tags files.
+
+2007-05-04  Karl Berry  <karl@gnu.org>
 
 	* emacs.texi (EMACSVER) [smallbook]: 22.1 for printed version, not 22.
 
-2007-05-03  Karl Berry  <karl@tug.org>
+2007-05-03  Karl Berry  <karl@gnu.org>
 
 	* emacs.texi (EMACSVER) [smallbook]: 22 for printed version.
 
@@ -31,6 +39,10 @@
 
 	* cmdargs.texi (Initial Options): Under --batch, mention --eval.
 
+2007-04-30  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus.texi (Article Highlighting): Clarify gnus-cite-parse-max-size.
+
 2007-04-28  Glenn Morris  <rgm@gnu.org>
 
 	* ack.texi (Acknowledgments):
@@ -43,17 +55,21 @@
 
 	* files.texi (File Names): Fixes to ~ description on MS systems.
 
-2007-04-28  Karl Berry  <karl@gnu.org>
+2007-04-27  J.D. Smith  <jdsmith@as.arizona.edu>
+
+	* idlwave.texi: Minor updates for IDLWAVE 6.1.
+
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* emacs.texi (EMACSVER): Increase to 22.1.50.
+
+2007-04-25  Karl Berry  <karl@gnu.org>
 
 	* emacs.texi: Improve line breaks on copyright page,
 	similar layout to lispref, 8.5x11 by default.
 
 	* dired.texi (Image-Dired): Improve line break, fix typo.
 
-2007-04-27  J.D. Smith  <jdsmith@as.arizona.edu>
-
-	* idlwave.texi: Minor updates for IDLWAVE 6.1.
-
 2007-04-24  Chong Yidong  <cyd@stupidchicken.com>
 
 	* programs.texi (Program Modes):
@@ -83,8 +99,8 @@
 	* misc.texi (Thumbnails): Node deleted.
 	* emacs.texi (Top): Update node listing.
 
-	* files.texi (File Conveniences): 
-	* ack.texi (Acknowledgments): 
+	* files.texi (File Conveniences):
+	* ack.texi (Acknowledgments):
 	* faq.texi (New in Emacs 22): Rename "tumme" to "image-dired".
 
 2007-04-21  Richard Stallman  <rms@gnu.org>
--- a/man/emacs.texi	Sat May 19 22:31:10 2007 +0000
+++ b/man/emacs.texi	Sun May 20 03:12:22 2007 +0000
@@ -5,7 +5,7 @@
 
 @c The edition number appears in several places in this file
 @set EDITION   Sixteenth
-@set EMACSVER  22.0.990
+@set EMACSVER  22.1.50
 
 @copying
 This is the @value{EDITION} edition of the @cite{GNU Emacs Manual},@*
@@ -51,7 +51,7 @@
 @tex
 @ifset smallbook
 @fonttextsize 10
-@set EMACSVER 22.1
+@set EMACSVER 22
 \global\let\urlcolor=\Black % don't print links in grayscale
 \global\let\linkcolor=\Black
 @end ifset
--- a/man/texinfo.tex	Sat May 19 22:31:10 2007 +0000
+++ b/man/texinfo.tex	Sun May 20 03:12:22 2007 +0000
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2007-05-03.09}
+\def\texinfoversion{2007-05-04.09}
 %
 % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -1435,7 +1435,7 @@
       \indexnofonts
       \setupdatafile
       \catcode`\\=\active \otherbackslash
-      \input \jobname.toc
+      \input \tocreadfilename
     \endgroup
   }
   %
@@ -4301,11 +4301,8 @@
     % The following is kludged to not output a line of dots in the index if
     % there are no page numbers.  The next person who breaks this will be
     % cursed by a Unix daemon.
-    \def\tempa{{\rm }}%
-    \def\tempb{#1}%
-    \edef\tempc{\tempa}%
-    \edef\tempd{\tempb}%
-    \ifx\tempc\tempd
+    \setbox\boxA = \hbox{#1}%
+    \ifdim\wd\boxA = 0pt
       \ %
     \else
       %
@@ -5177,7 +5174,7 @@
 \def\readtocfile{%
   \setupdatafile
   \activecatcodes
-  \input \jobname.toc
+  \input \tocreadfilename
 }
 
 \newskip\contentsrightmargin \contentsrightmargin=1in
@@ -5208,11 +5205,16 @@
     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
 }
 
+% redefined for the two-volume lispref.  We always output on
+% \jobname.toc even if this is redefined.
+% 
+\def\tocreadfilename{\jobname.toc}
 
 % Normal (long) toc.
+%
 \def\contents{%
   \startcontents{\putwordTOC}%
-    \openin 1 \jobname.toc
+    \openin 1 \tocreadfilename\space
     \ifeof 1 \else
       \readtocfile
     \fi
@@ -5250,7 +5252,7 @@
     \let\numsubsubsecentry = \numsecentry
     \let\appsubsubsecentry = \numsecentry
     \let\unnsubsubsecentry = \numsecentry
-    \openin 1 \jobname.toc
+    \openin 1 \tocreadfilename\space
     \ifeof 1 \else
       \readtocfile
     \fi
@@ -8340,7 +8342,7 @@
   \textleading = 12pt
   %
   \internalpagesizes{7.5in}{5in}%
-                    {\voffset}{.25in}%
+                    {-.2in}{0in}%
                     {\bindingoffset}{16pt}%
                     {9.25in}{7in}%
   %
--- a/nt/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/nt/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -3,6 +3,10 @@
 	* INSTALL: Fix URL of EmacsW32 site where building with image
 	support is described.
 
+2007-04-26  Glenn Morris  <rgm@gnu.org>
+
+	* emacs.rc: Increase version to 22.1.50.
+
 2007-03-31  Eli Zaretskii  <eliz@gnu.org>
 
 	* INSTALL: Mention the VCVARS32.BAT batch file for VS.NET users.
--- a/nt/emacs.rc	Sat May 19 22:31:10 2007 +0000
+++ b/nt/emacs.rc	Sun May 20 03:12:22 2007 +0000
@@ -6,8 +6,8 @@
 #endif
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 22,0,990,0
- PRODUCTVERSION 22,0,990,0
+ FILEVERSION 22,1,50,0
+ PRODUCTVERSION 22,1,50,0
  FILEFLAGSMASK 0x3FL
 #ifdef EMACSDEBUG
  FILEFLAGS 0x1L
@@ -24,12 +24,12 @@
 	BEGIN
 	    VALUE "CompanyName", "Free Software Foundation\0"
 	    VALUE "FileDescription", "GNU Emacs for Windows NT/95/98/2000/ME/XP\0"
-	    VALUE "FileVersion", "22, 0, 990, 0\0"
+	    VALUE "FileVersion", "22, 1, 50, 0\0"
 	    VALUE "InternalName", "Emacs\0"
 	    VALUE "LegalCopyright", "Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007\0"
 	    VALUE "OriginalFilename", "emacs.exe"
 	    VALUE "ProductName", "Emacs: The extensible self-documenting text editor\0"
-	    VALUE "ProductVersion", "22, 0, 990, 0\0"
+	    VALUE "ProductVersion", "22, 1, 50, 0\0"
 	    VALUE "OLESelfRegister", "\0"
 	 END
      END
--- a/src/ChangeLog	Sat May 19 22:31:10 2007 +0000
+++ b/src/ChangeLog	Sun May 20 03:12:22 2007 +0000
@@ -8,6 +8,59 @@
 	* macterm.c (x_calc_absolute_position): Add BLOCK_INPUT around
 	mac_get_window_bounds.
 
+2007-05-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* Makefile.in (LIBGPM): Allow it to be set from configure.
+	If set then link Emacs with it.
+
+	* config.in: Regenerate.
+
+	* lisp.h (add_gpm_wait_descriptor, delete_gpm_wait_descriptor):
+	New externs.
+
+	* termhooks.h [HAVE_GPM_H] (enum event_kind): Add GPM_CLICK_EVENT.
+	Include gpm.h.
+	(handle_one_term_event, term_gpm) New externs.
+
+	* sysdep.c [HAVE_GPM_H] (init_sys_modes): Make gpm_fd nonblocking
+	and allow it to be interrupted by SIGIO.
+
+	* process.c (gpm_wait_mask, max_gpm_desc): New variables.
+	(wait_reading_process_output): Wait on gpm_fd too.
+	(add_gpm_wait_descriptor, delete_gpm_wait_descriptor)): New functions.
+	(add_gpm_wait_descriptor_called_flag): New variable.
+	(delete_keyboard_wait_descriptor): Check gpm_wait_mask.
+
+	* keyboard.c [HAVE_GPM_H] (Qmouse_fixup_help_message)
+	(make_lispy_movement, tracking_off, Ftrack_mouse, some_mouse_moved)
+	(show_help_echo, readable_events, kbd_buffer_get_event, init_keyboard):
+	Extend HAVE_MOUSE ifdefs to HAVE_GPM_H.
+	(make_lispy_event): Add case GPM_CLICK_EVENT.
+	(read_avail_input): Handle mouse input.
+
+	* term.c (write_glyphs_with_face): New function.
+	[HAVE_GPM_H]: Include buffer.h, sys/fcntl.h.
+	(mouse_face_beg_row, mouse_face_beg_col, mouse_face_end_row)
+	(mouse_face_end_col, mouse_face_past_end, mouse_face_window)
+	(mouse_face_face_id, term_gpm, pos_x, pos_y)
+	(last_mouse_x, last_mouse_y): New variables.
+	(term_show_mouse_face, term_clear_mouse_face, fast_find_position)
+	(term_mouse_highlight, term_mouse_movement, term_mouse_position)
+	(term_mouse_click, handle_one_term_event, Fterm_open_connection)
+	(Fterm_close_connection): New functions.
+	(term_init): Initialise mouse_face_window.
+
+2007-05-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xdisp.c (redisplay_window): If first window line is a
+	continuation line, recompute the new window start instead of
+	recentering.
+
+2007-05-18  Glenn Morris  <rgm@gnu.org>
+
+	* m/alpha.h (ORDINARY_LINK): No longer define on OpenBSD.
+	Suggested by Alfred M. Szmidt <ams@gnu.org>.
+
 2007-05-17  Glenn Morris  <rgm@gnu.org>
 
 	* m/macppc.h (ORDINARY_LINK): No longer define on OpenBSD.
@@ -17,6 +70,10 @@
 	* macterm.c [USE_CARBON_EVENTS] (mac_convert_event_ref): Also convert
 	dead key repeat and up events.
 
+2007-05-14  Chong Yidong  <cyd@stupidchicken.com>
+
+	* image.c (pbm_load): Check image size for monochrome pbm.
+
 2007-05-13  Chong Yidong  <cyd@stupidchicken.com>
 
 	* xterm.c (XTread_socket): Revert last change.
@@ -31,16 +88,14 @@
 
 	* editfns.c (Ftranspose_regions): Yet another int/Lisp_Object mixup (YAILOM)
 
-2007-05-06  Richard Stallman  <rms@gnu.org>
-
-	* process.c: Undo May 3 change.
-
-2007-05-03  Per Cederqvist  <ceder@lysator.liu.se>  (tiny change)
-
-	* process.c (Faccept_process_output): Revert 2006-03-22 change so
-	that the third argument once again is in microseconds (not
-	milliseconds).  This makes it compatible with Emacs 21 and
-	earlier.  Problem found by Henrik Rindl,Av(Bw.
+2007-05-07  Andreas Schwab  <schwab@suse.de>
+
+	* keymap.c (Flookup_key): Fix typo in last change. 
+
+2007-05-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* keymap.c (Fdefine_key, Flookup_key): Only do the 0x80->meta_modifier
+	mapping for unibyte strings.
 
 2007-05-01  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
@@ -51,11 +106,19 @@
 
 	* insdel.c (replace_range): For undo, record insertion first.
 
+2007-04-29  Andreas Schwab  <schwab@suse.de>
+
+	* lisp.h (VECSIZE): Use OFFSETOF.
+
 2007-04-29  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* xdisp.c (try_window_reusing_current_matrix): Fix number of
 	disabled lines.
 
+2007-04-28  Richard Stallman  <rms@gnu.org>
+
+	* lread.c (read_escape): In a string, \s is always space.
+
 2007-04-27  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* xmenu.c (xdialog_show): Call Fredisplay before showing the dialog.
--- a/src/Makefile.in	Sat May 19 22:31:10 2007 +0000
+++ b/src/Makefile.in	Sun May 20 03:12:22 2007 +0000
@@ -460,6 +460,8 @@
 LIBSOUND= @LIBSOUND@
 CFLAGS_SOUND= @CFLAGS_SOUND@
 
+LIBGPM= @LIBGPM@
+
 #ifndef ORDINARY_LINK
 /* Fix linking if compiled with GCC.  */
 #ifdef __GNUC__
@@ -933,7 +935,7 @@
    Note that SunOS needs -lm to come before -lc; otherwise, you get
    duplicated symbols.  If the standard libraries were compiled
    with GCC, we might need gnulib again after them.  */
-LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \
+LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(LIBGPM)\
    LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
    LIBS_DEBUG $(GETLOADAVG_LIBS) $(GNULIB_VAR) LIB_MATH LIB_STANDARD \
    $(GNULIB_VAR)
--- a/src/config.in	Sat May 19 22:31:10 2007 +0000
+++ b/src/config.in	Sun May 20 03:12:22 2007 +0000
@@ -231,6 +231,9 @@
 /* Define to 1 if you have the ungif library (-lungif). */
 #undef HAVE_GIF
 
+/* Define to 1 if you have the <gpm.h> header file. */
+#undef HAVE_GPM_H
+
 /* Define to 1 if you have the `grantpt' function. */
 #undef HAVE_GRANTPT
 
--- a/src/image.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/image.c	Sun May 20 03:12:22 2007 +0000
@@ -5730,7 +5730,17 @@
 	    if (raw_p)
 	      {
 		if ((x & 7) == 0)
-		  c = *p++;
+		  {
+		    if (p >= end)
+		      {
+			x_destroy_x_image (ximg);
+			x_clear_image (f, img);
+			image_error ("Invalid image size in image `%s'",
+				     img->spec, Qnil);
+			goto error;
+		      }
+		    c = *p++;
+		  }
 		g = c & 0x80;
 		c <<= 1;
 	      }
--- a/src/keyboard.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/keyboard.c	Sun May 20 03:12:22 2007 +0000
@@ -521,7 +521,7 @@
 Lisp_Object Qselect_window;
 Lisp_Object Qhelp_echo;
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 Lisp_Object Qmouse_fixup_help_message;
 #endif
 
@@ -677,7 +677,7 @@
 static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int,
 						      Lisp_Object *));
 static Lisp_Object make_lispy_event P_ ((struct input_event *));
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object,
 					    enum scroll_bar_part,
 					    Lisp_Object, Lisp_Object,
@@ -1390,7 +1390,7 @@
   return Qnil;
 }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 
 /* Restore mouse tracking enablement.  See Ftrack_mouse for the only use
    of this function.  */
@@ -1466,7 +1466,7 @@
   return 0;
 }
 
-#endif	/* HAVE_MOUSE */
+#endif	/* HAVE_MOUSE || HAVE_GPM */
 
 /* This is the actual command reading loop,
    sans error-handling encapsulation.  */
@@ -2388,7 +2388,7 @@
 	return;
     }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   if (!noninteractive && STRINGP (help))
     {
       /* The mouse-fixup-help-message Lisp function can call
@@ -3640,7 +3640,7 @@
 	return 1;
     }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
       && !NILP (do_mouse_tracking) && some_mouse_moved ())
     return 1;
@@ -3992,7 +3992,7 @@
     {
       if (kbd_fetch_ptr != kbd_store_ptr)
 	break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
       if (!NILP (do_mouse_tracking) && some_mouse_moved ())
 	break;
 #endif
@@ -4014,7 +4014,7 @@
 #endif /* SIGIO */
       if (kbd_fetch_ptr != kbd_store_ptr)
 	break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
       if (!NILP (do_mouse_tracking) && some_mouse_moved ())
 	break;
 #endif
@@ -4250,7 +4250,7 @@
 	    }
 	}
     }
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   /* Try generating a mouse motion event.  */
   else if (!NILP (do_mouse_tracking) && some_mouse_moved ())
     {
@@ -4291,7 +4291,7 @@
       if (!NILP (x) && NILP (obj))
 	obj = make_lispy_movement (f, bar_window, part, x, y, time);
     }
-#endif	/* HAVE_MOUSE */
+#endif	/* HAVE_MOUSE || HAVE GPM */
   else
     /* We were promised by the above while loop that there was
        something for us to read!  */
@@ -6008,6 +6008,64 @@
       }
 #endif
 
+    case GPM_CLICK_EVENT:
+      {
+	FRAME_PTR f = XFRAME (event->frame_or_window);
+	Lisp_Object head, position;
+	Lisp_Object *start_pos_ptr;
+	Lisp_Object start_pos;
+	int button = event->code;
+
+	if (button >= ASIZE (button_down_location))
+	  {
+	    button_down_location = larger_vector (button_down_location,
+						  button + 1, Qnil);
+	    mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
+	  }
+
+	start_pos_ptr = &AREF (button_down_location, button);
+	start_pos = *start_pos_ptr;
+
+	position = make_lispy_position (f, &event->x, &event->y,
+					    event->timestamp);
+
+ 	if (event->modifiers & down_modifier)
+	  *start_pos_ptr = Fcopy_alist (position);
+	else if (event->modifiers & (up_modifier | drag_modifier))
+	  {
+	    if (!CONSP (start_pos))
+	      return Qnil;
+	    event->modifiers &= ~up_modifier;
+	  }
+
+	head = modify_event_symbol (button,
+				    event->modifiers,
+				    Qmouse_click, Vlispy_mouse_stem,
+				    NULL,
+				    &mouse_syms,
+				    XVECTOR (mouse_syms)->size);
+
+	if (event->modifiers & drag_modifier)
+	  return Fcons (head,
+			Fcons (start_pos,
+			       Fcons (position,
+				      Qnil)));
+	else if (event->modifiers & double_modifier)
+	  return Fcons (head,
+			Fcons (position,
+			       Fcons (make_number (2),
+				      Qnil)));
+	else if (event->modifiers & triple_modifier)
+	  return Fcons (head,
+			Fcons (position,
+			       Fcons (make_number (3),
+				      Qnil)));
+ 	else
+	  return Fcons (head,
+			Fcons (position,
+			       Qnil));
+       }
+
       /* The 'kind' field of the event is something we don't recognize.  */
     default:
       abort ();
@@ -6865,8 +6923,28 @@
       if (n_to_read == 0)
 	return 0;
 #else /* not MSDOS */
+#ifdef HAVE_GPM_H
+      if (term_gpm)
+	{
+	  Gpm_Event event;
+	  struct input_event hold_quit;
+	  int gpm;
+
+	  EVENT_INIT (hold_quit);
+	  hold_quit.kind = NO_EVENT;
+
+	  while (gpm = Gpm_GetEvent (&event), gpm == 1) {
+	    nread += handle_one_term_event (&event, &hold_quit);
+	  }
+	  if (hold_quit.kind != NO_EVENT)
+	    kbd_buffer_store_event (&hold_quit);
+	  if (nread)
+	    return nread;
+	}
+#endif /* HAVE_GPM_H */
 #ifdef FIONREAD
-      /* Find out how much input is available.  */
+
+     /* Find out how much input is available.  */
       if (ioctl (input_fd, FIONREAD, &n_to_read) < 0)
 	/* Formerly simply reported no input, but that sometimes led to
 	   a failure of Emacs to terminate.
@@ -11045,7 +11123,7 @@
   recent_keys_index = 0;
   kbd_fetch_ptr = kbd_buffer;
   kbd_store_ptr = kbd_buffer;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   do_mouse_tracking = Qnil;
 #endif
   input_pending = 0;
@@ -11235,7 +11313,7 @@
   Qmenu_bar = intern ("menu-bar");
   staticpro (&Qmenu_bar);
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   Qmouse_fixup_help_message = intern ("mouse-fixup-help-message");
   staticpro (&Qmouse_fixup_help_message);
 #endif
@@ -11367,7 +11445,7 @@
   defsubr (&Sread_key_sequence);
   defsubr (&Sread_key_sequence_vector);
   defsubr (&Srecursive_edit);
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   defsubr (&Strack_mouse);
 #endif
   defsubr (&Sinput_pending_p);
--- a/src/keymap.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/keymap.c	Sun May 20 03:12:22 2007 +0000
@@ -1156,7 +1156,8 @@
   if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt))
     Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands);
 
-  meta_bit = VECTORP (key) ? meta_modifier : 0x80;
+  meta_bit = (VECTORP (key) || STRINGP (key) && STRING_MULTIBYTE (key)
+	      ? meta_modifier : 0x80);
 
   if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0)))
     { /* DEF is apparently an XEmacs-style keyboard macro.  */
@@ -1312,7 +1313,7 @@
 	c = Fevent_convert_list (c);
 
       /* Turn the 8th bit of string chars into a meta modifier.  */
-      if (INTEGERP (c) && XINT (c) & 0x80 && STRINGP (key))
+      if (STRINGP (key) && XINT (c) & 0x80 && !STRING_MULTIBYTE (key))
 	XSETINT (c, (XINT (c) | meta_modifier) & ~0x80);
 
       /* Allow string since binding for `menu-bar-select-buffer'
--- a/src/lisp.h	Sat May 19 22:31:10 2007 +0000
+++ b/src/lisp.h	Sun May 20 03:12:22 2007 +0000
@@ -735,9 +735,9 @@
 
 /* If a struct is made to look like a vector, this macro returns the length
    of the shortest vector that would hold that struct.  */
-#define VECSIZE(type) ((sizeof (type) - (sizeof (struct Lisp_Vector)  \
-                                         - sizeof (Lisp_Object))      \
-                        + sizeof(Lisp_Object) - 1) /* round up */     \
+#define VECSIZE(type) ((sizeof (type)					  \
+			- OFFSETOF (struct Lisp_Vector, contents[0])      \
+                        + sizeof(Lisp_Object) - 1) /* round up */	  \
 		       / sizeof (Lisp_Object))
 
 /* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
@@ -3096,6 +3096,8 @@
 					    int));
 extern void add_keyboard_wait_descriptor P_ ((int));
 extern void delete_keyboard_wait_descriptor P_ ((int));
+extern void add_gpm_wait_descriptor P_ ((int));
+extern void delete_gpm_wait_descriptor P_ ((int));
 extern void close_process_descs P_ ((void));
 extern void init_process P_ ((void));
 extern void syms_of_process P_ ((void));
--- a/src/lread.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/lread.c	Sun May 20 03:12:22 2007 +0000
@@ -1894,7 +1894,7 @@
 
     case 's':
       c = READCHAR;
-      if (c != '-')
+      if (stringp || c != '-')
 	{
 	  UNREAD (c);
 	  return ' ';
--- a/src/m/alpha.h	Sat May 19 22:31:10 2007 +0000
+++ b/src/m/alpha.h	Sun May 20 03:12:22 2007 +0000
@@ -99,10 +99,6 @@
 # endif
 #endif
 
-#if defined(__OpenBSD__)
-#define ORDINARY_LINK
-#endif
-
 #ifdef __ELF__
 #undef UNEXEC
 #define UNEXEC unexelf.o
--- a/src/process.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/process.c	Sun May 20 03:12:22 2007 +0000
@@ -328,14 +328,18 @@
 
 static SELECT_TYPE input_wait_mask;
 
-/* Mask that excludes keyboard input descriptor (s).  */
+/* Mask that excludes keyboard input descriptor(s).  */
 
 static SELECT_TYPE non_keyboard_wait_mask;
 
-/* Mask that excludes process input descriptor (s).  */
+/* Mask that excludes process input descriptor(s).  */
 
 static SELECT_TYPE non_process_wait_mask;
 
+/* Mask for the gpm mouse input descriptor.  */
+
+static SELECT_TYPE gpm_wait_mask;
+
 #ifdef NON_BLOCKING_CONNECT
 /* Mask of bits indicating the descriptors that we wait for connect to
    complete on.  Once they complete, they are removed from this mask
@@ -357,6 +361,9 @@
 /* The largest descriptor currently in use for keyboard input.  */
 static int max_keyboard_desc;
 
+/* The largest descriptor currently in use for gpm mouse input.  */
+static int max_gpm_desc;
+
 /* Nonzero means delete a process right away if it exits.  */
 static int delete_exited_processes;
 
@@ -4446,7 +4453,8 @@
 	  IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
 
 	  EMACS_SET_SECS_USECS (timeout, 0, 0);
-	  if ((select (max (max_process_desc, max_keyboard_desc) + 1,
+	  if ((select (max (max (max_process_desc, max_keyboard_desc),
+			      max_gpm_desc) + 1,
 		       &Atemp,
 #ifdef NON_BLOCKING_CONNECT
 		       (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
@@ -4591,7 +4599,8 @@
 	    }
 #endif
 
-	  nfds = select (max (max_process_desc, max_keyboard_desc) + 1,
+	  nfds = select (max (max (max_process_desc, max_keyboard_desc),
+			      max_gpm_desc) + 1,
 			 &Available,
 #ifdef NON_BLOCKING_CONNECT
 			 (check_connect ? &Connecting : (SELECT_TYPE *)0),
@@ -6978,6 +6987,21 @@
     max_keyboard_desc = desc;
 }
 
+static int add_gpm_wait_descriptor_called_flag;
+
+void
+add_gpm_wait_descriptor (desc)
+     int desc;
+{
+  if (! add_gpm_wait_descriptor_called_flag)
+    FD_CLR (0, &input_wait_mask);
+  add_gpm_wait_descriptor_called_flag = 1;
+  FD_SET (desc, &input_wait_mask);
+  FD_SET (desc, &gpm_wait_mask);
+  if (desc > max_gpm_desc)
+    max_gpm_desc = desc;
+}
+
 /* From now on, do not expect DESC to give keyboard input.  */
 
 void
@@ -6993,10 +7017,29 @@
   if (desc == max_keyboard_desc)
     for (fd = 0; fd < lim; fd++)
       if (FD_ISSET (fd, &input_wait_mask)
-	  && !FD_ISSET (fd, &non_keyboard_wait_mask))
+	  && !FD_ISSET (fd, &non_keyboard_wait_mask)
+	  && !FD_ISSET (fd, &gpm_wait_mask))
 	max_keyboard_desc = fd;
 }
 
+void
+delete_gpm_wait_descriptor (desc)
+     int desc;
+{
+  int fd;
+  int lim = max_gpm_desc;
+
+  FD_CLR (desc, &input_wait_mask);
+  FD_CLR (desc, &non_process_wait_mask);
+
+  if (desc == max_gpm_desc)
+    for (fd = 0; fd < lim; fd++)
+      if (FD_ISSET (fd, &input_wait_mask)
+	  && !FD_ISSET (fd, &non_keyboard_wait_mask)
+	  && !FD_ISSET (fd, &non_process_wait_mask))
+	max_gpm_desc = fd;
+}
+
 /* Return nonzero if *MASK has a bit set
    that corresponds to one of the keyboard input descriptors.  */
 
--- a/src/sysdep.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/sysdep.c	Sun May 20 03:12:22 2007 +0000
@@ -1675,6 +1675,14 @@
       old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0);
       fcntl (input_fd, F_SETOWN, getpid ());
       init_sigio (input_fd);
+#ifdef HAVE_GPM_H
+      if (term_gpm)
+	{
+	  fcntl (gpm_fd, F_SETOWN, getpid ());
+	  fcntl (gpm_fd, F_SETFL, O_NONBLOCK);
+	  init_sigio (gpm_fd);
+	}
+#endif /* HAVE_GPM_H */
     }
 #endif /* F_GETOWN */
 #endif /* F_SETOWN_BUG */
--- a/src/term.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/term.c	Sun May 20 03:12:22 2007 +0000
@@ -144,25 +144,6 @@
 
 void (*frame_up_to_date_hook) P_ ((struct frame *));
 
-/* Return the current position of the mouse.
-
-   Set *f to the frame the mouse is in, or zero if the mouse is in no
-   Emacs frame.  If it is set to zero, all the other arguments are
-   garbage.
-
-   If the motion started in a scroll bar, set *bar_window to the
-   scroll bar's window, *part to the part the mouse is currently over,
-   *x to the position of the mouse along the scroll bar, and *y to the
-   overall length of the scroll bar.
-
-   Otherwise, set *bar_window to Qnil, and *x and *y to the column and
-   row of the character cell the mouse is over.
-
-   Set *time to the time the mouse was at the returned position.
-
-   This should clear mouse_moved until the next motion
-   event arrives.  */
-
 void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist,
 				 Lisp_Object *bar_window,
 				 enum scroll_bar_part *part,
@@ -413,6 +394,9 @@
 char *tparam ();
 
 extern char *tgetstr ();
+
+static void term_clear_mouse_face ();
+static void term_mouse_highlight (struct frame *f, int x, int y);
 
 
 #ifdef WINDOWSNT
@@ -426,6 +410,33 @@
 #define FRAME_TERMCAP_P(_f_) 0
 #endif /* WINDOWSNT */
 
+#ifdef HAVE_GPM_H
+#include <sys/fcntl.h>
+#include "buffer.h"
+
+/* Nonzero means mouse is enabled on Linux console.  */
+int term_gpm = 0;
+
+/* These variables describe the range of text currently shown in its
+   mouse-face, together with the window they apply to.  As long as
+   the mouse stays within this range, we need not redraw anything on
+   its account.  Rows and columns are glyph matrix positions in
+   MOUSE_FACE_WINDOW.  */
+static int mouse_face_beg_row, mouse_face_beg_col;
+static int mouse_face_end_row, mouse_face_end_col;
+static int mouse_face_past_end;
+static Lisp_Object mouse_face_window;
+static int mouse_face_face_id;
+
+/* FRAME and X, Y position of mouse when last checked for
+   highlighting.  X and Y can be negative or out of range for the frame.  */
+struct frame *mouse_face_mouse_frame;
+int mouse_face_mouse_x, mouse_face_mouse_y;
+
+static int pos_x, pos_y;
+static int last_mouse_x, last_mouse_y;
+#endif /* HAVE_GPM_H */
+
 void
 ring_bell ()
 {
@@ -1010,6 +1021,65 @@
   cmcheckmagic ();
 }
 
+void
+write_glyphs_with_face (string, len, face_id)
+     register struct glyph *string;
+     register int len, face_id;
+{
+  struct frame *sf = XFRAME (selected_frame);
+  struct frame *f = updating_frame ? updating_frame : sf;
+  unsigned char *conversion_buffer;
+  struct coding_system *coding;
+
+  turn_off_insert ();
+  tty_hide_cursor ();
+
+  /* Don't dare write in last column of bottom line, if Auto-Wrap,
+     since that would scroll the whole frame on some terminals.  */
+
+  if (AutoWrap
+      && curY + 1 == FRAME_LINES (sf)
+      && (curX + len) == FRAME_COLS (sf))
+    len --;
+  if (len <= 0)
+    return;
+
+  cmplus (len);
+
+  /* If terminal_coding does any conversion, use it, otherwise use
+     safe_terminal_coding.  We can't use CODING_REQUIRE_ENCODING here
+     because it always return 1 if the member src_multibyte is 1.  */
+  coding = (terminal_coding.common_flags & CODING_REQUIRE_ENCODING_MASK
+	    ? &terminal_coding : &safe_terminal_coding);
+  /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
+     the tail.  */
+  coding->mode &= ~CODING_MODE_LAST_BLOCK;
+
+
+  /* Turn appearance modes of the face.  */
+  highlight_if_desired ();
+  turn_on_face (f, face_id);
+
+  coding->mode |= CODING_MODE_LAST_BLOCK;
+  conversion_buffer = encode_terminal_code (string, len, coding);
+  if (coding->produced > 0)
+    {
+      BLOCK_INPUT;
+      fwrite (conversion_buffer, 1, coding->produced, stdout);
+      if (ferror (stdout))
+	clearerr (stdout);
+      if (termscript)
+	fwrite (conversion_buffer, 1, coding->produced, termscript);
+      UNBLOCK_INPUT;
+    }
+
+  /* Turn appearance modes off.  */
+  turn_off_face (f, face_id);
+  turn_off_highlight ();
+
+  cmcheckmagic ();
+}
+
 /* If start is zero, insert blanks instead of a string at start */
 
 void
@@ -2308,6 +2378,656 @@
 
 
 /***********************************************************************
+			       Mouse
+ ***********************************************************************/
+
+#ifdef HAVE_GPM_H
+static void
+term_show_mouse_face (enum draw_glyphs_face draw)
+{
+  struct window *w = XWINDOW (mouse_face_window);
+  int save_x, save_y;
+  int i, j;
+
+  if (/* If window is in the process of being destroyed, don't bother
+	 to do anything.  */
+      w->current_matrix != NULL
+      /* Recognize when we are called to operate on rows that don't exist
+	 anymore.  This can happen when a window is split.  */
+      && mouse_face_end_row < w->current_matrix->nrows)
+    {
+      /* write_glyphs writes at cursor position, so we need to
+	 temporarily move cursor coordinates to the beginning of
+	 the highlight region.  */
+      
+      /* Save current cursor co-ordinates */
+      save_y = curY;
+      save_x = curX;
+
+      /* Note that mouse_face_beg_row etc. are window relative.  */
+      for (i = mouse_face_beg_row; i <= mouse_face_end_row; i++)
+	{
+	  int start_hpos, end_hpos, nglyphs;
+	  struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
+
+	  /* Don't do anything if row doesn't have valid contents.  */
+	  if (!row->enabled_p)
+	    continue;
+
+	  /* For all but the first row, the highlight starts at column 0.  */
+	  if (i == mouse_face_beg_row)
+	    start_hpos = mouse_face_beg_col;
+	  else
+	    start_hpos = 0;
+
+	  if (i == mouse_face_end_row)
+	    end_hpos = mouse_face_end_col;
+	  else
+	    {
+	      end_hpos = row->used[TEXT_AREA];
+	      if (draw == DRAW_NORMAL_TEXT)
+		row->fill_line_p = 1; /* Clear to end of line */
+	    }
+
+	  if (end_hpos <= start_hpos)
+	    continue;
+	  /* Record that some glyphs of this row are displayed in
+	     mouse-face.  */
+	  row->mouse_face_p = draw > 0;
+
+	  nglyphs = end_hpos - start_hpos;
+
+	  if (end_hpos >= row->used[TEXT_AREA])
+	    nglyphs = row->used[TEXT_AREA] - start_hpos;
+
+	  pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
+	  pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
+	    + WINDOW_LEFT_EDGE_X (w);
+	  
+	  cursor_to (pos_y, pos_x);
+
+	  if (draw == DRAW_MOUSE_FACE)
+	    {
+	      write_glyphs_with_face (row->glyphs[TEXT_AREA] + start_hpos,
+				      nglyphs, mouse_face_face_id);
+	    }
+	  else /* draw == DRAW_NORMAL_TEXT */
+	    write_glyphs (row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
+	}
+      cursor_to (save_y, save_x);
+    }
+}
+
+static void
+term_clear_mouse_face ()
+{
+  if (!NILP (mouse_face_window))
+    term_show_mouse_face (DRAW_NORMAL_TEXT);
+
+  mouse_face_beg_row = mouse_face_beg_col = -1;
+  mouse_face_end_row = mouse_face_end_col = -1;
+  mouse_face_window = Qnil;
+}
+
+/* Find the glyph matrix position of buffer position POS in window W.
+   *HPOS and *VPOS are set to the positions found.  W's current glyphs
+   must be up to date.  If POS is above window start return (0, 0).
+   If POS is after end of W, return end of last line in W.
+   - taken from msdos.c */
+static int
+fast_find_position (struct window *w, int pos, int *hpos, int *vpos)
+{
+  int i, lastcol, line_start_position, maybe_next_line_p = 0;
+  int yb = window_text_bottom_y (w);
+  struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
+
+  while (row->y < yb)
+    {
+      if (row->used[TEXT_AREA])
+	line_start_position = row->glyphs[TEXT_AREA]->charpos;
+      else
+	line_start_position = 0;
+
+      if (line_start_position > pos)
+	break;
+      /* If the position sought is the end of the buffer,
+	 don't include the blank lines at the bottom of the window.  */
+      else if (line_start_position == pos
+	       && pos == BUF_ZV (XBUFFER (w->buffer)))
+	{
+	  maybe_next_line_p = 1;
+	  break;
+	}
+      else if (line_start_position > 0)
+	best_row = row;
+
+      /* Don't overstep the last matrix row, lest we get into the
+	 never-never land... */
+      if (row->y + 1 >= yb)
+	break;
+
+      ++row;
+    }
+
+  /* Find the right column within BEST_ROW.  */
+  lastcol = 0;
+  row = best_row;
+  for (i = 0; i < row->used[TEXT_AREA]; i++)
+    {
+      struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
+      int charpos;
+
+      charpos = glyph->charpos;
+      if (charpos == pos)
+	{
+	  *hpos = i;
+	  *vpos = row->y;
+	  return 1;
+	}
+      else if (charpos > pos)
+	break;
+      else if (charpos > 0)
+	lastcol = i;
+    }
+
+  /* If we're looking for the end of the buffer,
+     and we didn't find it in the line we scanned,
+     use the start of the following line.  */
+  if (maybe_next_line_p)
+    {
+      ++row;
+      lastcol = 0;
+    }
+
+  *vpos = row->y;
+  *hpos = lastcol + 1;
+  return 0;
+}
+
+static void
+term_mouse_highlight (struct frame *f, int x, int y)
+{
+  enum window_part part;
+  Lisp_Object window;
+  struct window *w;
+  struct buffer *b;
+
+  if (NILP (Vmouse_highlight)
+      || !f->glyphs_initialized_p)
+    return;
+
+  mouse_face_mouse_x = x;
+  mouse_face_mouse_y = y;
+  mouse_face_mouse_frame = f;
+
+  /* Which window is that in?  */
+  window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
+
+  /* Not on a window -> return.  */
+  if (!WINDOWP (window))
+    return;
+
+  if (!EQ (window, mouse_face_window))
+    term_clear_mouse_face ();
+
+  w = XWINDOW (window);
+
+  /* Are we in a window whose display is up to date?
+     And verify the buffer's text has not changed.  */
+  b = XBUFFER (w->buffer);
+  if (part == ON_TEXT
+      && EQ (w->window_end_valid, w->buffer)
+      && XFASTINT (w->last_modified) == BUF_MODIFF (b)
+      && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
+    {
+      int pos, i, nrows = w->current_matrix->nrows;
+      struct glyph_row *row;
+      struct glyph *glyph;
+
+      /* Find the glyph under X/Y.  */
+      glyph = NULL;
+      if (y >= 0 && y < nrows)
+	{
+	  row = MATRIX_ROW (w->current_matrix, y);
+	  /* Give up if some row before the one we are looking for is
+	     not enabled.  */
+	  for (i = 0; i <= y; i++)
+	    if (!MATRIX_ROW (w->current_matrix, i)->enabled_p)
+	      break;
+	  if (i > y  /* all rows upto and including the one at Y are enabled */
+	      && row->displays_text_p
+	      && x <  window_box_width (w, TEXT_AREA))
+	    {
+	      glyph = row->glyphs[TEXT_AREA];
+	      if (x >= row->used[TEXT_AREA])
+		glyph = NULL;
+	      else
+		{
+		  glyph += x;
+		  if (!BUFFERP (glyph->object))
+		    glyph = NULL;
+		}
+	    }
+	}
+
+      /* Clear mouse face if X/Y not over text.  */
+      if (glyph == NULL)
+	{
+	  term_clear_mouse_face ();
+	  return;
+	}
+
+      if (!BUFFERP (glyph->object))
+	abort ();
+      pos = glyph->charpos;
+
+      /* Check for mouse-face.  */
+      {
+	extern Lisp_Object Qmouse_face;
+	Lisp_Object mouse_face, overlay, position, *overlay_vec;
+	int noverlays, obegv, ozv;;
+	struct buffer *obuf;
+
+	/* If we get an out-of-range value, return now; avoid an error.  */
+	if (pos > BUF_Z (b))
+	  return;
+
+	/* Make the window's buffer temporarily current for
+	   overlays_at and compute_char_face.  */
+	obuf = current_buffer;
+	current_buffer = b;
+	obegv = BEGV;
+	ozv = ZV;
+	BEGV = BEG;
+	ZV = Z;
+
+	/* Is this char mouse-active?  */
+	XSETINT (position, pos);
+
+	/* Put all the overlays we want in a vector in overlay_vec.  */
+	GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
+	/* Sort overlays into increasing priority order.  */
+	noverlays = sort_overlays (overlay_vec, noverlays, w);
+
+	/* Check mouse-face highlighting.  */
+	if (!(EQ (window, mouse_face_window)
+	      && y >= mouse_face_beg_row
+	      && y <= mouse_face_end_row
+	      && (y > mouse_face_beg_row
+		  || x >= mouse_face_beg_col)
+	      && (y < mouse_face_end_row
+		  || x < mouse_face_end_col
+		  || mouse_face_past_end)))
+	  {
+	    /* Clear the display of the old active region, if any.  */
+	    term_clear_mouse_face ();
+
+	    /* Find the highest priority overlay that has a mouse-face
+	       property.  */
+	    overlay = Qnil;
+	    for (i = noverlays - 1; i >= 0; --i)
+	      {
+		mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
+		if (!NILP (mouse_face))
+		  {
+		    overlay = overlay_vec[i];
+		    break;
+		  }
+	      }
+
+	    /* If no overlay applies, get a text property.  */
+	    if (NILP (overlay))
+	      mouse_face = Fget_text_property (position, Qmouse_face,
+					       w->buffer);
+
+	    /* Handle the overlay case.  */
+	    if (!NILP (overlay))
+	      {
+		/* Find the range of text around this char that
+		   should be active.  */
+		Lisp_Object before, after;
+		int ignore;
+
+
+		before = Foverlay_start (overlay);
+		after = Foverlay_end (overlay);
+		/* Record this as the current active region.  */
+		fast_find_position (w, XFASTINT (before),
+				    &mouse_face_beg_col,
+				    &mouse_face_beg_row);
+
+		mouse_face_past_end
+		  = !fast_find_position (w, XFASTINT (after),
+					 &mouse_face_end_col,
+					 &mouse_face_end_row);
+		mouse_face_window = window;
+
+		mouse_face_face_id
+		  = face_at_buffer_position (w, pos, 0, 0,
+					     &ignore, pos + 1, 1);
+
+		/* Display it as active.  */
+		term_show_mouse_face (DRAW_MOUSE_FACE);
+	      }
+	    /* Handle the text property case.  */
+	    else if (!NILP (mouse_face))
+	      {
+		/* Find the range of text around this char that
+		   should be active.  */
+		Lisp_Object before, after, beginning, end;
+		int ignore;
+
+		beginning = Fmarker_position (w->start);
+		XSETINT (end, (BUF_Z (b) - XFASTINT (w->window_end_pos)));
+		before
+		  = Fprevious_single_property_change (make_number (pos + 1),
+						      Qmouse_face,
+						      w->buffer, beginning);
+		after
+		  = Fnext_single_property_change (position, Qmouse_face,
+						  w->buffer, end);
+
+		/* Record this as the current active region.  */
+		fast_find_position (w, XFASTINT (before),
+				    &mouse_face_beg_col,
+				    &mouse_face_beg_row);
+		mouse_face_past_end
+		  = !fast_find_position (w, XFASTINT (after),
+					 &mouse_face_end_col,
+					 &mouse_face_end_row);
+		mouse_face_window = window;
+
+		mouse_face_face_id
+		  = face_at_buffer_position (w, pos, 0, 0,
+					     &ignore, pos + 1, 1);
+
+		/* Display it as active.  */
+		term_show_mouse_face (DRAW_MOUSE_FACE);
+	      }
+	  }
+
+	/* Look for a `help-echo' property.  */
+	{
+	  Lisp_Object help;
+	  extern Lisp_Object Qhelp_echo;
+
+	  /* Check overlays first.  */
+	  help = Qnil;
+	  for (i = noverlays - 1; i >= 0 && NILP (help); --i)
+	    {
+	      overlay = overlay_vec[i];
+	      help = Foverlay_get (overlay, Qhelp_echo);
+	    }
+
+	  if (!NILP (help))
+	    {
+	      help_echo_string = help;
+	      help_echo_window = window;
+	      help_echo_object = overlay;
+	      help_echo_pos = pos;
+	    }
+	  /* Try text properties.  */
+	  else if (NILP (help)
+		   && ((STRINGP (glyph->object)
+			&& glyph->charpos >= 0
+			&& glyph->charpos < SCHARS (glyph->object))
+		       || (BUFFERP (glyph->object)
+			   && glyph->charpos >= BEGV
+			   && glyph->charpos < ZV)))
+	    {
+	      help = Fget_text_property (make_number (glyph->charpos),
+					 Qhelp_echo, glyph->object);
+	      if (!NILP (help))
+		{
+		  help_echo_string = help;
+		  help_echo_window = window;
+		  help_echo_object = glyph->object;
+		  help_echo_pos = glyph->charpos;
+		}
+	    }
+	}
+
+	BEGV = obegv;
+	ZV = ozv;
+	current_buffer = obuf;
+      }
+    }
+}
+
+static int
+term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
+{
+  /* Has the mouse moved off the glyph it was on at the last sighting?  */
+  if (event->x != last_mouse_x || event->y != last_mouse_y)
+    {
+      frame->mouse_moved = 1;
+      term_mouse_highlight (frame, event->x - 1, event->y - 1);
+      /* Remember which glyph we're now on.  */
+      last_mouse_x = event->x;
+      last_mouse_y = event->y;
+      return 1;
+    }
+  return 0;
+}
+
+/* Return the current position of the mouse.
+
+   Set *f to the frame the mouse is in, or zero if the mouse is in no
+   Emacs frame.  If it is set to zero, all the other arguments are
+   garbage.
+
+   Set *bar_window to Qnil, and *x and *y to the column and
+   row of the character cell the mouse is over.
+
+   Set *time to the time the mouse was at the returned position.
+
+   This should clear mouse_moved until the next motion
+   event arrives.
+
+   NOT CURRENTLY INVOKED: see mouse_position_hook below.  */
+static void
+term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
+		     enum scroll_bar_part *part, Lisp_Object *x,
+		     Lisp_Object *y, unsigned long *time)
+{
+  Gpm_Event event;
+  struct timeval now;
+  int i;
+
+  BLOCK_INPUT;
+
+  *fp = SELECTED_FRAME ();
+
+  *bar_window = Qnil;
+  *part = 0;
+
+  i = Gpm_GetSnapshot (&event);
+
+  XSETINT (*x, event.x);
+  XSETINT (*y, event.y);
+  gettimeofday(&now, 0);
+  *time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
+
+  UNBLOCK_INPUT;
+}
+
+/* Prepare a mouse-event in *RESULT for placement in the input queue.
+
+   If the event is a button press, then note that we have grabbed
+   the mouse.  */
+
+static Lisp_Object
+term_mouse_click (struct input_event *result, Gpm_Event *event,
+		  struct frame *f)
+{
+  struct timeval now;
+  int i, j;
+
+  result->kind = GPM_CLICK_EVENT;
+  for (i = 0, j = GPM_B_LEFT; i < 3; i++, j >>= 1 )
+    {
+      if (event->buttons & j) {
+	result->code = i; /* button number */
+	break;
+      }
+    }
+  gettimeofday(&now, 0);
+  result->timestamp = (now.tv_sec * 1000) + (now.tv_usec / 1000);
+
+  if (event->type & GPM_UP)
+    result->modifiers = up_modifier;
+  else if (event->type & GPM_DOWN)
+    result->modifiers = down_modifier;
+  else
+    result->modifiers = 0;
+  
+  if (event->type & GPM_SINGLE)
+    result->modifiers |= click_modifier;
+  
+  if (event->type & GPM_DOUBLE)
+    result->modifiers |= double_modifier;
+
+  if (event->type & GPM_TRIPLE)
+    result->modifiers |= triple_modifier;
+
+  if (event->type & GPM_DRAG)
+    result->modifiers |= drag_modifier;
+
+  if (!(event->type & (GPM_MOVE|GPM_DRAG))) {
+
+    /* 1 << KG_SHIFT */
+    if (event->modifiers & (1 << 0))
+      result->modifiers |= shift_modifier;
+
+    /* 1 << KG_CTRL */
+    if (event->modifiers & (1 << 2))
+      result->modifiers |= ctrl_modifier;
+
+    /* 1 << KG_ALT || KG_ALTGR */
+    if (event->modifiers & (1 << 3)
+	|| event->modifiers & (1 << 1))
+      result->modifiers |= meta_modifier;
+  }
+
+  XSETINT (result->x, event->x - 1);
+  XSETINT (result->y, event->y - 1);
+  XSETFRAME (result->frame_or_window, f);
+  result->arg = Qnil;
+  return Qnil;
+}
+
+int 
+handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
+{
+  struct frame *f = SELECTED_FRAME ();
+  int i, j, fd;
+  struct input_event ie;
+  int do_help = 0;
+  int count = 0;
+
+  EVENT_INIT (ie);
+  ie.kind = NO_EVENT;
+  ie.arg = Qnil;
+
+  if (event->type & GPM_MOVE) {
+    unsigned char buf[6 * sizeof (short)];
+    unsigned short *arg = (unsigned short *) buf + 1;
+    const char *name;
+
+    previous_help_echo_string = help_echo_string;
+    help_echo_string = Qnil;
+
+    /* Display mouse pointer */
+    buf[sizeof(short) - 1] = 2;  /* set selection */
+
+    arg[0] = arg[2] = (unsigned short) event->x;
+    arg[1] = arg[3] = (unsigned short) event->y;
+    arg[4] = (unsigned short) 3;
+    
+    name = (const char *) ttyname (0);
+    fd = open (name, O_WRONLY);
+    ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1);
+    close(fd);
+
+    term_mouse_movement (f, event);
+
+    /* If the contents of the global variable help_echo_string
+       has changed, generate a HELP_EVENT.  */
+    if (!NILP (help_echo_string)
+	|| !NILP (previous_help_echo_string))
+      do_help = 1;
+
+    goto done;
+  }
+  else {
+    f->mouse_moved = 0;
+    term_mouse_click (&ie, event, f);
+    //kbd_buffer_store_event_hold (&ie, hold_quit);
+  }
+
+ done:
+  if (ie.kind != NO_EVENT)
+    {
+      kbd_buffer_store_event_hold (&ie, hold_quit);
+      count++;
+    }
+
+  if (do_help
+      && !(hold_quit && hold_quit->kind != NO_EVENT))
+    {
+      Lisp_Object frame;
+
+      if (f)
+	XSETFRAME (frame, f);
+      else
+	frame = Qnil;
+
+      gen_help_event (help_echo_string, frame, help_echo_window,
+		      help_echo_object, help_echo_pos);
+      count++;
+    }
+
+  return count;
+}
+
+DEFUN ("term-open-connection", Fterm_open_connection, Sterm_open_connection,
+       0, 0, 0,
+       doc: /* Open a connection to Gpm.  */)
+     ()
+{
+  Gpm_Connect connection;
+
+  connection.eventMask = ~0;
+  connection.defaultMask = ~GPM_HARD;
+  connection.maxMod = ~0;
+  connection.minMod = 0;
+
+  if (Gpm_Open (&connection, 0) < 0)
+    return Qnil;
+  else
+    {
+      term_gpm = 1;
+      reset_sys_modes ();
+      init_sys_modes ();
+      add_gpm_wait_descriptor (gpm_fd);
+      return Qt;
+    }
+}
+
+DEFUN ("term-close-connection", Fterm_close_connection, Sterm_close_connection,
+       0, 0, 0,
+       doc: /* Close a connection to Gpm.  */)
+     ()
+{
+   delete_gpm_wait_descriptor (gpm_fd);
+   while (Gpm_Close()); /* close all the stack */
+   term_gpm = 0;
+   return Qnil;
+}
+#endif /* HAVE_GPM_H */
+
+
+/***********************************************************************
 			    Initialization
  ***********************************************************************/
 
@@ -2325,6 +3045,14 @@
 
   encode_terminal_bufsize = 0;
 
+#ifdef HAVE_GPM_H
+  /* TODO: Can't get Gpm_Snapshot in term_mouse_position to work: test with
+     (mouse-position).  Also set-mouse-position won't work as is.  */
+  /* mouse_position_hook = term_mouse_position;  */
+
+  mouse_face_window = Qnil;
+#endif
+
 #ifdef WINDOWSNT
   initialize_w32_display ();
 
@@ -2772,6 +3500,10 @@
   defsubr (&Stty_display_color_p);
   defsubr (&Stty_display_color_cells);
   defsubr (&Stty_no_underline);
+#ifdef HAVE_GPM_H
+  defsubr (&Sterm_open_connection);
+  defsubr (&Sterm_close_connection);
+#endif /* HAVE_GPM_H */
 
   fullscreen_hook = NULL;
 }
--- a/src/termhooks.h	Sat May 19 22:31:10 2007 +0000
+++ b/src/termhooks.h	Sun May 20 03:12:22 2007 +0000
@@ -340,7 +340,11 @@
      symbols, respectively.  Member `arg' is a Lisp object converted
      from the received Apple event.  Parameters for non-Apple events
      are converted to those in Apple events.  */
-  MAC_APPLE_EVENT
+  MAC_APPLE_EVENT,
+#endif
+
+#ifdef HAVE_GPM_H
+  GPM_CLICK_EVENT
 #endif
 };
 
@@ -446,6 +450,14 @@
   meta_modifier	=  CHAR_META	/* Under X, the XK_Meta_[LR] keysyms.  */
 };
 
+#ifdef HAVE_GPM_H
+#include <gpm.h>
+extern int handle_one_term_event (Gpm_Event *, struct input_event *);
+
+/* Nonzero means mouse is enabled on Linux console */
+extern int term_gpm;
+#endif
+
 #endif
 
 /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
--- a/src/xdisp.c	Sat May 19 22:31:10 2007 +0000
+++ b/src/xdisp.c	Sun May 20 03:12:22 2007 +0000
@@ -12777,7 +12777,7 @@
   int rc;
   int centering_position = -1;
   int last_line_misfit = 0;
-  int save_beg_unchanged, save_end_unchanged;
+  int beg_unchanged, end_unchanged;
 
   SET_TEXT_POS (lpoint, PT, PT_BYTE);
   opoint = lpoint;
@@ -12842,8 +12842,8 @@
   set_buffer_internal_1 (XBUFFER (w->buffer));
   SET_TEXT_POS (opoint, PT, PT_BYTE);
 
-  save_beg_unchanged = BEG_UNCHANGED;
-  save_end_unchanged = END_UNCHANGED;
+  beg_unchanged = BEG_UNCHANGED;
+  end_unchanged = END_UNCHANGED;
 
   current_matrix_up_to_date_p
     = (!NILP (w->window_end_valid)
@@ -12968,6 +12968,8 @@
 	w->force_start = Qt;
     }
 
+ force_start:
+
   /* Handle case where place to start displaying has been specified,
      unless the specified location is outside the accessible range.  */
   if (!NILP (w->force_start)
@@ -13147,40 +13149,16 @@
 	 than a simple mouse-click.  */
       if (NILP (w->start_at_line_beg)
 	  && NILP (do_mouse_tracking)
-	  && CHARPOS (startp) > BEGV)
-	{
-#if 0
-	  /* The following code tried to make BEG_UNCHANGED and
-	     END_UNCHANGED up to date (similar to try_window_id).
-	     Is it important to do so?
-
-	     The trouble is that it's a little too strict when it
-	     comes to overlays: modify_overlay can call
-	     BUF_COMPUTE_UNCHANGED, which alters BUF_BEG_UNCHANGED and
-	     BUF_END_UNCHANGED directly without moving the gap.
-
-	     This can result in spurious recentering when overlays are
-	     altered in the buffer.  So unless it's proven necessary,
-	     let's leave this commented out for now. -- cyd.  */
-	  if (MODIFF > SAVE_MODIFF
-	      || BEG_UNCHANGED + END_UNCHANGED > Z_BYTE)
-	    {
-	      if (GPT - BEG < BEG_UNCHANGED)
-		BEG_UNCHANGED = GPT - BEG;
-	      if (Z - GPT < END_UNCHANGED)
-		END_UNCHANGED = Z - GPT;
-	    }
-#endif
-
-	  if (CHARPOS (startp) > BEG + save_beg_unchanged
-	      && CHARPOS (startp) <= Z - save_end_unchanged)
-	    {
-	      /* There doesn't seems to be a simple way to find a new
-		 window start that is near the old window start, so
-		 we just recenter.  */
-	      goto recenter;
-	    }
-	}
+      	  && CHARPOS (startp) > BEGV
+	  && CHARPOS (startp) > BEG + beg_unchanged
+	  && CHARPOS (startp) <= Z - end_unchanged)
+	{
+	  w->force_start = Qt;
+	  if (XMARKER (w->start)->buffer == current_buffer)
+	    compute_window_start_on_continuation_line (w);
+	  SET_TEXT_POS_FROM_MARKER (startp, w->start);
+	  goto force_start;
+      	}
 
 #if GLYPH_DEBUG
       debug_method_add (w, "same window start");